@font-face {
  font-family: "GmarketSans";
  src: url("/fonts/GmarketSans-Medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "GmarketSans";
  src: url("/fonts/GmarketSans-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #f4f7ff;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-solid: #ffffff;
  --surface-muted: #f7f9ff;
  --text: #17213a;
  --muted: #68728a;
  --faint: #929aaf;
  --line: #dfe5f1;
  --primary: #315eea;
  --primary-strong: #2348c7;
  --primary-soft: #e9efff;
  --target: #e94e42;
  --target-soft: #fff0ee;
  --success: #11966b;
  --success-soft: #e6f8f1;
  --warning: #a86500;
  --warning-soft: #fff5dc;
  --danger: #ce354a;
  --danger-soft: #ffedf1;
  --shadow-sm: 0 8px 24px rgba(42, 62, 120, 0.08);
  --shadow-md: 0 20px 58px rgba(42, 62, 120, 0.16);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --max-width: 1080px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "GmarketSans", "Noto Sans KR", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  --bg: #0c1323;
  --surface: rgba(22, 31, 52, 0.96);
  --surface-solid: #161f34;
  --surface-muted: #1b263f;
  --text: #f4f6fc;
  --muted: #a9b2c8;
  --faint: #7d899f;
  --line: #2c3854;
  --primary: #7696ff;
  --primary-strong: #9bb1ff;
  --primary-soft: #1f315f;
  --target: #ff786b;
  --target-soft: #48272b;
  --success: #4bd4a5;
  --success-soft: #183c34;
  --warning: #f2bc5d;
  --warning-soft: #3e321c;
  --danger: #ff8092;
  --danger-soft: #47242d;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 20px 58px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, color-mix(in srgb, var(--primary) 11%, transparent), transparent 30rem),
    radial-gradient(circle at 95% 18%, color-mix(in srgb, var(--target) 7%, transparent), transparent 25rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
strong, b, h1, h2, h3, button { font-weight: 700; }
button, input, select { font: inherit; }
button { color: inherit; }
button, select, input[type="range"], input[type="checkbox"] { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
a { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 38%, transparent);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 10px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100vh; padding-bottom: calc(82px + var(--safe-bottom)); }
.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--surface-solid) 87%, transparent);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}
.topbar-inner {
  display: flex;
  width: min(calc(100% - 32px), var(--max-width));
  min-height: calc(72px + var(--safe-top));
  margin: 0 auto;
  padding-top: var(--safe-top);
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand { display: flex; min-width: 0; align-items: center; gap: 12px; }
.brand-icon { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; box-shadow: 0 8px 20px rgba(49, 94, 234, 0.23); }
.brand h1 { margin: 1px 0 0; font-size: clamp(17px, 3.8vw, 21px); line-height: 1.16; letter-spacing: -0.025em; }
.eyebrow, .section-kicker { margin: 0; color: var(--primary); font-size: 10px; font-weight: 850; letter-spacing: 0.14em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-solid);
  font-size: 20px;
}
.status-badge {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px color-mix(in srgb, var(--faint) 16%, transparent); }
.status-badge[data-state="connecting"] .status-dot { background: var(--warning); animation: pulse 1.15s infinite; }
.status-badge[data-state="live"] { border-color: color-mix(in srgb, var(--success) 32%, var(--line)); background: var(--success-soft); color: var(--success); }
.status-badge[data-state="live"] .status-dot { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent); animation: pulse 1.4s infinite; }
.status-badge[data-state="error"] { border-color: color-mix(in srgb, var(--danger) 32%, var(--line)); background: var(--danger-soft); color: var(--danger); }
.status-badge[data-state="error"] .status-dot { background: var(--danger); }

.banner {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 14px auto 0;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--warning) 28%, transparent);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: color-mix(in srgb, var(--warning) 88%, var(--text));
  font-size: 13px;
  line-height: 1.5;
}
.banner strong { display: block; margin-bottom: 2px; }

.main-content { width: min(calc(100% - 32px), var(--max-width)); margin: 0 auto; padding: 22px 0 34px; }
.page { animation: page-in 180ms ease-out; }
.page > * + * { margin-top: 20px; }
.direction-card, .live-card, .settings-card, .diagnostics {
  border: 1px solid color-mix(in srgb, var(--line) 90%, transparent);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.direction-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 20px;
  border-radius: var(--radius-lg);
}
.language-button {
  display: flex;
  min-width: 0;
  min-height: 72px;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.language-button:hover:not(:disabled) { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary) 42%, var(--line)); box-shadow: 0 7px 20px rgba(49, 94, 234, 0.09); }
.flag { flex: 0 0 auto; font-size: 29px; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.09)); }
.flag.small { font-size: 23px; }
.language-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.language-copy small { overflow: hidden; color: var(--muted); font-size: 10px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.language-copy strong { font-size: clamp(15px, 4vw, 18px); letter-spacing: -0.02em; }
.swap-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
  color: white;
  box-shadow: 0 9px 20px rgba(49, 94, 234, 0.23);
  font-size: 24px;
  line-height: 1;
  transition: transform 180ms ease;
}
.swap-button:hover:not(:disabled) { transform: rotate(180deg); }
.direction-summary { grid-column: 1 / -1; margin: 1px 2px 0; color: var(--muted); font-size: 13px; text-align: center; }

.input-section { overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.input-disclosure > summary { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; cursor: pointer; list-style: none; }
.input-disclosure > summary::-webkit-details-marker { display: none; }
.input-disclosure > summary > span:first-child { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.input-disclosure > summary small { color: var(--muted); font-size: 11px; }
.input-disclosure > summary strong { font-size: 15px; }
.input-disclosure[open] > summary { border-bottom: 1px solid var(--line); }
.input-help { margin: 0; padding: 14px 16px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.section-heading, .page-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.section-heading h2, .page-heading h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -0.025em; }
.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.pill.good, .pill[data-quality="good"] { border-color: color-mix(in srgb, var(--success) 28%, var(--line)); background: var(--success-soft); color: var(--success); }
.pill.bad, .pill[data-quality="poor"] { border-color: color-mix(in srgb, var(--danger) 28%, var(--line)); background: var(--danger-soft); color: var(--danger); }
.pill[data-quality="fair"] { border-color: color-mix(in srgb, var(--warning) 28%, var(--line)); background: var(--warning-soft); color: var(--warning); }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px 16px 16px; }
.mode-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 22px;
  min-height: 82px;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}
.mode-card:hover:not(:disabled) { transform: translateY(-1px); }
.mode-card.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 24%, transparent); }
.mode-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; background: var(--surface-muted); font-size: 21px; }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { margin-bottom: 4px; font-size: 14px; }
.mode-card small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.checkmark { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: transparent; font-size: 11px; }
.mode-card.selected .checkmark { border-color: var(--primary); background: var(--primary); color: white; }
.media-guide { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 16px 16px; padding: 12px 14px; border-radius: 13px; background: var(--warning-soft); color: color-mix(in srgb, var(--warning) 82%, var(--text)); font-size: 12px; }
.step { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; background: var(--warning); color: white; font-size: 10px; font-weight: 850; }

.live-card { padding: clamp(16px, 3vw, 24px); border-radius: var(--radius-lg); }
.live-heading { margin-bottom: 16px; }
.transcript-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.transcript-card { display: flex; min-height: 315px; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-solid); }
.transcript-card > header, .transcript-card > footer { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; }
.transcript-card > header { border-bottom: 1px solid var(--line); }
.transcript-card > footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.transcript-label { display: flex; align-items: center; gap: 9px; }
.transcript-label > span:last-child { display: flex; flex-direction: column; }
.transcript-label small { color: var(--muted); font-size: 10px; }
.transcript-label strong { font-size: 13px; }
.mini-button { min-height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); color: var(--muted); font-size: 11px; font-weight: 750; }
.transcript-body { flex: 1; min-height: 230px; max-height: 48vh; overflow: auto; padding: 16px; scroll-behavior: smooth; }
.translated { background: linear-gradient(150deg, color-mix(in srgb, var(--target-soft) 65%, transparent), transparent 72%); }
.transcript-line { margin: 0 0 14px; color: var(--text); font-size: 17px; line-height: 1.7; letter-spacing: -0.01em; overflow-wrap: anywhere; white-space: pre-wrap; }
.target .transcript-line { font-size: 25px; font-weight: 700; line-height: 1.72; letter-spacing: -0.025em; }
.transcript-line:last-child { margin-bottom: 0; }
.transcript-line.partial::after { display: inline-block; width: 6px; height: 15px; margin-left: 3px; border-radius: 2px; background: var(--primary); content: ""; vertical-align: -2px; animation: blink 0.9s steps(2) infinite; }
.target .transcript-line.partial::after { background: var(--target); }
.transcript-line time { display: block; margin-bottom: 4px; color: var(--faint); font-size: 9px; line-height: 1; }
.empty-copy { display: grid; min-height: 205px; margin: 0; place-items: center; color: var(--faint); font-size: 13px; line-height: 1.5; text-align: center; }
.level-meter { display: flex; height: 20px; align-items: end; gap: 2px; }
.level-meter span { width: 3px; height: 4px; border-radius: 2px; background: var(--faint); transition: height 80ms linear, background 80ms linear; }
.level-meter.active span { background: var(--success); }

.mix-control { margin-top: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); }
.mix-control > div:first-child, .range-labels { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mix-control > div:first-child { margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.mix-control > div:first-child span, .range-labels { color: var(--muted); font-size: 10px; font-weight: 500; }
.mix-control input { width: 100%; accent-color: var(--primary); }
.primary-controls { display: grid; grid-template-columns: minmax(0, 1fr) 54px; gap: 10px; margin-top: 16px; }
.primary-button, .stop-button {
  min-height: 60px;
  border: 0;
  border-radius: 17px;
  font-weight: 850;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 22px; background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: white; box-shadow: 0 12px 28px rgba(49, 94, 234, 0.25); }
.primary-button > span:first-child { font-size: 10px; animation: pulse 1.5s infinite; }
.primary-button:hover:not(:disabled), .stop-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.04); }
.stop-button { background: var(--danger-soft); color: var(--danger); font-size: 18px; }
.secondary-controls { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 9px; }
.text-button { display: inline-flex; min-height: 38px; align-items: center; gap: 6px; padding: 0 12px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.text-button:hover:not(:disabled) { background: var(--surface-muted); color: var(--text); }

.diagnostics { overflow: hidden; border-radius: var(--radius-md); }
.diagnostics summary { padding: 14px 16px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 800; }
.diagnostics[open] summary { border-bottom: 1px solid var(--line); }
.diagnostics dl, .service-card dl { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; margin: 0; background: var(--line); }
.diagnostics dl div, .service-card dl div { min-width: 0; padding: 12px; background: var(--surface-solid); }
.diagnostics dt, .service-card dt { color: var(--muted); font-size: 9px; }
.diagnostics dd, .service-card dd { overflow: hidden; margin: 4px 0 0; font-size: 11px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.diagnostic-log { max-height: 190px; margin: 0; overflow: auto; padding: 14px; background: #0b1020; color: #b9f6d4; font: 10px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }

.page-heading { margin-bottom: 16px; }
.danger-link { min-height: 36px; padding: 0 10px; border: 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 800; }
.history-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.search-box { display: flex; min-height: 44px; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-solid); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.outline-button, .danger-outline { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-solid); color: var(--text); font-size: 12px; font-weight: 800; }
.outline-button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.danger-outline { border-color: color-mix(in srgb, var(--danger) 42%, var(--line)); color: var(--danger); }
.full { width: 100%; }
.history-summary { margin: 13px 2px; color: var(--muted); font-size: 12px; }
.history-list { display: grid; gap: 12px; }
.history-item { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.history-item summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 15px; cursor: pointer; list-style: none; }
.history-item summary::-webkit-details-marker { display: none; }
.history-direction { display: grid; width: 48px; height: 45px; place-items: center; border-radius: 14px; background: var(--primary-soft); font-size: 16px; }
.history-item-title { min-width: 0; }
.history-item-title strong, .history-item-title small { display: block; }
.history-item-title strong { overflow: hidden; margin-bottom: 4px; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.history-item-title small { color: var(--muted); font-size: 10px; }
.history-chevron { color: var(--muted); transition: transform 150ms ease; }
.history-item[open] .history-chevron { transform: rotate(180deg); }
.history-detail { padding: 14px; border-top: 1px solid var(--line); }
.history-turn { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.history-turn:last-of-type { border-bottom: 0; }
.history-turn p { margin: 0; font-size: 12px; line-height: 1.55; white-space: pre-wrap; }
.history-turn p:first-child { color: var(--muted); }
.history-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 10px; }
.empty-state { display: grid; min-height: 340px; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.empty-state > span { font-size: 44px; }
.empty-state h3 { margin: 12px 0 6px; color: var(--text); font-size: 17px; }
.empty-state p { margin: 0; font-size: 12px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-card { overflow: hidden; border-radius: var(--radius-md); }
.settings-card.wide { grid-column: 1 / -1; }
.settings-card h3 { margin: 0; padding: 15px 16px 10px; font-size: 14px; }
.setting-row, .select-row { display: flex; min-height: 67px; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-top: 1px solid var(--line); }
.setting-row > span, .select-row > span { min-width: 0; }
.setting-row strong, .setting-row small, .select-row strong, .select-row small { display: block; }
.setting-row strong, .select-row strong { margin-bottom: 3px; font-size: 12px; }
.setting-row small, .select-row small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.setting-row input[type="checkbox"] { position: relative; width: 42px; height: 24px; flex: 0 0 auto; appearance: none; border-radius: 999px; background: var(--line); transition: background 140ms ease; }
.setting-row input[type="checkbox"]::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18); content: ""; transition: transform 140ms ease; }
.setting-row input[type="checkbox"]:checked { background: var(--primary); }
.setting-row input[type="checkbox"]:checked::after { transform: translateX(18px); }
.select-row select { max-width: 210px; min-height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-muted); color: var(--text); padding: 0 10px; }
.select-row.stacked { align-items: flex-start; flex-direction: column; gap: 8px; }
.select-row.stacked select { width: 100%; max-width: none; }
.settings-card > .outline-button, .settings-card > .danger-outline { width: calc(100% - 32px); margin: 0 16px 16px; }
.service-card dl { grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.privacy-card p { margin: 0; padding: 4px 16px 16px; color: var(--muted); font-size: 11px; line-height: 1.65; }

.bottom-nav {
  position: fixed;
  z-index: 60;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 150px));
  justify-content: center;
  min-height: calc(68px + var(--safe-bottom));
  padding: 7px 16px var(--safe-bottom);
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}
.nav-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 800; }
.nav-button > span:first-child { font-size: 19px; filter: grayscale(0.35); }
.nav-button.active { background: var(--primary-soft); color: var(--primary); }
.nav-button.active > span:first-child { filter: none; }

.onboarding-dialog { width: min(calc(100% - 28px), 480px); padding: 0; border: 0; border-radius: 28px; background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-md); }
.onboarding-dialog::backdrop { background: rgba(5, 10, 24, 0.58); backdrop-filter: blur(4px); }
.onboarding-dialog form { padding: 26px; text-align: center; }
.onboarding-dialog img { border-radius: 22px; box-shadow: 0 12px 30px rgba(49, 94, 234, 0.23); }
.onboarding-dialog h2 { margin: 7px 0 18px; font-size: 23px; }
.onboarding-dialog ol { display: grid; gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; text-align: left; }
.onboarding-dialog li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; padding: 10px; border-radius: 13px; background: var(--surface-muted); }
.onboarding-dialog li > span { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--primary); color: white; font-size: 11px; font-weight: 900; }
.onboarding-dialog li strong { font-size: 12px; }
.onboarding-dialog li p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.onboarding-dialog .primary-button { width: 100%; }
.dialog-check { display: inline-flex; align-items: center; gap: 6px; margin-top: 13px; color: var(--muted); font-size: 11px; }

.toast { position: fixed; z-index: 100; right: 16px; bottom: calc(83px + var(--safe-bottom)); max-width: min(360px, calc(100% - 32px)); padding: 12px 15px; transform: translateY(20px); border: 1px solid var(--line); border-radius: 13px; background: var(--surface-solid); box-shadow: var(--shadow-md); font-size: 12px; line-height: 1.45; opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: color-mix(in srgb, var(--danger) 38%, var(--line)); background: var(--danger-soft); color: var(--danger); }
.toast.success { border-color: color-mix(in srgb, var(--success) 38%, var(--line)); background: var(--success-soft); color: var(--success); }

.offline-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.offline-card { width: min(100%, 440px); padding: 32px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-solid); box-shadow: var(--shadow-md); text-align: center; }
.offline-card img { border-radius: 24px; }
.offline-card h1 { margin: 16px 0 8px; font-size: 22px; }
.offline-card p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.link-button { text-decoration: none; }

:root.large-text .transcript-line { font-size: 21px; line-height: 1.75; }
:root.large-text .target .transcript-line { font-size: 30px; line-height: 1.72; }
:root.large-text .transcript-body { min-height: 270px; }
body.session-active .swap-button,
body.session-active .language-button,
body.session-active .mode-card { pointer-events: none; opacity: 0.62; }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.56; transform: scale(0.86); } }
@keyframes blink { 0%, 45% { opacity: 1; } 46%, 100% { opacity: 0; } }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

@media (max-width: 760px) {
  .topbar-inner { width: calc(100% - 24px); }
  .main-content { width: calc(100% - 24px); padding-top: 16px; }
  .status-badge { padding: 0 9px; }
  .status-badge span:last-child { max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
  .direction-card { grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr); gap: 6px; padding: 14px; }
  .language-button { min-height: 66px; gap: 7px; padding: 10px 9px; }
  .flag { font-size: 24px; }
  .swap-button { width: 36px; height: 36px; border-radius: 12px; font-size: 20px; }
  .mode-grid { grid-template-columns: 1fr; gap: 8px; }
  .mode-card { min-height: 70px; }
  .transcript-grid { grid-template-columns: 1fr; }
  .transcript-card { min-height: 220px; }
  .transcript-card.target { min-height: 300px; }
  .transcript-body { min-height: 145px; max-height: 38vh; }
  .target .transcript-body { min-height: 225px; max-height: 46vh; }
  .empty-copy { min-height: 150px; }
  .target .empty-copy { min-height: 205px; font-size: 15px; }
  .primary-controls { position: static; margin: 16px 0 0; padding: 8px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface-solid); box-shadow: var(--shadow-md); }
  .primary-button, .stop-button { min-height: 62px; }
  .diagnostics dl { grid-template-columns: 1fr 1fr; }
  .diagnostics dl div:last-child { grid-column: 1 / -1; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-card.wide { grid-column: auto; }
  .history-turn { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .brand-icon { width: 39px; height: 39px; border-radius: 12px; }
  .brand h1 { font-size: 16px; }
  .eyebrow { font-size: 9px; }
  #installButton { display: none !important; }
  .language-copy small { display: none; }
  .language-button { justify-content: center; text-align: center; }
  .language-copy strong { font-size: 14px; }
  .direction-summary { font-size: 11px; }
  .history-toolbar { grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: 1 / -1; }
}

@media (min-width: 1100px) {
  .app-shell { padding-bottom: 30px; }
  .bottom-nav { position: static; width: 430px; min-height: 62px; margin: 18px auto 0; padding: 7px; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-md); }
  .toast { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
