*,
*::before,
*::after { box-sizing: border-box; }

:root {
  color-scheme: dark;
  --bg: #090b10;
  --glow: rgba(62, 230, 168, .14);
  --card: rgba(21, 25, 36, .82);
  --card-solid: #12161f;
  --card-2: #1a1f2c;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --text: #eef1f8;
  --muted: #8d95a9;
  --faint: #5d6478;
  --mint: #3ee6a8;
  --mint-deep: #10bd83;
  --mint-glow: rgba(62, 230, 168, .34);
  --amber: #ffc04d;
  --coral: #ff7a59;
  --red: #ff4d5e;
  --radius: 24px;
  --radius-sm: 15px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  left: 50%;
  top: -38vh;
  width: 140vw;
  height: 80vh;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--glow), transparent);
  pointer-events: none;
  z-index: -1;
  transition: background .6s;
}
body.is-off { --glow: rgba(125, 135, 160, .10); }
body.is-ringing { overflow: hidden; }

button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { display: block; }

.boot { min-height: 100vh; display: grid; place-items: center; color: var(--faint); }

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font: 800 21px/1 var(--display); letter-spacing: -.03em; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--coral), #ff3d6e);
  box-shadow: 0 6px 18px rgba(255, 77, 94, .35);
}
.brand-mark svg { width: 20px; height: 20px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font: 600 13px/1 var(--font); white-space: nowrap;
}
button.chip { cursor: pointer; }
.chip svg { width: 16px; height: 16px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.chip.ok .dot { background: var(--mint); box-shadow: 0 0 0 4px rgba(62, 230, 168, .15); }
.chip.warn .dot { background: var(--amber); }
.chip.bad { color: var(--red); }
.chip.bad .dot { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 77, 94, .18); }
.chip.armed { color: var(--mint); border-color: rgba(62, 230, 168, .3); }
.chip.unarmed { color: var(--amber); border-color: rgba(255, 192, 77, .35); }

/* ---------- banner ---------- */
.banner { max-width: 1080px; margin: 0 auto 14px; padding: 0 16px; }
.banner-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 16px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(255, 192, 77, .16), rgba(255, 122, 89, .12));
  border: 1px solid rgba(255, 192, 77, .32);
}
.banner-text { flex: 1; min-width: 0; font-weight: 700; }
.banner-text small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--card-2); color: var(--text);
  font: 700 14px/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: transform .12s, background .2s, border-color .2s, opacity .2s;
}
.btn:hover { border-color: rgba(255, 255, 255, .22); }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary {
  background: linear-gradient(135deg, var(--mint), var(--mint-deep));
  color: #03140d; border: 0; box-shadow: 0 8px 24px rgba(62, 230, 168, .25);
}
.btn.warn { background: linear-gradient(135deg, #ffc04d, #ff8a3d); color: #1d1200; border: 0; }
.btn.small { height: 36px; padding: 0 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.icon-btn {
  flex: none; width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
  transition: color .2s, border-color .2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn.danger:hover { color: var(--red); border-color: rgba(255, 77, 94, .45); }
.icon-btn svg { width: 18px; height: 18px; }
.linkish {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 4px; color: var(--muted);
  font: 600 13px/1 var(--font); cursor: pointer;
}
.linkish:hover { color: var(--text); }
.linkish svg { width: 16px; height: 16px; }

/* ---------- layout ---------- */
.grid {
  display: grid; gap: 16px;
  max-width: 1080px; margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
}
.col { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 960px) {
  .grid { grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); }
  .hero { grid-column: 1 / -1; }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.card h2 {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px; font: 800 17px/1.2 var(--display); letter-spacing: -.01em;
}
.card h2 .spacer { flex: 1; }
.badge {
  min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--card-2); color: var(--muted); font: 700 12px/1 var(--font);
}
.empty {
  padding: 18px; border-radius: 18px; border: 1px dashed var(--line-2);
  color: var(--muted); text-align: center;
}

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  display: grid; justify-items: center; text-align: center; gap: 14px;
  padding: 30px 20px 24px;
}
.hero::after {
  content: ""; position: absolute; left: -20%; right: -20%; bottom: -70%; height: 130%;
  background: radial-gradient(closest-side, rgba(62, 230, 168, .17), transparent 70%);
  opacity: 0; transition: opacity .6s; pointer-events: none;
}
.is-on .hero::after { opacity: 1; }
.hero > * { position: relative; z-index: 1; }
.power-wrap { width: 176px; height: 176px; display: grid; place-items: center; position: relative; }
.pulse {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid rgba(62, 230, 168, .5); opacity: 0;
}
.is-on .pulse { animation: pulse 2.8s ease-out infinite; }
.is-on .pulse:nth-child(2) { animation-delay: .93s; }
.is-on .pulse:nth-child(3) { animation-delay: 1.86s; }
@keyframes pulse { 0% { transform: scale(.62); opacity: .9; } 100% { transform: scale(1.22); opacity: 0; } }
.power {
  position: relative; z-index: 1;
  width: 134px; height: 134px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--faint);
  background: radial-gradient(circle at 50% 30%, #252c3d, #10141c 72%);
  box-shadow: inset 0 0 0 1px var(--line-2), inset 0 -10px 24px rgba(0, 0, 0, .45), 0 18px 50px rgba(0, 0, 0, .55);
  transition: color .3s, box-shadow .3s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.power:active { transform: scale(.95); }
.power svg { width: 54px; height: 54px; }
.is-on .power {
  color: var(--mint);
  box-shadow: inset 0 0 0 1.5px rgba(62, 230, 168, .5), inset 0 -10px 24px rgba(0, 0, 0, .4),
    0 0 0 10px rgba(62, 230, 168, .07), 0 0 70px var(--mint-glow);
}
.hero-label { font: 800 12px/1 var(--font); letter-spacing: .22em; text-transform: uppercase; color: var(--faint); }
.is-on .hero-label { color: var(--mint); }
.hero-title { margin: 0; font: 800 clamp(28px, 6vw, 38px)/1.04 var(--display); letter-spacing: -.035em; }
.hero-sub { margin: 0; color: var(--muted); max-width: 46ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
@media (min-width: 960px) {
  .hero { grid-template-columns: auto minmax(0, 1fr); justify-items: start; text-align: left; column-gap: 40px; padding: 34px 40px; }
  .hero .power-wrap { grid-row: span 5; align-self: center; }
  .hero-actions { justify-content: flex-start; }
}
.tickers { display: grid; gap: 8px; width: 100%; justify-items: center; }
.tickers:empty { display: none; }
@media (min-width: 960px) { .tickers { justify-items: start; } }
.ticker {
  width: 100%; max-width: 520px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: rgba(255, 192, 77, .08); border: 1px solid rgba(255, 192, 77, .26); text-align: left;
}
.ticker + .ticker { margin-top: -6px; }
.ticker-row { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }
.ticker-row span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker-row span:last-child { color: var(--amber); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticker-preview { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .07); margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--amber), var(--coral)); transition: width 1s linear; }

/* ---------- people ---------- */
.people { display: grid; gap: 8px; }
.person {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 12px; border-radius: 18px;
  background: var(--card-2); border: 1px solid var(--line);
  transition: opacity .2s;
}
.person.muted { opacity: .55; }
.ava {
  position: relative; overflow: hidden; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  font: 800 15px/1 var(--display); color: #fff;
  background: linear-gradient(135deg, hsl(var(--h, 200) 70% 56%), hsl(calc(var(--h, 200) + 40) 75% 44%));
}
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pinfo { flex: 1; min-width: 0; }
.pname { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmeta { display: block; color: var(--faint); font: 500 12px/1.4 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.switch { position: relative; flex: none; width: 48px; height: 28px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #2a3042; transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .2s;
}
.switch input:checked + span { background: var(--mint-deep); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--mint); outline-offset: 2px; }

.add { margin-top: 14px; }
.search {
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 8px 0 14px; border-radius: 16px;
  background: var(--card-solid); border: 1px solid var(--line-2);
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: rgba(62, 230, 168, .55); box-shadow: 0 0 0 4px rgba(62, 230, 168, .12); }
.search > svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  color: var(--text); font: 500 16px/1 var(--font);
}
.search input::placeholder { color: var(--faint); }
.results { display: grid; gap: 2px; margin-top: 8px; }
.results-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 4px 2px; }
.results-label { color: var(--faint); font: 700 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 10px; border-radius: 14px; border: 0;
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.result:hover, .result:focus-visible { background: var(--card-2); outline: 0; }
.result .ava { width: 38px; height: 38px; font-size: 13px; }
.pill {
  flex: none; height: 30px; padding: 0 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(62, 230, 168, .12); color: var(--mint); font: 700 13px/1 var(--font);
}
.pill svg { width: 14px; height: 14px; }
.result.in { cursor: default; }
.result.in .pill { background: transparent; color: var(--faint); }

/* ---------- settings ---------- */
.setting { padding: 14px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; padding-top: 2px; }
.setting-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.setting-head b { display: block; font-weight: 700; }
.setting-head small { display: block; color: var(--faint); font-size: 12px; }
.value { font: 800 15px/1 var(--display); color: var(--mint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.subhead { margin: 18px 0 2px; color: var(--faint); font: 700 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row + .row { margin-top: 12px; }
.row-text b { display: block; font-weight: 700; }
.row-text small { display: block; color: var(--faint); font-size: 12px; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, var(--mint) var(--p, 50%), #2a3042 var(--p, 50%));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .4), 0 0 0 4px rgba(62, 230, 168, .18);
}
input[type=range]::-moz-range-track { height: 6px; border-radius: 6px; background: #2a3042; }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--mint); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; }

/* ---------- history ---------- */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.history li:last-child { border-bottom: 0; }
.history time { flex: none; width: 46px; color: var(--faint); font: 600 12px/1.6 var(--mono); }
.history span { min-width: 0; overflow-wrap: anywhere; }

.tip { display: flex; gap: 14px; align-items: flex-start; color: var(--muted); font-size: 14px; }
.tip b { color: var(--text); }
.tip-emoji { font-size: 26px; line-height: 1; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; padding: 0 4px; }

/* ---------- alarm overlay ---------- */
.alarm {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  text-align: center; color: #fff; background: #3a0711; overflow: hidden;
}
.alarm::before {
  content: ""; position: absolute; inset: -30%;
  background: radial-gradient(circle at 50% 45%, #ff6a4d 0%, #e3173f 38%, #4a0716 75%);
  animation: alarmPulse 1.1s ease-in-out infinite;
}
.alarm::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(-45deg, rgba(0, 0, 0, .09) 0 18px, transparent 18px 36px);
  animation: stripes 1.4s linear infinite;
}
@keyframes alarmPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .7; transform: scale(1.05); } }
@keyframes stripes { to { background-position: 51px 0; } }
.alarm-body { position: relative; z-index: 1; display: grid; justify-items: center; gap: 14px; max-width: 700px; }
.alarm-bell {
  width: 100px; height: 100px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .16); box-shadow: 0 0 0 14px rgba(255, 255, 255, .08);
}
.alarm-bell svg { width: 54px; height: 54px; transform-origin: 50% 10%; animation: ring .45s ease-in-out infinite; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(16deg); } 75% { transform: rotate(-16deg); } }
.alarm-kicker { font: 800 13px/1 var(--font); letter-spacing: .32em; opacity: .85; }
.alarm-names { font: 900 clamp(32px, 8.5vw, 66px)/1.02 var(--display); letter-spacing: -.035em; text-shadow: 0 4px 30px rgba(0, 0, 0, .25); overflow-wrap: anywhere; }
.alarm-preview { font-size: 18px; opacity: .92; max-width: 34ch; overflow-wrap: anywhere; white-space: pre-line; }
.alarm-meta { font: 600 14px/1 var(--mono); opacity: .82; }
.alarm-ack {
  margin-top: 8px; height: 74px; padding: 0 58px; border-radius: 999px; border: 0;
  background: #fff; color: #d9123d; font: 900 27px/1 var(--display); letter-spacing: .08em;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .35); cursor: pointer;
  animation: breathe 1.1s ease-in-out infinite;
}
.alarm-ack:active { transform: scale(.96); }
@keyframes breathe { 50% { transform: scale(1.05); } }
.alarm-sound { background: rgba(0, 0, 0, .28); border: 1px solid rgba(255, 255, 255, .4); color: #fff; }
.alarm-hint { font-size: 13px; opacity: .78; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; display: grid; justify-items: center; gap: 16px; text-align: center; padding: 34px 24px; }
.login-logo {
  width: 78px; height: 78px; border-radius: 24px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--coral), #ff3d6e); box-shadow: 0 14px 40px rgba(255, 77, 94, .35);
}
.login-logo svg { width: 40px; height: 40px; }
.login h1 { margin: 2px 0 0; font: 900 36px/1 var(--display); letter-spacing: -.035em; }
.login p { margin: 0; color: var(--muted); }
.login .btn { width: 100%; height: 52px; font-size: 15px; }
.code-form { width: 100%; display: grid; gap: 12px; justify-items: center; }
.code-input {
  width: 100%; height: 62px; border-radius: 18px; border: 1px solid var(--line-2);
  background: var(--card-solid); color: var(--text); outline: 0;
  text-align: center; font: 800 28px/1 var(--mono); letter-spacing: .45em; text-indent: .45em;
}
.code-input:focus { border-color: rgba(62, 230, 168, .55); box-shadow: 0 0 0 4px rgba(62, 230, 168, .12); }
.login-msg { min-height: 20px; font-size: 14px; color: var(--muted); }
.login-msg.err { color: var(--red); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 200;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: #232938; border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  font-weight: 600; opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255, 77, 94, .55); }

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none !important; }
  .alarm::after { animation: none; }
}
