/* ===========================================================
   Tokens. Light is the default. Dark via [data-theme="dark"].
   Per-screen accent colour comes in as --screen (set by app.js).
   =========================================================== */
:root {
  --bg: #f1f4fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --ink: #111722;
  --muted: #647085;
  --border: #e4e9f1;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #e23b3b;
  --screen: #6366f1;
  --shadow: 0 1px 2px rgba(17,24,39,.05), 0 6px 18px rgba(17,24,39,.06);
  --radius: 16px;
  --gap: clamp(12px, 2vw, 22px);
  --pad: clamp(16px, 3vw, 32px);
}
:root[data-theme="dark"] {
  --bg: #0e1217;
  --surface: #161b22;
  --surface-2: #1e252f;
  --ink: #e8edf3;
  --muted: #8b97a6;
  --border: #273039;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #f87171;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 26px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; overflow: hidden;
  font-size: clamp(15px, 1.5vw, 17px);
}
button { font-family: inherit; }
.icon { display: inline-block; vertical-align: middle; flex: 0 0 auto; }

/* ---------------- top bar ---------------- */
#topbar { display: flex; align-items: center; gap: var(--gap); padding: 11px var(--pad); background: var(--surface); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: clamp(18px, 2.3vw, 24px); letter-spacing: -.02em; }
#tabs { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 7px; background: transparent; color: var(--muted); border: 1px solid transparent; padding: 8px 13px; border-radius: 999px; font-size: clamp(13px, 1.5vw, 15px); font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.tab .icon { color: var(--screen); }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.active { background: var(--screen); color: #fff; }
.tab.active .icon { color: #fff; }
.topbar-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); height: 38px; padding: 0 14px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 650; transition: background .15s, border-color .15s; }
.icon-btn.square { width: 38px; padding: 0; justify-content: center; }
.icon-btn .icon { color: var(--ink); }
.icon-btn:hover { border-color: var(--screen); }

/* ---------------- views ---------------- */
#views { position: relative; flex: 1 1 auto; overflow: hidden; }
.view { position: absolute; inset: 0; padding: var(--pad); overflow: auto; display: none; flex-direction: column; }
.view.active { display: flex; }
.view h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 var(--gap); font-size: clamp(22px, 3vw, 32px); font-weight: 750; letter-spacing: -.02em; }
.view h2 .icon { color: var(--screen); }
.view .body { flex: 1 1 auto; }
.loading, .muted { color: var(--muted); }

.kiosk-only { display: none !important; }

/* ---------------- home overview ---------------- */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--gap); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-height: 150px; }
.card-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.card-big { display: flex; align-items: center; gap: 12px; font-size: clamp(34px, 5vw, 50px); font-weight: 800; letter-spacing: -.02em; }
.card-sub { color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.card-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.card-list li { display: flex; gap: 10px; }
.card-list .ct { color: var(--muted); min-width: 68px; font-variant-numeric: tabular-nums; }
.card-meal { font-size: clamp(20px, 3vw, 28px); font-weight: 750; }
#h-weather .icon { color: #0ea5e9; } #h-today .icon { color: #6366f1; }
#h-tide .icon { color: #14b8a6; } #h-meal .icon { color: #f43f5e; }

/* ---------------- weather ---------------- */
.wx-place { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 650; margin-bottom: 14px; }
.wx-place .icon { color: var(--screen); }
.wx-current { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: var(--gap); }
.wx-current .big { font-size: clamp(50px, 9vw, 88px); font-weight: 800; letter-spacing: -.03em; line-height: .9; }
.wx-now-meta div:first-child { font-size: 18px; font-weight: 600; }
.wx-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.wx-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 8px; text-align: center; box-shadow: var(--shadow); }
.wx-day .d { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.wx-day .ic { margin: 8px 0; }
.wx-day .hi { font-weight: 700; } .wx-day .lo { color: var(--muted); }
.wx-day .pp { color: #38b6ff; font-size: 12px; font-weight: 700; margin-top: 2px; }
.wx-sun { color: #f59e0b; } .wx-cloudSun { color: #eab308; } .wx-cloud { color: #94a3b8; }
.wx-rain { color: #38b6ff; } .wx-snow { color: #7dd3fc; } .wx-storm { color: #a78bfa; } .wx-fog { color: #94a3b8; }

/* ---------------- lists ---------------- */
.list-add { display: flex; gap: 10px; margin-bottom: 12px; max-width: 640px; }
.list-add input { flex: 1 1 auto; background: var(--surface); border: 1px solid var(--border); color: var(--ink); padding: 13px 15px; border-radius: 12px; font-size: 16px; }
.list-add input:focus { outline: none; border-color: var(--screen); }
.list-add button { display: inline-flex; align-items: center; gap: 6px; background: var(--screen); color: #fff; border: 0; border-radius: 12px; padding: 0 18px; font-weight: 700; cursor: pointer; font-size: 15px; }
.list-add button .icon { color: #fff; }
.list-count { color: var(--muted); font-size: 13px; font-weight: 650; margin-bottom: 12px; }
ul.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
ul.items li { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); transition: opacity .2s; }
ul.items li.done { opacity: .6; }
ul.items li.done .txt { text-decoration: line-through; color: var(--muted); }
ul.items li .txt { flex: 1 1 auto; font-size: clamp(15px, 1.8vw, 18px); }
ul.items li.empty { justify-content: center; box-shadow: none; background: transparent; border-style: dashed; }
.chk { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #fff; }
li.done .chk { background: var(--good); border-color: var(--good); }
.chk .icon { color: #fff; }
.del { background: transparent; border: 0; color: var(--muted); cursor: pointer; display: inline-flex; padding: 4px; border-radius: 8px; }
.del:hover { color: var(--bad); background: var(--surface-2); }

/* ---------------- meals ---------------- */
.meals { display: flex; flex-direction: column; gap: 8px; max-width: 860px; }
.meal-row { display: grid; grid-template-columns: 170px 1fr 1.5fr; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid transparent; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.meal-row.today { border-left-color: var(--screen); background: color-mix(in srgb, var(--screen) 7%, var(--surface)); }
.meal-day { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.meal-today { font-size: 11px; background: var(--screen); color: #fff; padding: 2px 8px; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.meal-cook, .meal-meal { display: flex; align-items: center; gap: 8px; color: var(--muted); min-width: 0; }
.meal-cook .icon, .meal-meal .icon { color: var(--screen); }
.meal-row input { flex: 1 1 auto; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; color: var(--ink); font-size: 15px; }
.meal-row input:focus { outline: none; border-color: var(--screen); }
.meal-meal span, .meal-cook span { color: var(--ink); }

/* ---------------- trains ---------------- */
.train-row { display: grid; grid-template-columns: auto auto 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); font-size: clamp(15px, 2vw, 20px); }
.train-row .time { font-variant-numeric: tabular-nums; font-weight: 700; }
.train-row .exp { font-weight: 650; } .train-row .exp.delayed { color: var(--warn); } .train-row .exp.cancelled { color: var(--bad); }
.train-row .plat { color: var(--muted); font-weight: 650; }

/* ---------------- tides ---------------- */
.sea-stats { display: flex; gap: var(--gap); flex-wrap: wrap; margin-bottom: var(--gap); }
.sea-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 24px; box-shadow: var(--shadow); }
.sea-stat .v { font-size: clamp(30px, 5vw, 46px); font-weight: 800; letter-spacing: -.02em; }
.sea-stat .l { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.tide-list { display: flex; flex-direction: column; gap: 2px; max-width: 520px; }
.tide-day { margin-top: 14px; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tide-row { display: flex; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.tide-row .hw { color: var(--screen); font-weight: 700; } .tide-row .lw { color: var(--muted); font-weight: 700; }
.tide-row .time { font-variant-numeric: tabular-nums; font-weight: 650; }

/* ---------------- calendar ---------------- */
.cal-day { margin-bottom: 18px; }
.cal-day > .hd { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; font-weight: 700; }
.cal-ev { display: flex; gap: 12px; align-items: baseline; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--screen); border-radius: 12px; padding: 12px 14px; margin-bottom: 6px; box-shadow: var(--shadow); }
.cal-ev.c1 { border-left-color: #a855f7; }
.cal-ev .t { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 96px; font-weight: 650; }
.cal-ev .s { flex: 1 1 auto; font-weight: 600; }
.cal-ev .loc { color: var(--muted); font-size: 13px; font-weight: 400; }

/* ---------------- notes / web / image ---------------- */
.notes-edit { width: 100%; height: 100%; min-height: 60vh; resize: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink); padding: 18px; font-size: clamp(16px, 2vw, 20px); line-height: 1.5; box-shadow: var(--shadow); }
.notes-edit:focus { outline: none; border-color: var(--screen); }
.notes-view { white-space: pre-wrap; font-size: clamp(18px, 2.6vw, 28px); line-height: 1.5; }
.embed { width: 100%; height: calc(100% - 26px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.embed-note { font-size: 12px; margin-top: 8px; }
.image-screen { position: absolute; inset: var(--pad); }
.image-screen img { width: 100%; height: 100%; object-fit: contain; }

/* ---------------- setup hint ---------------- */
.setup { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 20px; color: var(--muted); max-width: 640px; box-shadow: var(--shadow); line-height: 1.6; }
.setup code { color: var(--screen); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

/* ---------------- pictures slideshow ---------------- */
.slideshow { position: absolute; inset: 0; }
.slideshow img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.2s ease; }
.slideshow img.show { opacity: 1; }

/* ---------------- manage modal ---------------- */
.manage-overlay { position: fixed; inset: 0; background: rgba(10,14,20,.5); backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow: auto; }
.manage-overlay.show { display: flex; }
.mg-panel { background: var(--surface); color: var(--ink); width: min(820px, 100%); border-radius: 18px; border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden; }
.mg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.mg-head h3 { margin: 0; font-size: 20px; }
.mg-x { background: var(--surface-2); border: 1px solid var(--border); color: var(--ink); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px; }
.mg-rows { padding: 12px 22px; display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; }
.mg-row { display: grid; grid-template-columns: auto 1fr auto 1.2fr auto auto auto; gap: 10px; align-items: center; padding: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.mg-move { display: flex; flex-direction: column; gap: 2px; }
.mg-move button { width: 26px; height: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 6px; cursor: pointer; font-size: 11px; line-height: 1; }
.mg-move button:disabled { opacity: .3; cursor: default; }
.mg-title, .mg-url { background: var(--surface); border: 1px solid var(--border); color: var(--ink); border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 0; }
.mg-title:focus, .mg-url:focus { outline: none; border-color: var(--screen); }
.mg-type { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.mg-flag { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.mg-flag input { accent-color: var(--screen); }
.mg-del { background: transparent; border: 1px solid var(--border); color: var(--bad); border-radius: 8px; padding: 7px 10px; font-size: 13px; font-weight: 650; cursor: pointer; }
.mg-del:disabled { color: var(--muted); opacity: .5; cursor: default; }
.mg-add { padding: 16px 22px; border-top: 1px solid var(--border); }
.mg-add h4 { margin: 0 0 10px; font-size: 15px; }
.mg-add-form { display: flex; gap: 10px; flex-wrap: wrap; }
.mg-add-form select, .mg-add-form input { background: var(--surface); border: 1px solid var(--border); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.mg-add-form select { flex: 2 1 220px; } .mg-add-form input { flex: 1 1 160px; }
.mg-add-form button { background: var(--screen); color: #fff; border: 0; border-radius: 10px; padding: 0 20px; font-weight: 700; cursor: pointer; }
.mg-foot { display: flex; align-items: center; gap: 14px; padding: 16px 22px; border-top: 1px solid var(--border); }
.mg-save { background: var(--screen); color: #fff; border: 0; border-radius: 10px; padding: 11px 22px; font-weight: 700; font-size: 15px; cursor: pointer; }

/* ---------------- kiosk ---------------- */
body.kiosk #topbar { display: none; }
body.kiosk .view { padding-top: clamp(20px, 5vh, 56px); }
body.kiosk .kiosk-only { display: block !important; }
#kioskProgress { position: fixed; left: 0; bottom: 0; height: 4px; width: 100%; }
#kioskBar { display: block; height: 100%; width: 0; background: var(--screen); }

/* ---------------- responsive ---------------- */
@media (max-aspect-ratio: 1/1), (max-width: 680px) {
  .wx-days { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); }
  .train-row { grid-template-columns: auto 1fr auto; }
  .train-row .operator { display: none; }
  .meal-row { grid-template-columns: 110px 1fr; }
  .meal-meal { grid-column: 2; }
  .mg-row { grid-template-columns: auto 1fr auto; row-gap: 8px; }
  .mg-url { grid-column: 1 / -1; }
}
@media (min-width: 1400px) and (min-aspect-ratio: 1/1) {
  :root { --gap: 26px; }
  body { font-size: 20px; }
}
