/* SmartHome 8 web app: same palette as the native app (Theme.swift). */
:root {
  --gold: #dbad5c; --gold-light: #f7db99; --gold-deep: #9e7029;
  --bg: #09090b; --surface: #18181b; --raised: #242428; --hairline: rgba(255,255,255,.08);
  --text: #f4f1ea; --muted: #9a978f; --off-ring: #424242; --off-icon: #8c8c8c; --off-track: #333;
  --green: #34c759; --orange: #ff9f0a; --red: #ff453a;
  --on: linear-gradient(135deg, var(--gold-light), var(--gold) 50%, var(--gold-deep));
  --radius: 26px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100dvh; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
  background: radial-gradient(1200px 600px at 50% -200px, #1c1a17 0%, var(--bg) 70%) fixed;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.app { max-width: 1120px; margin: 0 auto; padding: calc(14px + var(--safe-t)) calc(18px + var(--safe-r)) calc(28px + var(--safe-b)) calc(18px + var(--safe-l)); }

/* Header */
.hdr { display: flex; align-items: center; gap: 12px; }
.hdr-text { flex: 1; min-width: 0; }
.greet { color: var(--muted); font-size: 15px; font-weight: 500; }
.home-row { display: flex; align-items: center; gap: 6px; }
.home-row h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--gold); }
.icon-btn.round { width: 42px; height: 42px; background: var(--surface); border: 1px solid var(--hairline); }
.icon-btn svg { width: 19px; height: 19px; }
.brand { display: inline-block; flex: none; }
.brand svg { width: 100%; height: 100%; stroke: none; }
.brand-lg { width: 46px; height: 46px; filter: drop-shadow(0 0 8px rgba(219,173,92,.25)); }
.brand-xl { width: 96px; height: 96px; filter: drop-shadow(0 0 18px rgba(219,173,92,.3)); }

/* Status */
.status-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--hairline); }
.pill.subtle { color: var(--muted); font-weight: 500; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.warn .dot { background: var(--orange); animation: blink 1.2s infinite; }
.pill.bad .dot { background: var(--red); }
@keyframes blink { 50% { opacity: .3; } }

/* Quick actions */
.quick { display: flex; gap: 10px; overflow-x: auto; padding: 12px 6px 16px; margin: 0 -6px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.capsule { display: inline-flex; align-items: center; gap: 7px; flex: none; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 15px;
  background: var(--surface); border: 1px solid var(--hairline); transition: transform .15s, opacity .2s; }
.capsule svg { color: var(--gold); }
.capsule.prominent { background: var(--on); color: #1a1408; border-color: transparent; box-shadow: 0 3px 10px rgba(219,173,92,.22); }
.capsule.prominent svg { color: #1a1408; }
.capsule:active { transform: scale(.96); }
.capsule:disabled { opacity: .4; }
.capsule.wide { width: 100%; justify-content: center; padding: 14px; }

/* Channel grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { position: relative; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--hairline);
  transition: transform .18s cubic-bezier(.3,.7,.4,1.3), box-shadow .35s, border-color .35s; overflow: hidden; }
.card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(160px 120px at 30% 20%, rgba(219,173,92,.18), transparent 70%);
  opacity: 0; transition: opacity .4s; pointer-events: none; }
.card.on { border-color: rgba(219,173,92,.35); box-shadow: 0 10px 30px rgba(219,173,92,.12); }
.card.on::before { opacity: 1; }
.card:active { transform: scale(.97); }
.card.disabled { opacity: .55; }
.card.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.card-main { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; width: 100%; padding: 16px 16px 14px; text-align: left; position: relative; }
.card-more { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); z-index: 1; }
.card-more svg { width: 18px; height: 18px; }

.orb { position: relative; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  background: var(--raised); border: 2px solid var(--off-ring); color: var(--off-icon); transition: background .35s, color .35s, border-color .35s, box-shadow .35s; }
.orb svg.ic { width: 28px; height: 28px; }
.card.on .orb { background: var(--on); border-color: transparent; color: #1a1408; box-shadow: 0 0 22px rgba(247,219,153,.45), inset 0 1px 0 rgba(255,255,255,.5); }
.orb .arc { position: absolute; inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); stroke: var(--gold); stroke-width: 2.5; opacity: 0;
  stroke-dasharray: 40 200; transition: opacity .2s; }
.card.pending .orb .arc { opacity: 1; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card-name { font-weight: 650; font-size: 16px; line-height: 1.2; min-height: 1.2em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-right: 18px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.card-state { font-size: 13px; font-weight: 600; color: var(--muted); }
.card.on .card-state { color: var(--gold-light); }
.card-timer { font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; min-height: 1.2em; margin-top: -6px; }

.toggle { width: 50px; height: 30px; border-radius: 999px; background: var(--off-track); position: relative; transition: background .3s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #6b6b6b;
  box-shadow: 0 2px 4px rgba(0,0,0,.4); transition: transform .3s cubic-bezier(.3,.7,.4,1.3), background .3s; }
.card.on .toggle { background: var(--on); }
.card.on .toggle::after { transform: translateX(20px); background: #fff; }

.foot { color: var(--muted); font-size: 13px; text-align: center; margin: 26px auto 0; max-width: 520px; }

/* Enrollment */
.enroll { max-width: 520px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 22px calc(30px + var(--safe-b)); text-align: center; }
.enroll h1 { margin: 14px 0 4px; font-size: 30px; }
.lead { color: var(--muted); margin: 0 0 22px; }
.enroll form { text-align: left; display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 12px 14px; width: 100%; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--gold); }
#fCode { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 2px; text-transform: uppercase; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 0; }
.error { color: var(--red); font-size: 14px; margin: 0; min-height: 1em; }
.help { text-align: left; margin-top: 26px; color: var(--muted); font-size: 14px; background: var(--surface); border: 1px solid var(--hairline); border-radius: 18px; padding: 12px 16px; }
.help summary { color: var(--text); font-weight: 600; cursor: pointer; }

/* Sheets */
.sheet { border: 0; padding: 0; background: transparent; color: var(--text); width: min(560px, 100%); max-width: 100%; margin: auto auto 0; max-height: 92dvh; }
@media (min-width: 640px) { .sheet { margin: auto; } }
.sheet::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.sheet[open] { animation: rise .28s cubic-bezier(.2,.8,.3,1); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet-body { background: #121214; border: 1px solid var(--hairline); border-radius: 28px 28px 0 0; padding: 20px 20px calc(22px + var(--safe-b)); display: grid; gap: 14px; overflow-y: auto; max-height: 92dvh; }
@media (min-width: 640px) { .sheet-body { border-radius: 28px; } }
.sheet h2 { margin: 0; font-size: 21px; }
.sheet h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.sheet p { margin: 0; color: var(--muted); font-size: 14px; }
.sheet .row { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet .kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.sheet .kv dt { color: var(--muted); } .sheet .kv dd { margin: 0; text-align: right; word-break: break-all; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--hairline); border-radius: 999px; padding: 3px; }
.seg button { padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--on); color: #1a1408; }
.danger { color: var(--red) !important; }

.toast { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: #1f1f22; border: 1px solid var(--hairline); color: var(--text); padding: 11px 18px; border-radius: 16px; font-size: 14px;
  max-width: min(92vw, 460px); text-align: center; transition: opacity .25s, transform .25s; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
