:root {
  --bg: #0e0b09; --panel: #1a1512; --panel2: #241c17;
  --ink: #f4ece3; --muted: #a79684; --accent: #37e0a6; --hot: #ff6b4a; --line: #322721;
  --coffee: #c58a4a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #23180f, var(--bg));
  color: var(--ink); font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(14,11,9,.85);
  backdrop-filter: blur(8px); z-index: 5;
}
.brand { font-weight: 700; font-size: 18px; }
.brand span { color: var(--coffee); }
.tabs { margin-left: auto; display: flex; gap: 4px; background: var(--panel); border-radius: 999px; padding: 4px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 7px 16px; border-radius: 999px; font-weight: 600; }
.tab.active { background: var(--accent); color: #05231a; }
.icon-btn { border: 0; background: var(--panel); color: var(--ink); width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }

.view { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 14px; max-width: 620px; width: 100%; margin: 0 auto; }
.hidden { display: none !important; }

.camwrap { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 3/4; }
#cam { width: 100%; height: 100%; object-fit: cover; display: block; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.pill { position: absolute; top: 12px; left: 12px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: rgba(0,0,0,.55); }
.pill.ok { color: var(--accent); } .pill.cal { color: #ffd479; } .pill.hot { background: var(--hot); color: #2a0b06; }
.banner {
  position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 16px; border-radius: 14px;
  background: var(--hot); color: #2a0b06; font-weight: 800; font-size: 20px; text-align: center;
  animation: pop .3s ease;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

.signal-label { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 6px; }
.signal-label span { color: var(--ink); font-variant-numeric: tabular-nums; }
.signal-track { height: 10px; background: var(--panel2); border-radius: 999px; overflow: hidden; }
.signal-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--hot)); transition: width .2s; }

.controls { display: flex; gap: 10px; }
button.primary, button.ghost, button.stop { flex: 1; border: 0; border-radius: 14px; padding: 15px; font-weight: 700; font-size: 16px; }
button.primary { background: var(--accent); color: #05231a; }
button.stop { background: var(--hot); color: #2a0b06; }
button.ghost { background: var(--panel2); color: var(--ink); flex: 0 0 auto; padding: 15px 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

.rx-hero { text-align: center; padding: 32px 12px; background: var(--panel); border-radius: 18px; }
.rx-emoji { font-size: 56px; }
.rx-status { margin: 10px 0 16px; color: var(--muted); }
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alerts li { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.alerts .time { color: var(--muted); font-size: 12px; float: right; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: var(--panel); width: 100%; max-width: 620px; border-radius: 20px 20px 0 0; padding: 20px; display: flex; flex-direction: column; gap: 14px; max-height: 92dvh; overflow: auto; }
.sheet h2 { margin: 0; }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.sheet input[type=text], .sheet input:not([type]), .sheet input[type=number] {
  background: var(--panel2); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 12px; font-size: 15px;
}
.sheet input[type=range] { width: 100%; }
.row { display: flex; gap: 10px; } .row > label { flex: 1; }
.chk { flex-direction: row !important; align-items: center; gap: 8px; color: var(--ink); }
.muted { color: var(--muted); }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions button { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); color: var(--ink); padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line); z-index: 30; max-width: 90%; text-align: center; }
