:root {
  --bg: #f6f1ea;
  --surface: #fffdf9;
  --ink: #1d1a17;
  --muted: #8a7f76;
  --line: #e6ddd1;
  --hover: #ede5da;
  --accent: #9b2c3f;
  --accent-ink: #ffffff;
  --accent-soft: #f1dfe0;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(40 24 20 / 0.05), 0 12px 32px -8px rgb(40 24 20 / 0.12);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141112;
    --surface: #1d191a;
    --ink: #f3ece4;
    --muted: #9d928a;
    --line: #2f2829;
    --hover: #272122;
    --accent: #e3687d;
    --accent-ink: #1b0b0f;
    --accent-soft: #3a2026;
    --danger: #ff8a80;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px -8px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141112;
  --surface: #1d191a;
  --ink: #f3ece4;
  --muted: #9d928a;
  --line: #2f2829;
  --hover: #272122;
  --accent: #e3687d;
  --accent-ink: #1b0b0f;
  --accent-soft: #3a2026;
  --danger: #ff8a80;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px -8px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.page {
  max-width: 520px;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) 16px 0;
}

.page.wide {
  max-width: 1040px;
}

/* Type */

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0;
}

h1 {
  font-size: clamp(2.25rem, 9vw, 3.25rem);
  line-height: 1.02;
  font-variation-settings: "opsz" 144;
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  margin: 16px 0 0;
  font-size: 1.0625rem;
  color: var(--muted);
  max-width: 34ch;
}

.label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8125rem;
}

.hero {
  margin-bottom: 40px;
}

/* Inputs and buttons */

.name-field {
  display: grid;
  gap: 6px;
  margin-bottom: 36px;
}

.name-field input {
  width: 100%;
  padding: 8px 0 10px;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 1.75rem;
  outline: none;
  transition: border-color 0.2s;
}

.name-field input::placeholder {
  color: var(--line);
}

.name-field input:focus {
  border-bottom-color: var(--accent);
}

.primary {
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.15s, opacity 0.15s;
}

.primary:active {
  transform: scale(0.97);
}

.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.primary.block {
  width: 100%;
}

.ghost {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.ghost:hover {
  background: var(--hover);
  color: var(--ink);
}

.ghost.danger:hover {
  color: var(--danger);
}

.ghost.small {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.error {
  margin: 0;
  min-height: 0;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 500;
}

.error:empty {
  display: none;
}

/* Picker header */

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hint {
  margin: 10px 0 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Calendar */

.calendar {
  display: grid;
  gap: 28px;
  padding-bottom: 8px;
}

.month-name {
  font-size: 1.375rem;
  margin: 0 0 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 6px;
}

.dow {
  padding-bottom: 6px;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
}

.day {
  position: relative;
  aspect-ratio: 1;
  min-height: 40px;
  border: 0;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.12s, color 0.12s;
}

.day .num {
  position: relative;
}

.day:disabled {
  color: var(--line);
  cursor: default;
}

.day.today::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}

@media (hover: hover) {
  .picker .day:not(:disabled):not(.on):hover {
    background: var(--hover);
  }
}

.picker .day.on {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.picker .day.on.today::after {
  background: var(--accent-ink);
}

.picker .day.join-l {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.picker .day.join-r {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}


/* Bottom dock on the form */

.dock {
  position: sticky;
  bottom: 0;
  margin: 0 -16px;
  padding: 24px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 36%);
}

.dock .error {
  margin: 0 4px 8px;
}

.dock-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 0.875rem;
  color: var(--muted);
}

.dock-hint:not(:has(:not(:empty, [hidden]))) {
  display: none;
}

.pill-action {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: rise 0.2s ease-out;
}

@keyframes rise {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
}

/* Picked ranges */

.ranges {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.range-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.range {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.range-label {
  flex: 1;
  font-weight: 500;
}

.range-days {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
}

.range-remove {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--hover);
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
}

@media (hover: hover) {
  .range-remove:hover {
    color: var(--danger);
  }
}

.dock-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 22px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.tally {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.tally strong {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
}

.tally span {
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

/* Done screen */

.done {
  min-height: 70vh;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 4px;
}

.done-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}


@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

/* Admin */

.login {
  max-width: 400px;
  margin: 8vh auto 0;
}

.stack .name-field {
  margin-bottom: 24px;
}

.stack .error {
  margin-bottom: 16px;
}

.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.dash-head h1 {
  font-size: clamp(2rem, 6vw, 2.75rem);
}

.dash-actions {
  display: flex;
  gap: 4px;
  margin-right: -14px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  display: grid;
  gap: 4px;
  padding: 18px 20px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.stat strong {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.1;
}

.stat.best {
  grid-column: 1 / -1;
  order: -1;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.stat.best .label,
.stat.best .sub {
  color: inherit;
  opacity: 0.8;
}

.sub {
  font-size: 0.875rem;
  color: var(--muted);
}

.dash-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  padding: 24px 20px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.panel > .muted {
  margin: 0 0 16px;
}

.ranking {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.rank {
  display: flex;
  gap: 14px;
  padding: 12px;
  margin: 0 -12px;
  border-radius: 16px;
  cursor: pointer;
}

.rank:hover {
  background: var(--hover);
}

.rank-n {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--hover);
  font-weight: 600;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.rank.top .rank-n {
  background: var(--accent);
  color: var(--accent-ink);
}

.rank-body {
  flex: 1;
  min-width: 0;
}

.rank-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 500;
}

.rank-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.bar {
  height: 6px;
  margin: 8px 0 6px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.rank-names {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

#ranking-more {
  margin: 8px 0 0 -14px;
}

.heat .day {
  border-radius: 12px;
  margin: 0 2px;
  cursor: pointer;
}

.heat .day.warm {
  background: color-mix(in srgb, var(--accent) calc(var(--heat) * 100%), transparent);
}

.heat .day.hot {
  color: var(--accent-ink);
  font-weight: 600;
}

.heat .day.peak {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.heat .day.focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.heat .day.today::after {
  display: none;
}

.dot-count {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.5625rem;
  font-weight: 600;
  opacity: 0.85;
}

.detail {
  margin-bottom: 20px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--accent-soft);
}

.detail h3 {
  font-size: 1.125rem;
  margin-bottom: 6px;
}

.detail p {
  margin: 4px 0 0;
  font-size: 0.9375rem;
}

.answers {
  list-style: none;
  margin: 0;
  padding: 0;
}

.answer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.answer:first-child {
  border-top: 0;
}

.who {
  display: grid;
}

.page.wide {
  padding-bottom: 48px;
}

@media (min-width: 720px) {
  .page {
    padding-top: 72px;
  }

  .stats {
    grid-template-columns: 1fr 2fr 1fr;
  }

  .stat.best {
    grid-column: auto;
    order: 0;
  }

  .dash-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .panel {
    padding: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Password screen */

.lock {
  max-width: 400px;
  margin: 8vh auto 0;
}

/* Name picker */

.people {
  display: grid;
  gap: 10px;
  margin-bottom: 32px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--surface);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

@media (hover: hover) {
  .chip:hover {
    border-color: var(--muted);
  }
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.field-hint {
  min-height: 1.25em;
  font-size: 0.8125rem;
  color: var(--muted);
}

.field-hint:empty {
  display: none;
}

.done-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
}
