:root {
    /* The design tokens themselves (--ink, --seal, --font-sans…) live in public.css; these names map onto them. */
    --font-ui: var(--font-sans);
    --font-display: var(--font-sans);
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --type-body: 1rem;
    --type-body-small: 0.875rem;
    --type-label: 0.75rem;
    --type-title: clamp(2.25rem, 4vw, 3.1rem);
    --leading-body: 1.55;
    --leading-tight: 1.12;
    --surface-card: var(--paper);
    --surface-card-subtle: var(--archive);
    --surface-card-hover: color-mix(in srgb, var(--archive) 60%, var(--paper));
    --surface-card-line: var(--line);
    --surface-card-line-soft: var(--line-soft);
    --surface-card-ink: var(--ink);
    --surface-card-muted: var(--graphite);
    --surface-card-accent: var(--seal);
    --surface-card-success: var(--verified);
    --surface-card-warning: #9a6b23;
    --surface-card-danger: #b02a37;
    --surface-card-radius: 3px;
    /* Bootstrap's own "primary" (list markers, focus, links in components) follows the seal instead of its blue. */
    --bs-primary: var(--seal);
    --bs-primary-rgb: 138, 28, 43;
    --bs-link-color: var(--seal);
    --bs-link-color-rgb: 138, 28, 43;
    --bs-link-hover-color: var(--seal-deep);
    --bs-body-font-family: var(--font-sans);
    --surface-card-padding: 1.5rem;
}

html, body {
    font-family: var(--font-ui);
}

body {
    min-height: 100vh;
    color: var(--ink);
    background: var(--archive);
    font-size: var(--type-body);
    line-height: var(--leading-body);
    text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
    font: inherit;
}

h1, h2, h3, h4, h5, h6 {
    color: inherit;
    line-height: var(--leading-tight);
}

code,
kbd,
pre,
.font-monospace {
    font-family: var(--font-mono) !important;
}

.btn {
    font-weight: 650;
    line-height: 1.25;
}

.text-muted {
    line-height: var(--leading-body);
}

a, .btn-link {
    color: var(--seal);
    text-underline-offset: 0.2em;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--paper), 0 0 0 0.25rem color-mix(in srgb, var(--seal) 28%, transparent);
}

.btn-primary {
    --bs-btn-bg: var(--seal);
    --bs-btn-border-color: var(--seal);
    --bs-btn-hover-bg: var(--seal-deep);
    --bs-btn-hover-border-color: var(--seal-deep);
    --bs-btn-active-bg: var(--seal-deep);
    --bs-btn-active-border-color: var(--seal-deep);
    --bs-btn-disabled-bg: var(--seal);
    --bs-btn-disabled-border-color: var(--seal);
}

/* Outline buttons are secondary actions (Play, Export, View…): ink on paper, the seal is kept for the primary one. */
.btn-outline-primary {
    --bs-btn-color: var(--ink);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-bg: transparent;
    --bs-btn-hover-border-color: var(--ink);
    --bs-btn-active-color: var(--ink);
    --bs-btn-active-bg: var(--archive);
    --bs-btn-active-border-color: var(--ink);
    --bs-btn-disabled-color: var(--graphite);
    --bs-btn-disabled-border-color: var(--line);
}

/* Secondary actions are ink on paper; only the primary action carries the seal color. */
.btn-outline-secondary {
    --bs-btn-color: var(--ink);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-bg: transparent;
    --bs-btn-hover-border-color: var(--ink);
    --bs-btn-active-color: var(--ink);
    --bs-btn-active-bg: var(--archive);
    --bs-btn-active-border-color: var(--ink);
}

.btn {
    border-radius: 6px;
}

/* The seal color lightens in dark mode, so text on it turns dark to stay readable. */
[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: #1a0f12;
    --bs-btn-hover-color: #1a0f12;
    --bs-btn-active-color: #1a0f12;
    --bs-btn-disabled-color: #1a0f12;
}

.card {
    border: 1px solid var(--surface-card-line);
    border-radius: var(--surface-card-radius);
    background: var(--surface-card);
    color: var(--surface-card-ink);
    box-shadow: none;
}

.surface-card {
    border: 1px solid var(--surface-card-line);
    border-radius: var(--surface-card-radius);
    background: var(--surface-card);
    color: var(--surface-card-ink);
    box-shadow: none;
}

.surface-card--interactive {
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.surface-card--interactive:hover,
.surface-card--interactive:focus-within {
    border-color: color-mix(in srgb, var(--surface-card-accent) 48%, var(--surface-card-line));
    background: var(--surface-card-hover);
    transform: translateY(-1px);
}

.surface-card--emphasis {
    border-top: 3px solid var(--ink);
}

.surface-card--success { border-color: color-mix(in srgb, var(--surface-card-success) 48%, var(--surface-card-line)); }
.surface-card--warning { border-color: color-mix(in srgb, var(--surface-card-warning) 52%, var(--surface-card-line)); }
.surface-card--danger { border-color: color-mix(in srgb, var(--surface-card-danger) 52%, var(--surface-card-line)); }

/* The editor keeps the normal navigation, but uses every pixel still available in the main work area. */
@media (min-width: 641px) {
    .page:has(.transcript-shell) .content { max-width: none; }
    .page:has(.transcript-shell) article { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
}

.form-control,
.form-select {
    border-color: var(--line-strong);
    border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ink);
}

.alert {
    border-radius: 0.35rem;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: color-mix(in srgb, var(--seal) 5.5%, transparent);
    --bs-table-border-color: var(--line);
}

[data-bs-theme="dark"] body {
    color: var(--ink);
    background: var(--archive);
}

/* In dark mode the surfaces follow the tokens (public.css); only the status hues need their own lighter values. */
[data-bs-theme="dark"] {
    --surface-card-warning: #d5aa62;
    --surface-card-danger: #ff8a94;
}

[data-bs-theme="dark"] .card {
    border-color: var(--surface-card-line);
}

@media (prefers-reduced-motion: reduce) {
    .surface-card--interactive { transition: none; }
    .surface-card--interactive:hover,
    .surface-card--interactive:focus-within { transform: none; }
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    border-color: var(--line-strong);
}

/* Keep theme-control icons synchronized even when a layout is replaced by enhanced navigation. */
[data-bs-theme="dark"] [data-theme-toggle] .theme-toggle-icon-dark {
    display: none;
}

[data-bs-theme="dark"] [data-theme-toggle] .theme-toggle-icon-light {
    display: inline;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Excludes .docked: that variant already sets its own dark, theme-independent colors below. */
.transcript-segment-list {
    padding-top: 0.35rem;
    padding-bottom: 1rem;
}

.transcript-segment-card {
    text-align: left;
    border: 1px solid rgba(17, 24, 39, 0.08);
    transition: border-color 0.15s ease;
}

.transcript-segment-card:hover {
    border-color: rgba(13, 110, 253, 0.35);
}

.transcript-segment-text {
    white-space: pre-wrap;
}

.transcript-play-badge {
    color: #1d4ed8 !important;
}

/* Shared across Jobs.razor and TranscriptEditor.razor — kept here (not in either page's
   scoped .razor.css) because Blazor CSS isolation would otherwise only apply it to one page. */
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-pill-queued {
    background: rgba(49, 66, 56, 0.1);
    color: var(--ink);
}

.status-pill-processing {
    background: color-mix(in srgb, var(--seal) 13%, transparent);
    color: var(--seal-deep);
}

.status-pill-completed {
    background: rgba(48, 101, 70, 0.15);
    color: var(--verified);
}

.status-pill-failed {
    background: rgba(220, 53, 69, 0.15);
    color: #b02a37;
}

[data-bs-theme="dark"] .status-pill-queued {
    background: rgba(237, 240, 232, 0.1);
    color: #d5ddd1;
}

[data-bs-theme="dark"] .status-pill-processing {
    background: rgba(255, 131, 91, 0.18);
    color: #ffb198;
}

[data-bs-theme="dark"] .status-pill-completed {
    background: rgba(25, 135, 84, 0.22);
    color: #75d8a8;
}

[data-bs-theme="dark"] .status-pill-failed {
    background: rgba(220, 53, 69, 0.22);
    color: #ff9baa;
}

/* Shared across TranscriptEditor.razor and LegalAnalysisPanel.razor — same reasoning as .status-pill
   above: kept here so Blazor's per-component CSS isolation doesn't limit it to one component. */
.transcript-main-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.transcript-main-tab {
    padding: 0.55rem 1.15rem;
    border: 1px solid rgba(25, 35, 29, 0.13);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.5);
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.transcript-main-tab.small {
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
}

.transcript-main-tab:hover {
    border-color: color-mix(in srgb, var(--seal) 40%, transparent);
    color: var(--seal);
}

.transcript-main-tab.active,
.transcript-main-tab.active:hover {
    background: var(--seal);
    border-color: var(--seal);
    color: #fff;
}

.transcript-main-tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

[data-bs-theme="dark"] .transcript-main-tab {
    border-color: rgba(237, 240, 232, 0.16);
    background: rgba(255, 255, 255, 0.035);
    color: var(--ink);
}

.processing-spinner {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    border: 2px solid color-mix(in srgb, var(--seal) 22%, transparent);
    border-top-color: var(--seal);
    border-radius: 999px;
    animation: processing-spin 0.8s linear infinite;
}

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

/* Shared across TranscriptEditor.razor and LegalAnalysisPanel.razor — same reasoning as .status-pill
   above: kept here so Blazor's per-component CSS isolation doesn't limit it to one component. */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1045;
    background: transparent;
}

.export-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 1046;
    display: grid;
    min-width: 12rem;
    padding: 0.4rem;
}

.export-dropdown-menu-end {
    right: 0;
    left: auto;
}

.export-dropdown-menu .dropdown-item {
    padding: 0.5rem 0.65rem;
    border-radius: 0.35rem;
    color: inherit;
    text-decoration: none;
}

.export-dropdown-menu .dropdown-item:hover,
.export-dropdown-menu .dropdown-item:focus-visible {
    background: rgba(0, 0, 0, 0.06);
}

[data-bs-theme="dark"] .export-dropdown-menu .dropdown-item:hover,
[data-bs-theme="dark"] .export-dropdown-menu .dropdown-item:focus-visible {
    background: rgba(255, 255, 255, 0.08);
}


/* Loading bar along the top while a page is being fetched (see js/navigationProgress.js). */
.nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    height: 3px;
    width: 0;
    background: var(--seal);
    box-shadow: 0 0 8px color-mix(in srgb, var(--seal) 60%, transparent);
    pointer-events: none;
}

.nav-progress[hidden] { display: none; }
.nav-progress-running { width: 85%; transition: width 8s cubic-bezier(0.1, 0.6, 0.3, 1); }
.nav-progress-done { width: 100%; opacity: 0; transition: width 0.15s ease-out, opacity 0.3s ease 0.15s; }

@media (prefers-reduced-motion: reduce) {
    .nav-progress-running, .nav-progress-done { transition: none; }
}
/* Global selectors let the document's persisted state reach the isolated layout. */
@media (min-width: 641px) {
    html.sidebar-collapsed .page > main { margin-left: 72px; }
    html.sidebar-collapsed .page > .sidebar {
        width: 72px;
    }
    html.sidebar-collapsed.sidebar-hover-open .page > .sidebar {
        width: 250px;
    }
    html.sidebar-collapsed .sidebar-toggle { left: 60px; }
    html.sidebar-collapsed.sidebar-hover-open .sidebar-toggle { left: 238px; }

    /* These selectors deliberately live in the global stylesheet: the state
       belongs to <html>, outside NavMenu's scoped CSS. */
    html.sidebar-collapsed .sidebar .top-row {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    html.sidebar-collapsed .sidebar .top-row .container-fluid { justify-content: center !important; }
    html.sidebar-collapsed .sidebar .brand-name,
    html.sidebar-collapsed .sidebar .nav-label,
    html.sidebar-collapsed .sidebar .nav-footer { display: none; }
    html.sidebar-collapsed .sidebar .nav-item {
        padding-left: .65rem !important;
        padding-right: .65rem !important;
    }
    html.sidebar-collapsed .sidebar .nav-link {
        justify-content: center;
        padding: 0;
    }

    html.sidebar-collapsed.sidebar-hover-open .sidebar .brand-name,
    html.sidebar-collapsed.sidebar-hover-open .sidebar .nav-label { display: inline; }
    html.sidebar-collapsed.sidebar-hover-open .sidebar .nav-footer { display: block; }
    html.sidebar-collapsed.sidebar-hover-open .sidebar .top-row {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    html.sidebar-collapsed.sidebar-hover-open .sidebar .top-row .container-fluid { justify-content: space-between !important; }
    html.sidebar-collapsed.sidebar-hover-open .sidebar .nav-item {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    html.sidebar-collapsed.sidebar-hover-open .sidebar .nav-link {
        justify-content: flex-start;
        padding: 0 1rem;
    }
}
/* Playback paint is transient: it never becomes part of the rich editor's saved HTML. */
::highlight(transcript-playback) {
    background-color: var(--te-word-active-bg, #ffd8b5);
    color: var(--te-word-active-text, #42210d);
}

/* Words to check, painted the same way — see paintDoubtfulWords in transcriptPlayer.js. Violet on purpose:
   it must never be mistaken for the orange playback paint or the yellow search matches. */
::highlight(transcript-doubtful) {
    background-color: #e3dafb;
    color: #35206b;
}
::highlight(transcript-doubtful-current) {
    background-color: #c5b1f6;
    color: #25124f;
}
:root[data-bs-theme="dark"] ::highlight(transcript-doubtful) { background-color: #3f3470; color: #ece6ff; }
:root[data-bs-theme="dark"] ::highlight(transcript-doubtful-current) { background-color: #5b4a9e; color: #ffffff; }

/* Search matches — see paintSearchMatches in transcriptPlayer.js. A soft teal pill around the word: its own hue,
   so it never reads as playback (orange), words to check (violet) or the manual highlight (yellow). The tint is
   light enough to sit over the text; the current match (Next/Previous) fills in and gets a halo. */
.transcript-search-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}
.transcript-search-mark {
    position: absolute;
    box-sizing: border-box;
    border: 1.5px solid rgba(13, 148, 136, 0.55);
    border-radius: 0.45rem;
    background-color: rgba(20, 184, 166, 0.1);
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.transcript-search-mark-current {
    border-color: #0d9488;
    background-color: rgba(20, 184, 166, 0.22);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18), 0 1px 4px rgba(13, 148, 136, 0.25);
}
:root[data-bs-theme="dark"] .transcript-search-mark { border-color: rgba(94, 234, 212, 0.5); background-color: rgba(45, 212, 191, 0.1); }
:root[data-bs-theme="dark"] .transcript-search-mark-current { border-color: #5eead4; background-color: rgba(45, 212, 191, 0.22); box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2); }

/* Checkboxes, radios and switches follow the seal instead of Bootstrap's blue. */
.form-check-input {
    border-color: var(--line-strong);
}

.form-check-input:checked {
    border-color: var(--seal);
    background-color: var(--seal);
}

.form-check-input:focus {
    border-color: var(--ink);
}

.form-range::-webkit-slider-thumb { background-color: var(--seal); }
.form-range::-moz-range-thumb { background-color: var(--seal); }
