:root {
  color-scheme: light;
  --canvas:#F5F7F8; --card:#FFFFFF; --raised:#FFFFFF; --sunken:#EFF2F4;
  --line:#E3E8EA; --line-2:#CFD6DA;
  --fg:#0E1A21; --fg-2:#4A5C66; --fg-3:#7B8C95;
  --accent:#0E7A8C; --accent-2:#0A6675; --on-accent:#FFFFFF;
  --amber:#B26A1B; --amber-bg:#FDF4E7;
  --tint:12%;
  --shadow-sm: 0 1px 2px rgb(16 30 38 / .06), 0 1px 1px rgb(16 30 38 / .04);
  --shadow-md: 0 4px 12px rgb(16 30 38 / .08), 0 1px 3px rgb(16 30 38 / .05);
  --shadow-lg: 0 12px 32px rgb(16 30 38 / .14), 0 2px 8px rgb(16 30 38 / .07);
  --r-md:12px; --r-xl:20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas:#0B1114; --card:#141C21; --raised:#1A242A; --sunken:#111A1F;
    --line:#243138; --line-2:#33444C;
    --fg:#EAF0F2; --fg-2:#A9BAC2; --fg-3:#748891;
    --accent:#2FC0D2; --accent-2:#5BD3E2; --on-accent:#04252B;
    --amber:#E6A85C; --amber-bg:#2A2113;
    --tint:20%;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-md: 0 4px 14px rgb(0 0 0 / .45);
    --shadow-lg: 0 14px 36px rgb(0 0 0 / .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas:#0B1114; --card:#141C21; --raised:#1A242A; --sunken:#111A1F;
  --line:#243138; --line-2:#33444C;
  --fg:#EAF0F2; --fg-2:#A9BAC2; --fg-3:#748891;
  --accent:#2FC0D2; --accent-2:#5BD3E2; --on-accent:#04252B;
  --amber:#E6A85C; --amber-bg:#2A2113;
  --tint:20%;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 4px 14px rgb(0 0 0 / .45);
  --shadow-lg: 0 14px 36px rgb(0 0 0 / .6);
}
:root[data-theme="light"] {
  color-scheme: light;
  --canvas:#F5F7F8; --card:#FFFFFF; --raised:#FFFFFF; --sunken:#EFF2F4;
  --line:#E3E8EA; --line-2:#CFD6DA;
  --fg:#0E1A21; --fg-2:#4A5C66; --fg-3:#7B8C95;
  --accent:#0E7A8C; --accent-2:#0A6675; --on-accent:#FFFFFF;
  --amber:#B26A1B; --amber-bg:#FDF4E7;
  --tint:12%;
  --shadow-sm: 0 1px 2px rgb(16 30 38 / .06), 0 1px 1px rgb(16 30 38 / .04);
  --shadow-md: 0 4px 12px rgb(16 30 38 / .08), 0 1px 3px rgb(16 30 38 / .05);
  --shadow-lg: 0 12px 32px rgb(16 30 38 / .14), 0 2px 8px rgb(16 30 38 / .07);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--canvas); color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- app bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.bar-in { max-width: 640px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: var(--on-accent); display: grid; place-items: center;
  font-size: 15px; box-shadow: var(--shadow-sm);
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-txt strong { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; }
.brand-txt small { font-size: 11.5px; color: var(--fg-3); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: var(--fg-2);
  border: 1px solid var(--line); background: var(--card);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.switch select {
  font: inherit; font-size: 12.5px; color: var(--fg-2);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 8px; max-width: 130px;
}

.page { max-width: 640px; margin: 0 auto; padding: 18px 16px 200px; display: flex; flex-direction: column; gap: 18px; }

.crew { display: flex; gap: 7px; flex-wrap: wrap; }
.crew-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 11px 4px 4px;
  font-size: 12.5px; color: var(--fg-2); box-shadow: var(--shadow-sm);
}
.av {
  width: 21px; height: 21px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  background: var(--c); color: var(--card);
}
.av.lg { width: 30px; height: 30px; font-size: 12px; }

/* ---------- calendar ---------- */
.cal {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-md);
  padding: 14px 14px 16px;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-title { font-size: 16.5px; font-weight: 650; letter-spacing: -0.015em; text-transform: capitalize; }
.cal-title span { color: var(--fg-3); font-weight: 500; }
.stepper { display: flex; gap: 4px; background: var(--sunken); padding: 3px; border-radius: 11px; }
.stepper button { width: 30px; height: 28px; border-radius: 8px; color: var(--fg-2); display: grid; place-items: center; font-size: 15px; }
.stepper button:hover { background: var(--card); color: var(--accent); box-shadow: var(--shadow-sm); }

.dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em;
  color: var(--fg-3); text-align: center; margin-bottom: 7px; text-transform: uppercase;
}
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

.day {
  position: relative; aspect-ratio: 1 / 1.08;
  border-radius: var(--r-md);
  background: var(--sunken); border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 3px 5px;
  transition: transform .13s cubic-bezier(.2,.8,.3,1), background-color .13s ease, box-shadow .13s ease;
}
.day:hover:not(:disabled):not(.on) { transform: translateY(-1.5px); box-shadow: var(--shadow-sm); }
.day:active:not(:disabled) { transform: scale(.95); }
@media (prefers-reduced-motion: reduce) { .day { transition: none; } .day:hover, .day:active { transform: none; } }
.day.pad { visibility: hidden; pointer-events: none; }
.day:disabled { opacity: .3; cursor: not-allowed; }

.dnum { font-size: 13.5px; font-weight: 600; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.day.today .dnum { color: var(--accent); }
.day.today::after {
  content: ""; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.day.held { background: color-mix(in oklab, var(--dc) var(--tint), var(--card)); }
.day.held .dnum { color: color-mix(in oklab, var(--dc) 62%, var(--fg)); }
/* Your own days wear a ring. Every cell shows initials so the grid scans as
   one thing; the ring is what makes yours findable without knowing which
   colour you are. Outline, not border or shadow — those two are already spoken
   for by the selected state, and all three need to be able to show at once. */
.day.held.mine {
  outline: 1.5px solid var(--dc);
  outline-offset: -1.5px;
}
.day.held.mine .dnum { font-weight: 700; }
.who {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 9.5px; font-weight: 700;
  background: var(--dc); color: var(--card);
}
.qbadge {
  position: absolute; top: 3px; right: 3px;
  min-width: 15px; height: 15px; padding: 0 3px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; line-height: 15px; text-align: center;
  background: var(--line-2); color: var(--card);
}
.qbadge.mine { background: var(--amber); color: #fff; }

/* selection is client-side only — it never waits for the server */
.day.on { transform: translateY(-1.5px); }
.day.on.free { background: var(--accent); box-shadow: var(--shadow-md); }
.day.on.free .dnum { color: var(--on-accent); }
.day.on.free::after { background: var(--on-accent); }
.day.on.held {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
.day.on::before {
  content: "✓"; position: absolute; top: -5px; left: -5px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-size: 10px; font-weight: 800;
  box-shadow: var(--shadow-sm); border: 2px solid var(--card);
}

/* ---------- tabs + lists ---------- */
.tabs { display: flex; gap: 3px; background: var(--sunken); padding: 4px; border-radius: 13px; }
.tab { flex: 1; padding: 8px 6px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--fg-3); text-align: center; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--card); color: var(--fg); box-shadow: var(--shadow-sm); }
.tab .n { font-variant-numeric: tabular-nums; opacity: .65; margin-left: 3px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list[hidden] { display: none; }
.row {
  display: flex; align-items: center; gap: 11px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 11px 12px; box-shadow: var(--shadow-sm);
}
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-when { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.row-sub { font-size: 12px; color: var(--fg-3); }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--amber-bg); color: var(--amber);
  border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 650;
}
.row-act { flex: none; border: 1px solid var(--line-2); border-radius: 9px; padding: 6px 11px; font-size: 12.5px; font-weight: 550; color: var(--fg-2); }
.row-act:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-bg); }
.empty {
  text-align: center; padding: 26px 16px; color: var(--fg-3); font-size: 13.5px;
  background: var(--card); border: 1px dashed var(--line-2); border-radius: var(--r-md);
}

/* ---------- single-day dock ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  /* 100vw would include the scrollbar and re-introduce the overflow this is
     here to avoid; left/right 0 already gives the viewport width. */
  padding: 0 12px max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
  transform: translateY(130%); opacity: 0;
  transition: transform .24s cubic-bezier(.2,.8,.3,1), opacity .18s ease;
}
.dock.open { transform: translateY(0); opacity: 1; }
@media (prefers-reduced-motion: reduce) { .dock { transition: none; } }
.dock-in {
  pointer-events: auto; max-width: 616px; margin: 0 auto;
  /* Never taller than the screen: on a small phone in landscape the panel
     would otherwise run off the top with the button out of reach. */
  max-height: min(78dvh, 560px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  padding: 13px 14px; display: flex; flex-direction: column; gap: 12px;
}
.dock-head { display: flex; align-items: center; gap: 11px; }
.dock-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dock-date { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; text-transform: capitalize; }
.dock-state { font-size: 12.5px; color: var(--fg-3); }
.dock-state b { color: var(--amber); font-weight: 650; }
.link { font-size: 12.5px; color: var(--fg-3); font-weight: 550; padding: 6px; flex: none; }
.link:hover { color: var(--accent); }
.btn {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; text-align: center;
  transition: filter .12s ease;
}
.btn.solid { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.btn.solid:hover { filter: brightness(1.09); }
.btn.outline { border: 1px solid var(--line-2); color: var(--fg-2); }
.btn.outline:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-bg); }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; top: 68px; left: 50%; transform: translateX(-50%); z-index: 60;
  width: min(92vw, 460px); display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--raised); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: 11px 13px; font-size: 13px; line-height: 1.5; color: var(--fg-2);
  animation: pop .24s cubic-bezier(.2,.8,.3,1) both, fade .4s ease 5.6s both;
}
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes fade { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

.hint { font-size: 12.5px; color: var(--fg-3); line-height: 1.6; text-align: center; padding: 0 8px; margin: 0; }

/* ---------- sign in ---------- */
.gate {
  min-height: 100dvh; display: grid; place-items: center;
  padding: 24px 16px;
}
.gate-card {
  width: min(100%, 380px);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-md);
  padding: 26px 22px 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.gate-head { display: flex; flex-direction: column; align-items: center; gap: 7px; margin-bottom: 4px; }
.gate-head strong { font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.gate-sub { font-size: 12.5px; color: var(--fg-3); }
.mark.lg { width: 42px; height: 42px; border-radius: 13px; font-size: 21px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; font-weight: 550; color: var(--fg-2); }
.field input {
  font: inherit; font-size: 15px; color: var(--fg);
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 13px; width: 100%;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.gate-err {
  margin: 0; font-size: 12.5px; line-height: 1.5;
  color: var(--amber); background: var(--amber-bg);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  border-radius: var(--r-md); padding: 9px 11px;
}
.gate-msg { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--fg-2); text-align: center; }

.whoami { display: flex; align-items: center; }

/* ---------- phones ---------- */
/* Anything that cannot shrink below its content pushes the page wider than the
   screen. That widens the layout viewport, and a position:fixed bar sized to
   it then hangs off the right edge and sits below the fold. These are the
   elements that could do it. */
.tab, .row-main, .dock-txt, .brand-txt { min-width: 0; }
.tab { overflow: hidden; text-overflow: ellipsis; }
.row-when, .dock-date { overflow-wrap: anywhere; }

@media (max-width: 430px) {
  .page { padding: 14px 12px 210px; gap: 14px; }
  .bar-in { padding: 10px 12px; gap: 8px; }
  .cal { padding: 11px 9px 13px; border-radius: 16px; }
  .grid, .dow { gap: 4px; }
  .day { padding: 5px 2px 4px; }
  .dnum { font-size: 12.5px; }
  .who { width: 18px; height: 18px; font-size: 9px; }

  .dock { padding: 0 8px max(8px, env(safe-area-inset-bottom)); }
  .dock-in { padding: 12px; gap: 10px; border-radius: 17px; }
  .dock-date { font-size: 15px; }
  .btn { padding: 12px; }
}
