/* EPCNJ Live Translation. Quiet warm neutrals, one flame accent, captions are the content. */
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/figtree-latin.woff2") format("woff2");
}

:root {
  --bg: #f7f4ee; --surface: #fdfbf7; --raised: #efe9df;
  --text: #1f1b16; --text-2: #5e554a; --muted: #7b7266;
  --line: rgb(31 27 22 / .09); --line-strong: rgb(31 27 22 / .16);
  --accent: #c2410c; --on-accent: #ffffff; --accent-soft: rgb(194 65 12 / .08);
  --flame: #f26b1d; --live: #dc2626; --ok: #16a34a;
  --shadow: 0 1px 2px rgb(0 0 0 / .05); --shadow-float: 0 8px 24px rgb(0 0 0 / .08);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --caption-size: 1.375rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --surface: #1c1a18; --raised: #262421;
    --text: #efe9de; --text-2: #aaa398; --muted: #8a847a;
    --line: rgb(239 233 222 / .08); --line-strong: rgb(239 233 222 / .14);
    --accent: #ff7a26; --on-accent: #1a120c; --accent-soft: rgb(255 122 38 / .1);
    --flame: #ff7a26; --live: #e5484d; --ok: #4cc38a;
    --shadow: none; --shadow-float: 0 8px 24px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 400 16px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; }
.brand img { width: 28px; height: 28px; flex: none; }
.brand b { font-weight: 600; font-size: 1rem; }
.brand span { color: var(--text-2); font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand i { width: 1px; height: 16px; background: var(--line-strong); flex: none; }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--text-2); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; transition: background-color .18s var(--ease); }
.status.ok .dot { background: var(--ok); }
.status.live { color: var(--text); font-weight: 500; }
.status.live .dot { background: var(--live); box-shadow: 0 0 0 3px rgb(220 38 38 / .16); }
.status.down .dot { background: #d97706; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-weight: 500; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--raised); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn.stop { background: var(--live); border-color: transparent; color: #fff; }
.btn.stop:hover:not(:disabled) { background: color-mix(in srgb, var(--live) 88%, #000); }
.btn.big { min-height: 52px; font-size: 1.0625rem; border-radius: 12px; padding: 0 20px; }
.btn.square { width: 44px; padding: 0; }
.btn.big + .btn.square { width: 52px; min-height: 52px; border-radius: 12px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--raised); border-radius: 10px; max-width: 100%; }
.seg button { border: 0; background: transparent; color: var(--text-2); min-height: 38px; padding: 0 12px; border-radius: 7px; font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--line); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--line-strong); position: relative; flex: none; margin: 0; cursor: pointer; transition: background-color .15s var(--ease); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .18s var(--ease); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

label.field { display: block; font-weight: 500; font-size: .875rem; margin: 20px 0 8px; }
select, input[type="password"], input[type="text"] {
  width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); transition: border-color .15s var(--ease);
}
select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.note { font-size: .875rem; color: var(--text-2); margin: 8px 0 0; }
.err { color: var(--live); font-size: .875rem; margin: 12px 0 0; min-height: 20px; }
.err:empty { margin: 0; min-height: 0; }

/* ---------- captions (shared) ---------- */
.cap { position: relative; padding: 12px 0 12px 16px; color: var(--text-2); animation: rise .3s var(--ease) both; }
.cap::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 2px; background: transparent; transition: background-color .3s var(--ease); }
.cap:last-child { color: var(--text); }
.cap:last-child::before { background: var(--flame); }
.cap .en { font-size: var(--caption-size); line-height: 1.45; font-weight: 500; }
.cap .es { font-size: calc(var(--caption-size) * .72); line-height: 1.45; color: var(--muted); margin-top: 4px; }
.cap .es:empty { display: none; }
/* Sentence still being spoken: its words may still change. */
.cap.pending .en::after { content: " …"; color: var(--muted); }
.hide-es .cap .es { display: none; }
.interim { color: var(--muted); font-size: calc(var(--caption-size) * .78); line-height: 1.45; padding: 4px 0 4px 16px; min-height: 0; }
.interim:empty { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- listener page ---------- */
body.listen { height: 100dvh; overflow: hidden; }
.app { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.stage { position: relative; min-height: 0; }
.scroller { height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.reading { max-width: 720px; margin: 0 auto; padding: 16px 20px 24px; }

.waiting { min-height: 100%; display: flex; flex-direction: column; justify-content: center; max-width: 720px; margin: 0 auto; padding: 32px 24px; }
.waiting h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 500; margin: 0; letter-spacing: -.01em; max-width: 18ch; text-wrap: balance; }
.waiting p { color: var(--text-2); margin: 12px 0 0; max-width: 34rem; font-size: 1.0625rem; }
.waiting p[lang="es"] { color: var(--muted); font-size: .9375rem; margin-top: 8px; }
.waiting ol { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; max-width: 34rem; }
.waiting li { display: flex; gap: 12px; align-items: baseline; color: var(--text-2); }
.waiting li b { font-weight: 500; color: var(--muted); font-size: .875rem; min-width: 16px; }

.latest { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); box-shadow: var(--shadow-float); min-height: 36px; padding: 0 14px; border-radius: 18px; font-size: .875rem; }

.dock { border-top: 1px solid var(--line); background: var(--surface); padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
.dock-inner { max-width: 720px; margin: 0 auto; }
.dock-row { display: flex; gap: 8px; }
.dock-row .btn.big { flex: 1; }
.hint { font-size: .875rem; color: var(--text-2); margin: 0 0 12px; text-align: center; }
.hint:empty { display: none; }
.sheet { border-bottom: 1px solid var(--line); margin: 0 0 12px; padding: 0 0 12px; display: grid; gap: 4px; animation: rise .22s var(--ease) both; }
.sheet .line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: .9375rem; }
.sheet .size { display: inline-flex; align-items: center; gap: 8px; }
.sheet .size output { min-width: 44px; text-align: center; color: var(--text-2); font-size: .875rem; }
.sheet small { color: var(--muted); font-size: .8125rem; padding-top: 4px; }

/* ---------- control page ---------- */
body.control { min-height: 100dvh; }
.control .bar { position: sticky; top: 0; z-index: 2; padding: 0 24px; }
.bar-meta { display: flex; align-items: center; gap: 20px; }
.console { max-width: 1440px; margin: 0 auto; padding: 24px; display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 24px; align-items: start; }
.col { display: grid; gap: 16px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: .9375rem; font-weight: 600; margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head .note { margin: 0; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode { text-align: left; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 10px; padding: 12px; transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.mode strong { display: block; font-weight: 500; font-size: .9375rem; }
.mode span { display: block; font-size: .8125rem; color: var(--text-2); margin-top: 2px; line-height: 1.4; }
.mode[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: .875rem; color: var(--text-2); margin-top: 12px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

.meter { height: 8px; background: var(--raised); border-radius: 4px; overflow: hidden; margin: 16px 0; }
.meter > div { height: 100%; width: 0; background: var(--ok); border-radius: inherit; transition: width 80ms linear; }
.meter.thin { height: 4px; margin: 12px 0 0; }
.meter.thin > div { background: var(--accent); }
.go { width: 100%; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats > div { padding: 4px 16px; border-left: 1px solid var(--line); }
.stats > div:first-child { border-left: 0; padding-left: 0; }
.stats b { display: block; font-size: 1.75rem; line-height: 1.1; font-weight: 500; font-variant-numeric: tabular-nums; }
.stats span { font-size: .8125rem; color: var(--text-2); }

.monitor { min-height: 360px; max-height: calc(100dvh - 330px); overflow-y: auto; margin-top: 8px; }
.monitor .cap .en { font-size: 1.25rem; }
.monitor-empty { color: var(--muted); padding: 40px 0; text-align: center; font-size: .9375rem; }

.share { display: flex; gap: 20px; align-items: center; }
.qr { width: 132px; height: 132px; flex: none; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
.share .url { font-weight: 500; font-size: 1.0625rem; word-break: break-all; margin: 4px 0 8px; }

.login { max-width: 400px; margin: 64px auto; padding: 0 16px; }
.login .row { display: flex; gap: 8px; }
.login .btn.primary { width: 100%; margin-top: 16px; }

@media (max-width: 960px) {
  .console { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .monitor { max-height: 50dvh; min-height: 200px; }
}
@media (max-width: 520px) {
  .modes { grid-template-columns: 1fr; }
  .share { flex-direction: column; align-items: flex-start; }
  .bar-meta .hide-sm, .brand .hide-sm { display: none; }
  .stats b { font-size: 1.375rem; }
  .waiting h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
