:root {
  color-scheme: light;
  --bg: #f5f5f3;
  --surface: #ffffff;
  --text: #171717;
  --muted: #6b6b68;
  --line: #deded9;
  --line-strong: #c7c7c1;
  --soft: #eeeeea;
  --ok: #277a47;
  --danger: #a13d36;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden, .system-only { display: none !important; }

.shell { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 64px; }
.topbar { height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 750; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--text); border-radius: 8px; font-size: 11px; font-weight: 800; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #9a9a95; }
.status.online .dot { background: var(--ok); }
.status.connecting .dot { background: #9b7a31; }
.status.offline .dot { background: #8b8b86; }

.join-panel { min-height: calc(100vh - 150px); display: grid; place-items: center; padding: 48px 0; }
.join-card { width: min(460px, 100%); }
h1, h2, p { margin-top: 0; }
.join-card h1 { margin-bottom: 8px; font-size: clamp(28px, 5vw, 38px); letter-spacing: -0.035em; line-height: 1.1; }
.lead { margin-bottom: 30px; color: var(--muted); line-height: 1.55; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 7px; color: #3e3e3b; font-size: 13px; font-weight: 650; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; outline: none; }
input:focus, select:focus { border-color: #777772; box-shadow: 0 0 0 2px rgba(23,23,23,.08); }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
button { min-height: 40px; padding: 9px 13px; border: 1px solid transparent; border-radius: 8px; font-weight: 700; }
.primary { background: #171717; color: #fff; }
.primary:hover { background: #2b2b2b; }
.primary:disabled { opacity: .5; cursor: not-allowed; }
.primary.compact { min-width: 150px; }
.secondary { color: var(--text); background: var(--surface); border-color: var(--line-strong); }
.secondary:hover { background: #f3f3f0; }
.square { width: 44px; padding: 0; }
.quiet-danger { color: var(--danger); background: transparent; border-color: transparent; }
.quiet-danger:hover { background: #f7ecea; }
.hint { margin: -4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.troubleshoot { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.troubleshoot summary, .audio-settings summary { cursor: pointer; color: var(--muted); font-size: 12px; user-select: none; }
.troubleshoot[open] summary, .audio-settings[open] summary { margin-bottom: 12px; }

.meeting { display: flex; flex-direction: column; gap: 14px; padding-top: 20px; }
.meeting-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0 4px; }
.room-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.room-row h1 { margin: 0; font-size: 26px; letter-spacing: -0.025em; }
.muted { color: var(--muted); font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }

.mic-bar { padding: 15px 16px 13px; }
.mic-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
#micState { font-size: 16px; }
.level-wrap { height: 5px; margin-top: 13px; overflow: hidden; border-radius: 999px; background: var(--soft); }
.level-bar { width: 0%; height: 100%; background: #555552; transition: width 70ms linear; }
.audio-settings { margin-top: 11px; }
.settings-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; padding-top: 2px; }

.transcript-section { min-width: 0; }
.transcript-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 12px; }
.segmented { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.view-button { min-height: 34px; padding: 6px 10px; color: var(--muted); background: transparent; border-radius: 6px; font-size: 12px; }
.view-button.active { color: var(--text); background: var(--surface); border-color: var(--line); }
.toolbar-actions { display: flex; align-items: center; gap: 7px; }
.search { width: min(220px, 28vw); min-height: 40px; }
.toolbar-actions button { min-height: 40px; font-size: 12px; }

.processing-strip { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.processing-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; }
.spinner { width: 10px; height: 10px; border: 2px solid #d2d2cd; border-top-color: #555552; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { padding: 70px 24px; text-align: center; }
.empty-state h2 { margin-bottom: 6px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.transcript-window {
  min-height: 320px;
  max-height: min(58vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 4px;
}
.transcript { display: flex; flex-direction: column; gap: 8px; }
.item { padding: 15px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.meta-left { display: flex; align-items: center; gap: 7px; }
.meta-left strong { color: #30302e; font-size: 12px; }
.lang { padding: 2px 6px; color: #555552; background: var(--soft); border-radius: 999px; font-size: 10px; font-weight: 750; }
.original { color: var(--text); font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; word-break: break-word; }
.translation { margin-top: 7px; color: #656560; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; word-break: break-word; }
.sentence-line { display: block; }
.sentence-line + .sentence-line { margin-top: 3px; }
.item[data-view="original"] .translation { display: none; }
.item[data-view="translation"] .original { display: none; }
.item.filtered { display: none; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 20; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px)); }
.toast { padding: 10px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.09); font-size: 12px; }
.toast.error { border-color: #d5a8a4; }

@media (max-width: 700px) {
  .shell { width: min(100% - 22px, 960px); padding-top: 12px; }
  .topbar { height: 48px; }
  .join-panel { padding: 30px 0; align-items: start; }
  .meeting-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1; }
  .mic-main { align-items: flex-start; }
  .primary.compact { min-width: 0; }
  .settings-grid { grid-template-columns: 1fr; }
  .transcript-toolbar { align-items: stretch; flex-direction: column; }
  .segmented { width: 100%; }
  .view-button { flex: 1; }
  .toolbar-actions { flex-wrap: wrap; }
  .search { width: 100%; flex-basis: 100%; }
  .toolbar-actions button { flex: 1; }
  .transcript-window { min-height: 300px; max-height: 56vh; }
}
