/* Ttext — local text-based audio editor */
:root {
  --bg: #101216;
  --bg-2: #16191f;
  --bg-3: #1e232b;
  --line: #262c36;
  --line-2: #364050;
  --text: #e8ebf0;
  --text-2: #9aa4b2;
  --text-3: #67707e;
  --accent: #4f9cf9;
  --accent-2: #7c5cff;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f66;
  --sel: rgba(79, 156, 249, 0.30);
  --page: #171b22;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 28px rgba(0,0,0,.28);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f3f6; --bg-2: #fafbfc; --bg-3: #eceef2;
    --line: #e1e4ea; --line-2: #c9cfd9;
    --text: #191d24; --text-2: #57606e; --text-3: #8b95a3;
    --sel: rgba(79, 156, 249, 0.22);
    --page: #ffffff;
    --shadow: 0 1px 2px rgba(20,30,50,.08), 0 8px 28px rgba(20,30,50,.10);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  font-size: 15px; -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 6px 12px; border-radius: 9px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .05s;
}
button:active:not(:disabled) { transform: translateY(1px); }
button:hover:not(:disabled) { background: var(--line); border-color: var(--line-2); }
button:disabled { opacity: .38; cursor: default; }
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
}
button.primary:hover:not(:disabled) { filter: brightness(1.1); }
button.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
button.ghost:hover:not(:disabled) { background: var(--bg-3); color: var(--text); }
button.recording { border-color: var(--bad); color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  font-variant-numeric: tabular-nums; }
.iconbtn { display: inline-flex; align-items: center; gap: 6px; }
.iconbtn svg { width: 14px; height: 14px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.iconbtn.round { padding: 7px; border-radius: 50%; }
.iconbtn.round svg { width: 13px; height: 13px; }
.tgroup { display: inline-flex; gap: 2px; background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 11px; padding: 2px; }
.tgroup button { border: none; background: transparent; border-radius: 8px; }
.tgroup button:hover:not(:disabled) { background: var(--line); }
/* Style EVERY text-ish input. Enumerating types once left email and password
   unstyled - light text on the browser's default light background, i.e.
   invisible. Never enumerate input types again. */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
textarea, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 6px 10px;
  -webkit-text-fill-color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
select { background: var(--bg-3); cursor: pointer; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
/* Chrome/Safari paint autofilled fields with their own near-white background */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-3) inset;
  caret-color: var(--text);
}

/* ---------------------------------------------------------------- layout */
#app { display: grid; grid-template-columns: 250px 1fr; height: 100vh; }
aside {
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.brand { padding: 16px 16px 12px; display: flex; align-items: center; gap: 9px; }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: -.01em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.dot { width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.brand small { color: var(--text-3); font-size: 11px; margin-left: auto; }
.side-actions { padding: 0 12px 12px; display: flex; gap: 6px; }
.side-actions button { flex: 1; font-size: 13px; padding: 7px 4px; }
.side-head { padding: 6px 16px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); }
#projects { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.proj {
  padding: 8px 10px; border-radius: 9px; cursor: pointer; margin-bottom: 2px;
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid transparent;
}
.proj:hover { background: var(--bg-3); }
.proj.active {
  background: linear-gradient(120deg, var(--sel), color-mix(in srgb, var(--accent-2) 16%, transparent));
  border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.proj .n { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj .m { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.side-foot { flex-shrink: 0; padding: 10px 16px 12px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--text-3); line-height: 1.5; }

main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
header {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--bg-2); flex-wrap: wrap;
  flex-shrink: 0;
}
#title { background: transparent; border: 1px solid transparent; font-size: 15px;
  font-weight: 600; min-width: 120px; max-width: 280px; }
#title:hover { border-color: var(--line); }
.stat { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.stat b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.toolbar > button, .toolbar .tgroup button { font-size: 13px; padding: 5px 10px; }
#search { flex: 1; min-width: 160px; max-width: 420px; }
#search { width: 180px; }
.chip { font-size: 11px; color: var(--text-3); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px;
  display: inline-flex; align-items: center; gap: 5px; }

/* ------------------------------------------------------------- transcript */
#stage { flex: 1; overflow-y: auto; padding: 24px 24px 48px; min-height: 0;
  background:
    radial-gradient(900px 420px at 75% -8%, color-mix(in srgb, var(--accent-2) 9%, transparent), transparent 70%),
    radial-gradient(700px 380px at 12% 108%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%);
}
#transcript {
  max-width: 840px; margin: 0 auto; padding: 40px 56px 56px;
  background: var(--page); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 18px; line-height: 2.0; letter-spacing: -.003em;
  user-select: none; -webkit-user-select: none; min-height: 300px;
}
#transcript p { margin: 0 0 20px; }
.w { border-radius: 4px; padding: 2px 1px; cursor: text; transition: background .08s; }
.w:hover { background: var(--bg-3); }
.w.sel { background: var(--sel); }
.w.cut { color: var(--text-3); text-decoration: line-through;
  text-decoration-color: var(--bad); opacity: .55; }
.w.now { background: var(--accent); color: #fff; }
.w.now.cut { background: transparent; color: var(--text-3); }
.w.lowconf { border-bottom: 2px dotted var(--warn); }
.w.hit { box-shadow: inset 0 0 0 1px var(--warn); }
.w.take { color: var(--good); }
#transcript.hide-cut .w.cut { display: none; }
.para-take { border-left: 2px solid var(--good); padding-left: 12px; }
.empty { text-align: center; color: var(--text-3); padding: 60px 20px; }
.empty h2 { color: var(--text-2); font-weight: 600; font-size: 17px; }
.empty .drop { border: 2px dashed var(--line-2); border-radius: 14px;
  padding: 40px; max-width: 460px; margin: 20px auto; transition: .15s; }
.empty .drop.over { border-color: var(--accent); background: var(--sel); }
.progress { max-width: 420px; margin: 24px auto; }
.bar { height: 6px; background: var(--bg-3); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg,var(--accent),var(--accent-2));
  transition: width .3s; }

/* --------------------------------------------------------- recording view */
/* ------------------------------------------------------- overflow menu */
/* The toolbar carried eleven controls at once. Everything occasional moved
   here, where there is room to say what each one actually does. */
.menu { position: fixed; z-index: 60; min-width: 280px; padding: 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 44px rgba(0,0,0,.45); }
.menu .mi { display: block; width: 100%; text-align: left; border: none;
  background: transparent; padding: 9px 11px; border-radius: 8px; cursor: pointer; }
.menu .mi:hover:not(:disabled) { background: var(--bg-3); }
.menu .mi:disabled { opacity: .38; cursor: default; }
.menu .mi-t { display: block; font-size: 13.5px; color: var(--text); }
.menu .mi-d { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.menu .mi-sep { height: 1px; background: var(--line); margin: 6px 8px; }

/* ------------------------------------------------------ microphone picker */
.side-mic { padding: 0 12px 10px; }
.side-mic-l { display: block; font-size: 10.5px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 5px; }
.side-mic select.micpick { width: 100%; max-width: none; font-size: 12px; padding: 5px 7px; }
select.micpick { max-width: 320px; }
.microw { display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 22px auto 0; }
.microw-l { font-size: 12.5px; color: var(--text-3); }
.recbar .recmic { font-size: 11.5px; color: var(--text-3); flex-shrink: 0;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

body.recording #transcript { padding: 0; display: flex; min-height: 440px; }
body.recording #transcript > .recscreen { flex: 1; min-width: 0; }

/* While recording, the transcript IS the screen - the clock and meter shrink
   to a strip on top so the words get the room. */
.recscreen { display: flex; flex-direction: column; height: 100%; padding: 0; }
.recbar { display: flex; align-items: center; gap: 14px; flex-shrink: 0;
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--bg-2);
  border-radius: 10px 10px 0 0; }
.recbar .rec-dot-lg { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 35% 30%, #ff9d9d, var(--bad) 65%);
  box-shadow: 0 0 14px color-mix(in srgb, var(--bad) 55%, transparent);
  animation: pulse 1s infinite; }
.recbar .clock { font-size: 20px; font-weight: 700; letter-spacing: .02em;
  font-variant-numeric: tabular-nums; flex-shrink: 0; }
.recbar .levelwrap { flex: 1; margin: 0; max-width: none; }
.recbar .stopbig { font-size: 14px; padding: 8px 18px; flex-shrink: 0; }

.livescript { flex: 1; overflow-y: auto; padding: 26px 30px; min-height: 0;
  font-size: 17px; line-height: 1.85; }
.livescript .liveline { margin: 0; }
/* Settled words read as final; the tail is still being revised, so it is
   visibly lighter rather than silently rewriting itself under the reader. */
.livescript .w { cursor: default; }
.livescript .w.prov { color: var(--text-3); }
.draftbox { text-align: left; margin: 22px auto 0; max-width: 640px; padding: 16px 18px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; line-height: 1.8; max-height: 260px; overflow-y: auto; }
.draftacts { margin-top: 12px; text-align: center; }
.draftlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); margin-bottom: 8px; }
.draftbox .liveline { margin: 0; color: var(--text-2); }
.live-hint { color: var(--text-3); font-size: 14px; text-align: center; padding: 30px 0; }
.recscreen .hint { flex-shrink: 0; padding: 10px 18px 14px; text-align: center; }

.levelwrap { max-width: 340px; height: 8px; margin: 26px auto 0;
  background: var(--bg-3); border-radius: 6px; overflow: hidden; }
.levelwrap i { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--good), var(--warn) 75%, var(--bad));
  transition: width .08s linear; }

/* --------------------------------------------------------------- transport */
/* flex-shrink:0 is load-bearing: without it a wrapped toolbar pushed the
   transport bar (play/record) off the bottom of the window entirely. */
footer { border-top: 1px solid var(--line); background: var(--bg-2);
         padding: 8px 16px 10px; flex-shrink: 0; }
#overview { width: 100%; height: 26px; display: block; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px 8px 0 0; border-bottom: none; }
#wave { width: 100%; height: 72px; display: block; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.transport { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.time { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-2); }
#play { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 16px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 45%, transparent); }
#play:hover:not(:disabled) { filter: brightness(1.1); }
#speed { font-size: 12.5px; padding: 4px 6px; font-variant-numeric: tabular-nums; }
.tgroup.zoom button { min-width: 30px; font-variant-numeric: tabular-nums; }
.rec-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bad); animation: pulse 1s infinite; vertical-align: middle;
  margin-right: 5px; }
body.recording header { box-shadow: inset 0 2px 0 var(--bad); }
@keyframes pulse { 50% { opacity: .25; } }

/* ------------------------------------------------------------------ panels */
.panel {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid;
  place-items: center; z-index: 50;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.panel .card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px;
  width: min(560px, 92vw); max-height: 84vh; overflow-y: auto; padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card p.sub { margin: 0 0 16px; color: var(--text-2); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.row label { flex: 1; font-size: 13.5px; }
.row .val { font-variant-numeric: tabular-nums; color: var(--text-2);
  font-size: 12px; width: 52px; text-align: right; }
input[type=range] { flex: 1.2; accent-color: var(--accent); }
.card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.6; }
.fillers { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.fillers label { display: flex; align-items: center; gap: 5px; font-size: 12.5px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 20px;
  padding: 3px 10px; cursor: pointer; }
kbd { background: var(--bg-3); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 5px; font-size: 11px; font-family: var(--font); }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 16px; font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: .2s; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--bad); color: var(--bad); }


/* ---------------------------------------------------- the front door ---- */
.empty.start { padding: 44px 20px 60px; }
.empty.start h2 { font-size: 25px; color: var(--text); letter-spacing: -.02em; margin-bottom: 8px; }
.empty.start .lead { color: var(--text-2); font-size: 15px; margin: 0 auto 30px; max-width: 440px; }

.choices { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
           max-width: 640px; margin: 0 auto; }
.choice {
  flex: 1 1 250px; max-width: 300px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; padding: 26px 20px 22px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  transition: .16s; text-align: center;
}
.choice:hover { transform: translateY(-3px); border-color: var(--accent);
                box-shadow: 0 14px 40px rgba(0,0,0,.32); }
.choice .ico { font-size: 30px; line-height: 1; margin-bottom: 6px; }
.choice .t { font-size: 16.5px; font-weight: 650; color: var(--text); }
.choice .d { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.choice.rec { border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
              background: linear-gradient(180deg, color-mix(in srgb, var(--bad) 9%, var(--bg-2)), var(--bg-2)); }
.choice.rec:hover { border-color: var(--bad); }

/* --------------------------------------------- narrow windows behave ---- */
@media (max-width: 860px) {
  #app { grid-template-columns: 200px 1fr; }
  .toolbar button { font-size: 12.5px; padding: 5px 8px; }
  #search { width: 130px; }
}
@media (max-width: 680px) {
  #app { grid-template-columns: 1fr; }
  aside { display: none; }
  header { padding: 8px 12px; }
  .toolbar { padding: 6px 12px; }
  #transcript { padding: 0 18px; font-size: 16.5px; }
}


/* ------------------------------------------------- bottom bar polish ---- */
/* With no audio loaded the two canvases drew as large empty boxes, which
   read as a broken page. Collapse them until there is something to show. */
footer.no-audio #overview,
footer.no-audio #wave { display: none; }
footer.no-audio .transport { margin-top: 0; }

footer { display: flex; flex-direction: column; gap: 6px; }
#overview, #wave { flex-shrink: 0; }
.transport { margin-top: 0 !important; row-gap: 8px; }
.transport .time { min-width: 92px; }

/* keep the sidebar's own footer legible instead of clipping it */
aside { overflow: hidden; }
.side-foot { line-height: 1.5; word-break: break-word; }
.side-foot #drive-label { display: block; overflow: hidden; text-overflow: ellipsis;
                          white-space: nowrap; }

@media (max-height: 700px) {
  #wave { height: 54px; }
  #overview { height: 20px; }
}
