:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e3e1dd;
  --brand: #6b0f1a;
  --green: #1f7a3d;
  --green-bg: #e3f5e8;
  --red: #b42318;
  --red-bg: #fde8e6;
  --amber: #9a5b00;
  --amber-bg: #fff3d6;
  --yellow: #7a5a00;
  --yellow-bg: #fff2a8;
  --yellow-line: #f0d84a;
  --blue-bg: #e8f0fd;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--brand); }
main { max-width: 980px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
h1 { font-size: 1.5rem; margin: .25rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; }
h2.day { color: var(--muted); font-weight: 600; font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.right { text-align: right; }

/* header */
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  padding: .75rem 1.25rem; background: var(--brand); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.2rem; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem; }
.top nav a { color: #f3dfe1; text-decoration: none; padding: .3rem .65rem; border-radius: 6px; font-size: .95rem; }
.top nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.top nav a.on { background: rgba(255,255,255,.2); color: #fff; }
.top nav a.quiet { opacity: .8; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
footer a { color: var(--muted); }
.revision { margin-bottom: 1rem; }
.revision h2 { margin: 0 0 .4rem; font-size: 1.15rem; }
.revision h2 .muted { font-weight: 400; font-size: .95rem; }
.revision ul { margin: 0; padding-left: 1.25rem; }
.revision li { margin: .2rem 0; }
.revision.current { box-shadow: 0 0 0 2px var(--brand); }
.chip.current { background: var(--brand); border-color: var(--brand); color: #fff; }
.choice { display: block; font-weight: 400 !important; margin: .35rem 0; }
.choice input { width: auto !important; display: inline !important; margin: 0 .4rem 0 0 !important; }

/* the verdict */
.verdict { border-radius: var(--radius); padding: 1.4rem 1.6rem; margin-bottom: 1rem; border: 2px solid; }
.verdict .big { font-size: clamp(1.6rem, 4.5vw, 2.6rem); font-weight: 800; line-height: 1.15; }
.verdict .sub { margin-top: .35rem; font-size: 1.05rem; }
.verdict.clear { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.verdict.occupied { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.verdict.stale { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.verdict .who { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .35rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); color: var(--ink); font-size: 1.05rem; }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { background: #faf9f7; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.name { font-weight: 600; }
td.time { color: var(--muted); white-space: nowrap; width: 7.5rem; font-variant-numeric: tabular-nums; }
td.empty, p.empty { color: var(--muted); text-align: center; padding: 1.5rem; }
table.board td { font-size: 1.05rem; padding: .7rem .9rem; }
table.list:not(.devices) { table-layout: fixed; }
table.list:not(.devices):not(.kv) td:nth-child(2) { width: 30%; }
table.list:not(.devices):not(.kv) td:nth-child(3) { width: 7rem; }
table.kv th { width: 40%; text-transform: none; letter-spacing: 0; font-size: .95rem; background: var(--card); }
tr.inactive td { opacity: .55; }

.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.pill.here { background: var(--green-bg); color: var(--green); }
.pill.leaving { background: var(--yellow-bg); color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow-line); }
.pill.away { background: #eeedeb; color: var(--muted); }
.pill.unknown { background: var(--amber-bg); color: var(--amber); }
.chip { display: inline-block; padding: .05rem .5rem; border-radius: 6px; font-size: .85rem; background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.chip.ghost { background: transparent; color: var(--muted); }
.chip.leaving { background: var(--yellow-bg); border-color: var(--yellow-line); color: var(--yellow); }
.chip.warn { background: var(--amber-bg); border-color: #f0d38a; color: var(--amber); font-family: system-ui, sans-serif; }
.wifi { display: inline-block; font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 .45rem; margin-left: .25rem; white-space: nowrap; vertical-align: 1px; }
.warn-text { color: var(--amber); }
.hint { font-size: .8rem; color: var(--green); margin-top: .2rem; }

.note { color: var(--muted); font-size: .9rem; }
.updated { color: var(--muted); font-size: .85rem; text-align: center; margin-top: .75rem; }

/* forms */
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); padding: 1rem; margin: 1rem 0; }
.card.narrow { max-width: 380px; margin: 3rem auto; }
.card h2 { margin-top: 0; }
.card ol { padding-left: 1.25rem; margin: .25rem 0 .75rem; }
.card ol li { margin-bottom: .3rem; }
.card label { display: block; margin-bottom: .75rem; font-weight: 600; }
.card label input { display: block; width: 100%; margin-top: .3rem; }
.inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline form { margin: 0; }
.grid2 { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
input, select, textarea, button, .button {
  font: inherit; padding: .45rem .7rem; border-radius: 8px; border: 1px solid #cfccc6; background: #fff; color: var(--ink);
}
textarea { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; margin: .5rem 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
button, .button { background: var(--brand); border-color: var(--brand); color: #fff; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-block; }
button:hover, .button:hover { filter: brightness(1.1); }
button.secondary { background: #fff; color: var(--brand); }
button.danger { background: #fff; color: var(--red); border-color: var(--red); }
button.link { background: none; border: 0; color: var(--brand); padding: 0; font-weight: 500; text-decoration: underline; }
details summary { cursor: pointer; font-weight: 600; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .75rem; }
.flash.ok { background: var(--green-bg); color: var(--green); }
.flash.error { background: var(--red-bg); color: var(--red); }
.flash.warn { background: var(--amber-bg); color: var(--amber); }
.flash.info { background: var(--blue-bg); color: #1d3f7a; }

@media (max-width: 640px) {
  main { padding: 1rem .6rem 2rem; }
  table.board td { font-size: .95rem; padding: .55rem .5rem; }
  table.list { table-layout: auto; }
  table.devices th:nth-child(2), table.devices td:nth-child(2) { display: none; }
  th, td { padding: .5rem; }
}

/* help page */
.lead { font-size: 1.08rem; }
.toc { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; }
.toc a { background: var(--card); box-shadow: 0 0 0 1px var(--line); border-radius: 999px; padding: .25rem .75rem; text-decoration: none; font-size: .92rem; }
.card h3 { font-size: 1rem; margin: 1.1rem 0 .45rem; }
.card h2 { margin-top: 0; }
.sheets { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.legend { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: .5rem 1rem; align-items: center; }
.legend p { margin: 0; }
.verdict.mini { padding: .5rem .8rem; margin: 0; border-width: 2px; }
.verdict.mini .big { font-size: 1.05rem; }
.dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; margin-right: .4rem; vertical-align: -1px; }
.dot.clear { background: var(--green); } .dot.occupied { background: var(--red); } .dot.stale { background: var(--amber); }
ol.steps li { margin: .35rem 0; }
dl.faq dt { font-weight: 700; margin-top: .9rem; }
dl.faq dd { margin: .25rem 0 0; }
section[id] { scroll-margin-top: 1rem; }
@media (max-width: 640px) { .legend { grid-template-columns: 1fr; } .legend p { margin-bottom: .6rem; } }

a.person { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
a.person:hover { color: var(--brand); border-bottom-color: var(--brand); }
.person-now { font-size: 1.05rem; margin: -.5rem 0 1rem; }

/* ---------- phones (iPhone and Android) ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .top { padding: .55rem .75rem .35rem; gap: .25rem; }
  .brand { font-size: 1.1rem; }
  /* one swipeable row of tabs instead of several wrapped lines */
  .top nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; margin: 0 -.25rem; padding-bottom: .2rem;
             -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { flex: 0 0 auto; padding: .45rem .7rem; font-size: .95rem; }
  main { padding: .8rem .65rem 1.5rem; }
  h1 { font-size: 1.35rem; }
  .verdict { padding: 1rem 1.1rem; }
  .verdict .who { grid-template-columns: 1fr; }

  /* board: one card per person */
  table.board, table.board tbody { display: block; box-shadow: none; background: none; }
  table.board thead { display: none; }
  table.board tr { display: grid; grid-template-columns: 1fr auto; gap: .15rem .6rem; align-items: center;
                   background: var(--card); box-shadow: 0 0 0 1px var(--line); border-radius: var(--radius);
                   padding: .7rem .85rem; margin-bottom: .5rem; }
  table.board td { border: 0; padding: 0; font-size: 1rem; }
  table.board td.name { font-size: 1.08rem; }
  table.board td.where, table.board td.when { grid-column: 1 / -1; }
  table.board td.where.empty { display: none; }
  table.board td.when { font-size: .9rem; }
  table.board td.empty { grid-column: 1 / -1; }

  /* history: time and status on one line, name, then place */
  table.events, table.events tbody { display: block; table-layout: auto; }
  table.events tr { display: grid; grid-template-columns: auto 1fr auto; gap: .1rem .6rem; align-items: center;
                    padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
  table.events tr:last-child { border-bottom: 0; }
  table.events td { border: 0; padding: 0; width: auto !important; }
  table.events td.time { width: auto; font-size: .9rem; }
  table.events td:nth-child(4) { grid-column: 1 / -1; font-size: .9rem; color: var(--muted); }
  table.events td:nth-child(4):empty { display: none; }

  .filters select, .filters input { flex: 1 1 45%; min-width: 0; }
  .card { padding: .85rem; }
  button, .button { padding: .6rem .9rem; }
  table.list td, table.list th { padding: .55rem .5rem; }
  footer { padding: 1rem .75rem 1.5rem; }
}

/* refresh */
a.refresh-now { white-space: nowrap; }
.ptr { position: fixed; top: 0; left: 50%; z-index: 50; margin-left: -6.5rem; width: 13rem;
       transform: translateY(-60px); opacity: 0; pointer-events: none;
       display: flex; align-items: center; justify-content: center; gap: .45rem;
       background: var(--card); color: var(--ink); border-radius: 999px; padding: .45rem .9rem;
       box-shadow: 0 2px 10px rgba(0,0,0,.18); font-size: .9rem; font-weight: 600; }
.ptr-arrow { display: inline-block; transition: transform .15s; color: var(--brand); font-size: 1.05rem; }
.ptr.ready .ptr-arrow { transform: rotate(180deg); }
.ptr.spinning .ptr-arrow { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
html.ptr-on, html.ptr-on body { overscroll-behavior-y: contain; }
body.ptr-refreshing main { opacity: .55; transition: opacity .15s; }
