:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #d5dce4;
    --accent: #1d4e6f;
    --accent-hover: #163d57;
    --live: #b4322c;
    --live-soft: #fbeceb;
    --ok: #2f6f4f;
    --error: #a2341f;
    --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.page {
    max-width: 760px;
    margin: 0 auto;
    padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
}

.top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.tab {
    font: inherit; font-weight: 600;
    padding: 8px 16px;
    color: var(--muted); background: none;
    border: 1px solid transparent; border-bottom: 0;
    border-radius: 6px 6px 0 0;
    margin-bottom: -1px;
    cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--accent); background: var(--surface); border-color: var(--border); }
.tab-info { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; }

.interim {
    margin: 0 0 16px; padding: 10px 14px;
    font-size: 1.1rem; color: var(--muted); font-style: italic;
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

.top h1 { font-size: 1.5rem; margin: 0; }
.tag {
    font-size: 0.75rem; color: var(--muted);
    border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px;
}

/* Talk button: big touch target; suppress iPad long-press selection and callout. */
.talk { text-align: center; margin-bottom: 20px; }
.talk-button {
    width: 100%;
    min-height: 120px;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    font: inherit; font-size: 1.25rem; font-weight: 600;
    color: #fff; background: var(--accent);
    border: 0; border-radius: var(--radius);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.talk-button:hover { background: var(--accent-hover); }
.talk-button:focus-visible { outline: 3px solid #7fa7c4; outline-offset: 3px; }
.talk-button[data-state="live"],
.talk-button[data-state="locked"] { background: var(--live); }
.talk-button[data-state="locked"] { box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.55); }
.talk-button[data-state="starting"] { opacity: 0.7; }
.talk-button:disabled { background: var(--muted); cursor: not-allowed; }
.talk-icon { display: inline-flex; }

.hint { color: var(--muted); font-size: 0.9rem; margin: 10px 0; }

.meter { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
#meter-bar { height: 100%; width: 0; background: var(--live); transition: width 60ms linear; }

.status { min-height: 1.5em; margin: 10px 0 0; font-size: 0.95rem; color: var(--muted); }
.status.error { color: var(--error); }
.status.ok { color: var(--ok); }

.output { margin-bottom: 16px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.toolbar label { font-weight: 600; }
.spacer { flex: 1; }

textarea, select {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}
#text { font-size: 1.1rem; min-height: 240px; resize: vertical; }
textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button.small {
    font: inherit; font-size: 0.9rem;
    padding: 6px 12px;
    color: var(--accent); background: var(--surface);
    border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer;
}
button.small:hover { border-color: var(--accent); }
button.small.quiet { color: var(--muted); }
button.small:disabled { opacity: 0.5; cursor: default; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 12px;
}
.panel summary { cursor: pointer; font-weight: 600; }
.panel[open] summary { margin-bottom: 12px; }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.settings .check, .settings .wide { grid-column: 1 / -1; }
.settings .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.settings .check input { width: 20px; height: 20px; }

#raw { font-size: 0.95rem; color: var(--muted); }
.log { margin: 10px 0 0; padding-left: 20px; font-size: 0.85rem; color: var(--muted); }

@media (max-width: 560px) {
    .settings { grid-template-columns: 1fr; }
    .talk-button { min-height: 100px; }
}
