:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #f0ede4;
  --ink: #1c1a15;
  --muted: #6b665a;
  --line: #e3ded1;
  --accent: #2d5a4c;
  --accent-hover: #234a3e;
  --accent-ink: #ffffff;
  --accent-soft: #e2ece7;
  --star: #c98a0b;
  --danger: #b4441f;
  --danger-soft: #f8e6df;
  --ok: #2f7a4f;
  --shadow: 0 1px 2px rgba(40, 35, 20, 0.05), 0 4px 16px rgba(40, 35, 20, 0.05);
  --radius: 12px;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #14130f;
    --surface: #1d1c17;
    --surface-2: #27251f;
    --ink: #eceadf;
    --muted: #a29d8e;
    --line: #35322a;
    --accent: #7fbfa6;
    --accent-hover: #95cdb6;
    --accent-ink: #0f1a16;
    --accent-soft: #1f3029;
    --star: #f2c14e;
    --danger: #ef8a66;
    --danger-soft: #3a2119;
    --ok: #7fcf9c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #14130f;
  --surface: #1d1c17;
  --surface-2: #27251f;
  --ink: #eceadf;
  --muted: #a29d8e;
  --line: #35322a;
  --accent: #7fbfa6;
  --accent-hover: #95cdb6;
  --accent-ink: #0f1a16;
  --accent-soft: #1f3029;
  --star: #f2c14e;
  --danger: #ef8a66;
  --danger-soft: #3a2119;
  --ok: #7fcf9c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  padding-bottom: 72px;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 0.4em; }
h1 { font-size: 1.9rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 620; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 0.75em; }
[hidden] { display: none !important; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.pad { padding: 48px 0; }
.mono { font-family: var(--mono); letter-spacing: 0.04em; }
.prewrap { white-space: pre-wrap; }
.eyebrow { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.3em; }
.lede { font-size: 1.05rem; color: var(--muted); max-width: 60ch; }
.err { color: var(--danger); min-height: 1.2em; margin: 0.4em 0; font-size: 0.92rem; }
.err:empty { min-height: 0; margin: 0; }
.empty { color: var(--muted); padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }
.crumb { margin: 0 0 12px; font-size: 0.92rem; }
.crumb a { text-decoration: none; }
.foot { margin-top: 40px; }

/* top bar */
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 650; letter-spacing: -0.02em; font-size: 1.05rem; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 24px; height: 24px; color: var(--accent); }
.nav-in { display: inline-flex; gap: 16px; align-items: center; font-size: 0.92rem; }
.nav a { text-decoration: none; }

main.wrap { padding-top: 28px; }

/* cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 550; font-size: 0.92rem;
  padding: 8px 14px; min-height: 38px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 0.85rem; }
.danger-text { color: var(--danger) !important; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.icon-btn { flex: none; width: 32px; height: 36px; border: 0; background: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.wrap-actions { flex-wrap: wrap; }

/* inputs */
input, textarea, select {
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%; min-height: 38px;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, .slot:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
select { width: auto; }
.field { display: block; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-weight: 580; font-size: 0.9rem; margin-bottom: 5px; }
.hint { display: block; font-size: 0.84rem; color: var(--muted); margin: -2px 0 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 label span { display: block; font-size: 0.88rem; font-weight: 560; margin-bottom: 4px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; }

/* home */
.hero { text-align: center; padding: 48px 0 16px; }
.hero h1 { font-size: 2.3rem; }
.hero .lede { margin: 0 auto 24px; }
.code-form { display: flex; gap: 10px; justify-content: center; max-width: 420px; margin: 0 auto; }
.code-input { font-family: var(--mono); font-size: 1.35rem; letter-spacing: 0.12em; text-align: center; text-transform: uppercase; min-height: 50px; }
.code-form .btn { min-height: 50px; padding: 0 20px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border: 0; }

/* invite */
.event-head { margin-bottom: 24px; }
.days { display: grid; gap: 18px; }
.day h3 { font-size: 0.95rem; margin-bottom: 8px; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.slot {
  font: inherit; font-weight: 560; font-size: 0.92rem;
  padding: 10px 8px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--surface); color: var(--accent);
}
.slot:hover { background: var(--accent-soft); }
.slot.selected { background: var(--accent); color: var(--accent-ink); }
.confirm { margin-top: 20px; border-color: var(--accent); }

/* booking */
.summary .when { font-size: 1.55rem; margin: 2px 0 8px; }
.summary .when.cancelled { color: var(--muted); }
.banner { background: var(--accent-soft); border-radius: 9px; padding: 10px 14px; margin-bottom: 14px; }
.move { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.confirm-inline { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.form-section h2 { margin-bottom: 2px; }
.form-section .help { font-size: 0.9rem; margin-bottom: 14px; }
.list-rows { display: grid; gap: 6px; }
.list-row { display: flex; gap: 6px; align-items: center; }
.team-row input:first-child { flex: 1 1 40%; }
.team-row input:nth-child(2) { flex: 1 1 60%; }
.add { margin-top: 8px; }
.with-link { display: flex; gap: 8px; align-items: center; }
.open-link { flex: none; font-size: 0.88rem; text-decoration: none; padding: 0 4px; }
.questions { margin: 0; padding-left: 28px; display: grid; gap: 6px; }
.questions li { padding-left: 4px; }
.questions li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.questions li { display: list-item; }
.questions li > input { width: calc(100% - 42px); vertical-align: middle; }
.star {
  width: 36px; height: 36px; margin-left: 6px; vertical-align: middle;
  border: 0; background: none; cursor: pointer; font-size: 1.3rem; color: var(--muted); border-radius: 8px;
}
.star:hover { background: var(--surface-2); }
.star.on { color: var(--star); }
.focus-count { display: inline-block; font-size: 0.85rem; color: var(--muted); background: var(--surface-2); padding: 2px 10px; border-radius: 99px; margin-bottom: 10px; }
.focus-count.done { color: var(--accent); background: var(--accent-soft); }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--star); border-radius: 8px; } 100% { box-shadow: 0 0 0 3px transparent; } }

.statusbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 5; }
.statusbar-in { display: flex; gap: 16px; align-items: center; justify-content: space-between; height: 44px; font-size: 0.86rem; }
.sync::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--muted); vertical-align: 1px; }
.sync.ok::before { background: var(--ok); }
.sync.busy::before { background: var(--star); }
.sync.bad { color: var(--danger); }
.sync.bad::before { background: var(--danger); }

/* host */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.event-list { display: grid; gap: 10px; }
.event-card { display: block; text-decoration: none; color: var(--ink); margin: 0; }
.event-card:hover { border-color: var(--accent); color: var(--ink); }
.event-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.event-card h3 { margin: 0 0 4px; }
.badge { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.badge.open { background: var(--accent-soft); color: var(--accent); }
.badge.closed { background: var(--surface-2); color: var(--muted); }
.login h1 { font-size: 1.5rem; }
.login input { margin: 8px 0 4px; }

.event-edit { margin-bottom: 18px; }
.title-input { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.01em; border-color: transparent; background: transparent; padding: 4px 6px; margin: 0 0 10px -7px; }
.title-input:hover { border-color: var(--line); }
.invite-main { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.invite-main .actions { margin-top: 0; }
.code-big { font-size: 1.9rem; font-weight: 650; margin: 0; color: var(--accent); }
.invite-sub { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.92rem; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }

/* calendar */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.cal-toolbar h2 { margin: 0; }
.cal-nav { display: inline-flex; align-items: center; gap: 4px; }
.cal-range { font-weight: 580; min-width: 150px; text-align: center; font-size: 0.92rem; }
.cal-card .help { margin: 8px 0 12px; }
.cal-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.cal { min-width: 680px; user-select: none; -webkit-user-select: none; }
.cal-head, .cal-body { display: grid; grid-template-columns: 58px repeat(7, minmax(0, 1fr)); }
.cal-head { border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.cal-tz { font-size: 0.7rem; display: flex; align-items: end; justify-content: center; padding-bottom: 6px; }
.cal-day-h { text-align: center; padding: 6px 0; font-size: 0.8rem; color: var(--muted); border-left: 1px solid var(--line); }
.cal-day-h b { display: block; font-size: 1.05rem; color: var(--ink); font-weight: 620; }
.cal-day-h.today b { color: var(--accent); }
.cal-body { position: relative; }
.cal-gutter { position: relative; }
.cal-hour { position: absolute; right: 6px; transform: translateY(-50%); font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.cal-hour:first-child { transform: none; }
.cal-col {
  position: relative; border-left: 1px solid var(--line); cursor: crosshair; touch-action: pan-x pan-y;
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px), linear-gradient(to bottom, transparent 23.5px, color-mix(in srgb, var(--line) 50%, transparent) 24px, transparent 24.5px);
  background-size: 100% 48px, 100% 48px;
}
.cal-col.today { background-color: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.cal-past { position: absolute; left: 0; right: 0; top: 0; background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--line) 55%, transparent) 6px 7px); }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 1; pointer-events: none; }
.cal-block {
  position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 2px 6px;
  font-size: 0.74rem; line-height: 1.25; overflow: hidden; cursor: default;
  display: flex; flex-direction: column;
}
.cal-block.free { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); }
.cal-block.booked { background: var(--accent); border: 1px solid var(--accent); color: var(--accent-ink); cursor: pointer; }
.cal-block.past { opacity: 0.5; }
.cal-block.preview { background: color-mix(in srgb, var(--star) 25%, transparent); border: 1px dashed var(--star); color: var(--ink); font-weight: 600; pointer-events: none; z-index: 3; }
.cal-time { font-weight: 600; }
.cal-block.free .cal-time { padding-right: 14px; }
.cal-who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-x {
  position: absolute; top: 1px; right: 2px; width: 20px; height: 20px; border: 0; border-radius: 5px;
  background: transparent; color: inherit; font-size: 1rem; line-height: 1; cursor: pointer; opacity: 0;
}
.cal-block:hover .cal-x, .cal-x:focus-visible { opacity: 1; }
.cal-x:hover { background: var(--danger); color: #fff; }
@media (hover: none) { .cal-x { opacity: 0.8; } }
.cal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* bookings list */
.b-list { display: grid; }
.b-row { display: grid; grid-template-columns: 180px 1fr 120px auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.b-row:last-child { border-bottom: 0; }
.b-row.is-cancelled { opacity: 0.7; }
.b-when, .b-who { display: flex; flex-direction: column; min-width: 0; font-size: 0.92rem; }
.b-who span { overflow: hidden; text-overflow: ellipsis; }
.b-progress { display: flex; align-items: center; gap: 8px; }
.bar { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.b-actions { display: flex; gap: 6px; }
.danger-zone { margin: 24px 0; text-align: right; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 60px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 9px;
  font-size: 0.9rem; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 10; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  h1 { font-size: 1.55rem; }
  .hero h1 { font-size: 1.8rem; }
  .card { padding: 16px; }
  .row2 { grid-template-columns: 1fr; }
  .code-form { flex-direction: column; }
  .summary .when { font-size: 1.25rem; }
  .b-row { grid-template-columns: 1fr auto; }
  .b-progress { grid-column: 1 / -1; order: 3; }
  .b-actions { grid-column: 1 / -1; order: 4; }
  .team-row { flex-wrap: wrap; }
  .team-row input { flex: 1 1 100% !important; }
  .statusbar-in { font-size: 0.8rem; }
}
