:root {
  --bg: #f5f6f3;
  --card: #ffffff;
  --text: #1b2420;
  --muted: #5d6a63;
  --line: #dfe4e0;
  --soft: #eef1ee;
  --accent: #1f7a4d;
  --accent-hover: #186540;
  --accent-ink: #ffffff;
  --yes: #1a9152;
  --yes-bg: #e0f4e8;
  --maybe: #b67c00;
  --maybe-bg: #fff1cc;
  --no: #cc3d33;
  --no-bg: #fde9e7;
  --best: #f2faf5;
  --final: #d9f2e4;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 14px rgba(20, 30, 25, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613;
    --card: #1a211d;
    --text: #e6ece8;
    --muted: #9aa8a0;
    --line: #2d3832;
    --soft: #222b26;
    --accent: #3fae74;
    --accent-hover: #52c285;
    --accent-ink: #0b1510;
    --yes: #4cc782;
    --yes-bg: #173a27;
    --maybe: #f0b429;
    --maybe-bg: #3d3113;
    --no: #f07167;
    --no-bg: #43201d;
    --best: #1c2a22;
    --final: #1d3b2a;
    --danger: #f2877e;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1 { font-size: 1.7rem; line-height: 1.2; margin: .2em 0 .4em; letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; margin: 0 0 .6em; }
h3 { font-size: 1rem; margin: 1.4em 0 .5em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 960px; margin: 0 auto; padding: 14px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
/* main spans the window; its blocks keep a readable column, except the answer table, which grows
   past it (centred) when there are many dates and only scrolls sideways once it fills the window */
main { padding: 0 16px 48px; }
#app > * { max-width: 928px; margin-left: auto; margin-right: auto; }
#app > .grid-wrap { width: max-content; min-width: min(100%, 928px); max-width: 100%; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin: 16px 0;
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn-big { min-height: 50px; padding: 0 24px; font-size: 1.05rem; }
.btn-link { background: none; border: 0; padding: 6px 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.btn-icon {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; padding: 0;
}
.btn-icon:hover { background: var(--soft); color: var(--text); }
.btn-icon:disabled { opacity: .3; cursor: default; }
.btn-icon svg { width: 18px; height: 18px; }
.danger { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* icons: stroke-drawn, coloured by vote */
.ic { display: inline-grid; place-items: center; flex: none; }
.ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.ic.maybe svg { width: 28px; }
.btn-icon svg, .ic.pin svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.yes { color: var(--yes); }
.ic.maybe { color: var(--maybe); }
.ic.no { color: var(--no); }
.ic.star { color: var(--maybe); }
.ic.star svg { fill: currentColor; stroke-width: 1.5; width: 14px; height: 14px; }

/* forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
label:first-child { margin-top: 0; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.error { color: var(--danger); font-weight: 600; }
.block { display: block; }
label.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; margin-top: 18px; cursor: pointer; }
label.check .muted { font-weight: 400; }
.check input { width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; padding: 0; flex: none; accent-color: var(--accent); }
.pin-in { max-width: 12em; letter-spacing: .15em; font-variant-numeric: tabular-nums; }
.pin-in::placeholder { letter-spacing: normal; }

/* home */
.hero { text-align: center; padding: 32px 0 12px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 34em; margin: 0 auto 24px; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--text); }
.legend-item .ic svg { width: 18px; height: 18px; }
.legend-item .ic.maybe svg { width: 24px; }
.mylist { list-style: none; margin: 0; padding: 0; }
.mylist li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.mylist li:first-child { border-top: 0; }
.mylist a { flex: 1; min-width: 0; font-weight: 600; text-decoration: none; padding: 6px 0; }
.mytitle { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); background: var(--final); border-radius: 6px; padding: 1px 6px; }

/* editor */
.picker { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 680px) { .picker { grid-template-columns: minmax(0, 1fr); } }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.cal-day {
  aspect-ratio: 1; min-height: 38px; border: 0; border-radius: 10px; background: var(--soft);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.cal-day:hover:not(:disabled) { background: var(--final); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.sel { background: var(--accent); color: var(--accent-ink); }
.cal-day:disabled { background: transparent; color: var(--muted); opacity: .45; cursor: default; }
.daylist { display: flex; flex-direction: column; gap: 10px; }
.dayrow { border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 4px 12px; }
.dayrow-head { display: flex; align-items: center; justify-content: space-between; }
.dayrow p { margin: 0; }
.slot { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.slot input { width: auto; flex: 1; min-width: 0; padding: 6px 8px; min-height: 40px; }
.copy-times { align-self: flex-start; }

/* poll */
.poll-head { margin: 8px 0 12px; }
.loc { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; color: var(--muted); }
.loc .ic svg { width: 18px; height: 18px; }
.desc { white-space: pre-wrap; margin: 0; overflow-wrap: anywhere; }
.banner {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; background: var(--soft);
}
.banner-final { background: var(--final); }
.banner div { display: flex; flex-direction: column; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 12px 0; font-size: .9rem; }

.grid-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.grid { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 0; }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid .corner, .grid .name {
  position: sticky; left: 0; z-index: 1; background: var(--card);
  border-right: 1px solid var(--line); text-align: left; min-width: 150px; max-width: 200px; width: 170px;
}
.grid .corner { vertical-align: bottom; padding: 10px 12px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.grid .opt {
  min-width: 68px; padding: 10px 6px 8px; text-align: center; vertical-align: top; font-weight: 400;
  border-left: 1px solid var(--line);
}
.grid .opt > span { display: block; }
.o-m { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.o-d { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.o-w { font-size: .8rem; color: var(--muted); }
.o-t { font-size: .78rem; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.o-c { display: flex !important; align-items: center; justify-content: center; gap: 1px; margin-top: 6px; font-size: .85rem; font-weight: 700; }
.o-c .ic svg { width: 15px; height: 15px; }
.o-c .ic.maybe svg { width: 19px; }
.o-c .ic.maybe { margin-left: 4px; }
.grid .opt.best { background: var(--best); }
.grid .opt.best .o-d { color: var(--yes); }
.grid .final, .grid .opt.final { background: var(--final); }

.grid .name { padding: 6px 6px 6px 12px; }
.name-inner { display: flex; align-items: center; gap: 6px; min-height: 40px; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.who-name { max-width: 100%; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid tr.mine .name, .grid tr.mine td { background: color-mix(in srgb, var(--final) 45%, var(--card)); }
.grid .edit { color: var(--muted); }
.cell { text-align: center; height: 52px; border-left: 1px solid var(--line); }
.cell.yes { background: var(--yes-bg); }
.cell.maybe { background: var(--maybe-bg); }
.cell.no { background: var(--no-bg); }
.cell .ic { width: 100%; }
.dash { color: var(--muted); opacity: .6; }

.edit-row > * { background: var(--soft); vertical-align: middle; }
.edit-row .name { background: var(--soft); padding: 8px; }
.name-in { min-height: 40px; padding: 6px 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.row-actions .btn-small { min-height: 32px; padding: 0 10px; }
.cell.edit { padding: 6px 4px; }
.vote {
  display: grid; place-items: center; width: 100%; min-width: 56px; height: 52px;
  border: 2px dashed var(--line); border-radius: 10px; background: var(--card); cursor: pointer; font: inherit; color: var(--muted);
}
.vote.yes { background: var(--yes-bg); border: 2px solid var(--yes); }
.vote.maybe { background: var(--maybe-bg); border: 2px solid var(--maybe); }
.vote.no { background: var(--no-bg); border: 2px solid var(--no); }
.vote .ic svg { width: 26px; height: 26px; }
.vote .ic.maybe svg { width: 32px; }

.linkbox { display: flex; gap: 8px; }
.add-date-fields { display: flex; flex-wrap: wrap; gap: 0 12px; }
.add-date-fields label { flex: 1 1 140px; margin-top: 0; }
.add-date-fields input { margin-top: 4px; font-weight: 400; }
.linkbox input { flex: 1; min-width: 0; font-size: .9rem; }
.created { border-color: var(--accent); }
.admin select { margin-bottom: 4px; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2); z-index: 10; max-width: calc(100% - 32px);
}
#toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 520px) {
  h1 { font-size: 1.45rem; }
  .grid .corner, .grid .name { min-width: 118px; width: 124px; max-width: 140px; }
  .card { padding: 14px; }
}
