/* Best Friend Fix — prototype styles.
   Deliberately large touch targets and high contrast: the target users
   include elderly people who need help, so nothing tiny or clever. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #16202e;
  --muted: #5b6675;
  --border: #dbe1ea;
  --primary: #2563eb;
  --primary-press: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #b45309;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(20, 32, 46, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151e;
    --surface: #182230;
    --text: #eef2f8;
    --muted: #9aa7b8;
    --border: #2a3648;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; display: block; border-radius: 7px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.tag {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
}

#main {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.view { animation: fade 0.2s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.headline {
  font-size: clamp(20px, 5.6vw, 26px);
  line-height: 1.25;
  margin: 8px 0 6px;
  letter-spacing: -0.02em;
}
.sub { color: var(--muted); font-size: 16px; margin: 0 0 22px; }

.choice { display: grid; gap: 14px; }

.big-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 22px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.06s ease, background 0.15s ease;
}
.big-btn:active { transform: scale(0.985); }
.big-btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.big-btn.primary:active { background: var(--primary-press); }
.big-btn-emoji { font-size: 30px; }
.big-btn-text { font-size: 20px; font-weight: 650; }
.big-btn-hint { font-size: 14px; opacity: 0.85; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.link-row { display: flex; gap: 8px; margin-bottom: 14px; }
.link-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.mini-btn {
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.share-btn { padding: 16px; }

.passcode-card { text-align: center; }
.passcode {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.passcode-input {
  width: 100%;
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.2em;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 14px;
}
.passcode-input:focus { outline: none; border-color: var(--primary); }

.status { font-size: 15px; margin: 14px 0; text-align: center; }
.status.waiting { color: var(--warn); }
.status.error { color: var(--danger); font-weight: 600; }
.status.ok { color: var(--ok); }

.text-btn {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
}

/* ---- Live session ----------------------------------------------------------
   .stage wraps the screen + control bar + settings popover, and is the element
   that goes fullscreen — so the bar stays reachable in both modes. Docked under
   the screen normally; floats over the bottom of the video in fullscreen. */
#view-session {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(1100px, 94vw);
  margin-left: 50%;
  transform: translateX(-50%);
}

.stage { position: relative; display: flex; flex-direction: column; }

.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
#remote-video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

.stage-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; color: #cbd5e1;
}
.spinner {
  width: 42px; height: 42px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Compact control bar ---- */
.control-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}
.cb-btn {
  flex: none;
  height: 36px;
  min-width: 38px;
  padding: 0 9px;
  font-size: 16px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.cb-btn:hover { border-color: var(--primary); }
.cb-btn:active { transform: scale(0.97); }
.cb-btn.cb-wide { font-size: 13px; font-weight: 600; padding: 0 12px; }
.cb-btn.muted { background: var(--warn); color: #fff; border-color: transparent; }
.cb-btn.cb-end {
  font-size: 14px; font-weight: 700; padding: 0 14px;
  background: var(--danger); color: #fff; border-color: transparent;
}
.cb-icon { flex: none; font-size: 15px; opacity: 0.75; }
.cb-spacer { flex: 1 1 auto; }

.meter {
  flex: 1 1 60px;
  min-width: 42px;
  max-width: 130px;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  height: 100%; width: 0%;
  background: var(--muted);
  border-radius: 999px;
  transition: width 0.08s linear;
}
.meter-fill.active { background: var(--ok); }

/* ---- Device settings popover (toggled by the gear) ---- */
.audio-panel {
  position: absolute;
  right: 8px;
  bottom: 60px;
  z-index: 5;
  width: min(320px, calc(100% - 16px));
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(20,32,46,0.22);
}
.dev-row { display: flex; align-items: center; gap: 10px; }
.dev-label { flex: none; width: 84px; font-size: 13px; font-weight: 600; color: var(--muted); }
.dev-select {
  flex: 1; min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.audio-hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }

.mic-problem {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #fff4e5;
  border: 1px solid #f5c98a;
  color: #7a4a00;
  font-size: 14px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  .mic-problem { background: #3a2a12; border-color: #6b4a1c; color: #ffd9a0; }
}

/* ---- Fullscreen: same bar, floating over the bottom of the video ---- */
.stage:fullscreen { width: 100vw; height: 100vh; background: #000; }
.stage:fullscreen .screen {
  flex: 1; height: 100%; aspect-ratio: auto;
  border-radius: 0; box-shadow: none;
}
.stage:fullscreen .control-bar {
  position: absolute;
  left: 16px; right: 16px; bottom: 16px;
  border: none;
  border-radius: 12px;
  background: rgba(255,255,255,0.94);
  color: #16202e;
  box-shadow: 0 6px 28px rgba(0,0,0,0.45);
}
.stage:fullscreen .control-bar .cb-btn { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.12); color: #16202e; }
.stage:fullscreen .control-bar .cb-btn.cb-end { background: var(--danger); color: #fff; border-color: transparent; }
.stage:fullscreen .control-bar .meter { background: rgba(0,0,0,0.08); border-color: rgba(0,0,0,0.12); }
.stage:fullscreen .audio-panel { bottom: 72px; right: 16px; }
.stage:fullscreen .mic-problem { position: absolute; left: 16px; right: 16px; bottom: 72px; margin: 0; }

@media (max-width: 560px) {
  .cb-btn { min-width: 34px; padding: 0 7px; font-size: 15px; }
  .cb-btn.cb-end { padding: 0 10px; font-size: 13px; }
  .meter { max-width: 80px; }
}

/* ---- Remote control ---- */
.cb-btn.cb-active { background: var(--ok); color: #fff; border-color: transparent; }
.screen.controlling { cursor: crosshair; }
.screen.controlling::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border: 3px solid var(--ok); border-radius: inherit;
}
.control-banner {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #fdecec;
  border: 1px solid #f3b4b4;
  color: #8a1c1c;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  .control-banner { background: #3a1616; border-color: #6d2626; color: #ffb9b9; }
}
.stage:fullscreen .control-banner { position: absolute; left: 16px; right: 16px; top: 16px; margin: 0; }

/* ---- In-app browser escape banner ---- */
.iab-banner {
  margin: 0;
  padding: 16px 18px;
  background: #fff4e5;
  border-bottom: 1px solid #f5c98a;
  color: #7a4a00;
}
.iab-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.iab-text { margin: 0 0 12px; font-size: 14px; line-height: 1.45; }
.iab-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.iab-btn {
  flex: 1 1 130px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid #e0b070;
  border-radius: 12px;
  background: #fff;
  color: #7a4a00;
  cursor: pointer;
}
.iab-btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.iab-hint { margin: 10px 0 0; font-size: 13px; line-height: 1.4; opacity: 0.9; }
@media (prefers-color-scheme: dark) {
  .iab-banner { background: #3a2a12; border-color: #6b4a1c; color: #ffd9a0; }
  .iab-btn { background: #241a0c; color: #ffd9a0; border-color: #6b4a1c; }
}

/* ---- Host share screen ---- */
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin-right: 7px;
  border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 700; vertical-align: -5px;
}
#host-link { width: 100%; margin-bottom: 12px; }
.wide-btn {
  display: block; width: 100%; margin-top: 10px; padding: 13px;
  font-size: 15px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--text); cursor: pointer;
}
.wide-btn:hover { border-color: var(--primary); }
.code-note { margin: 12px 0 0; font-size: 13px; color: var(--muted); line-height: 1.4; }

/* ---- Download page ---- */
.dl-btn { text-decoration: none; margin-bottom: 18px; }
.notice {
  padding: 14px 16px; margin-bottom: 26px;
  background: #fff4e5; border: 1px solid #f5c98a; border-radius: var(--radius);
  color: #7a4a00; font-size: 15px; line-height: 1.5;
}
.sec-title { font-size: 20px; margin: 30px 0 12px; letter-spacing: -0.01em; }
.body-text { font-size: 15px; line-height: 1.6; color: var(--muted); margin: 0 0 14px; }
.warn-text {
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.step-card { padding: 16px; }
.step-head { margin: 0 0 12px; font-size: 16px; font-weight: 650; }
.step-note { margin: 12px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

/* Simplified pictures of the real dialogs, so nothing is a surprise. */
.mock { border-radius: 12px; padding: 14px; font-size: 13px; }
.mock-light { background: var(--bg); border: 1px solid var(--border); }
.mock-blue { background: #1f5fa8; color: #fff; }
.mock-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.mock-line { margin: 0; line-height: 1.45; }
.mock-dim { color: var(--muted); }
.mock-link { margin: 10px 0 0; text-decoration: underline; font-size: 13px; }
.mock-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.mock-btn {
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: #fff; color: #16202e; border: 1px solid var(--border);
}
.mock-btn.hot { background: var(--ok); color: #fff; border-color: transparent; }
.done-card { text-align: center; background: #e8f6ec; border-color: #a8dcb8; }
.done-text { margin: 0; font-size: 16px; font-weight: 600; color: #14532d; }
@media (prefers-color-scheme: dark) {
  .notice { background: #3a2a12; border-color: #6b4a1c; color: #ffd9a0; }
  .done-card { background: #14301f; border-color: #2d5f3f; }
  .done-text { color: #a7e9bf; }
  .mock-btn { background: var(--surface); color: var(--text); }
}
.get-app { margin: 18px 0 0; font-size: 14px; color: var(--muted); text-align: center; line-height: 1.5; }
.get-app a { color: var(--primary); font-weight: 600; }
