:root {
  --fs: 40px;            /* transcript font size, adjustable */
  --bg: #000;
  --fg: #f5f5f5;
  --muted: #8a8a8a;
  --accent: #2dd4bf;
  --interim: #fbbf24;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  /* respect iPhone notch / home indicator */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button { cursor: pointer; }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.35; }
button.ghost {
  font-size: 15px; padding: 8px 13px; border-radius: 11px;
  border: 1px solid #2a2a2a; background: #1a1a1a; color: var(--fg);
}

/* ---- top bar: language pill + settings ---- */
#topbar {
  display: flex; align-items: center; justify-content: center;
  position: relative;
  padding: 12px 14px 10px;
}
.langpill {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 600; color: var(--fg);
  background: #161616; border: 1px solid #262626;
  padding: 8px 16px; border-radius: 999px;
}
.langpill .arrow { color: var(--accent); font-weight: 700; }
.icon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid #262626; background: #161616; color: var(--fg);
  font-size: 18px; line-height: 1;
}

/* ---- settings sheet ---- */
.settings {
  background: #0d0d0d; border-bottom: 1px solid #1c1c1c;
  padding: 6px 16px 12px;
}
.srow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 9px 0; border-top: 1px solid #161616;
  font-size: 15px; color: var(--muted);
}
.srow:first-child { border-top: none; }
.srow .btns { display: flex; gap: 8px; }
.srow small { color: #5a5a5a; }
.settings .engine {
  font-size: 15px; padding: 9px 12px; border-radius: 11px;
  border: 1px solid #2a2a2a; background: #1a1a1a; color: var(--fg);
}
.settings .gate input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---- bottom dock: big mic button (Google-Translate style) ---- */
#dock {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 18px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid #161616;
  background: linear-gradient(to top, var(--bg), var(--bg) 60%, transparent);
}
.mic {
  justify-self: center;
  width: 76px; height: 76px; border-radius: 999px;
  border: none; background: var(--accent); color: #00201c;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(45, 212, 191, 0.30);
  transition: background .15s, box-shadow .15s, transform .1s;
}
.mic.recording {
  background: #ef4444; color: #fff;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  70%  { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.dock-side {
  justify-self: start;
  font-size: 15px; padding: 9px 16px; border-radius: 999px;
  border: 1px solid #2a2a2a; background: #1a1a1a; color: var(--fg);
}
.dock-side.danger { background: #ef4444; color: #fff; border-color: transparent; }

.status { justify-self: end; font-size: 13px; color: var(--muted); text-align: right; }
.status.err { color: #f87171; }
.status.ok  { color: var(--accent); }

.gate { display: flex; align-items: center; gap: 6px; }

.diag {
  background: #0a0a0a;
  border-bottom: 1px solid #1c1c1c;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--muted);
  max-height: 32vh;
  overflow-y: auto;
}
.diag-now { margin-bottom: 6px; }
.diag-now b { color: var(--fg); }
.pill {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}
.pill.shown   { background: #064e3b; color: #6ee7b7; }
.pill.dropped { background: #4a1d1d; color: #fca5a5; }
.diag-log { list-style: none; margin: 0; padding: 0; }
.diag-log li {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  border-top: 1px solid #141414;
  font-variant-numeric: tabular-nums;
}
.diag-log .t { color: #555; min-width: 58px; }
.diag-log .lang { min-width: 52px; font-weight: 700; }
.diag-log .lang.zh { color: #6ee7b7; }
.diag-log .lang.en { color: #fca5a5; }
.diag-log .tx { color: #aaa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  /* top pad pushes first lines down; big bottom pad parks the ACTIVE line in the
     lower third where it's comfortable to read (not jammed against the edge). */
  padding: 16vh 22px calc(36vh + env(safe-area-inset-bottom)) 22px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* fade older lines out as they scroll toward the top */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 15%, #000 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 15%, #000 100%);
}

#transcript p {
  margin: 0 0 0.62em 0;
  font-size: var(--fs);
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #585858;                 /* default: faded history */
  transition: color 240ms ease;
  text-wrap: pretty;
}
#transcript p:nth-last-child(3) { color: #7d7d7d; }
#transcript p:nth-last-child(2) { color: #b9b9b9; }
#transcript p:last-child {        /* newest / active line: brightest */
  color: #ffffff;
  font-weight: 700;
}
/* blinking caret on the streaming line = "still translating" cue */
#transcript p.live::after {
  content: "";
  display: inline-block;
  width: 0.46ch;
  height: 0.92em;
  margin-left: 3px;
  background: var(--accent);
  vertical-align: -0.1em;
  border-radius: 2px;
  animation: caret 1s steps(2, start) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.hint { color: var(--muted) !important; font-size: 18px !important; font-weight: 400 !important; line-height: 1.5; }

.interim { display: none; }   /* live text now renders inline in the transcript */
