/* Aligned with the rest of the tools ------------------------------------
   The theme attribute is now the site-wide data-bs-theme, set before paint by
   includes/theme_boot.php, and the accent comes from this tool's entry in
   tools_meta.json via the --sg-* tokens includes/tool_header.php emits. The
   original colours stay as var() fallbacks, so the tool still stands up if it
   is ever opened outside the SenHOST shell.
   --------------------------------------------------------------------- */
/* ---------------------------------------------------------------- tokens */

:root {
    --bg: var(--page, #f6f7f9);
    --surface: var(--glass, #ffffff);
    --surface-2: var(--glassH, #f0f2f5);
    --surface-3: var(--well, #e6e9ee);
    --border: var(--stroke, #dce0e6);
    --border-strong: var(--strokeH, #c3c9d2);
    --text: var(--ink, #14181f);
    --text-dim: var(--ink2, #59616e);
    --text-faint: var(--ink3, #8a919c);
    --accent: var(--sg-accent-ink, #d63c2f);
    --accent-hover: color-mix(in oklch, var(--sg-accent-ink, #b82f24) 84%, black);
    --accent-soft: color-mix(in oklch, var(--sg-accent-ink, #fdecea) 12%, transparent);
    --ok: #17864a;
    --ok-soft: color-mix(in oklch, var(--ok) 14%, transparent);
    --warn: #a1620a;
    --warn-soft: color-mix(in oklch, var(--warn) 14%, transparent);
    --error: #c0332e;
    --error-soft: color-mix(in oklch, var(--error) 14%, transparent);
    --shadow: var(--sg-shadow-card, 0 1px 2px rgba(16, 22, 32, .06));
    --radius: var(--sg-r-md, 10px);
    --mono: var(--sg-font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
    --sans: var(--sg-font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

:root[data-bs-theme="dark"] {
    --accent: var(--sg-accent-ink, #ff7b6b);
    --accent-hover: color-mix(in oklch, var(--sg-accent-ink, #ff9a8d) 84%, white);
    --accent-soft: color-mix(in oklch, var(--sg-accent-ink, #3a1c18) 18%, transparent);
    --ok: #4ac97e;
    --ok-soft: color-mix(in oklch, var(--ok) 14%, transparent);
    --warn: #e0a34a;
    --warn-soft: color-mix(in oklch, var(--warn) 14%, transparent);
    --error: #f0736c;
    --error-soft: color-mix(in oklch, var(--error) 14%, transparent);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--page, var(--bg));
    -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- panels */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tab-panel { padding: 18px; }
.tab-panel[hidden] { display: none; }

/* ---------------------------------------------------------------- fields */

input[type="url"],
input[type="text"],
textarea,
select {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 9px 12px;
    transition: border-color .12s, box-shadow .12s;
}

textarea {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    min-height: 190px;
    resize: vertical;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.hint {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--text-faint);
}

/* --------------------------------------------------------------- buttons */

.btn {
    appearance: none;
    font: inherit;
    font-size: 14px;
    font-weight: 550;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s, transform .06s;
}

.btn:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--sg-accent-fill, var(--accent));
    border-color: var(--sg-accent-fill, var(--accent));
    color: var(--sg-on-accent, #fff);
    /* The shared style.css also defines .btn-primary, and its rule ends in
       "0 14px 30px -16px var(--a1)" - a coloured glow under the button. The
       other tools never meet it because they use .btn-brand. Flat, like them. */
    box-shadow: none;
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm { padding: 5px 11px; font-size: 13px; }

.formats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 18px;
    font-size: 13px;
    color: var(--text-faint);
}

.formats b {
    color: var(--text-dim);
    font-weight: 600;
    margin-right: 5px;
}

.formats code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    margin-right: 3px;
    color: var(--text-dim);
}

/* --------------------------------------------------------------- results */

.results { margin-top: 26px; }
.results[hidden] { display: none; }

.results-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.results-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 620;
}

.results-head .spacer { flex: 1; }

/* ----------------------------------------------------------------- output */

.output { min-width: 0; overflow: hidden; }

.switch {
    display: inline-flex;
    background: var(--surface-3);
    border-radius: 7px;
    padding: 2px;
}

.switch button {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 550;
    color: var(--text-dim);
    padding: 4px 12px;
    border-radius: 5px;
    cursor: pointer;
}

.switch button[aria-selected="true"] {
    background: var(--surface);
    color: var(--text);
}

.stats {
    font-size: 12.5px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.stats .chip {
    display: inline-block;
    background: var(--surface-3);
    border-radius: 4px;
    padding: 1px 6px;
    margin-right: 6px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text-dim);
}

.viewport {
    max-height: 620px;
    overflow: auto;
    padding: 20px 22px;
}

/* -------------------------------------------------------------- messaging */

.notice {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    padding: 10px 13px;
    border-radius: 8px;
    font-size: 13.5px;
    margin: 0 0 10px;
    line-height: 1.5;
}

.notice:last-child { margin-bottom: 0; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.error { background: var(--error-soft); color: var(--error); }
.notice .glyph { flex: 0 0 auto; }

.notices { padding: 12px 12px 2px; }
.notices:empty { display: none; }

/* ---------------------------------------------------------------- overlay */

.busy {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 14px;
    color: var(--text-dim);
}

.busy[hidden] { display: none; }

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex: 0 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2s; }
    * { transition: none !important; }
}

/* ------------------------------------------------------------------ toast */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%) translateY(14px);
    background: var(--text);
    color: var(--bg);
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 550;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    z-index: 50;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----------------------------------------------------------------- footer */

.colophon {
    margin-top: 40px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-faint);
    line-height: 1.65;
}

.colophon code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------ transcribe specific */

.links-input {
    width: 100%;
    min-height: 120px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: flex-end;
    margin-top: 14px;
}

.control {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control label {
    font-size: 12.5px;
    font-weight: 550;
    color: var(--text-dim);
}

.control select { width: auto; min-width: 150px; padding: 7px 10px; font-size: 14px; }

.toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin-top: 14px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ------------------------------------------------------------- video cards */

.video {
    margin-bottom: 14px;
    overflow: hidden;
}

.video-head {
    display: flex;
    gap: 12px;
    padding: 13px 15px;
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.thumb {
    width: 108px;
    height: 61px;
    flex: 0 0 108px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--surface-3);
}

.video-info { min-width: 0; flex: 1; }

.video-info h3 {
    margin: 0 0 3px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.video-info h3 a { color: inherit; text-decoration: none; }
.video-info h3 a:hover { color: var(--accent); }

.video-meta {
    font-size: 12.5px;
    color: var(--text-faint);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    align-items: center;
}

.pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 550;
    background: var(--surface-3);
    color: var(--text-dim);
}

.pill.auto { background: var(--warn-soft); color: var(--warn); }
.pill.human { background: var(--ok-soft); color: var(--ok); }

.video-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.transcript {
    max-height: 380px;
    overflow: auto;
    padding: 14px 16px;
    margin: 0;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

.video.failed .video-head { background: var(--error-soft); }
.video.failed .video-info h3 { color: var(--error); }

@media (max-width: 620px) {
    .thumb { display: none; }
    .video-actions { width: 100%; margin-top: 8px; }
}
