/* Speech to Text (stt.js). Loaded after tool.css. */
.tk-note { color: var(--text-2); }
.st-main { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "stage set" "text set"; grid-template-rows: auto 1fr; gap: 14px; align-items: start; align-content: start; }
.st-stage { grid-area: stage; display: grid; gap: 12px; min-width: 0; }
.st-textp { grid-area: text; display: grid; gap: 10px; min-width: 0; }
.st-set { grid-area: set; position: sticky; top: 0; display: grid; gap: 16px; }
.st-set .tk-h, .st-textp .tk-h { margin: 0; }

/* ---------- the two ways in, and the clock ---------- */
.st-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.st-rec { gap: 9px; height: 44px; padding: 0 20px 0 14px; border-radius: 999px; font-size: 15px; font-weight: 650; background: var(--fail); border-color: transparent; color: #1c0505; }
[dir="rtl"] .st-rec { padding: 0 14px 0 20px; }
.st-rec:hover { background: var(--fail); filter: brightness(1.08); }
.st-rec .st-dot { width: 14px; height: 14px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(28, 5, 5, 0.18); }
:root[data-theme="light"] .st-rec { color: #fff; }
.st-or { color: var(--text-2); font-size: 12.5px; }
.st-pick { position: relative; overflow: hidden; height: 44px; border-radius: 999px; padding: 0 18px; }
.st-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.st-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-ctl { display: flex; flex-wrap: wrap; gap: 8px; }
.st-ctl:empty { display: none; }
.st-ctl .tk-btn { height: 44px; border-radius: 999px; padding: 0 18px; font-size: 14px; }
.st-stop { background: var(--text); color: var(--bg); border-color: transparent; }
.st-stop:hover { background: var(--text); filter: brightness(0.92); }
.st-stop i { width: 12px; height: 12px; border-radius: 2px; background: currentColor; }
.st-clock { margin: 0; margin-inline-start: auto; font-size: 30px; font-weight: 600; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1; direction: ltr; unicode-bidi: isolate; }

/* ---------- the sound: picture and level ---------- */
.st-scope { display: grid; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--stage); border: 1px solid var(--line); }
.st-wave { display: block; width: 100%; height: 64px; }
.st-level { display: grid; grid-template-columns: auto minmax(0, 1fr) 4.6em; align-items: center; gap: 10px; }
.st-level > span { color: var(--text-2); font-size: 12px; }
.st-meter { position: relative; height: 10px; border-radius: 3px; background: var(--raised); overflow: hidden;
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px); mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px); }
.st-meter i { position: absolute; inset: 0; --v: 0; background: linear-gradient(90deg, var(--pass) 0 66%, var(--warn) 66% 86%, var(--fail) 86%); clip-path: inset(0 calc((1 - var(--v)) * 100%) 0 0); }
/* right to left: the level grows from the right, like the picture of the sound */
[dir="rtl"] .st-meter i { background: linear-gradient(270deg, var(--pass) 0 66%, var(--warn) 66% 86%, var(--fail) 86%); clip-path: inset(0 0 0 calc((1 - var(--v)) * 100%)); }
.st-db { text-align: end; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-2); direction: ltr; unicode-bidi: isolate; white-space: nowrap; }

/* ---------- what is happening now ---------- */
.st-now { display: grid; gap: 6px; }
.st-state { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text); min-height: 1.4em; }
.st-state:empty { display: none; }
.st-state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.st-state[data-kind="rec"]::before { background: var(--fail); animation: st-blink 1.2s ease-in-out infinite; }
.st-state[data-kind="paused"]::before { background: var(--warn); }
.st-state[data-kind="work"]::before { background: var(--accent); }
@keyframes st-blink { 50% { opacity: 0.25; } }
.st-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.st-row p { margin: 0; }
.st-bar { position: relative; height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; direction: ltr; }
.st-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--accent); transition: width 0.25s; }
.st-bar.is-busy i { width: 100% !important; background: linear-gradient(90deg, var(--accent) 0 30%, transparent 30% 100%); background-size: 200% 100%; animation: st-busy 1.1s linear infinite; }
@keyframes st-busy { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.st-improve { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border-radius: 10px; background: var(--info-bg); border: 1px solid rgba(71, 198, 232, 0.25); }
.st-improve[hidden] { display: none; }
.st-improve p { margin: 0; flex: 1 1 220px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }

/* ---------- the text ---------- */
.st-text-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.st-info { margin: 0; color: var(--text-2); font-size: 12.5px; }
.st-src { margin: 0; color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-player { width: 100%; height: 40px; }
.st-box { position: relative; min-height: 220px; max-height: min(56vh, 560px); overflow: auto; padding: 6px 4px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.st-empty { display: grid; place-items: center; min-height: 200px; margin: 0; padding: 20px; text-align: center; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.st-text { margin: 0; }
.st-seg { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-items: baseline; margin: 0; padding: 6px 10px; border-radius: 8px; }
.st-seg:hover { background: var(--hover); }
.st-ts { padding: 2px 6px; border: 0; border-radius: 6px; background: transparent; color: var(--accent); font: inherit; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; white-space: nowrap; }
.st-ts:hover:not(:disabled) { background: var(--info-bg); }
.st-ts:disabled { color: var(--text-2); cursor: default; }
:root[data-theme="light"] .st-ts:not(:disabled) { color: #08617f; }
.st-tx { font-size: 15px; line-height: 1.65; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; outline: none; border-radius: 4px; }
.st-tx[contenteditable="true"]:focus { box-shadow: 0 0 0 2px var(--accent); background: var(--panel); }
/* a paragraph's own direction (Hebrew text in an English page, and the other way) */
.st-seg[dir="rtl"] .st-tx, .st-seg[dir="ltr"] .st-tx { unicode-bidi: plaintext; }
.st-seg.is-partial { display: block; padding-inline-start: 10px; color: var(--text-2); font-size: 15px; line-height: 1.65; font-style: italic; }
.st-seg.is-partial::after { content: ""; display: inline-block; width: 7px; height: 1em; margin-inline-start: 4px; vertical-align: -0.12em; background: var(--accent); animation: st-blink 1s steps(2) infinite; }

.st-out { display: grid; gap: 10px; }
.st-dl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.st-dl > span { color: var(--text-2); font-size: 13px; margin-inline-end: 2px; }
.st-dl .tk-btn svg { width: 15px; height: 15px; }
.st-dl .tk-btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }
.st-dl .tk-btn.is-done { color: var(--pass); }
.st-out-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }

/* ---------- settings ---------- */
.st-field { display: grid; gap: 8px; }
.st-field > span, .st-field > label { color: var(--text-2); font-size: 13px; }
.st-field p { margin: 0; }
.st-field .tk-select { max-width: none; width: 100%; }
.st-set .tk-seg { display: flex; }
.st-set .tk-seg button { flex: 1; height: auto; min-height: 30px; padding: 5px 6px; line-height: 1.25; }
.st-set .tk-seg button:disabled { opacity: 0.45; cursor: not-allowed; }
.st-na { color: var(--msg-warn) !important; }
.st-model { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.st-model-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.st-model h3 { margin: 0; font-size: 13px; font-weight: 650; }
.st-model p { margin: 0; }
.st-model p.is-err { color: var(--msg-error); }
.st-engine { padding: 2px 10px; border-radius: 999px; background: var(--raised); color: var(--text-2); font-size: 12px; font-weight: 600; }
.st-engine[data-kind="gpu"] { background: var(--pass-bg); color: var(--pass); }
.st-model-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.st-private { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--text-2); font-size: 12px; line-height: 1.5; }
.st-private svg { width: 16px; height: 16px; flex: none; color: var(--pass); margin-top: 1px; }

.st-veil { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(8, 14, 24, 0.55); color: #fff; font-size: 22px; font-weight: 650; pointer-events: none; text-align: center; padding: 20px; }
.st-veil.is-on { display: grid; }

@media (max-width: 860px) {
  /* on a phone the text comes right after the controls, and the settings after it */
  .st-main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "text" "set"; }
  .st-set { position: static; }
  .st-box { max-height: 60vh; }
}
@media (max-width: 520px) {
  /* the clock next to the record button, the file button on its own row */
  .st-clock { font-size: 24px; order: 1; }
  .st-pick { order: 2; flex: 1 1 100%; justify-content: center; }
  .st-rec, .st-pick, .st-ctl .tk-btn { height: 40px; }
  .st-or { display: none; }
  .st-wave { height: 48px; }
  .st-seg { grid-template-columns: minmax(0, 1fr); padding: 6px 6px; }
  .st-ts { justify-self: start; padding-inline: 0; }
  .st-tx { font-size: 14.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .st-state[data-kind="rec"]::before, .st-seg.is-partial::after { animation: none; }
  .st-bar.is-busy i { animation-duration: 3s; }
  .st-bar i { transition: none; }
}
html.a11y-still .st-state[data-kind="rec"]::before, html.a11y-still .st-seg.is-partial::after, html.a11y-still .st-bar.is-busy i { animation: none; }
@media (forced-colors: active) {
  .st-bar i, .st-meter i { background: Highlight; forced-color-adjust: none; }
  .st-state::before, .st-rec .st-dot, .st-stop i { background: CanvasText; forced-color-adjust: none; }
}
