/* Stefie: red / white / gold, Nunito. Rules from the UI Design Principles book:
   16px base, 1.6 body line height, 8px grid, >=44px tap targets, one corner radius,
   no pure black, shadows only on interactive things, colour shadow on coloured buttons. */
:root {
  --red-600: #C41E3A; --red-700: #9E1630; --red-50: #FDECEF;
  --gold-500: #D4A017; --gold-300: #F2D675; --gold-50: #FFF7DD;
  --ink: #2B2326; --muted: #6B6266; --line: #E6DFE1; --surface: #FFF9F4; --ok: #2E7D32;
  --r: 14px;                                   /* the one corner radius */
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px;
  --shadow-red: 0 8px 20px rgba(196, 30, 58, .28);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  font: 400 1rem/1.6 var(--font); color: var(--ink);
  background: radial-gradient(1200px 500px at 85% -10%, var(--gold-50), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, var(--red-50), transparent 60%), var(--surface);
}
h1, h2 { line-height: 1.2; margin: 0; font-weight: 800; }
h1 { font-size: clamp(2rem, 7vw, 3.25rem); }
h2 { font-size: 1.5rem; }
p { margin: 0; }
.accent { color: var(--red-600); }
.lead { font-size: 1.125rem; color: var(--muted); max-width: 34ch; }
.hint, .help { font-size: .875rem; color: var(--muted); }
.eyebrow { font-weight: 700; color: var(--red-600); text-transform: uppercase; letter-spacing: .08em; font-size: .8125rem; }
:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }

/* header + notice */
.top { display: flex; align-items: center; gap: var(--s1); padding: var(--s2) var(--s3); padding-top: max(var(--s2), env(safe-area-inset-top)); }
.logo { max-width: 120px; max-height: 40px; width: auto; height: auto; object-fit: contain; }   /* can never overflow its box */
.logo[hidden] { display: none; }
.brand { font-weight: 800; font-size: 1.375rem; color: var(--red-600); }
.notice { margin: 0 var(--s2); padding: var(--s1) var(--s2); background: var(--gold-50); border: 1px solid var(--gold-300); border-radius: var(--r); font-size: .875rem; text-align: center; }

/* screens */
main { flex: 1; display: flex; }
.screen { width: min(100%, 520px); margin: 0 auto; padding: var(--s3) var(--s2) var(--s4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2); text-align: center; }
.screen[hidden] { display: none; }
.actions { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: var(--s1); }
@media (min-width: 640px) { .actions { flex-direction: row; } .actions .btn { flex: 1; } }

/* buttons */
.btn { min-height: 52px; padding: 0 var(--s3); border-radius: var(--r); border: 2px solid transparent; font: 700 1rem var(--font); display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); cursor: pointer; text-decoration: none; transition: transform .15s, background .15s, box-shadow .15s; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--red-600); color: #fff; box-shadow: var(--shadow-red); }
.btn-primary:hover { background: var(--red-700); }
.btn-secondary { background: #fff; color: var(--red-600); border-color: var(--red-600); }
.btn-secondary:hover { background: var(--red-50); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(43, 35, 38, .06); }
.btn-danger { background: var(--red-700); color: #fff; box-shadow: var(--shadow-red); }
.ic { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* waiting */
.code { font-weight: 800; font-size: clamp(2rem, 10vw, 2.75rem); letter-spacing: .12em; padding: var(--s2) var(--s3); border: 2px dashed var(--gold-500); background: var(--gold-50); border-radius: var(--r); user-select: all; }
.waiting { display: flex; align-items: center; gap: var(--s1); color: var(--muted); font-weight: 600; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--gold-500); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(.8); opacity: .6; } 50% { transform: scale(1.3); opacity: 1; } }

/* in call */
.bar { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-weight: 600; flex-wrap: wrap; }
.q { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.q.poor { background: var(--gold-500); } .q.lost { background: var(--red-600); }
.chip { display: inline-block; padding: 2px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: .875rem; font-weight: 700; color: var(--ink); }
.chip:empty { display: none; }
.chip-gold { background: var(--gold-50); border-color: var(--gold-300); }
.banner { width: 100%; padding: 12px var(--s2); border-radius: var(--r); background: var(--gold-50); border: 1px solid var(--gold-300); font-weight: 600; }
.banner[hidden] { display: none; }
.avatar { width: clamp(140px, 38vw, 200px); aspect-ratio: 1; padding: 6px; border-radius: 50%; border: 4px solid var(--line); background: #fff; transition: border-color .2s, box-shadow .2s; margin-top: var(--s2); }
.avatar.speaking { border-color: var(--gold-500); box-shadow: 0 0 0 10px rgba(212, 160, 23, .25); }
.avatar svg { width: 100%; height: 100%; display: block; }
.av-bg { fill: var(--red-50); } .av-fg { fill: #D2B3BA; }
#peer-name { overflow-wrap: anywhere; }
.controls { display: flex; gap: var(--s4); margin-top: var(--s3); align-items: flex-start; }
.round { background: none; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: var(--s1); font: 700 .875rem var(--font); color: var(--ink); cursor: pointer; min-width: 72px; }
.disc { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--line); transition: background .15s, transform .15s; }
.round:active .disc { transform: scale(.95); }
.round[aria-pressed="true"] .disc { background: var(--ink); color: #fff; border-color: var(--ink); }
.round-danger .disc { width: 72px; height: 72px; background: var(--red-600); color: #fff; border-color: var(--red-600); box-shadow: var(--shadow-red); }
.round-danger:hover .disc { background: var(--red-700); }
.hang { transform: rotate(135deg); }

/* forms + popups */
label { display: block; text-align: left; font-weight: 700; margin: var(--s2) 0 6px; }
input, select { width: 100%; min-height: 52px; padding: 0 var(--s2); border: 2px solid var(--line); border-radius: var(--r); font: inherit; color: var(--ink); background: #fff; }
input:focus, select:focus { border-color: var(--gold-500); outline: none; box-shadow: 0 0 0 3px rgba(212, 160, 23, .3); }
.invalid { border-color: var(--red-600); background: var(--red-50); }
.code-input { font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.help { text-align: left; margin-top: 6px; }
.form-error { margin-top: var(--s2); padding: 12px var(--s2); border-radius: var(--r); background: var(--red-50); color: var(--red-700); font-weight: 700; text-align: left; border-left: 5px solid var(--red-600); }
.form-error[hidden] { display: none; }
dialog { border: 0; border-radius: var(--r); padding: var(--s3); width: min(92vw, 440px); color: var(--ink); box-shadow: 0 20px 60px rgba(43, 35, 38, .3); }
dialog::backdrop { background: rgba(43, 35, 38, .55); }
dialog[open] { animation: pop .2s ease; }
dialog h2 { text-align: left; margin-bottom: var(--s1); }
dialog p { text-align: left; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.row { display: flex; gap: 12px; margin-top: var(--s3); }
.row .btn { flex: 1; }
@media (max-width: 599px) {   /* phones: popups slide up as a bottom sheet */
  dialog { margin: auto auto 0; width: 100%; max-width: none; border-radius: var(--r) var(--r) 0 0; padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom)); }
}

/* toast (for messages outside popups; errors inside popups show inline) */
.toast { position: fixed; z-index: 10; top: max(var(--s2), env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(92vw, 440px); padding: 14px var(--s2); border-radius: var(--r); background: var(--ink); color: #fff; font-weight: 600; border-left: 6px solid var(--red-600); }
.toast[hidden] { display: none; }

@media (min-width: 1024px) { .screen { width: min(100%, 600px); } .lead { font-size: 1.25rem; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
