/* ============================================================
   Demo stage: on desktop the app runs inside a phone frame with a
   side panel of screens; under 900px, or installed as a PWA, the app
   fills the real screen and the OS provides the chrome.
   ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--stage-bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

.stage {
  display: grid;
  grid-template-columns: 320px auto;
  gap: 48px;
  padding: 32px;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 600px at 0% 0%, var(--stage-glow-1), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, var(--stage-glow-2), transparent 60%),
    var(--stage-bg);
}

/* ---------- Side panel (desktop only) ---------- */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--stage-ink);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  scrollbar-width: none;
}
.side-panel::-webkit-scrollbar { display: none; }
.side-brand { display: flex; flex-direction: column; gap: 10px; padding: 4px 4px 8px; }
.side-brand img { width: 230px; }
.side-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.side-brand p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--stage-muted); }
.side-card {
  background: var(--stage-card);
  border: 1px solid var(--stage-line);
  border-radius: 18px;
  padding: 16px;
}
.side-card h4 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--stage-muted);
}
.side-links { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.side-links a {
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--stage-chip);
  transition: background .15s, color .15s;
}
.side-links a:hover { background: var(--stage-chip-hover); }
.side-links a.is-active { background: var(--brand); color: var(--on-brand); }
.side-qr { display: flex; gap: 14px; align-items: center; }
.side-qr .qr {
  width: 104px; height: 104px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
}
.side-qr .qr svg { width: 100%; height: 100%; display: block; }
.side-qr p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--stage-muted); }
.side-qr strong { color: var(--stage-ink); }
.side-reset {
  font-size: 12px;
  color: var(--stage-muted);
  text-decoration: underline;
  align-self: flex-start;
  padding: 0 4px;
}

/* ---------- Phone frame ---------- */
.device {
  --phone-w: 402px;
  --phone-h: 874px;
  width: var(--phone-w);
  height: var(--phone-h);
  background: #0b0b0c;
  border-radius: 62px;
  padding: 13px;
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 40px 90px rgba(0, 0, 0, .45),
    0 8px 24px rgba(0, 0, 0, .3),
    inset 0 0 0 2px rgba(255, 255, 255, .08),
    inset 0 0 0 6px #1d1d1f;
}
.device-island {
  position: absolute;
  top: 24px; left: 50%;
  transform: translateX(-50%);
  width: 122px; height: 34px;
  background: #000;
  border-radius: 20px;
  z-index: 60;
  pointer-events: none;
}
.device-home {
  position: absolute;
  bottom: 21px; left: 50%;
  transform: translateX(-50%);
  width: 136px; height: 5px;
  border-radius: 3px;
  background: currentColor;
  color: #111;
  opacity: .85;
  z-index: 60;
  pointer-events: none;
  transition: color .25s;
}
.device-home.light { color: #fff; }
.device-status {
  position: absolute;
  top: 28px; left: 13px; right: 13px;
  height: 26px;
  padding: 0 34px 0 44px;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: 600 15.5px/1 -apple-system, "SF Pro Text", system-ui, sans-serif;
  color: #000;
  pointer-events: none;
  transition: color .25s;
}
.device-status.light { color: #fff; }
.device-status .right { display: flex; gap: 6px; align-items: center; }
.device-status .battery {
  width: 25px; height: 12px;
  border: 1.4px solid currentColor;
  border-radius: 4px;
  padding: 1.5px;
  position: relative;
  opacity: .95;
}
.device-status .battery::before { content: ""; display: block; width: 78%; height: 100%; background: currentColor; border-radius: 1.5px; }
.device-status .battery::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; background: currentColor; border-radius: 0 2px 2px 0; }

.screen {
  width: 100%;
  height: 100%;
  border-radius: 50px;
  overflow: hidden;
  position: relative;
  background: var(--bg);
  isolation: isolate;
  /* The simulated status bar inside the frame stands in for the OS one. */
  --safe-top: 54px;
  --safe-bottom: 26px;
}

/* ---------- Real phone / narrow window: no frame ---------- */
@media (max-width: 900px) {
  .stage { display: block; padding: 0; min-height: 0; height: 100dvh; background: var(--bg); }
  .side-panel { display: none; }
  .device { width: 100vw; height: 100dvh; border-radius: 0; padding: 0; box-shadow: none; background: var(--bg); }
  .device-island, .device-home, .device-status { display: none; }
  .screen {
    border-radius: 0;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* ---------- Installed to the home screen ---------- */
@media (display-mode: standalone), (display-mode: fullscreen) {
  .stage { display: block; padding: 0; min-height: 0; height: 100dvh; background: var(--bg); }
  .side-panel, .device-island, .device-home, .device-status { display: none !important; }
  .device { width: 100vw; height: 100dvh; border-radius: 0; padding: 0; box-shadow: none; background: var(--bg); }
  .screen {
    border-radius: 0;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Short desktop windows: main.js sets --frame-zoom so the phone scales down
   rather than being cropped. */
@media (min-width: 901px) {
  .device { zoom: var(--frame-zoom, 1); }
}
