:root {
  color-scheme: light;
  --bg: #f4f5f8; --fg: #15191f; --muted: #5d6570; --line: #dde0e8; --panel: #ffffff;
  --brand: #2b4a8f; --head: #1a2f5c; --up: #1f7a49; --down: #b8352c; --on: #ffffff;
  --green: #237a4b; --green-t: #dff3e7; --teal: #0f7676; --teal-t: #d8f1f0;
  --blue: #2b5fb8; --blue-t: #e0e9f8; --orange: #b35a0e; --orange-t: #fbe8d7;
  --red: #b8352c; --red-t: #f8dfdc; --purple: #7a43b0; --purple-t: #ede3f7;
  --yellow: #8a6a00; --yellow-t: #f6eec9; --pink: #b03a72; --pink-t: #f8e0eb;
  --brown: #7a5230; --brown-t: #f0e5da;
  --to-dark: inline; --to-light: none;
}
/* Dark follows the system, unless the person picked light or dark at the top */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;
    --bg: #0f1116; --fg: #e6ebe7; --muted: #9aa49e; --line: #2a2f3a; --panel: #171a21;
    --brand: #8fb4ff; --head: #101d3a; --up: #63d193; --down: #f4817a; --on: #0f1311;
    --green: #5fcf8f; --green-t: #15301f; --teal: #4fd1cc; --teal-t: #0f2f2e;
    --blue: #7aa7f5; --blue-t: #16233d; --orange: #f5a35a; --orange-t: #352312;
    --red: #f4807a; --red-t: #381a18; --purple: #b893ee; --purple-t: #281c38;
    --yellow: #e8c547; --yellow-t: #322a0e; --pink: #f08cbc; --pink-t: #351a28;
    --brown: #d1a77d; --brown-t: #2e2217;
    --to-dark: none; --to-light: inline;
  }
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #0f1116; --fg: #e6ebe7; --muted: #9aa49e; --line: #2a2f3a; --panel: #171a21;
  --brand: #8fb4ff; --head: #101d3a; --up: #63d193; --down: #f4817a; --on: #0f1311;
  --green: #5fcf8f; --green-t: #15301f; --teal: #4fd1cc; --teal-t: #0f2f2e;
  --blue: #7aa7f5; --blue-t: #16233d; --orange: #f5a35a; --orange-t: #352312;
  --red: #f4807a; --red-t: #381a18; --purple: #b893ee; --purple-t: #281c38;
  --yellow: #e8c547; --yellow-t: #322a0e; --pink: #f08cbc; --pink-t: #351a28;
  --brown: #d1a77d; --brown-t: #2e2217;
  --to-dark: none; --to-light: inline;
}

/* One colour pair per card type, and one per column */
.c-green { --c: var(--green); --t: var(--green-t); }
.c-teal { --c: var(--teal); --t: var(--teal-t); }
.c-blue { --c: var(--blue); --t: var(--blue-t); }
.c-orange { --c: var(--orange); --t: var(--orange-t); }
.c-red { --c: var(--red); --t: var(--red-t); }
.c-purple { --c: var(--purple); --t: var(--purple-t); }
.c-yellow { --c: var(--yellow); --t: var(--yellow-t); }
.c-pink { --c: var(--pink); --t: var(--pink-t); }
.c-brown { --c: var(--brown); --t: var(--brown-t); }

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--fg); background: var(--bg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--c, var(--brand)); text-underline-offset: 3px; }
h1 { margin: 0; font-size: 22px; color: var(--c, var(--brand)); }
h2 { margin: 0 0 8px; font-size: 16px; color: var(--c, var(--brand)); }
.small, label, th { font-size: 13px; }
.small { color: var(--muted); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); }
textarea { font-family: ui-monospace, monospace; font-size: 13px; resize: vertical; }
button, .button { display: inline-block; padding: 8px 14px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--c, var(--brand)); color: var(--on); font-weight: 700; text-decoration: none; }
button.link { padding: 0; background: none; color: inherit; font-weight: 400; text-decoration: underline; }
.to-dark { display: var(--to-dark); } .to-light { display: var(--to-light); }
.vh { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }

header { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; padding: 10px 16px;
  background: var(--head); color: #fff; }
header .brand { display: flex; gap: 10px; align-items: center; color: #fff; font-size: 20px; font-weight: 700;
  text-decoration: none; margin-right: auto; }
header .brand img { width: 30px; height: 30px; }
header nav { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
header nav a { color: #fff; text-decoration: none; padding-bottom: 2px; border-bottom: 3px solid var(--c); }
header nav a.on { font-weight: 700; }
header nav button.link { color: #fff; }
.count { padding: 0 7px; border-radius: 10px; background: var(--c); color: var(--on); }

main { padding: 16px; }
.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin-bottom: 12px; }
section { margin: 0 0 20px; max-width: 1000px; }
.card { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin: 0 0 6px; padding: 10px 12px;
  border-left: 5px solid var(--c); border-radius: 8px; background: var(--t); color: var(--fg); text-decoration: none; }
.card .small { margin-left: auto; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 10px; background: var(--c, var(--line)); color: var(--on);
  font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
h2 .chip { background: var(--c); }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
/* Doors share each row equally, so a group never leaves one or two alone on a line of their own */
.doors { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.door { flex: 1 1 150px; display: flex; flex-direction: column; padding: 14px; border-radius: 10px; background: var(--c); color: var(--on);
  font-weight: 700; text-decoration: none; }
.door b { font-size: 28px; line-height: 1.1; }
.door .small { color: var(--on); font-weight: 400; }
.empty { color: var(--muted); }
.box { max-width: 520px; margin: 40px auto; padding: 20px; border-top: 5px solid var(--c); border-radius: 10px;
  background: var(--panel); }

.text { max-width: 720px; padding: 4px 20px; border-radius: 10px; background: var(--panel); margin-bottom: 16px; }
.text h1, .text h2, .text h3 { color: var(--fg); margin: 20px 0 8px; }
.text table, table { border-collapse: collapse; }
table.wide { width: 100%; }
td, th { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--c, var(--brand)); }
details { margin: 12px 0; max-width: 1000px; }
summary { cursor: pointer; color: var(--muted); }
details.card { display: block; }
details.card summary { color: var(--fg); }
pre { overflow-x: auto; padding: 10px; border-radius: 8px; background: var(--panel); font-size: 13px; }

.sheet { display: grid; gap: 12px; max-width: 720px; padding: 16px; border-top: 5px solid var(--c); border-radius: 10px;
  background: var(--panel); }
.sheet label { display: grid; gap: 4px; color: var(--c); font-weight: 700; }
.sheet button { justify-self: start; }
form.inline { display: inline; }
.decide { display: flex; flex-wrap: wrap; gap: 10px; max-width: 720px; }
.decide input { flex: 1; min-width: 200px; }
ins { background: var(--green-t); color: var(--green); text-decoration: none; border-radius: 3px; padding: 0 2px; }
del { background: var(--red-t); color: var(--red); text-decoration: line-through; border-radius: 3px; padding: 0 2px; }
.diff .add { background: var(--green-t); border-left: 4px solid var(--green); border-radius: 6px; padding: 1px 10px; margin: 6px 0; }
.diff .cut { background: var(--red-t); border-left: 4px solid var(--red); border-radius: 6px; padding: 1px 10px; margin: 6px 0;
  text-decoration: line-through; color: var(--red); }

.tour { position: fixed; inset: auto 16px 16px auto; max-width: 340px; margin: 0; padding: 14px; border: 0;
  border-top: 5px solid var(--orange); border-radius: 10px; background: var(--panel); color: var(--fg); z-index: 5; }
.tour p { margin: 0 0 10px; }
.tour div { display: flex; gap: 14px; align-items: center; }
.toured { outline: 3px solid var(--orange); outline-offset: 4px; border-radius: 6px; }
@media (max-width: 600px) { .tour { inset: auto 8px 8px 8px; max-width: none; } }

.two { display: grid; grid-template-columns: minmax(0, 720px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.side section { margin-bottom: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.row input:not([type=checkbox]) { flex: 1; min-width: 160px; width: auto; }
.row select { width: auto; }
.top .row { margin: 0; flex: 1; max-width: 560px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; color: var(--fg); font-weight: 400; }
.check input { width: 18px; height: 18px; accent-color: var(--c, var(--brand)); }
.step { margin: 0 0 6px; }
.chip.big { font-size: 16px; padding: 4px 14px; border-radius: 14px; }
tr.gone { opacity: .55; }
table.grid { display: block; overflow-x: auto; margin: 0 0 20px; border-collapse: separate; border-spacing: 4px; }
table.grid th { border: 0; color: var(--muted); }
table.grid td { min-width: 130px; height: 64px; border: 0; border-radius: 8px; background: var(--t); border-left: 5px solid var(--c); }
table.grid td .small { display: block; color: var(--c); font-weight: 700; }
table.grid td .chip { margin: 2px 2px 0 0; white-space: normal; }
.facts .chip { white-space: normal; }
@media print {
  header, .noprint, dialog { display: none !important; }
  body { background: #fff; }
  .door, .chip, .card { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
@media (max-width: 700px) { table.wide { display: block; overflow-x: auto; } }
@media (max-width: 700px) { .top .row { flex-basis: 100%; max-width: none; } }
.gate { display: grid; gap: 12px; margin-top: 8vh; background: var(--panel); }
.gate label { display: grid; gap: 4px; color: var(--c); font-weight: 700; }
.gate button { justify-self: start; }
.hero { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.hero img { width: 64px; height: 64px; }
.hero b { display: block; font-size: 22px; color: var(--brand); }
.hero span { color: var(--muted); }
.said { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--red-t); color: var(--red); font-weight: 700; }
.qr svg { display: block; border-radius: 8px; }
.link-out { word-break: break-all; }
header form.inline button.link { color: #fff; }

/* One line per person; on a phone the table scrolls sideways. */
table.people td { white-space: nowrap; }

/* The board page fills the window, and the board scrolls inside it both ways, so the column heads
   stay on top and the row names on the left. */
.boardpage { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.boardpage main { display: flex; flex-direction: column; flex: 1; min-height: 0; padding-bottom: 0; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
details.new { position: relative; }
details.new > summary { list-style: none; cursor: pointer; padding: 4px 14px; border-radius: 8px;
  background: var(--c); color: var(--on); font-weight: 700; }
details.new > summary::-webkit-details-marker { display: none; }
details.new form { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; display: grid; gap: 8px;
  width: min(320px, calc(100vw - 32px)); padding: 12px; border: 1px solid var(--line); border-top: 4px solid var(--c);
  border-radius: 10px; background: var(--panel); }
details.new button { justify-self: start; }
.views { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.views a { padding: 4px 12px; color: var(--fg); text-decoration: none; font-size: 13px; background: var(--panel); }
.views a.on { background: var(--c); color: var(--on); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chips a { opacity: .6; }
.chips a.on, .chips a:hover { opacity: 1; outline: 2px solid var(--c); outline-offset: 1px; }
.dot { padding: 0 5px; border-radius: 8px; background: var(--red); color: var(--on); border: 1px solid var(--on);
  font-size: 11px; }
.search input { width: 190px; padding: 5px 10px; font-size: 13px; }
.tag { display: inline-block; padding: 0 7px; border-radius: 6px; background: var(--t); color: var(--c);
  font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.tag.who { border-radius: 10px; }

.board { flex: 1; min-height: 0; overflow: auto; padding-bottom: 8px; }
.brow { display: flex; flex-wrap: nowrap; gap: 8px; min-width: min-content; }
.colhead, .cell { flex: 1 1 0; min-width: 220px; }
.brow.head { position: sticky; top: 0; z-index: 3; align-items: start; padding-bottom: 4px; background: var(--bg); }
.colhead { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 8px;
  background: var(--c); color: var(--on); font-weight: 700; }
.colhead .n { margin-left: auto; padding: 0 6px; font-size: 13px; }
.colhead .n.over { border-radius: 6px; background: var(--red); }
button.fold { padding: 0 5px; background: none; color: inherit; font-size: 14px; line-height: 1.4; }
.lanehead { position: sticky; left: 0; display: flex; align-items: center; gap: 6px; width: fit-content;
  margin: 10px 0 4px; color: var(--c); font-size: 14px; font-weight: 700; }
.lanehead.folded .fold { transform: rotate(-90deg); }
.cells.folded { display: none; }
.cell { display: flex; flex-direction: column; gap: 6px; min-height: 52px; padding: 6px; border-radius: 8px;
  background: color-mix(in srgb, var(--t) 60%, transparent); }
.cell.over { outline: 2px dashed var(--c); outline-offset: -2px; }
.colhead.folded, .cell.folded { flex: 0 0 34px; min-width: 34px; }
/* A folded column keeps a head as high as the others; its name runs down each row's strip */
.colhead.folded { justify-content: center; padding: 4px 0; }
.colhead.folded > :not(.fold) { display: none; }
.colhead.folded .fold { transform: rotate(180deg); }
.cell.folded > * { display: none; }
.cell.folded::before { content: attr(data-col); overflow: hidden; writing-mode: vertical-rl; color: var(--c);
  font-size: 13px; font-weight: 700; white-space: nowrap; }
.board[data-by=owner] .meta .who { display: none; }

/* A card on the board: its title, and more only when there is more to say */
.tile { display: flex; flex-direction: column; gap: 4px; padding: 7px 10px; border-left: 4px solid var(--c); border-radius: 8px;
  background: var(--panel); color: var(--fg); text-decoration: none; font-size: 14px; line-height: 1.35;
  cursor: grab; user-select: none; overflow-wrap: anywhere; }
.tile:hover { outline: 1px solid var(--c); }
.tile.dragging { position: relative; z-index: 4; pointer-events: none; opacity: .9; }
.tile .title { font-weight: 700; }
.tile .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tile .subs { display: flex; flex-direction: column; padding-left: 8px; border-left: 2px solid var(--line);
  color: var(--muted); font-size: 13px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--muted); font-size: 12px; }
.meta .who { margin-left: auto; }
.due.late { padding: 0 5px; border-radius: 6px; background: var(--red); color: var(--on); font-weight: 700; }
.progress { display: inline-flex; align-items: center; gap: 5px; }
progress { width: 46px; height: 6px; accent-color: var(--green); }
.addcard input { padding: 3px 8px; border-color: transparent; background: transparent; font-size: 13px; }
.addcard input:focus { border-color: var(--c); background: var(--panel); }

/* The card, open beside the board */
.cardpanel { position: fixed; z-index: 4; top: 0; right: 0; bottom: 0; width: min(540px, 100vw); overflow-y: auto;
  padding: 12px 18px 30px; border-left: 4px solid var(--yellow); background: var(--bg); }
.cardpanel .close { float: right; margin-left: 12px; font-size: 28px; line-height: 1; color: var(--muted); text-decoration: none; }
.cardpanel .sheet { margin-bottom: 16px; }
.picks { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.picks .label { width: 100%; color: var(--c); font-size: 13px; font-weight: 700; }
.picks input[name=newtag] { width: 140px; padding: 3px 8px; font-size: 13px; }
@media (max-width: 600px) {
  .colhead, .cell { min-width: 78vw; }
  .search input { width: 140px; }
}
.sheet .picks label.check { display: flex; color: var(--fg); font-weight: 400; }
.sheet input, .sheet select, .sheet textarea { color: var(--fg); font-weight: 400; }

/* A HyperList drawn as a flow chart: steps blue, questions orange, parts lists teal, hand-overs purple */
.flow { margin: 12px 0; overflow-x: auto; }
.flow svg { max-width: none; height: auto; }
.flow svg .node path, .flow svg .node polygon { fill: var(--blue-t); stroke: var(--blue); stroke-width: 1.5; }
.flow svg .ask polygon { fill: var(--orange-t); stroke: var(--orange); }
.flow svg .parts polygon { fill: var(--teal-t); stroke: var(--teal); }
.flow svg .hand path { fill: var(--purple-t); stroke: var(--purple); }
.flow svg text { fill: var(--fg); }
.flow svg .edge path { stroke: var(--muted); }
.flow svg .edge polygon { fill: var(--muted); stroke: var(--muted); }
.flow svg .edge text { fill: var(--orange); }
.flow svg .jump path { stroke: var(--purple); stroke-dasharray: 4 3; }
.flow svg .jump polygon { fill: var(--purple); stroke: var(--purple); }

/* Admin: one line for each switch */
#switches .check { padding: 6px 0; }
#switches .days { width: 70px; height: auto; }  /* .check input is a tick box of 18px */
