:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #17201d;
  --muted: #5d6b66;
  --line: #dde3e0;
  --accent: #0f5c4d;
  --accent-ink: #ffffff;
  --accent-soft: #e2efeb;
  --warn: #9a5b00;
  --warn-soft: #fff3df;
  --bad: #a3271f;
  --ok: #1d7a43;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1413; --surface: #182120; --text: #e7eeeb; --muted: #9aa9a4; --line: #2a3533;
    --accent: #4cc2a5; --accent-ink: #062a22; --accent-soft: #173a33;
    --warn: #f0b45a; --warn-soft: #3a2b12; --bad: #ff8a80; --ok: #6fd69a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1413; --surface: #182120; --text: #e7eeeb; --muted: #9aa9a4; --line: #2a3533;
  --accent: #4cc2a5; --accent-ink: #062a22; --accent-soft: #173a33;
  --warn: #f0b45a; --warn-soft: #3a2b12; --bad: #ff8a80; --ok: #6fd69a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.status {
  display: inline-flex; align-items: center; gap: 6px; max-width: 60vw;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 4px 10px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status[data-state="ready"] .dot { background: var(--ok); }
.status[data-state="downloading"] .dot, .status[data-state="loading"] .dot { background: var(--warn); }
.status[data-state="error"] .dot { background: var(--bad); }

.banner { margin: 10px 16px 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--text); font-size: 14px; }

main { max-width: 720px; margin: 0 auto; padding: 12px 16px; }
.panel h2 { font-size: 17px; margin: 18px 0 8px; }
.card .h2, .card h2 { margin-top: 0; }

.dir { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 10px; }
.lang { text-align: center; font-weight: 650; padding: 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.swap { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--accent); color: var(--accent-ink); font-size: 20px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
textarea {
  width: 100%; border: 0; outline: none; resize: vertical; background: transparent; color: var(--text);
  font: inherit; font-size: 18px; min-height: 96px;
}
.out { font-size: 20px; min-height: 60px; white-space: pre-wrap; word-wrap: break-word; }
.out.placeholder { color: var(--muted); font-size: 16px; }
.note { font-size: 14px; color: var(--muted); margin-top: 6px; }
.row { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.grow { flex: 1; }
.icon-btn { min-width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; font-size: 20px; }
.icon-btn:active { background: var(--accent-soft); }
.icon-btn.on { background: var(--accent-soft); }
.icon-btn.listening { background: var(--bad); color: #fff; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.search { width: 100%; padding: 12px; font-size: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chips button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px 10px 12px; margin-bottom: 8px; }
.pair { display: flex; align-items: center; gap: 4px; }
.pair .txt { flex: 1; min-width: 0; }
.pair .tag { font-size: 11px; font-weight: 700; color: var(--muted); width: 22px; flex: none; }
.pair + .pair { margin-top: 2px; }
.pair .icon-btn { min-width: 38px; height: 38px; font-size: 17px; }
.list .note { margin: 2px 0 0 26px; }

.detail { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 10px; font-size: 14px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 12px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.primary { border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); padding: 12px 16px; font-weight: 650; width: 100%; }
.primary:disabled { opacity: .5; }
.link-btn { border: 0; background: none; color: var(--accent); padding: 8px 0; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { border: 0; background: none; padding: 8px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); }
.tabs button span { font-size: 19px; line-height: 1; }
.tabs button b { font-size: 12px; font-weight: 600; }
.tabs button[aria-current="page"] { color: var(--accent); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10; max-width: calc(100vw - 32px);
}
