/* Akarika ASR. Brand: electric blue + amber orange on deep navy (from the Akarika logo). */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --border: #dfe5f0;
  --text: #0d1426;
  --muted: #5a6479;
  --blue: #1f6fff;
  --blue-strong: #1559d6;
  --orange: #f07c12;
  --on-accent: #ffffff;
  --danger: #d93b3b;
  --ok: #12a150;
  --focus: rgb(31 111 255 / 0.35);
  --shadow: 0 1px 2px rgb(13 20 38 / 0.05), 0 8px 24px rgb(13 20 38 / 0.06);
  --radius: 14px;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #060a14;
  --surface: #0c1222;
  --surface-2: #121a2e;
  --border: #1d2741;
  --text: #e7ecf7;
  --muted: #8d97af;
  --blue: #4a8dff;
  --blue-strong: #6aa2ff;
  --orange: #ff9a3c;
  --on-accent: #ffffff;
  --danger: #ff6b6b;
  --ok: #3ddc84;
  --focus: rgb(74 141 255 / 0.45);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", Inter, system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .2s ease, color .2s ease;
}
[hidden] { display: none !important; }
a { color: var(--blue); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark { border-radius: 10px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 19px; font-weight: 600; letter-spacing: .02em; }
.brand-name b {
  font-weight: 700;
  background: linear-gradient(90deg, var(--blue), var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok .dot { background: var(--ok); }
.pill.bad .dot { background: var(--danger); }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer;
}
.icon-btn:hover { border-color: var(--blue); }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
  gap: 24px;
  padding: 24px 28px;
  max-width: 1320px; width: 100%; margin: 0 auto;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  min-width: 0;
}
.panel-title { font-size: 22px; line-height: 1.25; margin: 0 0 6px; font-weight: 650; }
.panel-title.small { font-size: 17px; margin: 0; }
.lede { margin: 0 0 20px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; min-width: 0; }
.field select { width: 100%; text-overflow: ellipsis; }
.settings { grid-template-columns: 1.35fr 1fr; }
select {
  appearance: none;
  padding: 10px 34px 10px 12px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%238d97af' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); font-size: 14px; cursor: pointer; min-width: 0;
}
select:hover { border-color: var(--blue); }
select option:disabled { color: var(--muted); }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  margin: 22px 0 16px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.tab {
  border: 0; background: transparent; padding: 9px; border-radius: 9px;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- upload ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 34px 16px; border: 2px dashed var(--border); border-radius: 12px;
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: var(--surface-2); color: var(--text); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dz-main { font-weight: 600; color: var(--text); }
.dz-main u { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.dz-sub { font-size: 12px; }
.sample-line { margin-top: 10px; text-align: center; }
.linklike { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 10px 18px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--blue); color: var(--on-accent); }
.btn.primary:hover { background: var(--blue-strong); }
.btn.primary:disabled { opacity: .55; cursor: progress; }
.btn.ghost { background: var(--surface-2); border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { border-color: var(--blue); }
.btn.ghost:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
#retranscribe-btn { width: 100%; margin-top: 14px; }

/* ---------- live ---------- */
.live-box { display: flex; align-items: center; gap: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.rec-btn {
  flex: none; width: 76px; height: 76px; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-items: center;
  background: conic-gradient(from 200deg, var(--blue), var(--orange), var(--blue));
  padding: 4px;
}
.rec-core { width: 100%; height: 100%; border-radius: 50%; background: var(--surface); display: grid; place-items: center; position: relative; }
.rec-core::after { content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--danger); transition: border-radius .15s, transform .15s; }
.rec-btn.on .rec-core::after { border-radius: 6px; transform: scale(.85); }
.rec-btn.on { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgb(240 124 18 / .35); } 50% { box-shadow: 0 0 0 12px rgb(240 124 18 / 0); } }
.live-meta { flex: 1; min-width: 0; }
.live-time { font: 600 26px/1 var(--mono); letter-spacing: .04em; }
.meter { height: 6px; border-radius: 3px; background: var(--border); margin: 10px 0 4px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--orange)); transition: width .08s linear; }

#player { width: 100%; margin-top: 18px; }

/* ---------- output ---------- */
.output-panel { display: flex; flex-direction: column; min-height: 520px; }
.out-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.export { display: flex; gap: 6px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; margin-right: 4px; }
.switch input { accent-color: var(--blue); width: 16px; height: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0 0; }
.stats div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.stats dt { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 14px; }
.progress-bar { height: 100%; width: 30%; background: linear-gradient(90deg, var(--blue), var(--orange)); animation: slide 1.2s ease-in-out infinite; }
.progress.det .progress-bar { animation: none; transition: width .3s; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

.transcript { flex: 1; margin-top: 16px; overflow-y: auto; max-height: calc(100vh - 290px); min-height: 300px; padding-right: 4px; }
.empty { height: 100%; min-height: 300px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty p { margin: 4px 0; }
.seg { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 8px 10px; border-radius: 8px; }
.seg:hover { background: var(--surface-2); }
.seg .ts {
  font: 12px/1.9 var(--mono); color: var(--blue); background: none; border: 0; padding: 0;
  text-align: left; cursor: pointer; align-self: start;
}
.seg .ts:disabled { cursor: default; color: var(--muted); }
.seg .tx { font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.seg.partial .tx { color: var(--muted); font-style: italic; }
.seg.active { background: color-mix(in srgb, var(--blue) 10%, transparent); }
.no-ts .seg { grid-template-columns: 1fr; }
.no-ts .seg .ts { display: none; }

.footer { padding: 16px 28px 22px; text-align: center; color: var(--muted); font-size: 12.5px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 20; max-width: calc(100vw - 32px);
}
.toast.err { background: var(--danger); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .topbar { padding: 12px 16px; }
  .transcript { max-height: none; }
}
@media (max-width: 480px) {
  .settings { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .brand-sub, #status-text { display: none; }
  .seg { grid-template-columns: 1fr; gap: 0; }
  .live-box { flex-direction: column; text-align: center; }
  .live-meta { width: 100%; }
  .export .btn.sm { padding: 6px 8px; }
}

/* ---------------------------------------------------------------- sign-in */
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip img { border-radius: 50%; display: block; }
.user-name { font-size: 13px; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-screen {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: var(--bg);
}
.auth-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 24px;
}
.auth-logo { align-self: center; border-radius: 12px; }
.auth-title { margin: 4px 0 0; font-size: 20px; text-align: center; }
.auth-sub { margin: 0 0 6px; text-align: center; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.google-btn:hover { border-color: var(--blue); }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-card .field input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit;
}
.auth-card .field input:focus { outline: 3px solid var(--focus); border-color: var(--blue); }
.auth-error { margin: 0; color: var(--danger); font-size: 13px; }
.auth-links { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 0; }
@media (max-width: 480px) { .user-name { display: none; } }
