:root {
  --accent-default: #e8b53a;
  --bg: #1b1f2a; --bg2: #232838; --panel: #262b38; --panel2: #303648; --line: #3a4157;
  --text: #f4f1e8; --muted: #a9b0c2; --gold: #e8b53a; --ok: #3ddc84; --bad: #ff5c5c;
  --radius: 18px; --tap: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 17px/1.4 var(--font); overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: var(--panel2); color: var(--text); border-radius: 12px; min-height: var(--tap); padding: 0 18px; }
button.primary { background: var(--gold); color: #1b1f2a; font-weight: 700; }
button.ghost { background: transparent; color: var(--muted); }
button.danger { background: #5a2a2a; color: #ffb4b4; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; min-height: var(--tap); padding: 10px 14px; width: 100%; }
textarea { min-height: 90px; }
label { display: block; color: var(--muted); font-size: .9rem; margin: 12px 0 6px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.chip { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 6px 12px; background: var(--panel2); font-size: .9rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }

/* Login overlay */
.overlay { position: fixed; inset: 0; background: rgba(20, 23, 32, .96); display: grid; place-items: center; padding: 24px; z-index: 50; }
.card { background: var(--panel); border-radius: var(--radius); padding: 28px; width: min(420px, 100%); }
.card h2 { margin: 0 0 6px; }
.error { color: var(--bad); margin-top: 10px; min-height: 1.4em; }

/* Display page */
.display { height: 100%; display: grid; grid-template-rows: auto 1fr auto; padding: 28px 36px; gap: 20px; }
.display header { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.display .clock { font-size: clamp(3rem, 9vw, 7rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.display .date { color: var(--muted); font-size: clamp(1.1rem, 2.4vw, 1.8rem); margin-top: 6px; }
.weather { display: flex; align-items: center; gap: 14px; background: var(--panel); border-radius: var(--radius); padding: 14px 22px; }
.weather .temp { font-size: 2.6rem; font-weight: 700; line-height: 1; }
.weather .icon { font-size: 2.8rem; }
.weather .desc { color: var(--muted); font-size: .95rem; }
.display main { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; min-height: 0; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 20px 22px; overflow: hidden; display: flex; flex-direction: column; }
.panel h2 { margin: 0 0 12px; font-size: 1.15rem; color: var(--gold); letter-spacing: .04em; text-transform: uppercase; }
.panel .list { overflow: hidden; flex: 1; }
.ev { display: grid; grid-template-columns: 6px 110px 1fr; gap: 14px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: 0; }
.ev .bar { width: 6px; border-radius: 3px; background: var(--c, var(--muted)); align-self: stretch; }
.ev .time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev .title { font-weight: 600; }
.ev .sub { color: var(--muted); font-size: .9rem; }
.ev.layer .bar { background: var(--gold); }
.daygroup h3 { margin: 14px 0 4px; font-size: 1rem; color: var(--muted); font-weight: 600; }
.empty { color: var(--muted); padding: 14px 0; }
.display footer { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .95rem; }
.display footer .status { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
.people { display: flex; gap: 10px; flex-wrap: wrap; }
.person { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border-radius: 999px; padding: 8px 14px 8px 10px; }

/* Photo reel */
.reel { position: fixed; inset: 0; background: #000; display: none; }
.reel.on { display: block; }
.reel img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 1.2s; }
.reel img.show { opacity: 1; }
.reel .corner { position: absolute; left: 32px; bottom: 28px; background: rgba(20, 23, 32, .72); border-radius: var(--radius); padding: 16px 22px; backdrop-filter: blur(6px); }
.reel .corner .clock { font-size: 3rem; font-weight: 700; line-height: 1; }
.reel .corner .next { color: var(--muted); margin-top: 6px; max-width: 40vw; }

/* Touch app */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--bg2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .title { font-weight: 700; font-size: 1.2rem; margin-right: 8px; }
.topbar .title span { color: var(--gold); }
.tabs { display: inline-flex; background: var(--panel); border-radius: 12px; padding: 4px; }
.tabs button { min-height: 48px; padding: 0 18px; font-size: 1rem; background: transparent; color: var(--muted); border-radius: 9px; }
.tabs button.on { background: var(--panel2); color: var(--text); }
.nav { display: inline-flex; gap: 6px; align-items: center; }
.nav button { min-width: 48px; }
.nav .label { min-width: 200px; text-align: center; font-weight: 600; }
.view { padding: 14px 16px; overflow: auto; }

.dayview .allday { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.dayview .ev { grid-template-columns: 6px 120px 1fr; background: var(--panel); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; border: 0; }

.weekview { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; min-height: 60vh; }
.weekview .col { background: var(--panel); border-radius: 12px; padding: 8px; min-width: 0; }
.weekview .col h4 { margin: 0 0 8px; font-size: .95rem; color: var(--muted); text-align: center; }
.weekview .col.today h4 { color: var(--gold); }
.evc { border-left: 4px solid var(--c, var(--muted)); background: var(--panel2); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: .88rem; overflow: hidden; }
.evc .t { color: var(--muted); font-size: .8rem; }
.evc.layer { border-left-color: var(--gold); background: #3a3520; }

.monthview { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.monthview .dow { text-align: center; color: var(--muted); font-size: .85rem; padding: 4px 0; }
.monthview .cell { background: var(--panel); border-radius: 10px; min-height: 92px; padding: 6px; font-size: .82rem; overflow: hidden; }
.monthview .cell.out { opacity: .45; }
.monthview .cell.today .num { background: var(--gold); color: #1b1f2a; }
.monthview .num { display: inline-block; min-width: 24px; text-align: center; border-radius: 12px; font-weight: 600; margin-bottom: 4px; }
.monthview .pill { display: block; border-left: 3px solid var(--c, var(--muted)); padding-left: 5px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.monthview .pill.layer { border-left-color: var(--gold); color: var(--gold); }
.monthview .more { color: var(--muted); }

/* Sections */
.section { min-height: 0; overflow: auto; }
#sec-calendar { display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.childbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.childbar button { min-height: 56px; border-radius: 999px; background: var(--bg2); border: 3px solid var(--c); font-size: 1.1rem; font-weight: 600; padding: 0 22px; }
.childbar button.on { background: var(--c); color: #fff; }
.lootbig { display: flex; align-items: center; gap: 16px; background: linear-gradient(135deg, #3a3520, #262b38); border: 1px solid #5a512c; border-radius: var(--radius); padding: 16px 22px; margin-bottom: 18px; }
.lootbig .coin { font-size: 2.8rem; }
.lootbig .amount { font-size: 2rem; font-weight: 700; color: var(--gold); line-height: 1; }
.lootbig .pounds { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card-chore { background: var(--panel); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card-chore .icon { font-size: 2.2rem; line-height: 1; }
.card-chore .name { font-weight: 600; font-size: 1.05rem; }
.card-chore .value { color: var(--gold); font-size: .9rem; }
.card-chore .state { color: var(--muted); font-size: .9rem; }
.card-chore .row button { flex: 1; min-height: 46px; padding: 0 10px; }
.card-chore.waiting { border: 1px solid #5a512c; }
.card-chore.finished { opacity: .6; }
.progress { height: 10px; background: var(--bg2); border-radius: 5px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); }
h2.sec { margin: 6px 0 12px; font-size: 1.15rem; color: var(--gold); letter-spacing: .04em; text-transform: uppercase; }
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 10px; justify-content: center; margin: 14px 0; }
.pinpad button { min-height: 64px; font-size: 1.5rem; border-radius: 16px; }
.pindots { text-align: center; font-size: 2rem; letter-spacing: .4em; min-height: 2.6rem; }
.ledger td.amt { text-align: right; font-weight: 700; white-space: nowrap; }
.ledger td.amt.neg { color: var(--bad); } .ledger td.amt.pos { color: var(--ok); }
.approvals .item { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; flex-wrap: wrap; }
.approvals .item .who { font-weight: 600; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { min-height: 42px; min-width: 46px; padding: 0 8px; border-radius: 10px; background: var(--bg2); border: 2px solid var(--line); }
.days button.on { background: var(--gold); color: #1b1f2a; border-color: var(--gold); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .two { grid-template-columns: 1fr; } }

/* Expiry banner */
.banner { background: #3a3520; color: var(--gold); border: 1px solid #5a512c; border-radius: 12px; padding: 10px 16px; margin: 10px 16px 0; font-size: 1rem; }
.display .banner { margin: 0; }
.display.has-banner { grid-template-rows: auto auto 1fr auto; }
.display .banner.hidden { display: none; }

/* Breathing room in forms and cards */
.two + .row, .row + .row, label + .row { margin-top: 12px; }
.card-chore .progress { margin: 6px 0 8px; }
.card-chore .state + .state { margin-top: 2px; }
.card-chore .muted { line-height: 1.35; }
h2.sec + .two, h2.sec + .row { margin-top: 6px; }

.swatch { min-height: 44px; min-width: 44px; padding: 0; border-radius: 50%; border: 3px solid var(--line); }

/* Display loot row */
.display main.with-loot { grid-template-rows: minmax(220px, 1fr) auto auto auto; }
.display .panel { min-height: 220px; }
.loottile.countdown { grid-template-columns: 1fr; gap: 4px; }
.loottile.countdown .cd { font-size: 1.05rem; }
.loottile.countdown .cd b { color: var(--gold); }
.loottile.money .amount { color: var(--text); }
.lootrow { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.loottile { background: var(--panel); border-radius: var(--radius); padding: 12px 18px; border-top: 8px solid var(--c); display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
.loottile .name { font-size: 1.3rem; font-weight: 700; grid-column: 1 / -1; }
.loottile .coin { font-size: 2.4rem; }
.loottile .amount { font-size: 1.9rem; font-weight: 700; color: var(--gold); line-height: 1.1; }
.loottile .sub { color: var(--muted); font-size: .9rem; grid-column: 1 / -1; }

.emoji-strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.emoji-strip button { min-height: 44px; min-width: 44px; padding: 0 8px; font-size: 1.4rem; border-radius: 10px; }

/* Sheet (event editor / details) */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: none; align-items: flex-end; justify-content: center; z-index: 40; }
.sheet.on { display: flex; }
.sheet .body { background: var(--panel); border-radius: var(--radius) var(--radius) 0 0; width: min(720px, 100%); max-height: 92vh; overflow: auto; padding: 22px 22px 34px; }
.sheet h2 { margin: 0 0 8px; }
.members { display: flex; gap: 8px; flex-wrap: wrap; }
.members button { min-height: 44px; border-radius: 999px; background: var(--bg2); border: 2px solid var(--c); color: var(--text); }
.members button.on { background: var(--c); color: #fff; }
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.actions .primary { flex: 1; }
table.plain { width: 100%; border-collapse: collapse; }
table.plain td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); padding: 12px 18px; border-radius: 12px; z-index: 60; }

@media (max-width: 700px) {
  .display main { grid-template-columns: 1fr; }
  .weekview { grid-template-columns: 1fr; }
  .monthview .cell { min-height: 64px; }
  .nav .label { min-width: 120px; }
}

/* Phone layout */
.phone-only { display: none; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-grid button { min-height: 64px; font-size: 1.05rem; display: flex; align-items: center; gap: 12px; justify-content: flex-start; padding: 0 16px; }
.menu-grid button.on { background: var(--gold); color: #1b1f2a; font-weight: 700; }
.menu-grid .mi { font-size: 1.5rem; }
.app-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--panel); color: var(--muted); text-decoration: none; }
@media (max-width: 700px) {
  .phone-only { display: inline-flex; }
  .wide-only { display: none !important; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .title { font-size: 1.25rem; }
  .toolbar { padding: 8px 12px; gap: 8px; }
  .nav .label { min-width: 0; flex: 1; text-align: left; }
  .toolbar .primary { width: 100%; }
  .view { padding: 12px; }
  /* dashboard stacks and grows instead of fitting one screen */
  .display { height: auto; min-height: 100%; grid-template-rows: auto; padding: 16px; gap: 14px; }
  .display header { grid-template-columns: 1fr; gap: 10px; }
  .display .clock { font-size: 3.4rem; }
  .display main { grid-template-columns: 1fr; grid-template-rows: auto; }
  .panel { overflow: visible; }
  .panel .list { overflow: visible; }
  .ev { grid-template-columns: 6px 84px 1fr; gap: 10px; }
  .lootrow { grid-template-columns: 1fr; }
  .loottile { grid-template-columns: auto 1fr; }
  .display footer { flex-direction: column; align-items: stretch; gap: 10px; }
  .display footer .status { margin-left: 0; }
  .display footer .app-link { justify-content: center; min-height: 52px; font-size: 1.05rem; color: var(--text); }
  .reel .corner { left: 12px; right: 12px; bottom: 12px; }
  .reel .corner .next { max-width: none; }
}
