/* Board Pro signage — 1920×1080 logical viewport, gen1-safe styling:
   animations restricted to transform/opacity, no filters or shadows on
   anything that moves, system font stack. */

:root {
  --bg: #0d1117;
  --bg-card: #161c26;
  --bg-card-2: #1b2230;
  --ink: #e8edf4;
  --ink-dim: #93a0b4;
  --ink-faint: #74849a;
  --accent: #58a6ff;
  --good: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
  --radius: 18px;
  --gap: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must always win, even over rules that set display. */
[hidden] { display: none !important; }

/* RoomOS draws a "Tap here to start" bar BELOW our web viewport in signage
   mode (the viewport bottom == the bar's top edge), so an element at bottom:0
   sits right on the bar. --safe-bottom is a comfortable clearance that
   dashboard/settings content keeps from that bottom edge; the ambient info
   band instead hugs the very bottom (bottom:0) so it meets the bar. Tunable. */
:root { --safe-bottom: 84px; }

html, body {
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { position: relative; width: 100%; height: 100%; padding: 32px 40px; padding-bottom: var(--safe-bottom); display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 24px; }
.topbar__greeting { font-size: 40px; font-weight: 600; letter-spacing: -0.01em; }
.topbar__clock { display: flex; align-items: baseline; gap: 18px; }
.topbar__time { font-size: 54px; font-weight: 700; font-variant-numeric: tabular-nums; }
.topbar__date { font-size: 26px; color: var(--ink-dim); }

/* ---------- dashboard grid ---------- */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: var(--gap);
  min-height: 0;
}
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px 26px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.card__title { font-size: 20px; font-weight: 600; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 14px; }
.card__body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.card__stamp { position: absolute; top: 24px; right: 26px; font-size: 20px; color: var(--warn); }
.card.is-stale { opacity: 0.75; }

.empty { color: var(--ink-faint); font-size: 22px; }

/* ---------- world clock ---------- */
/* 35px rows (capacity constant 45 = row + gap): five zones fit a 3-tall card.
   City stays at the 20px legibility floor. */
.wc-row { display: flex; align-items: baseline; min-height: 35px; flex-wrap: nowrap; }
.wc-row__city { flex: 1 1 auto; min-width: 0; padding-right: 12px; font-size: 20px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-row__time { flex: none; font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* fixed-width hour cell → colon lands on one axis for 1- and 2-digit hours */
.wc-row__hh { display: inline-block; width: 2ch; text-align: right; }
/* day-offset badge: 0-width by default; the row reserves a real gutter only
   when some city crosses a day boundary (.wc-has-day), so the time never moves */
.wc-row__day { flex: none; width: 0; overflow: hidden; font-size: 13px; color: var(--warn); font-weight: 600; text-align: left; transform: translateY(-2px); }
.wc-has-day .wc-row__day { width: 30px; margin-left: 4px; }

/* ---------- weather ---------- */
.alert { display: flex; gap: 10px; align-items: center; background: rgba(210, 153, 34, 0.15); color: var(--warn); border-radius: 10px; padding: 8px 14px; font-size: 20px; font-weight: 600; }
.icon { width: 28px; height: 28px; }
.icon--sm { width: 24px; height: 24px; }
.icon--xl { width: 96px; height: 96px; }

/* ---------- weather layout (editorial redesign) ----------
   Placed after the .icon utilities on purpose: the glyphs render as
   `.icon .wx-now__icon` / `.icon .wx-day__ico`, so these same-specificity
   rules must come later in source to win the size over the base .icon. */
/* condition-driven accent (current conditions) */
.card--weather { --wx-accent: var(--accent); }
.card--weather[data-cond="clear"]    { --wx-accent: #e3b341; }
.card--weather[data-cond="partly"]   { --wx-accent: #9db2c9; }
.card--weather[data-cond="cloudy"],
.card--weather[data-cond="fog"]      { --wx-accent: #8a97ab; }
.card--weather[data-cond="rain"],
.card--weather[data-cond="drizzle"]  { --wx-accent: #58a6ff; }
.card--weather[data-cond="snow"],
.card--weather[data-cond="sleet"]    { --wx-accent: #7fc8e6; }
.card--weather[data-cond="thunder"]  { --wx-accent: #d29922; }

/* per-condition glyph tints (current glyph + each daily glyph) */
.wx-ico--clear    { color: #e3b341; }
.wx-ico--partly   { color: #9db2c9; }
.wx-ico--cloudy,
.wx-ico--fog      { color: #8a97ab; }
.wx-ico--rain,
.wx-ico--drizzle  { color: #58a6ff; }
.wx-ico--snow,
.wx-ico--sleet    { color: #7fc8e6; }
.wx-ico--thunder  { color: #d29922; }

/* the sections own their spacing; override the base body gap */
.card--weather .card__body { gap: 0; }

/* hero */
.wx-now { display: flex; align-items: center; gap: 16px; }
.wx-now__icon { width: 50px; height: 50px; flex: none; }
.wx-now__temp { font-size: 78px; font-weight: 700; line-height: 0.9; letter-spacing: -0.03em; }
.wx-now__meta { display: flex; flex-direction: column; gap: 2px; margin-left: auto; text-align: right; min-width: 0; }
.wx-now__label { font-size: 22px; font-weight: 600; color: #c1ccda; white-space: nowrap; }
.wx-now__feels { font-size: 18px; color: var(--ink-faint); white-space: nowrap; }

.wx-rule { height: 1px; background: rgba(255, 255, 255, 0.07); margin: 16px 0 10px; flex: none; }

/* hourly trend */
.wx-trend { display: flex; flex-direction: column; gap: 4px; }
.wx-trend__row { display: flex; }
.wx-trend__row > span { flex: 1; min-width: 0; text-align: center; font-size: 18px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.wx-trend__row--hours > span { font-size: 14px; font-weight: 400; color: var(--ink-faint); }
.wx-trend__chart { width: 100%; height: 60px; display: block; }
.wx-trend__line { fill: none; stroke: var(--wx-accent); stroke-width: 3px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.wx-trend__g0 { stop-color: var(--wx-accent); stop-opacity: 0.30; }
.wx-trend__g1 { stop-color: var(--wx-accent); stop-opacity: 0; }

/* daily strip (tiles) */
.wx-days { display: flex; gap: 8px; margin-top: auto; }
.wx-day { flex: 1; min-width: 0; background: var(--bg-card-2); border-radius: 12px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.wx-day__name { font-size: 16px; color: var(--ink-dim); }
.wx-day__ico { width: 26px; height: 26px; }
.wx-day__hi { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wx-day__lo { font-size: 15px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* --- wider cards (w >= 5): larger hero + tiles, 8-hour trend, 5 tiles --- */
.card--weather:not(.t-narrow) .wx-now__temp { font-size: 92px; }
.card--weather:not(.t-narrow) .wx-now__icon { width: 62px; height: 62px; }
.card--weather:not(.t-narrow) .wx-now__label { font-size: 26px; }
.card--weather:not(.t-narrow) .wx-now__feels { font-size: 20px; }
.card--weather:not(.t-narrow) .wx-trend__chart { height: 44px; }
.card--weather:not(.t-narrow) .wx-day { padding: 9px 4px; }
.card--weather:not(.t-narrow) .wx-day__name { font-size: 17px; }
.card--weather:not(.t-narrow) .wx-day__ico { width: 30px; height: 30px; }
.card--weather:not(.t-narrow) .wx-day__hi { font-size: 24px; }
.card--weather:not(.t-narrow) .wx-day__lo { font-size: 16px; }

/* --- tall cards (h >= 5): scale hero + trend up, even vertical rhythm --- */
.card--weather.t-l .card__body { justify-content: space-between; }
.card--weather.t-l .wx-rule { display: none; }
.card--weather.t-l .wx-now__temp { font-size: 112px; }
.card--weather.t-l .wx-now__icon { width: 72px; height: 72px; }
.card--weather.t-l .wx-trend__chart { height: 116px; }
.card--weather.t-l .wx-days { margin-top: 0; }
.card--weather.t-l .wx-day { padding: 16px 4px; gap: 8px; }
.card--weather.t-l .wx-day__name { font-size: 18px; }
.card--weather.t-l .wx-day__ico { width: 34px; height: 34px; }
.card--weather.t-l .wx-day__hi { font-size: 27px; }
.card--weather.t-l .wx-day__lo { font-size: 17px; }

/* --- measured-fit tweaks (resize-fit audit) --- the NWS alert banner adds
   ~41px of height the base tiers don't budget for. At h==4 (t-m) trim the
   hairline margin + chart, and cap the wide-card hero so hero+8h-trend+strip
   still clear the body; at h==5 the fixed t-l chart must shrink to fit the
   shorter body. Verified zero-overflow at every w×h from 3×4→12×8, alert
   present or not. (Placed last so these win over the tier rules above.) */
.card--weather.t-m .wx-rule { margin: 8px 0 6px; }
.card--weather.t-m .wx-trend__chart { height: 40px; }
.card--weather.t-m:not(.t-narrow) .wx-now__temp { font-size: 78px; }
.card--weather.t-m:not(.t-narrow) .wx-day { padding: 7px 4px; }
.card--weather.t-l .wx-trend__chart { height: 100px; }

/* ---------- transit ---------- */
.stop-group { display: flex; flex-direction: column; gap: 8px; }
.stop-group__head { display: flex; justify-content: space-between; align-items: baseline; }
.stop-group__name { font-size: 22px; font-weight: 600; }
.stop-group__dir { font-size: 20px; color: var(--ink-faint); }
.stop-group__arrivals { display: flex; flex-direction: column; gap: 6px; }
.arrival { display: flex; align-items: center; gap: 12px; font-size: 24px; }
.arrival__min { font-weight: 700; font-variant-numeric: tabular-nums; }
.arrival__unit { color: var(--ink-faint); font-size: 21px; }

.bullet {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; color: #fff; background: #808183;
  flex: none;
}
/* MTA line colors */
.bullet--1, .bullet--2, .bullet--3 { background: #ee352e; }
.bullet--4, .bullet--5, .bullet--6 { background: #00933c; }
.bullet--7 { background: #b933ad; }
.bullet--A, .bullet--C, .bullet--E { background: #0039a6; }
.bullet--B, .bullet--D, .bullet--F, .bullet--M { background: #ff6319; }
.bullet--G { background: #6cbe45; }
.bullet--J, .bullet--Z { background: #996633; }
.bullet--L { background: #a7a9ac; }
.bullet--N, .bullet--Q, .bullet--R, .bullet--W { background: #fccc0a; color: #111; }
.bullet--S, .bullet--GS { background: #808183; }
.bullet--SI { background: #0f3d92; }

.train { display: flex; align-items: center; gap: 16px; font-size: 22px; }
.train__min { display: flex; align-items: baseline; gap: 4px; min-width: 76px; }
.train__min span { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.train__min small { color: var(--ink-faint); font-size: 20px; }
.train__info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.train__dest { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.train__line { font-size: 20px; color: var(--ink-dim); }
.train__track { background: var(--bg-card-2); border-radius: 8px; padding: 6px 10px; font-size: 20px; color: var(--accent); white-space: nowrap; }

/* ---------- art card ---------- */
.artwork { display: flex; flex-direction: column; height: 100%; gap: 10px; }
.artwork__img { flex: 1; min-height: 0; width: 100%; object-fit: cover; border-radius: 10px; background: var(--bg-card-2); }
.artwork__caption { display: flex; flex-direction: column; gap: 2px; }
.artwork__title { font-size: 22px; font-weight: 600; }
.artwork__artist { font-size: 20px; color: var(--ink-dim); }

/* ---------- photos settings thumbnail ---------- */
.photo-preview__img { max-width: 240px; border-radius: 10px; margin-top: 12px; }

/* ---------- history / quote / sky / markets ---------- */
.history { display: flex; flex-direction: column; gap: 10px; }
/* Year column hugs four tabular digits; right-aligned so short years ("324")
   end where long ones do and the text column starts sooner. */
.history__item { display: grid; grid-template-columns: 54px 1fr; gap: 10px; font-size: 22px; align-items: baseline; }
.history__year { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; text-align: right; }
.history__text { color: var(--ink-dim); }

.quote { display: flex; flex-direction: column; justify-content: center; height: 100%; gap: 12px; }
.quote__text { font-size: 24px; line-height: 1.4; font-style: italic; }
.quote__author { font-size: 21px; color: var(--ink-dim); text-align: right; }

.sky { display: flex; flex-direction: column; gap: 12px; }
/* AQI + UV as equal labeled stat blocks; single column when UV is absent */
.sky__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sky__stats--single { grid-template-columns: 1fr; }
.sky__aqi { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sky__aqi-head { font-size: 17px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Category sits under the number so both get the block's full width */
.sky__aqi-reading { display: flex; flex-direction: column; min-width: 0; }
/* The category never wraps under the number — it shrinks then ellipsizes */
.sky__aqi-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sky__aqi-value { font-size: 54px; font-weight: 700; line-height: 1.05; }
.sky__aqi--good .sky__aqi-value { color: var(--good); }
.sky__aqi--moderate .sky__aqi-value { color: var(--warn); }
.sky__aqi--bad .sky__aqi-value { color: var(--bad); }
.sky__aqi-label { font-size: 22px; color: var(--ink-dim); }
.sky__row { display: flex; align-items: center; gap: 10px; font-size: 20px; color: var(--ink-dim); }

/* One shared grid for all rows (rows are display:contents) so the spark and
   delta columns align down the card; the auto track fits the widest delta. */
.indexes { display: grid; grid-template-columns: 1fr 90px auto; align-items: center; column-gap: 14px; row-gap: 10px; }
.index { display: contents; }
.index__info { display: flex; flex-direction: column; }
.index__name { font-size: 21px; color: var(--ink-dim); }
.index__price { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.spark { width: 90px; height: 28px; }
.spark--up { color: var(--good); }
.spark--down { color: var(--bad); }
.delta { font-size: 21px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta--up { color: var(--good); }
.delta--down { color: var(--bad); }

/* ---------- ambient mode ---------- */
.ambient { position: absolute; inset: 0; }
.slideshow { position: absolute; inset: 0; background: #000; touch-action: none; /* swipes must reach the pointer handlers, not the browser's pan gesture */ }
.slide {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0;
  transition: opacity 2.5s ease-in-out;
}
.slide[data-active] { opacity: 1; }
.slide-caption {
  /* Sit just above the info band (which sits at the very bottom). */
  position: absolute; left: 48px; bottom: 82px;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(0, 0, 0, 0.55);
  padding: 14px 22px; border-radius: 12px;
}
.slide-caption__title { font-size: 24px; font-weight: 600; }
.slide-caption__meta { font-size: 21px; color: var(--ink-dim); }
.strip {
  /* Original ~70px translucent info band at bottom:0, so its bottom edge meets
     the RoomOS bar (which sits just below the viewport). Not stretched. */
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 36px;
  padding: 18px 48px;
  background: rgba(0, 0, 0, 0.65);
  font-size: 24px;
}
.strip__time { font-weight: 700; font-size: 28px; font-variant-numeric: tabular-nums; }
.strip__temp { color: var(--accent); font-weight: 600; }
.strip__transit { color: var(--ink-dim); }
.strip__transit b { color: var(--ink); font-variant-numeric: tabular-nums; }
body.mode-ambient .topbar, body.mode-ambient #grid { visibility: hidden; }

/* ---------- welcome ---------- */
.welcome { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.welcome__inner {
  max-width: 760px; text-align: center; display: flex; flex-direction: column; gap: 22px;
  background: var(--bg-card); border-radius: var(--radius); padding: 48px 56px;
}
.welcome__inner h1 { font-size: 48px; }
.welcome__inner p { font-size: 24px; color: var(--ink-dim); }
.welcome__actions { display: flex; gap: 18px; justify-content: center; }
.welcome__hint { font-size: 21px !important; color: var(--ink-faint) !important; }
.welcome__qr { display: flex; justify-content: center; margin-top: 10px; }

.btn {
  font-size: 24px; padding: 16px 34px; border-radius: 14px;
  border: 1px solid var(--ink-faint); background: var(--bg-card);
  color: var(--ink); cursor: pointer;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #06131f; font-weight: 700; }

/* ---------- gear ---------- */
.gear {
  /* Edit + settings FABs. BOARD-VERIFIED: on the dashboard the RoomOS
     "Tap to start" bar OVERLAYS the bottom ~40 logical px of the viewport
     (a FAB at bottom:14px was ~45% covered — 26 of 56px = the 40px bar).
     The free strip between bar top (40px) and grid edge (84px) is only 44px,
     so a 56px FAB can't fully fit: bottom:44px clears the bar with 4px to
     spare and intrudes just ~16px into the lower-right widget (was 63px at
     the old calc(--safe-bottom + 7px) spot). In ambient mode they drop onto
     the info strip. */
  position: absolute; right: 28px; bottom: 44px;
  width: 56px; height: 56px; border-radius: 50%;
  font-size: 26px; border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.08); color: var(--ink-dim);
}
/* Ambient mode: the FABs align with the info strip sitting at the bottom. */
body.mode-ambient .gear { bottom: 7px; }

/* ---------- settings overlay ---------- */
.settings {
  position: absolute; inset: 0; z-index: 40;
  display: grid; grid-template-columns: 380px 1fr;
  background: var(--bg);
}
.settings__rail {
  background: var(--bg-card); padding: 28px 24px calc(28px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 18px;
  min-height: 0; /* children may scroll; the footer must never leave view */
}
.settings__brand { font-size: 30px; font-weight: 700; flex: none; }
.settings__nav {
  display: flex; flex-direction: column; gap: 4px;
  flex: 1; min-height: 0; overflow-y: auto; /* nav scrolls, never the footer */
}
.settings__navitem {
  text-align: left; font-size: 22px; padding: 11px 16px; min-height: 48px;
  border: none; border-radius: 10px; background: none; color: var(--ink-dim); cursor: pointer;
  flex: none;
}
.settings__navitem.is-active { background: var(--bg-card-2); color: var(--ink); font-weight: 600; }
.settings__navgroup {
  display: flex; align-items: center; gap: 10px;
  text-align: left; font-size: 22px; padding: 11px 16px; min-height: 48px;
  border: none; border-radius: 10px; background: none; color: var(--ink-dim); cursor: pointer; flex: none;
}
.settings__chev {
  width: 0; height: 0; flex: none;
  border-left: 7px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
}
.settings__navgroup.is-open .settings__chev { transform: rotate(90deg); }
.settings__navchild { padding-left: 34px; font-size: 21px; }
/* Accordion expand/collapse: grid-template-rows 0fr↔1fr animates to exact height
   (degrades to an instant snap on older engines). The inner clips during collapse. */
.settings__navkids {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.settings__navkids.is-open { grid-template-rows: 1fr; }
.settings__navkids__inner { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.settings__navkids.is-open .settings__navkids__inner { padding-top: 4px; }
@media (prefers-reduced-motion: reduce) {
  .settings__chev, .settings__navkids { transition: none; }
}
.settings__railfoot { display: flex; flex-direction: column; gap: 10px; flex: none; }
.settings__pane { padding: 44px 56px calc(44px + var(--safe-bottom)); overflow-y: auto; }
.pane__title { font-size: 34px; font-weight: 700; margin-bottom: 10px; }
.pane__hint { font-size: 21px; color: var(--ink-dim); margin: 14px 0; }
.pane__empty { font-size: 21px; color: var(--ink-faint); }
.pane__rule { border: none; border-top: 1px solid var(--bg-card-2); margin: 28px 0; }

.rows { display: flex; flex-direction: column; gap: 8px; max-width: 860px; }
.row {
  display: flex; align-items: center; gap: 18px;
  min-height: 64px; padding: 8px 18px;
  background: var(--bg-card); border-radius: 12px;
}
.row__label { font-size: 24px; flex: 1; }
.row__actions { display: flex; gap: 10px; }
.row--tap { border: none; color: var(--ink); font-size: 23px; text-align: left; cursor: pointer; }
.row--tap.is-selected { outline: 2px solid var(--accent); }

.wgroups { columns: 2; column-gap: 48px; max-width: 1200px; }
.wgroup { break-inside: avoid; margin-bottom: 28px; }
.wgroup__title {
  font-size: 18px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-dim); margin: 0 0 10px;
}
.wgroup__rows { display: flex; flex-direction: column; gap: 8px; }

.toggle {
  width: 76px; height: 44px; border-radius: 22px; border: none; cursor: pointer;
  background: var(--bg-card-2); position: relative; flex: none;
  transition: background 0.2s;
}
.toggle__knob {
  position: absolute; top: 4px; left: 4px; width: 36px; height: 36px;
  border-radius: 50%; background: var(--ink-faint);
  transition: transform 0.2s ease-out, background 0.2s;
}
.toggle.is-on { background: rgba(88, 166, 255, 0.35); }
.toggle.is-on .toggle__knob { transform: translateX(32px); background: var(--accent); }

.iconbtn {
  width: 56px; height: 56px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--bg-card-2); color: var(--ink); font-size: 26px;
}
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 20px; }
.chip {
  font-size: 22px; padding: 14px 20px; min-height: 56px;
  border: none; border-radius: 28px; cursor: pointer;
  background: var(--bg-card-2); color: var(--ink);
}
.chip--on { background: var(--accent); color: #0d1117; }
.kv { display: flex; align-items: center; gap: 16px; min-height: 60px; font-size: 23px; }
.kv span { color: var(--ink-dim); min-width: 260px; }
.kv__small { font-size: 20px; font-weight: 400; color: var(--ink-dim); }

.drill { margin-top: 22px; max-width: 860px; }
.drill__head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.drill__head h3 { font-size: 26px; }
.drill__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; max-height: 640px; overflow-y: auto; }
.drill__item {
  min-height: 64px; font-size: 23px; padding: 10px 16px;
  border: none; border-radius: 12px; cursor: pointer;
  background: var(--bg-card); color: var(--ink);
  display: flex; align-items: center; gap: 12px;
}
.drill__letter { color: var(--accent); }

.code__display, .zip__display {
  display: block; font-size: 52px; letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums; margin: 16px 0; min-height: 64px;
}
.keypad { display: grid; gap: 10px; max-width: 640px; }
.keypad--zip { grid-template-columns: repeat(3, 1fr); max-width: 320px; }
.keypad--code { grid-template-columns: repeat(8, 1fr); }
.key {
  min-height: 64px; font-size: 26px; font-weight: 600;
  border: none; border-radius: 12px; cursor: pointer;
  background: var(--bg-card); color: var(--ink);
}
.key:active { background: var(--bg-card-2); }
.key--wide { grid-column: span 2; }
.code__status, .zip__status { font-size: 22px; color: var(--warn); margin-top: 14px; min-height: 30px; }
.segmented { display: inline-flex; border: 1px solid var(--bg-card-2); border-radius: 10px; overflow: hidden; }
.seg { min-height: 48px; padding: 0 22px; font-size: 22px; border: none; background: none; color: var(--ink-dim); cursor: pointer; }
.seg.is-active { background: var(--accent); color: #06131f; font-weight: 700; }
.qr { margin-top: 20px; }
.qr svg { background: #fff; border-radius: 12px; }

/* ---------- line chips (subway settings) ---------- */
.linechips { display: flex; flex-wrap: wrap; gap: 12px; max-width: 720px; margin-bottom: 16px; }
.linechip { width: 56px; height: 56px; font-size: 24px; border: none; cursor: pointer; }
.linechip--off { opacity: 0.25; }

/* ---------- edit mode ---------- */
.gear--edit { right: 96px; }
.editor { position: absolute; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; padding: 32px 40px; padding-bottom: var(--safe-bottom); }
.editor__stage { position: relative; flex: 1; min-height: 0; }
.editor__cells, .editor__blocks {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: 10px;
}
.editor__cell { border: 1px dashed rgba(147, 160, 180, 0.25); border-radius: 10px; }
.edit-block {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--ink-faint);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: grab; touch-action: none; user-select: none;
}
.edit-block.is-dragging { opacity: 0.85; z-index: 5; cursor: grabbing; }
.edit-block.is-invalid { border-color: var(--bad); }
.edit-block__title { font-size: 26px; font-weight: 600; color: var(--ink-dim); pointer-events: none; }
.edit-remove {
  position: absolute; top: 10px; right: 10px;
  width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(248, 81, 73, 0.2); color: var(--bad); font-size: 22px;
}
.edit-handle {
  position: absolute; bottom: 6px; right: 6px;
  width: 56px; height: 56px; cursor: nwse-resize; touch-action: none;
  border-right: 4px solid var(--accent); border-bottom: 4px solid var(--accent);
  border-bottom-right-radius: 12px;
}
.editor__bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 24px; }
.edit-tray { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.edit-tray__label { font-size: 22px; color: var(--ink-dim); }
.edit-tray__chip {
  font-size: 22px; padding: 14px 22px; min-height: 56px;
  border: none; border-radius: 28px; cursor: pointer;
  background: var(--bg-card); color: var(--ink);
}
.edit-tray__chip:disabled { opacity: 0.4; cursor: default; }
.editor__actions { display: flex; gap: 14px; }
@media (prefers-reduced-motion: reduce) {
  .slide { transition: none; }
}

/* ---------- full-screen art viewer (tap art card to open, tap to close) ---------- */
.art-viewer {
  position: absolute; inset: 0; z-index: 45;
  background: #000; cursor: pointer;
  /* Without this, a touch swipe is claimed by the browser's gesture
     arbitration: pointercancel fires instead of pointerup and the swipe
     classifier never runs (mouse drags were unaffected — no arbitration). */
  touch-action: none;
}
.art-viewer__img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- full-screen text viewer (tap truncated text) ---------- */
.text-viewer {
  position: fixed; inset: 0; z-index: 46; /* above the art viewer's 45 */
  background: rgba(13, 17, 23, 0.96);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.text-viewer__panel { max-width: 1400px; padding: 60px; display: flex; flex-direction: column; gap: 26px; }
.text-viewer__title { font-size: 24px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); }
.text-viewer__body { font-size: 42px; line-height: 1.45; color: var(--ink); text-wrap: pretty; }
.text-viewer__hint { font-size: 20px; color: var(--ink-faint); }

/* ---------- per-size compact variants (gen1 Chromium lacks container queries;
   cards carry data-w/data-h and the tier classes t-s/t-m/t-l/t-narrow that
   main.js derives from the layout: t-s when h≤2, t-narrow when w≤4) ---------- */
/* Quote in a shallow card: clamp long quotes */
.card--quote.t-s .quote__text {
  font-size: 22px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Markets in a shallow card: single-line rows (name beside price) — stacked
   rows plus the +N hint clip a 2-tall body (measured: 141px into 121px) */
.card--markets.t-s .index__info { flex-direction: row; align-items: baseline; gap: 8px; min-width: 0; }
.card--markets.t-s .index__price { font-size: 22px; }
.card--markets.t-s .index__name { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card--markets.t-s .delta { font-size: 16px; }
.card--markets.t-s .spark { height: 20px; }
/* Markets when narrow (≤4 cols): tighten the row so the delta never clips.
   The sparkline must shrink WITH its column — at 90px it bleeds into the
   delta triangle (viewBox scales, preserveAspectRatio=none). */
.card--markets.t-narrow .indexes { column-gap: 10px; grid-template-columns: 1fr 72px auto; }
.card--markets.t-narrow .spark { width: 72px; }
/* History when shallow or narrow: clamp each event to two lines so the rows
   stay bounded and never overflow (narrow cards wrap text into tall rows) */
.card--history.t-s .history__text,
.card--history.t-narrow .history__text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Air & Sky measured variants (nth-of-type counts ALL div siblings of .sky:
   .sky__stats is div #1, sky rows start at #2).
   Shallow (h<=2): compact dials, sunrise row only. */
.card--aqi.t-s .sky { gap: 8px; }
.card--aqi.t-s .sky__aqi-value { font-size: 36px; }
.card--aqi.t-s .sky__aqi-label { font-size: 17px; }
.card--aqi.t-s .sky__row { font-size: 18px; }
.card--aqi.t-s .sky__row:nth-of-type(n+3) { display: none; }
/* 2-wide: half-columns can't hold the categories — stack the stats full
   width with slightly smaller dials; at 2x3 the moon row goes too. */
.card--aqi[data-w="2"] .sky__stats { grid-template-columns: 1fr; }
.card--aqi[data-w="2"]:not(.t-s) .sky { gap: 8px; }
.card--aqi[data-w="2"]:not(.t-s) .sky__aqi-value { font-size: 40px; }
.card--aqi[data-w="2"]:not(.t-s) .sky__aqi-head { font-size: 15px; }
.card--aqi[data-w="2"]:not(.t-s) .sky__aqi-label { font-size: 17px; }
.card--aqi[data-w="2"][data-h="3"] .sky__row:nth-of-type(n+3) { display: none; }
/* 2x2 minimum: the two dials fill the whole body — no sky rows; value at
   the 34px primary-data floor */
.card--aqi[data-w="2"].t-s .sky { gap: 6px; }
.card--aqi[data-w="2"].t-s .sky__aqi { gap: 0; }
.card--aqi[data-w="2"].t-s .sky__aqi-value { font-size: 34px; }
.card--aqi[data-w="2"].t-s .sky__row { display: none; }
/* Art at its smallest (shallow + narrow): caption reduces to the title */
.card--art.t-s.t-narrow .artwork__artist { display: none; }
/* Transit rows tighten when narrow */
.card.t-narrow .train__track { padding: 4px 8px; font-size: 17px; }


/* ---------- transit service alerts ---------- */
.talert {
  display: flex; align-items: center; gap: 8px;
  background: rgba(210, 153, 34, 0.14); border-radius: 8px;
  padding: 6px 10px; flex: none;
}
.talert__icon { color: var(--warn); font-size: 18px; flex: none; }
.talert__text {
  color: var(--warn); font-size: 20px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bullet--sm { width: 26px; height: 26px; font-size: 15px; }
.trains { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }

/* ---------- subway line-status board ---------- */
.linestatus { display: flex; align-items: center; gap: 14px; min-height: 50px; }
.linestatus__text { font-size: 22px; color: var(--ink-dim); }
.linestatus--alert .linestatus__text {
  color: var(--warn); font-size: 20px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.linestatus__icon { color: var(--warn); font-size: 18px; margin-left: auto; flex: none; }

/* ---------- bus ---------- */
.buspill {
  display: inline-block; background: #0039a6; color: #fff;
  border-radius: 8px; padding: 2px 10px; font-size: 19px; margin-right: 6px;
}
.train__dist { color: var(--ink-dim); font-size: 18px; line-height: 1.1; display: inline-block; max-width: 76px; }

/* ---------- PATH ---------- */
.path-section { display: flex; flex-direction: column; gap: 8px; }
.path-section + .path-section { margin-top: 8px; }
.path-section__label { font-size: 17px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.pathdot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.pathdot + .pathdot { margin-left: -2px; }

/* ---------- NYC Ferry ---------- */
.ferryroute { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 8px; vertical-align: -1px; }

/* ---------- word of the day ---------- */
.wotd { display: flex; flex-direction: column; justify-content: center; height: 100%; gap: 8px; }
.wotd__word { font-size: 40px; font-weight: 700; letter-spacing: -0.01em; }
.wotd__meta { font-size: 20px; color: var(--ink-dim); }
.wotd__def { font-size: 22px; line-height: 1.35; }
.wotd__ex { font-size: 20px; color: var(--ink-dim); font-style: italic; }
/* Shallow cards: smaller word, clamp the definition */
.card--wotd.t-s .wotd__word { font-size: 30px; }
.card--wotd.t-s .wotd__def { font-size: 19px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Narrow cards: smaller word, clamped definition and example, so even
   worst-case entries (long word + long pronunciation) never scroll */
.card--wotd.t-narrow .wotd__word { font-size: 32px; }
.card--wotd.t-narrow .wotd__def { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card--wotd.t-narrow .wotd__ex { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- edit-mode gesture preview ---------- */
.edit-placeholder {
  border: 3px dashed var(--good);
  border-radius: var(--radius);
  background: rgba(63, 185, 80, 0.08);
  pointer-events: none;
}
.edit-placeholder--invalid {
  border-color: var(--bad);
  background: rgba(248, 81, 73, 0.10);
}
/* During a resize gesture the placeholder lifts above the blocks (they're
   grid items, so z-index applies): a shrink target lies inside the block's
   footprint and is invisible beneath its opaque background otherwise.
   4 stays under .edit-block.is-dragging's 5. */
.editor__blocks.is-resize-gesture .edit-placeholder { z-index: 4; }
.edit-block__size {
  position: absolute; left: 0; right: 0; bottom: 14px;
  text-align: center; font-size: 18px; color: var(--ink-faint);
  pointer-events: none;
}
.edit-block { flex-direction: column; gap: 4px; }
.edit-tray__chip small { color: var(--ink-dim); font-size: 17px; }

.more-hint { font-size: 18px; color: var(--ink-faint); padding-top: 2px; }

.icon--btn { width: 28px; height: 28px; display: block; margin: 0 auto; }
.gear { display: flex; align-items: center; justify-content: center; color: var(--ink-dim); }
/* nowrap: the widget name never wraps to a second line — the corner note
   (min-width 0) shrinks and ellipsizes first on narrow cards */
.card__title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; white-space: nowrap; }
.card__asof { font-size: 17px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink-faint); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card.is-stale .card__asof { visibility: hidden; } /* the amber stale stamp takes over */

/* ---------- my teams ---------- */
.team { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.team__abbr { width: 64px; font-size: 24px; font-weight: 800; letter-spacing: 0.02em; flex: none; }
.team__info { display: flex; flex-direction: column; min-width: 0; }
.team__name { font-size: 21px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team__name small { color: var(--ink-faint); font-weight: 400; font-size: 18px; }
.team__line { font-size: 20px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team--live .team__line { color: var(--ink); font-weight: 600; }
.team__livedot { color: var(--bad); font-size: 14px; }

/* ---------- world cup ---------- */
.wc-section { display: flex; flex-direction: column; gap: 6px; }
.wc-section__label { font-size: 17px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.wc-match { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-height: 40px; }
.wc-match__teams { font-size: 22px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wc-match__teams b { font-size: 24px; }
.wc-match__meta { font-size: 19px; color: var(--ink-dim); white-space: nowrap; flex: none; }
.wc-match--live .wc-match__meta { color: var(--ink); font-weight: 600; }
.wc-match__note { font-size: 17px; color: var(--ink-faint); margin-top: -4px; }

/* ---------- headlines ---------- */
/* Source + age on a small meta line above the full-width headline; the
   headline clamps to two lines (one in shallow cards) — no marquee, per the
   calm-motion rule. */
.headline { display: flex; flex-direction: column; gap: 3px; }
.headline__meta { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.headline__src { font-size: 15px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.headline__age { font-size: 15px; color: var(--ink-faint); flex: none; }
.headline__title { font-size: 21px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-width: 0; }
.card--news.t-s .headline__title, .card--substack.t-s .headline__title, .card--bsky.t-s .headline__title { -webkit-line-clamp: 1; }
/* Fill-to-fit's slack spender: the final headline rides leftover space with a
   one-line ellipsized title (renderHeadlines adds this class only when the
   full item wouldn't fit). */
.headline--clamp .headline__title { -webkit-line-clamp: 1; }

/* 7px padding keeps the contained logo inside the circle's inscribed square
   (44px circle inscribes ~31px; 4px padding left 36px — wide logos like the
   Mets NY clipped at the sides) */
.team__logo { width: 44px; height: 44px; object-fit: contain; flex: none; background: rgba(232, 237, 244, 0.08); border-radius: 50%; padding: 7px; }
.team__last { font-size: 17px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-flag { width: 26px; height: 26px; object-fit: contain; vertical-align: -5px; margin-right: 5px; border-radius: 3px; }

/* ---------- on-screen keyboard (OSK) ---------- */
.osk { display: flex; flex-direction: column; gap: 10px; }
.osk__display { display: block; font-size: 40px; letter-spacing: 0.08em; min-height: 56px; margin: 10px 0; word-break: break-all; }
.osk__row { display: flex; gap: 10px; justify-content: center; }
.osk__key { min-width: 72px; min-height: 64px; font-size: 28px; }
.osk__key--wide { min-width: 150px; }
.osk__key--primary { background: var(--accent); color: #06131f; font-weight: 700; }
.osk__key.is-on { background: rgba(88, 166, 255, 0.35); }
