/* oneshot - one stylesheet, no framework, no build step.
   Mobile first; everything below 640px is the primary target. */

:root {
  --bg:        #f6f6f4;
  --surface:   #ffffff;
  --surface-2: #f0f0ee;
  --text:      #191917;
  --muted:     #6b6b66;
  --line:      #dedeD8;
  --accent:    #4338ca;
  --accent-ink:#ffffff;
  --accent-sub:#eceafc;
  --good:      #197d4b;
  --good-bg:   #e6f4ec;
  --warn:      #8a5a00;
  --warn-bg:   #fdf3e0;
  --bad:       #a33232;
  --bad-bg:    #fbecec;
  --radius:    12px;
  --shadow:    0 1px 2px rgba(0,0,0,.05), 0 1px 8px rgba(0,0,0,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14141a;
    --surface:   #1d1d25;
    --surface-2: #26262f;
    --text:      #eceaf2;
    --muted:     #9d9dab;
    --line:      #34343f;
    --accent:    #8b83f5;
    --accent-ink:#14141a;
    --accent-sub:#2a2740;
    --good:      #6ddc9f;
    --good-bg:   #14312a;
    --warn:      #f0c073;
    --warn-bg:   #33290f;
    --bad:       #f08b8b;
    --bad-bg:    #34191b;
    --shadow:    0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 48px; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex; align-items: baseline; gap: 10px;
  max-width: 640px; margin: 0 auto; padding: 18px 16px 10px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -.02em;
  color: var(--text); text-decoration: none;
}
.brand-mark {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-sub);
}
.brand-tag { color: var(--muted); font-size: .82rem; }

.foot {
  max-width: 640px; margin: 0 auto; padding: 8px 16px 32px;
  color: var(--muted); font-size: .78rem; text-align: center;
}

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 0 16px;
}
.card.center { text-align: center; }
.hero { padding: 8px 2px 18px; }
.lede { color: var(--muted); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .82rem; margin: .35em 0 0; }
.hint.center { text-align: center; }
.mini { font-size: .95rem; margin-top: 1.2em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ------------------------------------------------------------------- forms */

.field { margin: 0 0 16px; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
label.sub { font-weight: 500; color: var(--muted); font-size: .82rem; }
.req { float: right; font-weight: 400; color: var(--muted); font-size: .78rem; }

input[type=text], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
input[type=date], input[type=time] { min-height: 44px; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible,
summary:focus-visible, .slot:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.row { display: flex; gap: 12px; }
.row .col { flex: 1 1 0; min-width: 0; }

.choices { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-weight: 500; margin: 0; cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-sub); }
.choice input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.choice span { display: block; }
.choice small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 4px 0 16px; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.unavail { border-top: 1px solid var(--line); padding-top: 14px; }

details.more > summary, details.peek > summary, details.qr > summary,
details.more-recs > summary, details.tzbar > summary {
  cursor: pointer; font-weight: 600; font-size: .9rem;
}
details.more { margin: 0 0 16px; }
details.more[open] > summary { margin-bottom: 12px; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  font: inherit; font-weight: 600;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-lg { width: 100%; min-height: 50px; font-size: 1.02rem; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: .85rem; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }

.linkbtn {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.linkbtn-danger { color: var(--bad); }
.inline { display: inline; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.chip-me   { background: var(--accent-sub); color: var(--accent); border-color: transparent; }
.chip-out  { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.presets .chip {
  cursor: pointer; font-size: .82rem; padding: 7px 12px;
  background: var(--surface-2); color: var(--text);
}
.presets .chip:hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------------ alerts */

.alert { border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; font-size: .9rem; }
.alert p:last-child { margin: 0; }
.alert-bad   { background: var(--bad-bg);  color: var(--bad); }
.alert-warn  { background: var(--warn-bg); color: var(--warn); }
.alert-muted { background: var(--surface-2); color: var(--muted); }
.alert h2 { color: inherit; }

/* ----------------------------------------------------------------- tz bar */

.tzbar {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px;
  font-size: .84rem;
}
.tzbar > summary { list-style: none; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-weight: 500; }
.tzbar > summary::-webkit-details-marker { display: none; }
.tz-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; }
.tz-change { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; margin-left: auto; }
.tz-warn { color: var(--warn); font-size: .76rem; }
.tzform { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tzform select { flex: 1 1 200px; }

/* ------------------------------------------------------------ status panel */

.status { margin: 0 0 16px; }
.verdict {
  border-radius: var(--radius); padding: 16px 18px;
  border: 1px solid var(--line); background: var(--surface);
}
.verdict-head { font-size: 1.2rem; font-weight: 700; letter-spacing: -.015em; margin: 0 0 .2em; }
.verdict-sub  { font-size: .86rem; color: var(--muted); margin: 0; }
.verdict-met  { background: var(--good-bg); border-color: transparent; }
.verdict-met .verdict-head { color: var(--good); }
.verdict-met .verdict-sub  { color: var(--good); opacity: .85; }
.verdict-ok .verdict-head  { color: var(--accent); }
.verdict-short, .verdict-bad { background: var(--warn-bg); border-color: transparent; }
.verdict-short .verdict-head, .verdict-bad .verdict-head { color: var(--warn); }
.verdict-short .verdict-sub, .verdict-bad .verdict-sub { color: var(--warn); opacity: .85; }
.verdict-cancelled { background: var(--bad-bg); border-color: transparent; }
.verdict-cancelled .verdict-head { color: var(--bad); }

.signals { display: flex; gap: 10px; margin-top: 10px; }
.signal {
  flex: 1 1 0; min-width: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px;
}
.signal-main { font-size: .9rem; font-weight: 600; margin: 0; }
.signal-sub  { font-size: .8rem; color: var(--muted); margin: 2px 0 0; }
.signal-you.is-todo { border-color: var(--accent); background: var(--accent-sub); }
.signal-you.is-todo .signal-main { color: var(--accent); }

.progress {
  height: 5px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; margin: 7px 0 0;
}
.progress span { display: block; height: 100%; background: var(--accent); }

/* ----------------------------------------------------------------- picker */

.pick-hint { margin: 0 0 10px; }
.slots { list-style: none; margin: 0 0 4px; padding: 0; }
.slots li { margin: 0 0 4px; }
/* While painting, the list stops panning so a drag selects instead of scrolling.
   Set only for the duration of the gesture, so ordinary scrolling is untouched. */
.slots.is-painting { touch-action: none; }
.slot {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 12px; margin: 0;
  border: 1px solid var(--line); border-radius: 9px;
  font-weight: 500; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.slot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slot-time { flex: 1 1 auto; font-variant-numeric: tabular-nums; }
.slot-mark {
  width: 20px; height: 20px; flex: none; border-radius: 6px;
  border: 1.5px solid var(--line); background: var(--surface);
}
.slot:has(input:checked) { border-color: var(--accent); background: var(--accent-sub); color: var(--accent); }
.slot:has(input:checked) .slot-mark { background: var(--accent); border-color: var(--accent); position: relative; }
.slot:has(input:checked) .slot-mark::after {
  content: ""; position: absolute; left: 6px; top: 2px;
  width: 5px; height: 10px; border: solid var(--accent-ink);
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.picker.is-unavailable .slots,
.picker.is-unavailable .presets,
.picker.is-unavailable .pick-hint { opacity: .4; pointer-events: none; }

.daybreak {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: .76rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  margin: 12px 0 6px; list-style: none;
}
.daybreak::before, .daybreak::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ------------------------------------------------------------- freshness */

.freshness {
  display: flex; align-items: center; gap: 10px;
  font-size: .78rem; color: var(--muted); margin: 0 0 10px; padding: 0 2px;
}
.asof { font-variant-numeric: tabular-nums; }
.countdown { margin-left: auto; font-variant-numeric: tabular-nums; }
.countdown.is-news { color: var(--good); font-weight: 600; }
.refresh-link { margin-left: auto; }

/* ------------------------------------------------------- recommendations */

.reclist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rec {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: var(--surface);
}
.rec-top { border-width: 2px; }
.rec-quorum { border-color: var(--good); background: var(--good-bg); }
.rec-when { font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; }
.rec-quorum .rec-when { color: var(--good); }
.rec-meta { font-size: .82rem; color: var(--muted); margin-top: 1px; }
.rec-quorum .rec-meta { color: var(--good); opacity: .9; }
.rec-who { font-size: .8rem; color: var(--muted); margin-top: 5px; }
.more-recs { margin-top: 12px; }
.more-recs[open] > summary { margin-bottom: 10px; }

/* ---------------------------------------------------------------- timeline */

.tl { margin: 0; }
.tl-row { border-radius: 8px; }
.tl-row > summary {
  display: flex; align-items: center; gap: 10px;
  list-style: none; cursor: pointer; padding: 5px 8px; border-radius: 8px;
}
.tl-row > summary::-webkit-details-marker { display: none; }
.tl-row:hover > summary { background: var(--surface-2); }
.tl-time {
  flex: none; width: 72px; font-size: .8rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tl-bar { flex: 1 1 auto; height: 14px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.tl-bar > span { display: block; height: 100%; background: var(--accent); opacity: .55; border-radius: 4px; }
.tl-count { flex: none; width: 20px; text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.tl-row.is-quorum .tl-bar > span { background: var(--good); opacity: 1; }
.tl-row.is-quorum .tl-time, .tl-row.is-quorum .tl-count { color: var(--good); font-weight: 600; }
.tl-row.is-empty .tl-count { opacity: .4; }
.tl-who { font-size: .8rem; color: var(--muted); margin: 0 0 8px; padding: 0 8px 0 82px; }
.legend { display: flex; align-items: center; gap: 7px; margin-top: 12px; }
.swatch { width: 22px; height: 8px; border-radius: 3px; background: var(--good); flex: none; }
.empty { margin: 0; }

/* ------------------------------------------------------------------ people */

.peoplelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.person { border-top: 1px solid var(--line); padding-top: 10px; }
.person:first-child { border-top: 0; padding-top: 0; }
.person-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.person-name { font-weight: 600; }
.person-times { font-size: .86rem; color: var(--muted); margin-top: 1px; }
.person.is-out .person-times { color: var(--bad); }
.person-note {
  font-size: .84rem; margin: 6px 0 0; padding: 7px 10px;
  background: var(--surface-2); border-radius: 8px; color: var(--text);
}
.person.is-me { padding-left: 10px; margin-left: -10px; border-left: 3px solid var(--accent); }

/* ------------------------------------------------------------------- share */

.sharerow { display: flex; gap: 8px; margin: 0 0 10px; }
.urlbox {
  flex: 1 1 auto; min-width: 0; font-size: .82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
}
.qrimg {
  display: block; margin: 12px auto 0; border-radius: 8px;
  background: #fff; padding: 8px; max-width: 100%; height: auto;
}
.keepit { margin-top: 20px; text-align: left; }
.danger hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.peek { margin: 0 0 16px; }
.peek[open] > summary { margin-bottom: 14px; }

.recent ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recent li { font-size: .9rem; }
.recent .when { color: var(--muted); font-size: .8rem; }

/* ------------------------------------------------------------------ event */

.event-head { padding: 4px 2px 14px; }
.event-when { margin: 0; font-size: .95rem; }
.event-by { margin: 2px 0 0; color: var(--muted); font-size: .84rem; }

/* --------------------------------------------------------------- desktop */

@media (min-width: 700px) {
  h1 { font-size: 1.85rem; }
  .verdict-head { font-size: 1.45rem; }
  .tl-who { display: none; }
  .tl-row > summary::after {
    content: attr(data-who); flex: none; max-width: 42%;
    font-size: .78rem; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .tl-row[open] > summary::after { content: none; }
  .tl-row[open] .tl-who { display: block; }
}

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