:root {
  --ink: #1B1D20; --text: #EEEBE5; --muted: #B9BCC0; --accent: #E0915A; --line: #4A4F55; --plate: rgba(27, 29, 32, 0.9);
  --card: rgba(32, 35, 39, 0.93);
  --flecks: radial-gradient(rgba(235, 233, 228, 0.10) 0.7px, transparent 1.3px), radial-gradient(rgba(235, 233, 228, 0.06) 0.6px, transparent 1.1px);
}
* { box-sizing: border-box; }
html { background: var(--ink); }
body { margin: 0; color: var(--text); font: 15px/1.4 Inter, system-ui, sans-serif; min-height: 100vh;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom)); }
h1 { margin: 0; font: 400 32px/1.1 "IM Fell English", Georgia, serif; }
h2.tag { align-self: flex-start; margin: 8px 0 0; padding: 4px 10px; border-radius: 8px; background: var(--plate);
  font-size: 13px; font-weight: 600; color: var(--muted); }
b { font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.guide { color: var(--text); font-size: 15px; line-height: 1.45; }
.button-link { display: block; text-align: center; background: var(--accent); color: var(--ink); font-weight: 600; border-radius: 14px; padding: 14px; text-decoration: none; } /* instructions sit on a card: the coat behind is too busy for small grey text */
.eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
a { color: var(--accent); }

/* one horse per page, under a dark scrim at the top and bottom so headings and tabs stay readable */
.coat { position: fixed; inset: 0; z-index: -1; background: #D4D4D0 center / cover no-repeat; }
.coat::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(#1B1D20f0, #1B1D20c7 90px, #1B1D2000 150px, #1B1D2000 calc(100% - 130px), #1B1D20e6); }
body[data-view="home"] .coat { background-image: url(coats/foal.svg); }
body[data-view="live"] .coat { background-image: url(coats/blueroan.svg); }
body[data-view="voice"] .coat { background-image: url(coats/fleabitten.svg); }
body[data-view="gestures"] .coat { background-image: url(coats/leopard.svg); }
body[data-view="battery"] .coat { background-image: url(coats/dapple.svg); }
/* sub-pages: the same five coats, re-framed and re-tinted so each page still looks like its own horse (no new files) */
body[data-view="settings"] .coat { background-image: url(coats/dapple.svg); background-size: 260%; background-position: 70% 20%; filter: hue-rotate(160deg) saturate(.7); }
body[data-view="files"] .coat { background-image: url(coats/blueroan.svg); }
body[data-view="photos"] .coat { background-image: url(coats/leopard.svg); background-size: 220%; background-position: 15% 60%; filter: sepia(.35); }
body[data-view="videos"] .coat { background-image: url(coats/fleabitten.svg); background-size: 240%; background-position: 80% 40%; filter: brightness(.82); }
body[data-view="audio"] .coat { background-image: url(coats/foal.svg); background-size: 200%; background-position: 30% 80%; filter: hue-rotate(200deg) saturate(.6); }
body[data-view="snapshots"] .coat { background-image: url(coats/blueroan.svg); background-size: 230%; background-position: 60% 10%; filter: sepia(.25) brightness(.9); }

main { max-width: 480px; margin: 0 auto; padding: 0 16px; }
section { display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }
section[hidden] { display: none; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 20px 4px 4px; }
.card { background: var(--card); background-image: var(--flecks); background-size: 6px 8px, 9px 7px;
  background-position: 0 0, 3px 4px; border: 1px solid rgba(238, 235, 229, 0.08); border-radius: 18px; color: var(--text); }
.plate { margin: 0; background: var(--plate); border-radius: 14px; padding: 10px 14px; font-size: 13px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.stack { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 22px;
  background: var(--card); color: var(--accent); font-weight: 600; text-decoration: none; }
.pill.rec { color: #FF8A7A; }
.chips, .grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chip { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; border-radius: 14px; }
.chip > span:last-child { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 4px; border: 1.5px solid var(--muted); flex: none; }
.dot.on { background: #5FD39A; border-color: #5FD39A; }
.dot.warn { background: #FF8A7A; border-color: #FF8A7A; }
button, .big { font: inherit; color: inherit; cursor: pointer; border: 0; }
.big { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 92px;
  border-radius: 18px; font-weight: 600; text-decoration: none; padding: 12px 6px; }
.big small { font-size: 11px; font-weight: 400; color: var(--muted); }
.big.accent { background: var(--accent); color: var(--ink); }
.big.accent small { color: var(--ink); opacity: .75; }
svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button.small { background: #33373C; border-radius: 12px; padding: 0 14px; min-height: 44px; font-weight: 600; font-size: 14px; }
button.wide { background: var(--accent); color: var(--ink); border-radius: 14px; min-height: 52px; font-weight: 600; }
button:disabled { opacity: .5; cursor: progress; }
.photo-row { padding: 10px 14px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--ink); border-radius: 14px; padding: 4px; }
.seg button { min-height: 44px; border-radius: 10px; background: none; color: var(--muted); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--ink); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.list.compact li { padding: 8px 14px; flex-direction: row; justify-content: space-between; }
.list audio { width: 100%; height: 40px; }
.list select { background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: 10px; min-height: 40px; padding: 0 8px; font: inherit; }
.empty { color: var(--muted); font-size: 13px; background: var(--plate); border-radius: 14px; }
.hud { display: grid; grid-template-columns: 1fr 1fr; padding: 14px 16px; }
.hud div, .stat { display: flex; flex-direction: column; gap: 4px; }
.hud b, .stat b { font: 400 40px/1.1 "IM Fell English", Georgia, serif; }
.stat { padding: 14px 16px; }
.accent-text { color: var(--accent); }
.chart { height: 120px; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line); }
.chart i { flex: 1 1 0; border-radius: 2px 2px 0 0; background: var(--accent); min-height: 2px; }
.chart i.low { background: #FF8A7A; }
.player { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; justify-content: center; gap: 14px;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); background: rgba(14, 15, 17, 0.97); }
.player[hidden], .player [hidden] { display: none; }
.player img, .player video { width: 100%; max-width: 900px; margin: 0 auto; aspect-ratio: 4 / 3; object-fit: contain; background: #000; border-radius: 14px; }
.player .muted { text-align: center; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(27, 29, 32, 0.96); border-top: 1px solid #33373C; padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 48px; justify-content: center;
  color: var(--muted); text-decoration: none; font-size: 11px; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabs svg { width: 22px; height: 22px; }
.banner { position: fixed; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); z-index: 5; padding: 12px 14px;
  border-radius: 14px; background: #33373C; font-size: 14px; }
.toast { top: auto; bottom: calc(86px + env(safe-area-inset-bottom)); background: var(--ink); border: 1px solid var(--line); }

.thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .empty, #hs-files .empty { grid-column: 1 / -1; }
.list video { width: 100%; border-radius: 10px; background: #000; }
#hs-files label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
#hs-files img { width: 48px; height: 36px; object-fit: cover; border-radius: 6px; }
#hs-files input { width: 22px; height: 22px; }

.stack-buttons { display: flex; flex-direction: column; gap: 10px; }
.stack-buttons .big { flex-direction: row; justify-content: flex-start; gap: 14px; min-height: 72px; padding: 0 18px; font-size: 18px; }
.stack-buttons .big small { margin-left: auto; font-size: 15px; }
.back { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--accent); font-weight: 600; text-decoration: none; }
.thumbs button { display: block; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--ink); padding: 0; }
.viewer { position: fixed; inset: 0; z-index: 50; background: #000; touch-action: none; overflow: hidden; }
.viewer img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; user-select: none; -webkit-user-select: none; }
.viewer button { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; width: 48px; height: 48px; border-radius: 24px; background: rgba(0,0,0,.55); color: #fff; font-size: 30px; line-height: 1; }
.viewer span { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); text-align: center; text-shadow: 0 1px 3px #000; }

.row.gap { gap: 8px; }
.row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.banner.warn { background: #8a5a1c; }
button.danger { background: #8e2f2a; color: #fff; }
.card input[type=range] { width: 100%; accent-color: var(--accent); }
.card input[type=text], #bt-name, #wifi-ssid, #wifi-psk { flex: 1; min-width: 0; background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: 10px; min-height: 40px; padding: 0 10px; font: inherit; }
.card select { background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: 10px; min-height: 40px; padding: 0 8px; font: inherit; max-width: 60%; }
.eq { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.eq label { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.eq input { writing-mode: vertical-lr; direction: rtl; height: 110px; width: 24px; accent-color: var(--accent); }

[hidden] { display: none !important; } /* layout rules (grid, block) must never beat the hidden attribute */

.rec-icon .rec-dot { fill: currentColor; stroke: none; opacity: .55; transition: fill .2s, opacity .2s; }
body.rec-on .rec-icon .rec-dot { fill: #d63c35; opacity: 1; animation: rec-pulse 1.2s ease-in-out infinite; }
body.rec-flash .rec-icon .rec-dot { fill: #d63c35; opacity: 1; }
@keyframes rec-pulse { 50% { opacity: .35; } }

.card select.infinity { font-size: 1.6em; line-height: 1; padding-top: 0; padding-bottom: 2px; }
.chart i.charging { background: #5f9e6e; }

.setup { position: fixed; inset: 0; z-index: 60; background: rgba(15,16,18,.94); overflow-y: auto; padding: 24px 16px; }
.setup .card { max-width: 440px; margin: 0 auto; padding: 18px; }
.setup input { background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: 10px; min-height: 44px; padding: 0 10px; font: inherit; }

.seg.small button { min-height: 32px; padding: 0 12px; font-size: 13px; }
.axis { display: flex; justify-content: space-between; font-size: 12px; margin-top: -6px; }
.chart.scatter { display: block; position: relative; }
.chart.scatter i { position: absolute; width: 5px; height: 5px; min-height: 0; border-radius: 50%; transform: translate(-50%, 50%); }

.chart-wrap { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 6px; row-gap: 10px; }
.yaxis { height: 120px; display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; text-align: right; margin-top: -6px; margin-bottom: -6px; }
.chart { background: linear-gradient(to top, transparent calc(50% - .5px), var(--line) calc(50% - .5px), var(--line) calc(50% + .5px), transparent calc(50% + .5px)); touch-action: none; }
.chart-wrap .axis { margin-top: 0; }
.chart i.active { outline: 2px solid var(--text); outline-offset: 1px; }
.tip { position: absolute; transform: translate(-50%, calc(-100% - 8px)); background: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 2; }

.chart { display: block; position: relative; }
.chart i { position: absolute; bottom: 0; transform: translateX(-50%); border-radius: 2px 2px 0 0; }
.yaxis { position: relative; width: 3.2em; height: 120px; margin: 0; display: block; }
.yaxis span { position: absolute; right: 0; transform: translateY(-50%); }

/* parallax: the coat is a little larger than the screen so it can drift without showing an edge */
.coat { inset: -24px; transition: transform .25s ease-out; will-change: transform; }
