:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d2433; --muted: #5d6577; --line: #dcd8cf;
  --brand: #2b3a67; --s0: #d9dde3; --s1: #d64545; --s2: #2e9e5b; --s3: #e0a400; --part: #b7e0c5;
  font-size: 20px; /* larger text by default */
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; line-height: 1.4; -webkit-text-size-adjust: 100%; }
main { max-width: 720px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 14px 90px; }
h1 { font-size: 1.6rem; margin: .3em 0 .2em; }
h2 { font-size: 1.2rem; margin: 1.4em 0 .5em; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big { font-size: 1.15rem; font-weight: 600; }

.top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.back { text-decoration: none; font-size: 1rem; display: inline-block; padding: 8px 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 10px 0; }
.card.event { border: 2px solid var(--s2); }
.card.error { border-color: var(--s1); }
a.card { display: block; text-decoration: none; color: inherit; }
.label { text-transform: uppercase; letter-spacing: .05em; font-size: .75rem; color: var(--muted); font-weight: 700; }

.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 8px 16px;
  font: inherit; font-size: 1rem; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.on { outline: 3px solid var(--brand); }
.btn.link { border: none; background: none; color: var(--muted); text-decoration: underline; }
.btn[disabled] { opacity: .45; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
input[type=text] { font: inherit; font-size: 1.05rem; width: 100%; min-height: 50px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.field { display: flex; gap: 8px; margin-top: 8px; }
.field input { flex: 1; }

.tabs { display: flex; gap: 6px; margin: 10px 0; }
.tabs a { flex: 1; text-align: center; padding: 12px 8px; border-radius: 12px; text-decoration: none; background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* Brushes */
.brushes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; }
.brush { font: inherit; font-size: .8rem; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); cursor: pointer; color: var(--ink); }
.brush.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; font-weight: 700; }
.sw { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-size: 1.1rem; color: #fff; }

/* State colours (always paired with a symbol) */
.s0 { background: var(--s0); color: var(--muted); }
.s1 { background: var(--s1); color: #fff; }
.s2 { background: var(--s2); color: #fff; }
.s3 { background: var(--s3); color: #1d2433; }

/* Grids */
.grid-head, .row { display: grid; grid-template-columns: 6.2em repeat(3, 1fr); gap: 6px; align-items: stretch; }
.grid-head { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 6px; }
.row { margin: 6px 0; }
.daylbl { font: inherit; font-size: .9rem; text-align: left; background: none; border: none; padding: 4px 2px; color: var(--ink); cursor: pointer; line-height: 1.15; }
.daylbl .chev { color: var(--muted); }
.daylbl.today { font-weight: 700; }
.cell { font: inherit; min-height: 52px; border: none; border-radius: 10px; font-size: 1.2rem; cursor: pointer; position: relative; display: grid; place-items: center; }
.cell .dot { position: absolute; top: 5px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.cell.good { background: var(--s2); color: #fff; }
.cell.part { background: var(--part); color: #14532d; font-size: .95rem; font-weight: 600; }
.cell.bad { background: #f3d6d6; color: #8a1c1c; }
.cell.unk { background: var(--s0); color: var(--muted); }
.cell.past { opacity: .35; }
.hours { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 5px; margin: 0 0 12px 6.2em; }
.hcell { font: inherit; border: none; border-radius: 8px; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1rem; cursor: pointer; }
.hcell small { font-size: .7rem; opacity: .9; }

/* Day view */
.hrow { display: grid; grid-template-columns: 4.2em 1fr; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 12px; margin: 4px 0; background: var(--card); border: 2px solid transparent; cursor: pointer; }
.hrow.good { background: #e3f4ea; }
.hrow.sel { border-color: var(--brand); }
.hrow .t { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 4px 10px; border-radius: 999px; font-size: .85rem; }
.panel { position: sticky; bottom: 10px; z-index: 3; box-shadow: 0 6px 24px rgba(0,0,0,.15); }

.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .8rem; color: var(--muted); margin: 6px 0; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 18px; height: 18px; border-radius: 5px; }

.run { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.run .when { flex: 1; }
.stars { color: #9a6d00; font-weight: 700; white-space: nowrap; }

#status { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 8px 16px; border-radius: 999px; font-size: .9rem; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 10; }
#status.show { opacity: .92; }
.linkbox { font-size: .85rem; word-break: break-all; background: #f0eee8; padding: 10px; border-radius: 10px; margin-top: 8px; user-select: all; }
