/* Self-hosted Latin typeface. The font stack has always asked for Inter first,
   but it was never bundled — so on any machine without Inter installed the UI
   silently fell back to Segoe UI and capped at weight 700. One variable file
   covers 100-900. */
@font-face {
    font-family: 'Inter';
    src: url('vendor/fonts/InterVariable.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* Self-hosted Traditional Chinese typeface. App is localhost-only, so the
   ~8MB combined OTF size is acceptable; a woff2 subset is a future
   optimization once the app is served over a network. */
@font-face {
    font-family: 'Noto Sans TC';
    src: url('vendor/fonts/NotoSansTC-Regular.otf') format('opentype');
    font-weight: 400 500;
    font-display: swap;
}

@font-face {
    font-family: 'Noto Sans TC';
    src: url('vendor/fonts/NotoSansTC-Bold.otf') format('opentype');
    font-weight: 700;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #121215; /* Crisp, bright slate-light background */
    --sidebar-bg: #121215; /* Clean white sidebar */
    --surface: #121215; /* Pure white card background */
    --surface-soft: #121215; /* Soft slate white for list elements and inputs */
    --ink: #f4f4f5; /* Deep slate-900 primary text */
    --muted: #d4d4d8; /* Slate-600 secondary text */
    --subtle: #a1a1aa; /* Slate-500 tertiary text */
    --faint: #a1a1aa; /* Slate-400 faint text/decorative */
    --line: #27272a; /* Slate-200 border - extremely clean and thin */

    /* Typography tokens */
    --font-sans: "Inter", "Segoe UI", system-ui, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;

    /* Compatibility aliases (referenced by index.html inline styles) */
    --text-main: var(--ink);
    --text-muted: var(--muted);
    --border-color: var(--line);
    --card-bg: var(--surface);
    --red: var(--danger);

    /* Enterprise accent: Cyber Emerald (blue/teal family banned suite-wide) */
    --accent: #10b981; /* Emerald — marks, borders, selected bars. Not a text fill. */
    --accent-hover: #059669; /* Darker emerald */
    --accent-strong: #059669; /* Deep emerald */
    --accent-soft: rgba(16, 185, 129, 0.12); /* Soft emerald background */
    --accent-ink: #34d399; /* AA-safe emerald ink for accent-coloured TEXT on obsidian */
    --accent-line: rgba(16, 185, 129, 0.22); /* Hairline next to emerald chrome */
    /* Filled actions: on-accent ink on the emerald fill token. */
    --accent-fill: var(--accent-hover); /* ~5.1:1 */
    /* One step down (~7.6:1). --accent-strong is a hole, not a hover. */
    --accent-fill-hover: #059669;

    --blue: #f59e0b; /* info / hypothesis = amber (legacy name) */
    --blue-soft: rgba(245, 158, 11, 0.12);
    --blue-ink: #fbbf24;

    /* High-end Muted Status Indicators */
    --danger: #dc2626; /* Emerald Rose/Red */
    --danger-soft: rgba(255, 26, 92, 0.12);
    --danger-ink: #991b1b;

    --warning: #d97706; /* Amber */
    --warning-soft: rgba(245, 158, 11, 0.12);
    --warning-ink: #fbbf24;

    --success: #059669; /* Emerald Green */
    --success-soft: rgba(16, 185, 129, 0.12);
    --success-ink: #34d399;

    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.06); /* Ultra-soft card shadow */
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.02);
    --shadow-card: 0 8px 24px rgba(24, 24, 27, 0.06);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --motion-fast: 120ms;
    --motion-base: 180ms;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    min-height: 100%;
    overflow-x: visible;
    overflow-y: auto;
}

body {
    font-family: "Inter", "Segoe UI", system-ui, "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* app sets document.documentElement.lang = 'zh-Hant-TW' at runtime */
:lang(zh-Hant) body, body:lang(zh-Hant) { line-height: 1.7; }
html:lang(zh-Hant) { letter-spacing: 0.01em; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

.hidden {
    display: none !important;
}

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

button:disabled,
[aria-disabled="true"] {
    cursor: not-allowed;
}

/* App Shell Layout */
.app-container {
    display: flex;
    align-items: flex-start;
    width: 100%;
    flex: 1 0 auto;
    min-height: 100vh;
    height: auto;
    max-height: none;
    overflow: visible;
}

/* Premium White Sidebar (Stripe/Vercel Style) */
.sidebar {
    position: sticky;
    top: 0;
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    padding: 2.25rem 1rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

/* Brand lockup: mark + stacked wordmark. The sidebar text column is only
   ~172px, so the name and the product descriptor must sit on separate lines
   instead of wrapping mid-phrase. */
.logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 2.5rem;
    padding-left: 0.5rem;
}

.logo-icon {
    flex: 0 0 auto;
    background: var(--accent-fill);
    color: #f4f4f5;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.875rem;
    letter-spacing: -0.02em;
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}

.logo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
}

/* Brand Wordmark: Clean, modern enterprise styling */
.logo-brand {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-ink);
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.logo-bar {
    display: inline-block;
    flex: 0 0 auto;
    width: 9px;
    height: 2.5px;
    margin: 0 3px 0 2px;
    border-radius: 2px;
    background: var(--accent-ink);
}

.logo-sub {
    margin-top: 2px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Uppercase and wide tracking are Latin-only conventions — they make CJK
   look broken, so the Chinese descriptor keeps its natural case and spacing. */
.lang-zh .logo-sub {
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 0.75rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nav-links li {
    padding: 0.65rem 1rem;
    border-radius: 8px; /* Clean rounded edges */
    cursor: pointer;
    transition: background-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.nav-links li:hover {
    color: var(--ink);
    background: #121215;
}

/* Clean, crisp active navigation links */
.nav-links li.active {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
}

.nav-links li .icon {
    font-style: normal;
    font-size: 1.1rem;
    display: inline-block;
    width: 18px;
    text-align: center;
}

/* De-inlined from index.html: pushes reference button toward sidebar bottom */
.sidebar-spacer {
    flex-grow: 1;
}

/* The toolbar owns its controls in normal flow. Wrapping keeps the guide
   launcher clear of page actions at narrow widths and larger text sizes. */
.top-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: rgba(18, 18, 21, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
}

.top-bar-right {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    max-width: 100%;
    gap: 0.5rem;
}

.mode-tier-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink);
    white-space: nowrap;
}

.mode-tier-badge.tier-t1 {
    border-color: #10b981;
    color: #34d399;
}

.mode-tier-badge.tier-t2 {
    border-color: var(--warning, #b8860b);
    color: var(--warning, #b8860b);
}

#local-mode-status {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.finding-explain-note,
.slot-candidates-box {
    margin-top: 0.75rem;
}

.finding-explain-note {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    background: var(--success-soft, rgba(70, 120, 101, 0.08));
    font-size: 0.9rem;
}

.slot-candidates-hint {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.industry-selector-container,
#lbl-global-industry {
    white-space: nowrap;
    flex-shrink: 0;
}

/* De-inlined from index.html: global industry selector in the top bar */
.industry-selector-container {
    display: inline-flex;
    align-items: center;
    margin-right: 12px;
}

#lbl-global-industry {
    margin-right: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

#global-industry-select {
    padding: 4px 10px;
    border-radius: 15px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
    outline: none;
    cursor: pointer;
}

.lang-btn, .zoom-btn, .blueprint-btn {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:hover, .zoom-btn:hover {
    background: #121215;
    border-color: #3f3f46;
    color: var(--ink);
}

.home-btn {
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    color: var(--accent-ink);
    padding: 0.45rem 0.95rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast);
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    box-shadow: var(--shadow-sm);
}

.home-btn:hover {
    background: var(--accent-fill);
    color: var(--surface);
    border-color: var(--accent-fill);
}

.home-btn .home-icon {
    font-size: 1.3rem; /* Make the ⌂ symbol larger and highly visible */
    font-weight: bold;
    line-height: 1;
    margin-top: -3px; /* vertical alignment tweak */
}

/* Mobile navigation drawer trigger (hidden on desktop, shown < 900px) */
.nav-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}

.nav-toggle-btn:hover {
    background: #121215;
    border-color: #3f3f46;
}

.nav-toggle-btn svg {
    display: block;
}

/* Scrim behind the open drawer — only rendered at mobile widths (see media query) */
.nav-scrim {
    display: none;
}

.zoom-control {
    display: flex;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface);
}

.zoom-btn {
    border: none;
    border-radius: 0;
    padding: 0.45rem 0.75rem;
}

.zoom-btn:first-child {
    border-right: 1px solid var(--line);
}

/* Main Content Area */
.main-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 1.5rem 3.5rem 4.5rem;
    overflow: visible;
    background: transparent;
}

.tab-content {
    display: none;
    animation: fadeIn 0.15s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.85rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--muted);
    font-size: 0.95rem;
    max-width: 750px;
}

/* Premium Card Layout */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.paper-card {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

/* Segmented Tabs (Stripe style) */
.verify-tabs {
    display: flex;
    gap: 0.25rem;
    background: #121215;
    border-radius: 8px;
    padding: 0.25rem;
    width: fit-content;
    margin-bottom: 1.5rem;
    border: 1px solid var(--line);
}

.verify-tab-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color var(--motion-fast), color var(--motion-fast);
    border-radius: 6px;
}

.verify-tab-btn:hover {
    color: var(--ink);
}

.verify-tab-btn.active {
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Form inputs & details */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--ink);
    font-weight: 500;
    font-size: 0.9rem;
}

select, input[type="text"], input[type="password"], textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background-color var(--motion-fast);
    box-shadow: var(--shadow-sm);
}

textarea {
    height: 180px;
    resize: vertical;
    line-height: 1.6;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.12);
}

.primary-btn {
    background: var(--accent-fill);
    color: var(--surface);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease;
    box-shadow: var(--shadow-sm);
}

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

.primary-btn:disabled {
    background: #1c1c21;
    color: #a1a1aa;
    cursor: not-allowed;
    box-shadow: none;
}

/* Stripe styled Document Dropzone */
.upload-zone {
    border: 1px dashed #3f3f46;
    border-radius: 12px;
    padding: 3.5rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--motion-base), background-color var(--motion-base), box-shadow var(--motion-base);
    background: var(--bg);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upload-icon {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    display: block;
    color: var(--accent-ink);
}

.upload-zone h3 {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--ink);
    font-size: 1.1rem;
}

.upload-zone p {
    color: var(--muted);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.browse-link {
    color: var(--accent-ink);
    text-decoration: underline;
    font-weight: 600;
}

.upload-zone small {
    color: var(--muted);
    font-size: 0.8rem;
    display: block;
    margin-top: 0.75rem;
}

/* Selected File Ingestion list */
.uploaded-files-container {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--line);
}

.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.files-header h4 {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink);
}

.clear-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.85rem;
}

.clear-btn:hover {
    text-decoration: underline;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.file-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.file-name {
    font-weight: 600;
    color: var(--ink);
    font-size: 0.9rem;
}

.file-size {
    font-size: 0.8rem;
    color: var(--muted);
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* High-end Minimal Status lights (subtle pulsing dots) */
.file-status {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.file-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    transition: background-color 0.16s ease, opacity 0.16s ease;
}

.file-status.queued {
    background: #121215;
    color: var(--muted);
}
.file-status.queued::before {
    background: var(--muted);
}

.file-status.processing {
    background: var(--accent-soft);
    color: var(--accent-ink);
}
.file-status.processing::before {
    background: var(--accent);
}

.file-status.done {
    background: var(--success-soft);
    color: var(--success-ink);
}
.file-status.done::before {
    background: var(--success);
}

.file-status.error {
    background: var(--danger-soft);
    color: var(--danger-ink);
}
.file-status.error::before {
    background: var(--danger);
}

.remove-file-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    transition: color var(--motion-fast), background-color var(--motion-fast), transform var(--motion-fast);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.remove-file-btn:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

/* Master-Detail Verification Dashboard */
.multi-result-container {
    margin-top: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.dashboard-sidebar h3 {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.5rem;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.multi-files-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.multi-files-nav li {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast);
    background: var(--surface);
    border: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.multi-files-nav li:hover {
    border-color: #3f3f46;
}

.multi-files-nav li.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
    font-weight: 600;
}

.nav-file-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    color: var(--ink);
}

.nav-file-score {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    min-width: 32px;
    text-align: center;
}

/* Score Indicators */
.score-high { background: var(--success-soft); color: var(--success-ink); }
.score-medium { background: var(--warning-soft); color: var(--warning-ink); }
.score-low { background: var(--danger-soft); color: var(--danger-ink); }

.submission-readiness {
    margin: 0 0 1.25rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--warning);
    background: var(--surface);
    border-radius: 6px;
}

.submission-readiness.ready { border-left-color: var(--success); }
.submission-readiness.not-ready { border-left-color: var(--danger); }
.submission-readiness.conditionally-ready { border-left-color: var(--warning); }

.submission-readiness-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.submission-readiness-heading > div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.submission-readiness-heading span,
.submission-readiness-heading small {
    color: var(--muted);
    font-size: 0.78rem;
}

.submission-readiness-heading strong {
    color: var(--text);
    font-size: 1.05rem;
}

.readiness-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(96px, 1fr));
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.readiness-metric {
    min-width: 0;
    padding: 0.55rem 0.65rem;
    border-top: 2px solid var(--border);
    background: var(--bg);
}

.readiness-metric span,
.readiness-metric strong {
    display: block;
}

.readiness-metric span {
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.25;
}

.readiness-metric strong {
    margin-top: 0.2rem;
    color: var(--text);
    font-size: 1rem;
}

.readiness-blockers,
.presentation-review-summary {
    margin-top: 0.85rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
}

.readiness-blockers ul,
.presentation-review-summary ul {
    margin: 0.45rem 0 0 1.15rem;
    padding: 0;
}

.presentation-review-summary {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.builder-readiness {
    margin-bottom: 0.8rem;
    padding: 0.75rem 0.85rem;
    border-left: 4px solid var(--warning);
    background: var(--bg);
}

.builder-readiness.ready { border-left-color: var(--success); }
.builder-readiness.conditionally-ready { border-left-color: var(--warning); }
.builder-readiness.not-ready { border-left-color: var(--danger); }
.builder-readiness h4 { margin-top: 0; }

.builder-health-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.8rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(135deg, #121215 0%, rgba(16, 185, 129, 0.12) 100%);
}

.builder-health-score {
    display: flex;
    width: 76px;
    height: 76px;
    border: 4px solid var(--accent);
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent-ink);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.builder-health-score span {
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.builder-health-score strong {
    color: var(--ink);
    font-size: 1.2rem;
    line-height: 1;
}

.builder-health-score small {
    color: var(--muted);
    font-size: 0.68rem;
}

.builder-health-metrics {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.builder-health-metrics span {
    display: inline-flex;
    gap: 0.25rem;
    align-items: baseline;
    padding: 0.38rem 0.55rem;
    border-radius: 999px;
    background: rgba(18, 18, 21, 0.78);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.builder-health-card p {
    grid-column: 2;
    margin: -0.25rem 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

@media (max-width: 860px) {
    .readiness-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .submission-readiness-heading { flex-direction: column; }
    .builder-health-card {
        grid-template-columns: 1fr;
    }
    .builder-health-score {
        width: 68px;
        height: 68px;
    }
    .builder-health-card p {
        grid-column: auto;
    }
}

/* Detailed Report content area */
.dashboard-content {
    max-width: 860px; /* Cap visual width */
}

.report-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
    max-width: 860px;
}

.report-title-meta {
    max-width: 600px;
}

.report-title-meta h2 {
    font-size: 1.35rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: var(--ink);
    word-break: break-all;
    letter-spacing: -0.3px;
}

.report-title-meta p {
    color: var(--muted);
    font-size: 0.85rem;
}

/* Detail sub-tab list */
.detail-tabs {
    display: flex;
    gap: 0.25rem;
    background: #121215;
    border-radius: 8px;
    padding: 0.2rem;
    width: fit-content;
    margin-bottom: 1.5rem;
    border: 1px solid var(--line);
    max-width: 860px;
}

.detail-tab-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 0.45rem 1rem;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color var(--motion-fast), color var(--motion-fast);
    border-radius: 6px;
    border-bottom: none;
    margin-bottom: 0;
}

.detail-tab-btn:hover {
    color: var(--ink);
}

.detail-tab-btn.active {
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    border-bottom: none;
}

.detail-pane {
    animation: fadeIn 0.15s ease-out;
}

/* Stripe styled Check Summary Panel */
.wtc-panel {
    background: var(--blue-soft);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-left: 4px solid var(--blue);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    max-width: 860px;
    box-shadow: var(--shadow-sm);
}

.wtc-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--blue-ink);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wtc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wtc-item {
    font-size: 0.9rem;
    color: var(--ink);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    line-height: 1.45;
}

.wtc-bullet {
    color: var(--blue);
    font-weight: bold;
}

/* Minimal Concentric Quality Gauge */
.score-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.score-circle {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(var(--score-color) calc(var(--score) * 1%), #121215 0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-circle::after {
    content: '';
    position: absolute;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--surface);
}

.score-circle-text {
    position: relative;
    z-index: 10;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    font-family: monospace;
}

.score-circle-text span {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
}

.gauge-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

/* Linear-style Flaws / Pitfalls tracker */
.pitfalls-section {
    margin-bottom: 2rem;
    max-width: 860px;
}

.pitfalls-section h3 {
    margin-bottom: 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
}

.pitfall-cards-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pitfall-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--severity-color, var(--line));
    border-radius: 8px; /* Clean rectangular rounded cards */
    padding: 1.25rem;
    transition: border-color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast);
    max-width: 860px;
    display: grid;
    gap: 0.65rem;
    box-shadow: var(--shadow-sm);
}

.pitfall-card:hover {
    border-color: #3f3f46;
}

.pitfall-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pitfall-title-id {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ink);
}

.severity-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.severity-high {
    background: var(--danger-soft);
    color: var(--danger-ink);
    border-color: rgba(239, 68, 68, 0.15);
}

.severity-medium {
    background: var(--warning-soft);
    color: var(--warning-ink);
    border-color: rgba(245, 158, 11, 0.15);
}

.severity-low {
    background: var(--success-soft);
    color: var(--success-ink);
    border-color: rgba(16, 185, 129, 0.15);
}

.pitfall-issue {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.5;
}

.pitfall-improvement {
    font-size: 0.88rem;
    background: var(--success-soft);
    padding: 0.65rem 1rem;
    border-radius: 6px;
    border: 1px solid rgba(16, 185, 129, 0.1);
    color: var(--success-ink);
    line-height: 1.45;
}

/* Detailed Critique Markdown accordion */
.critique-section h3 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
}

.empty-state {
    text-align: center;
    padding: 4.5rem 2rem;
    color: var(--muted);
}

.empty-state p {
    font-size: 0.95rem;
}

/* Results & Chat Area */
.result-area {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--line);
}

.result-area h3 {
    margin-bottom: 1rem;
    color: var(--ink);
    font-weight: 600;
}

/* Search list */
.search-box {
    display: flex;
    gap: 0.5rem;
}

.results-list {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-item {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.search-item h4 {
    margin-bottom: 0.25rem;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.95rem;
}

.search-item .meta {
    font-size: 0.8rem;
    color: var(--accent-ink);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.search-item p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Chat Layout */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 560px;
    padding: 1rem !important;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1rem;
}

.chat-msg {
    max-width: 80%;
    padding: 0.75rem 1.15rem;
    border-radius: 8px;
    line-height: 1.5;
    font-size: 0.92rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--accent-soft);
    color: var(--accent-ink);
    border-color: rgba(16, 185, 129, 0.15);
    border-bottom-right-radius: 2px;
}

.chat-msg.agent {
    align-self: flex-start;
    background: var(--surface);
    color: var(--ink);
    border-bottom-left-radius: 2px;
}

/* Settings */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.message-box {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 1rem;
    border: 1px solid transparent;
}

.message-box.success {
    background: var(--success-soft);
    color: var(--success-ink);
    border-color: rgba(16, 185, 129, 0.15);
}

.message-box.error {
    background: var(--danger-soft);
    color: var(--danger-ink);
    border-color: rgba(239, 68, 68, 0.15);
}

/* Standard inline error box (JS-rendered, form-local failures) */
.inline-error-box {
    padding: 1rem 1.25rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--danger);
    border-radius: 8px;
    background: var(--danger-soft);
    color: var(--danger-ink);
    font-size: 0.9rem;
    line-height: 1.5;
}

.inline-error-box h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    color: var(--danger-ink);
}

/* Markdown Rendering in B2B SaaS theme */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--ink);
    font-weight: 600;
}
.markdown-body h1 { font-size: 1.35rem; border-bottom: 1px solid var(--line); padding-bottom: 0.3rem;}
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1rem; }
.markdown-body p { margin-bottom: 0.85rem; line-height: 1.6; color: var(--ink); max-width: 760px; font-size: 0.95rem; }
.markdown-body ul { margin-left: 1.25rem; margin-bottom: 0.85rem; max-width: 760px; }
.markdown-body li { margin-bottom: 0.25rem; line-height: 1.6; font-size: 0.95rem; }
.markdown-body strong { color: var(--ink); font-weight: 600; }
.markdown-body code {
    background: #121215;
    color: var(--ink);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.85rem;
    border: 1px solid var(--line);
}
.markdown-body pre {
    background: #121215;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    max-width: 760px;
}
.markdown-body pre code {
    background: transparent;
    padding: 0;
    border: none;
    font-size: 0.83rem;
}
.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    background: var(--surface-soft);
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
    color: var(--muted);
    font-style: italic;
    border-radius: 0 6px 6px 0;
    max-width: 760px;
}
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    max-width: 760px;
}
.markdown-body th, .markdown-body td {
    border: 1px solid var(--line);
    padding: 0.5rem 0.75rem;
    text-align: left;
}
.markdown-body th {
    background: #121215;
    font-weight: 600;
}
.markdown-body tr:nth-child(even) {
    background: rgba(18, 18, 21, 0.5);
}

/* Responsive Grid Control */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        align-items: stretch;
        height: auto;
        max-height: none;
        overflow: visible;
    }
    /* Sidebar becomes an off-canvas drawer. visibility:hidden (scoped to this
       media query only) keeps the off-canvas nav links out of the tab order,
       so keyboard focus can never land on a hidden link. */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(80vw, 300px);
        height: 100%;
        padding: 1.5rem 1rem;
        flex-direction: column;
        align-items: stretch;
        border-right: 1px solid var(--line);
        border-bottom: 0;
        box-shadow: 6px 0 28px rgba(24, 24, 27, 0.16);
        z-index: 1000;
        overflow-y: auto;
        transform: translateX(-100%);
        visibility: hidden;
        /* Closing is decorative once navigation restores the main content. */
        pointer-events: none;
        transition: transform var(--motion-base) var(--ease-out), visibility var(--motion-base);
    }
    body.drawer-open .sidebar {
        transform: none;
        visibility: visible;
        pointer-events: auto;
    }
    .logo {
        display: flex;
    }
    .sidebar-spacer {
        display: none;
    }
    .nav-links {
        flex-direction: column;
        gap: 0.2rem;
    }
    .nav-links li {
        min-height: 44px;
    }

    /* Scrim overlay + hamburger trigger */
    .nav-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 999;
        background: rgba(24, 24, 27, 0.4);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity var(--motion-base), visibility var(--motion-base);
    }
    body.drawer-open .nav-scrim {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    .nav-toggle-btn {
        display: inline-flex;
    }

    .main-content {
        padding: 0.75rem 1rem 2rem;
        overflow-y: visible;
    }
    .top-bar {
        position: static;
        margin-bottom: 1rem;
        padding: 0.5rem 0;
        gap: 0.5rem;
        overflow: visible;
    }
    .top-bar-right {
        flex: 1 1 100%;
        min-width: 0;
        justify-content: flex-end;
    }
    .industry-selector-container {
        min-width: 0;
        margin-right: 0 !important;
    }
    #global-industry-select {
        max-width: 145px;
    }
    header {
        margin-bottom: 1.25rem;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   8D Stepper & Filter Pill Styles (Neurodivergent/AuDHD Friendly)
   ========================================================================== */
.stepper-card {
    padding: 1.25rem 1.5rem !important;
    margin-bottom: 1.5rem;
    max-width: 860px;
}

.stepper-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stepper-flow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    position: relative;
    padding: 0.5rem 0;
}

.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    z-index: 10;
    transition: transform 0.2s ease;
    user-select: none;
    width: 72px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
}

.stepper-step:hover {
    transform: scale(1.05);
}

.step-circle-wrapper {
    position: relative;
    width: 42px;
    height: 42px;
    margin-bottom: 0.5rem;
}

.step-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    border: 2px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    transition: background-color var(--motion-base), border-color var(--motion-base), color var(--motion-base), box-shadow var(--motion-base), transform var(--motion-base);
}

.step-status-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    color: #f4f4f5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.step-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    text-align: center;
    white-space: nowrap;
}

.step-count-badge {
    position: absolute;
    bottom: 22px;
    background: var(--danger);
    color: white;
    font-size: 0.62rem;
    font-weight: bold;
    padding: 0.05rem 0.35rem;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Connective Line */
.stepper-line {
    flex: 1;
    height: 2px;
    background: var(--line);
    margin: 0 -8px;
    margin-top: -24px;
    z-index: 5;
}

/* Stepper Status Coloring */
.stepper-step.status-success .step-circle {
    border-color: var(--success);
    background: var(--success-soft);
    color: var(--success-ink);
}
.stepper-step.status-success .step-status-badge {
    background: var(--success);
}
.stepper-step.status-success .step-label {
    color: var(--success-ink);
}

.stepper-step.status-warning .step-circle {
    border-color: var(--warning);
    background: var(--warning-soft);
    color: var(--warning-ink);
}
.stepper-step.status-warning .step-status-badge {
    background: var(--warning);
}
.stepper-step.status-warning .step-label {
    color: var(--warning-ink);
}

.stepper-step.status-error .step-circle {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger-ink);
}
.stepper-step.status-error .step-status-badge {
    background: var(--danger);
}
.stepper-step.status-error .step-label {
    color: var(--danger-ink);
}

/* Connecting line highlight based on success/error */
.stepper-line.line-success {
    background: var(--success);
}
.stepper-line.line-warning {
    background: var(--warning);
}
.stepper-line.line-error {
    background: var(--danger);
}

/* Filters for Pitfalls */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-pills {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.filter-pill {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}

.filter-pill:hover {
    background: #121215;
    border-color: #3f3f46;
    color: var(--ink);
}

.filter-pill.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* ==========================================================================
   Severity Distribution Segmented Bar
   ========================================================================== */
.severity-dist-container {
    margin-top: 0.75rem;
    max-width: 450px;
    margin-bottom: 0.5rem;
}

.severity-dist-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.severity-dist-legend {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.high { background: var(--danger); }
.legend-dot.medium { background: var(--warning); }
.legend-dot.low { background: var(--success); }

.severity-dist-bar {
    display: flex;
    height: 8px;
    background: #1c1c21;
    border-radius: 4px;
    overflow: hidden;
}

.dist-segment {
    height: 100%;
}

.dist-segment.high { background: var(--danger); }
.dist-segment.medium { background: var(--warning); }
.dist-segment.low { background: var(--success); }

/* ==========================================================================
   12 Deadly Pitfalls Checkup Checklist Grid
   ========================================================================== */
.checklist-card {
    padding: 1.25rem 1.5rem !important;
    margin-top: 1.5rem;
    max-width: 860px;
}

.checklist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checklist-card-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.checklist-subtitle {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
    font-style: italic;
}

.checklist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

.checklist-item {
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: background-color var(--motion-base), border-color var(--motion-base), color var(--motion-base), box-shadow var(--motion-base), transform var(--motion-base);
    user-select: none;
}

.checklist-item.passed {
    background: var(--success-soft);
    border-color: rgba(16, 185, 129, 0.15);
    color: var(--success-ink);
}

.checklist-item.failed-medium {
    background: var(--warning-soft);
    border-color: rgba(245, 158, 11, 0.15);
    color: var(--warning-ink);
    cursor: pointer;
}

.checklist-item.failed-medium:hover {
    transform: translateY(-1px);
    border-color: var(--warning);
    box-shadow: var(--shadow-sm);
}

.checklist-item.failed-high {
    background: var(--danger-soft);
    border-color: rgba(239, 68, 68, 0.15);
    color: var(--danger-ink);
    cursor: pointer;
}

.checklist-item.failed-high:hover {
    transform: translateY(-1px);
    border-color: var(--danger);
    box-shadow: var(--shadow-sm);
}

.checklist-item-title {
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
}

.checklist-item-status {
    font-size: 0.65rem;
    font-weight: 700;
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   Goblin.tools Magic Breakdown Styles (AuDHD/ADHD Friendly)
   ========================================================================== */
.goblin-action-area {
    margin-top: 1rem;
    border-top: 1px dashed var(--line);
    padding-top: 1rem;
}

.goblin-btn {
    background: var(--accent-soft);
    border: 1px solid rgba(16, 185, 129, 0.15);
    color: var(--accent-ink);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.goblin-btn:hover {
    background: var(--accent-fill);
    color: var(--surface);
    border-color: var(--accent-fill);
}

.goblin-container {
    margin-top: 1rem;
    background: #121215; /* Soft warm daydream cream background */
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem;
    animation: calmSlideDown 0.2s ease-out;
}

.goblin-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Progress Tracker */
.goblin-progress-wrapper {
    margin-bottom: 1rem;
}

.goblin-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.goblin-progress-percent {
    font-family: monospace;
    font-weight: 700;
    color: var(--accent-ink);
}

.goblin-progress-bar-bg {
    height: 6px;
    background: #1c1c21;
    border-radius: 3px;
    overflow: hidden;
}

.goblin-progress-bar-fill {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 0.25s ease-out;
}

/* Horizontal Visual Stepper Dot Flow */
.goblin-visual-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding: 0 0.5rem;
}

.goblin-stepper-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    transition: opacity var(--motion-base), transform var(--motion-base);
}

.goblin-dot-circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--muted);
}

.goblin-dot-emoji {
    font-size: 0.85rem;
    opacity: 0.3;
    transition: opacity var(--motion-base), transform var(--motion-base);
    margin-top: 2px;
}

.goblin-stepper-line {
    flex: 1;
    height: 2px;
    background: var(--line);
    margin: 0 -4px;
    margin-top: -16px;
    z-index: 5;
    transition: background 0.2s ease;
}

.goblin-stepper-dot.completed .goblin-dot-circle {
    border-color: var(--success);
    background: var(--success-soft);
    color: var(--success-ink);
}

.goblin-stepper-dot.completed .goblin-dot-emoji {
    opacity: 1;
}

.goblin-stepper-line.completed {
    background: var(--success);
}

/* Visual Checklist Cards Grid */
.goblin-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.goblin-step-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color var(--motion-base), border-color var(--motion-base), box-shadow var(--motion-base), transform var(--motion-base);
}

.goblin-step-card:hover {
    border-color: var(--accent);
    background: #121215;
}

.goblin-step-card.completed {
    background: var(--success-soft);
    border-color: rgba(16, 185, 129, 0.15);
}

.goblin-card-checkbox-area {
    display: flex;
    align-items: center;
}

.goblin-card-checkbox-area input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--success);
}

.goblin-card-num {
    font-family: monospace;
    font-weight: 700;
    font-size: 0.9rem;
    color: #a1a1aa;
    user-select: none;
}

.goblin-step-card.completed .goblin-card-num {
    color: rgba(6, 95, 70, 0.4);
}

.goblin-card-icon {
    font-size: 1.2rem;
    user-select: none;
}

.goblin-card-content {
    flex: 1;
}

.goblin-step-text {
    font-size: 0.85rem;
    color: var(--ink);
    line-height: 1.4;
    transition: color var(--motion-base), opacity var(--motion-base);
}

.goblin-step-text.completed {
    text-decoration: line-through;
    color: var(--muted);
    opacity: 0.7;
}

/* Loading & Error States */
.goblin-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--muted);
    padding: 1rem 0;
}

.goblin-spinner {
    display: inline-block;
    opacity: 0.75;
    transition: opacity 0.16s ease;
}

.goblin-error {
    color: var(--danger);
    font-size: 0.82rem;
    padding: 0.5rem 0;
}

@keyframes calmSlideDown {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Visual 4-Step Explanation Breakdown Flow */
.visual-breakdown-flow {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1.25rem;
    background: var(--surface-soft);
    border-radius: 12px;
    border: 1px solid var(--line);
}

.visual-breakdown-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ==========================================================================
   Visual 3-Step Explanation Deck Card Layout (Amber/Red/Green)
   ========================================================================== */
.deck-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.deck-card {
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.deck-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.deck-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.deck-icon {
    font-size: 1.05rem;
}

.deck-text {
    font-size: 0.9rem;
    line-height: 1.55;
    color: #d4d4d8; /* Dark charcoal */
}

/* Specific Card Colors */
.deck-card.process-gap {
    background-color: rgba(245, 158, 11, 0.12); /* Light Amber */
    border-color: rgba(245, 158, 11, 0.25);
}

.deck-card.process-gap .deck-title {
    color: #b45309; /* Dark Amber */
}

.deck-card.small-changes {
    background-color: rgba(255, 26, 92, 0.12); /* Light Red */
    border-color: rgba(239, 68, 68, 0.2);
}

.deck-card.small-changes .deck-title {
    color: #b91c1c; /* Dark Red */
}

.deck-card.corrected-example {
    background-color: rgba(16, 185, 129, 0.12); /* Light Green */
    border-color: rgba(16, 185, 129, 0.2);
}

.deck-card.corrected-example .deck-title {
    color: #34d399; /* Dark Green */
}

/* Corrected checkbox square wrapper */
.corrected-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.corrected-checkbox {
    width: 18px;
    height: 18px;
    background-color: #10b981; /* Green square */
    color: #f4f4f5;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 900;
    line-height: 1;
}

/* Dark Code Block inside Corrected Example */
.deck-code-container {
    background-color: #0c0c0f; /* Slate 900 */
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin-top: 0.65rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    overflow-x: auto;
}

.deck-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.85rem;
    color: #f4f4f5; /* Slate 100 text */
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
    margin: 0;
}

/* Vertical Flow Arrows */
.deck-arrow {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #a1a1aa; /* Slate 400 */
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    margin: 0.15rem 0;
    opacity: 0.75;
}

/* ==========================================================================
   Off-canvas Drawer for 8D Reference Blueprint
   ========================================================================== */
.blueprint-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    visibility: hidden;
    transition: visibility 0.3s ease;
}

.blueprint-drawer.active {
    visibility: visible;
}

.drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(24, 24, 27, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.blueprint-drawer.active .drawer-overlay {
    opacity: 1;
}

.drawer-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 100%;
    background: var(--surface);
    box-shadow: -4px 0 24px rgba(24, 24, 27, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
}

.blueprint-drawer.active .drawer-content {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.drawer-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.4;
}

.close-drawer-btn {
    background: transparent;
    border: none;
    font-size: 1.75rem;
    font-weight: 300;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
    transition: color 0.15s ease;
}

.close-drawer-btn:hover {
    color: var(--danger);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.drawer-intro {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
    line-height: 1.4;
    font-style: italic;
    border-bottom: 1px dashed var(--line);
    padding-bottom: 0.75rem;
}

/* 8D Blueprint Step Nodes Flow */
.blueprint-flow {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.blueprint-step-node {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    text-align: left;
}

.blueprint-step-node .node-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.35rem;
}

.blueprint-step-node .node-num {
    font-family: monospace;
    font-weight: 800;
    font-size: 0.85rem;
    background: var(--accent-soft);
    color: var(--accent-ink);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
}

.blueprint-step-node .node-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink);
}

.blueprint-step-node .node-desc {
    font-size: 0.8rem;
    color: #d4d4d8;
}

.blueprint-step-node .node-desc ul {
    margin: 0;
    padding-left: 1.15rem;
    line-height: 1.5;
}

.blueprint-step-node .node-desc li {
    margin-bottom: 0.35rem;
}

.blueprint-step-node .node-desc li:last-child {
    margin-bottom: 0;
}

.node-avoid {
    color: var(--danger);
    font-weight: 600;
}

.blueprint-flow-arrow {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #a1a1aa;
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0.1rem 0;
    opacity: 0.6;
}

/* Color theme overrides for specific steps for visual cueing (Glanceability) */
.blueprint-step-node.d1-node {
    border-left: 4px solid #10b981; /* Emerald */
}
.blueprint-step-node.d2-node {
    border-left: 4px solid #f59e0b; /* Amber */
}
.blueprint-step-node.d3-node {
    border-left: 4px solid #ef4444; /* Red */
}
.blueprint-step-node.d4-node {
    border-left: 4px solid #f59e0b; /* Amber */
}
.blueprint-step-node.d5-node {
    border-left: 4px solid #10b981; /* Green */
}
.blueprint-step-node.d6-node {
    border-left: 4px solid #f59e0b; /* Amber */
}
.blueprint-step-node.d7-node {
    border-left: 4px solid #a1a1aa; /* Purple */
}
.blueprint-step-node.d8-node {
    border-left: 4px solid #ec4899; /* Pink */
}

/* Dashboard Blueprint Accordion */
.dashboard-blueprint-accordion {
    margin-top: 1.5rem;
    max-width: 860px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.accordion-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.25rem;
    background: var(--surface-soft);
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.accordion-toggle:hover {
    background: #121215;
}

.accordion-content {
    padding: 1.25rem;
    border-top: 1px solid var(--line);
    background: var(--surface);
    animation: calmSlideDown 0.2s ease-out;
}

.dashboard-blueprint-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}

.dashboard-blueprint-item {
    padding: 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    text-align: left;
}

.dashboard-blueprint-item.d1 { border-left: 3px solid #10b981; }
.dashboard-blueprint-item.d2 { border-left: 3px solid #f59e0b; }
.dashboard-blueprint-item.d3 { border-left: 3px solid #ef4444; }
.dashboard-blueprint-item.d4 { border-left: 3px solid #f59e0b; }
.dashboard-blueprint-item.d5 { border-left: 3px solid #10b981; }
.dashboard-blueprint-item.d6 { border-left: 3px solid #f59e0b; }
.dashboard-blueprint-item.d7 { border-left: 3px solid #a1a1aa; }
.dashboard-blueprint-item.d8 { border-left: 3px solid #ec4899; }

.dashboard-blueprint-item .item-header {
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--ink);
}

.dashboard-blueprint-item .item-body {
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--muted);
}

.danger-highlight {
    color: var(--danger);
    font-weight: 600;
}

.success-highlight {
    color: var(--success-ink);
    font-weight: 600;
}


/* Dashboard D1-D8 Separation Card */
.d1d8-knowledge-card {
    background: var(--accent-soft);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    max-width: 860px;
    box-shadow: var(--shadow-sm);
}

.d1d8-knowledge-card h4 {
    color: var(--accent-strong);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.d1d8-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.d1d8-card-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.d1d8-card-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.d1d8-card-item.d1 { border-top: 3px solid #10b981; }
.d1d8-card-item.d2 { border-top: 3px solid #f59e0b; }
.d1d8-card-item.d3 { border-top: 3px solid #f59e0b; }
.d1d8-card-item.d4 { border-top: 3px solid #10b981; }
.d1d8-card-item.d5 { border-top: 3px solid #a1a1aa; }
.d1d8-card-item.d6 { border-top: 3px solid #f59e0b; }
.d1d8-card-item.d7 { border-top: 3px solid #f97316; }
.d1d8-card-item.d8 { border-top: 3px solid #ec4899; }

.d1d8-card-icon {
    font-size: 1.6rem;
    line-height: 1;
    margin-bottom: 0.3rem;
}

.d1d8-card-title {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--ink);
}

.d1d8-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}

/* Pill tags for dashboard cards */
.dtag {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}
.dtag.do {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.dtag.dont {
    background: rgba(239, 68, 68, 0.10);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.dtag.special {
    background: rgba(16, 185, 129, 0.10);
    color: var(--accent-ink);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.d1d8-card-desc {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.45;
}

.d5d8-warning-note {
    background: rgba(239, 68, 68, 0.05);
    border: 1px dashed rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
    color: var(--danger-ink);
    margin-top: 1.25rem;
    line-height: 1.45;
}

/* Blueprint Warning Callout in Drawer */
.blueprint-warning-callout {
    background: var(--danger-soft);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-left: 4px solid var(--danger);
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--danger-ink);
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.blueprint-warning-callout .callout-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.blueprint-warning-callout .zh-callout {
    display: block;
    margin-top: 0.5rem;
    border-top: 1px dashed rgba(239, 68, 68, 0.2);
    padding-top: 0.5rem;
}

/* ===== Language Visibility Toggle ===== */
/* Default: show English, hide Chinese */
body .lang-zh { display: none !important; }
body.lang-zh .lang-zh { display: inline !important; }
body.lang-zh .lang-en { display: none !important; }
body.lang-en .lang-en { display: inline !important; }
body.lang-en .lang-zh { display: none !important; }

/* ===== Zigzag Visual Timeline ===== */
.zigzag-timeline {
    position: relative;
    padding: 1.5rem 0;
}
/* Central vertical connector line */
.zigzag-timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom,
        var(--d1, #10b981),
        var(--d2, #f59e0b),
        var(--d3, #f59e0b),
        var(--d4, #10b981),
        var(--d5, #a1a1aa),
        var(--d6, #f59e0b),
        var(--d7, #f97316),
        var(--d8, #ec4899));
    border-radius: 2px;
    transform: translateX(-50%);
}

.zigzag-step {
    display: flex;
    align-items: flex-start;
    position: relative;
    margin-bottom: 0.75rem;
    width: 50%;
}
.zigzag-step.left {
    margin-right: auto;
    padding-right: 2rem;
    justify-content: flex-end;
}
.zigzag-step.right {
    margin-left: auto;
    padding-left: 2rem;
    justify-content: flex-start;
}

/* Horizontal connector dot */
.zigzag-connector {
    position: absolute;
    top: 1.5rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--paper-bg, rgba(245, 158, 11, 0.12));
    border: 3px solid rgba(16, 185, 129, 0.5);
    z-index: 2;
}
.zigzag-step.left .zigzag-connector {
    right: -6px;
}
.zigzag-step.right .zigzag-connector {
    left: -6px;
}

/* Card */
.zigzag-card {
    background: var(--paper-bg, rgba(245, 158, 11, 0.12));
    border-radius: 14px;
    padding: 1rem 1.2rem;
    border-left: 4px solid transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    text-align: center;
    min-width: 170px;
    max-width: 240px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.zigzag-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.10);
}

/* Color accents per step */
.zigzag-card.d1-accent { border-left-color: #10b981; }
.zigzag-card.d2-accent { border-left-color: #f59e0b; }
.zigzag-card.d3-accent { border-left-color: #f59e0b; }
.zigzag-card.d4-accent { border-left-color: #10b981; }
.zigzag-card.d5-accent { border-left-color: #a1a1aa; }
.zigzag-card.d6-accent { border-left-color: #f59e0b; }
.zigzag-card.d7-accent { border-left-color: #f97316; }
.zigzag-card.d8-accent { border-left-color: #ec4899; }

/* Connector dot color matching */
.zigzag-step:nth-child(1) .zigzag-connector { border-color: #10b981; }
.zigzag-step:nth-child(2) .zigzag-connector { border-color: #f59e0b; }
.zigzag-step:nth-child(3) .zigzag-connector { border-color: #f59e0b; }
.zigzag-step:nth-child(4) .zigzag-connector { border-color: #10b981; }
.zigzag-step:nth-child(5) .zigzag-connector { border-color: #a1a1aa; }
.zigzag-step:nth-child(6) .zigzag-connector { border-color: #f59e0b; }
.zigzag-step:nth-child(7) .zigzag-connector { border-color: #f97316; }
.zigzag-step:nth-child(8) .zigzag-connector { border-color: #ec4899; }

/* Step number badge */
.zigzag-badge {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f4f4f5;
    letter-spacing: 0.02em;
}
.d1-accent .zigzag-badge { background: #10b981; }
.d2-accent .zigzag-badge { background: #f59e0b; }
.d3-accent .zigzag-badge { background: #f59e0b; }
.d4-accent .zigzag-badge { background: #10b981; }
.d5-accent .zigzag-badge { background: #a1a1aa; }
.d6-accent .zigzag-badge { background: #f59e0b; }
.d7-accent .zigzag-badge { background: #f97316; }
.d8-accent .zigzag-badge { background: #ec4899; }

/* Large icon */
.zigzag-icon-large {
    font-size: 1.8rem;
    line-height: 1;
    margin-bottom: 0.3rem;
}

/* Label */
.zigzag-label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary, #f4f4f5);
    margin-bottom: 0.4rem;
}

/* Pill tags */
.zigzag-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}
.ztag {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}
.ztag.do {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.ztag.dont {
    background: rgba(239, 68, 68, 0.10);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.ztag.special {
    background: rgba(16, 185, 129, 0.10);
    color: var(--accent-ink);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Last step: no bottom margin */
.zigzag-step.last {
    margin-bottom: 0;
}

/* ===== Responsive: stack on narrow drawer ===== */
@media (max-width: 640px) {
    .zigzag-timeline::before {
        left: 20px;
    }
    .zigzag-step,
    .zigzag-step.left,
    .zigzag-step.right {
        width: 100%;
        padding-left: 3rem;
        padding-right: 0;
        margin-left: 0;
        margin-right: 0;
        justify-content: flex-start;
    }
    .zigzag-step.left .zigzag-connector,
    .zigzag-step.right .zigzag-connector {
        left: 14px;
        right: auto;
    }
    .zigzag-card {
        max-width: 100%;
        text-align: left;
    }
    .zigzag-tags {
        justify-content: flex-start;
    }
}

/* ===== 8D Reference Drawer ===== */
/* The launcher is an in-flow toolbar button, never an overlay on case actions.
   Only the intentionally opened reference drawer uses fixed positioning. */
.ref-open-tab {
    position: static;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(18, 18, 21, 0.94);
    color: var(--ink);
    box-shadow: none;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.ref-open-tab:hover {
    border-color: var(--accent-line);
    color: var(--accent-ink);
    background: #121215;
}

.ref-open-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 0.66rem;
    font-weight: 850;
    letter-spacing: 0;
}

.reference-panel {
    position: fixed;
    right: 18px;
    top: 72px;
    bottom: 18px;
    z-index: 990;
    width: min(360px, calc(100vw - 36px));
    background: #121215;
    border: 1px solid var(--line);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    box-shadow: 0 24px 60px rgba(24, 24, 27, 0.20);
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    transition: transform 0.22s ease, opacity 0.18s ease, box-shadow 0.22s ease;
}

.reference-panel.collapsed {
    transform: translateX(calc(100% + 32px));
    opacity: 0;
    pointer-events: none;
}

.ref-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1rem 0.85rem;
    border-bottom: 1px solid var(--line);
    background: #121215;
    flex-shrink: 0;
}

.ref-panel-kicker {
    color: var(--accent-ink);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin: 0 0 0.18rem;
    text-transform: uppercase;
}

.ref-panel-header h3 {
    font-size: 1.02rem;
    font-weight: 750;
    margin: 0;
    color: var(--ink);
    letter-spacing: 0;
}

.ref-panel-toggle {
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #121215;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--muted);
}

.ref-panel-toggle:hover {
    color: var(--ink);
    background: #121215;
}

.ref-panel-body {
    overflow-y: auto;
    padding: 0.85rem;
    flex-grow: 1;
    background: #121215;
}

.ref-panel-intro {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
    margin: 0 0 0.85rem;
    line-height: 1.45;
}

.ref-flow {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.ref-step {
    border-radius: 8px;
    padding: 0.65rem 0.7rem;
    background: #121215;
    border: 1px solid var(--line);
    border-left: 3px solid transparent;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    column-gap: 0.55rem;
    row-gap: 0.22rem;
    position: relative;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.ref-step:hover,
.ref-step:focus-visible {
    transform: translateY(-1px);
    border-color: #3f3f46;
    box-shadow: 0 8px 22px rgba(24, 24, 27, 0.08);
}

/* Step colors */
.ref-step.d1-accent { border-left-color: #10b981; }
.ref-step.d2-accent { border-left-color: #f59e0b; }
.ref-step.d3-accent { border-left-color: #f59e0b; }
.ref-step.d4-accent { border-left-color: #10b981; }
.ref-step.d5-accent { border-left-color: #a1a1aa; }
.ref-step.d6-accent { border-left-color: #f59e0b; }
.ref-step.d7-accent { border-left-color: #f97316; }
.ref-step.d8-accent { border-left-color: #ec4899; }

.ref-num {
    font-size: 0.65rem;
    font-weight: 800;
    color: #f4f4f5;
    background: var(--line);
    border-radius: 4px;
    padding: 2px 6px;
    flex-shrink: 0;
    min-width: 24px;
    text-align: center;
}
.d1-accent .ref-num { background: #10b981; }
.d2-accent .ref-num { background: #f59e0b; }
.d3-accent .ref-num { background: #f59e0b; }
.d4-accent .ref-num { background: #10b981; }
.d5-accent .ref-num { background: #a1a1aa; }
.d6-accent .ref-num { background: #f59e0b; }
.d7-accent .ref-num { background: #f97316; }
.d8-accent .ref-num { background: #ec4899; }

.ref-name {
    font-weight: 700;
    font-size: 0.84rem;
    color: var(--ink);
    line-height: 1.3;
    grid-column: 2;
}

.ref-summary {
    margin: 0;
    grid-column: 2;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.4;
}

.ref-warning {
    margin-top: 0.85rem;
    padding: 0.62rem 0.7rem;
    background: var(--warning-soft);
    border: 1px solid #fde68a;
    border-radius: 8px;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--warning-ink);
}

@media (max-width: 900px) {
    .ref-open-tab {
        min-height: 44px;
    }

    .reference-panel {
        right: 10px;
        left: 10px;
        top: 64px;
        bottom: 10px;
        width: auto;
    }
}

/* ==========================================================================
   8D Builder Tab styles
   ========================================================================== */
.step-evidence-kicker {
    margin: 0 0 0.14rem;
    color: var(--accent-ink);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.builder-case-map-shell {
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.builder-case-map-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.builder-case-map-kicker,
.agent-workflow-kicker,
.d6-validation-kicker {
    margin: 0 0 0.14rem;
    color: var(--accent-ink);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.builder-case-map-header h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 750;
}

.builder-case-map-legend {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--muted);
    font-size: 0.68rem;
}

.builder-case-map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
}

.builder-case-map-legend b {
    font-weight: 600;
}

.legend-swatch {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--line);
}

.legend-swatch.drafted { background: var(--success); }
.legend-swatch.needs-info { background: var(--warning); }
.legend-swatch.empty { background: var(--danger); }

.builder-progress-bar {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (max-width: 900px) {
    .builder-progress-bar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.progress-step-btn {
    position: relative;
    min-width: 0;
    min-height: 56px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-soft);
    color: var(--ink);
    padding: 0.5rem 0.55rem 0.45rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.progress-step-btn::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: var(--line);
}

.progress-step-btn:hover {
    border-color: #3f3f46;
    background: var(--surface);
    transform: translateY(-1px);
}

/* Active chip lifts out: raised surface vs soft siblings, emerald edge + soft ring.
   The 1px box-shadow ring reads as a 1.5px accent border without a layout reflow. */
.progress-step-btn.active {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--accent), 0 6px 16px rgba(16, 185, 129, 0.12);
}

.progress-step-btn.active::before { background: var(--accent); }

/* 7px status dot — state applied at runtime via [data-state] (updateBuilderProgressDots).
   drafted = emerald fill, needs-facts = amber fill, empty = faint outline (not an error). */
.step-dot {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    border: 1.5px solid var(--faint);
    background: transparent;
    box-sizing: border-box;
}

.progress-step-btn[data-state="drafted"] .step-dot { background: var(--accent); border-color: var(--accent); }
.progress-step-btn[data-state="needs_info"] .step-dot { background: var(--warning); border-color: var(--warning); }
.progress-step-btn[data-state="empty"] .step-dot { background: transparent; border-color: var(--faint); }

/* D-number and name share a line ("D1 Team") to halve the chip height. */
.step-number,
.step-name,
.step-state,
.step-evidence {
    display: inline;
}

.step-meta {
    display: block;
}

.step-number {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.step-name {
    margin-left: 0.28rem;
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 750;
    line-height: 1.2;
}

.step-meta {
    margin-top: 0.26rem;
    color: var(--muted);
    font-size: 0.63rem;
    line-height: 1.3;
}

.step-state {
    font-weight: 700;
}

.progress-step-btn[data-state="drafted"] .step-state { color: var(--accent-ink); }
.progress-step-btn[data-state="needs_info"] .step-state { color: var(--warning-ink); }
.progress-step-btn[data-state="empty"] .step-state { color: var(--subtle); }

/* "0 sources" repeated on eight empty chips is noise; the count only appears
   once updateBuilderProgressDots() marks the chip .has-source. */
.step-evidence {
    display: none;
    color: var(--muted);
}

.progress-step-btn.has-source .step-evidence {
    display: inline;
    color: var(--accent-ink);
    font-weight: 700;
}

.progress-step-btn.has-source .step-evidence::before {
    content: " · ";
    color: var(--muted);
    font-weight: 400;
}

.secondary-btn {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color var(--motion-base), border-color var(--motion-base), color var(--motion-base), box-shadow var(--motion-base);
}

.secondary-btn:hover {
    background: #121215;
    border-color: #3f3f46;
}

.builder-evidence-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.builder-evidence-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.builder-stage-kicker {
    margin: 0 0 0.18rem;
    color: var(--accent-ink);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.lang-zh .builder-stage-kicker,
.lang-zh .guide-section h4 {
    text-transform: none;
    letter-spacing: 0.02em;
}

.builder-evidence-header h2 {
    margin: 0 0 0.2rem 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
}

.builder-evidence-header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.builder-file-drop {
    border: 1px dashed #3f3f46;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--surface-soft);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.builder-file-drop:hover,
.builder-file-drop.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.builder-file-drop strong {
    display: block;
    color: var(--ink);
    font-size: 0.92rem;
    margin-bottom: 0.18rem;
}

.builder-file-drop span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.builder-files-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.builder-file-row {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--bg);
}

.builder-file-row-main {
    flex: 1 1 auto;
    min-width: 0;
}

.builder-file-row-controls,
.builder-file-step-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.builder-file-row-controls {
    flex: 0 0 auto;
}

.builder-file-step-label span {
    color: var(--muted);
    font-size: 0.76rem;
    white-space: nowrap;
}

.builder-file-step-select {
    min-width: 7.2rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    padding: 0.38rem 1.8rem 0.38rem 0.55rem;
    font: inherit;
    font-size: 0.8rem;
}

.builder-file-step-select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.builder-file-row-name {
    color: var(--ink);
    font-size: 0.88rem;
    font-weight: 600;
    word-break: break-word;
}

.builder-file-row-meta {
    color: var(--muted);
    font-size: 0.76rem;
    margin-top: 0.12rem;
}

.builder-file-remove {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 5px;
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
}

.builder-file-remove:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.builder-evidence-actions {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.9rem;
    flex-wrap: wrap;
}

.builder-primary-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
}

.builder-start-blank {
    border: 0;
    background: none;
    color: var(--accent-ink);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    padding: 0;
}

.builder-start-blank:hover {
    color: var(--accent-fill);
}

#builder:not(.builder-has-draft):not(.builder-manual-start) #builder-workspace {
    display: none;
}

#builder.builder-has-draft .builder-start-blank {
    display: none;
}

.builder-workspace-lead {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.84rem;
    max-width: 40rem;
}

.builder-keep-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--accent-line);
    border-radius: 8px;
    background: var(--accent-soft);
}

.builder-keep-bar.hidden {
    display: none;
}

.builder-keep-bar p {
    margin: 0;
    color: var(--accent-ink);
    font-size: 0.84rem;
    font-weight: 600;
    flex: 1 1 16rem;
}

.builder-keep-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.builder-build-status {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.4;
}

.builder-build-status.success {
    color: var(--success-ink);
}

.builder-build-status.error {
    color: var(--danger-ink);
}

.builder-source-summary {
    margin-top: 0.9rem;
    border-top: 1px solid var(--line);
    padding-top: 0.85rem;
    color: var(--ink);
    font-size: 0.84rem;
    line-height: 1.55;
}

.builder-source-summary h4 {
    margin: 0 0 0.35rem 0;
    font-size: 0.86rem;
}

.builder-source-summary ul {
    margin: 0;
    padding-left: 1.1rem;
}

.agent-workflow-card {
    position: relative;
    margin-top: 0.85rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 0.7rem 0.8rem;
}

/* Before any run the card only restates the drop-zone instructions, so it stays
   hidden until renderAgentWorkflow() applies a run-state class. */
.agent-workflow-card:not(.is-running):not(.is-complete):not(.is-warning):not(.is-error) {
    display: none;
}

.agent-workflow-card.is-running::before {
    content: "";
    position: absolute;
    inset: 0 auto auto -35%;
    width: 35%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: agentWorkflowSweep 1.35s ease-in-out infinite;
}

@keyframes agentWorkflowSweep {
    to { transform: translateX(390%); }
}

.agent-workflow-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.agent-workflow-header h3 {
    margin: 0;
    color: var(--ink);
    font-size: 0.95rem;
}

.agent-workflow-overall {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    padding: 0.26rem 0.62rem;
    font-size: 0.7rem;
    font-weight: 750;
}

.agent-workflow-card.is-running .agent-workflow-overall {
    border-color: var(--accent-line);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.agent-workflow-card.is-complete .agent-workflow-overall {
    border-color: #a7f3d0;
    background: var(--success-soft);
    color: var(--success-ink);
}

.agent-workflow-card.is-warning .agent-workflow-overall {
    border-color: #fde68a;
    background: var(--warning-soft);
    color: var(--warning-ink);
}

.agent-workflow-card.is-error .agent-workflow-overall {
    border-color: rgba(255, 26, 92, 0.12);
    background: var(--danger-soft);
    color: var(--danger-ink);
}

.agent-workflow-track {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
    margin-top: 0.6rem;
}

.agent-workflow-step {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 0.42rem 0.55rem;
    opacity: 0.68;
    transform: translateY(4px);
    transition: border-color 0.18s ease, background-color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.agent-workflow-step.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.agent-workflow-step.is-active {
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.agent-workflow-step.is-complete { border-color: #a7f3d0; }
.agent-workflow-step.is-warning { border-color: #fde68a; }
.agent-workflow-step.is-failed { border-color: rgba(255, 26, 92, 0.12); }

.agent-workflow-index {
    color: #a1a1aa;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.agent-workflow-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.agent-workflow-copy strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-workflow-copy small {
    overflow: hidden;
    color: var(--muted);
    font-size: 0.64rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-workflow-step.is-complete small { color: var(--success-ink); }
.agent-workflow-step.is-warning small { color: var(--warning-ink); }
.agent-workflow-step.is-failed small { color: var(--danger-ink); }
.agent-workflow-step.is-active small { color: var(--accent-ink); }

.agent-workflow-note {
    margin: 0.65rem 0 0;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.4;
}

.agent-loop-blockers {
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
    color: var(--warning-ink);
    font-size: 0.72rem;
    line-height: 1.4;
}

.agent-loop-blockers[hidden] {
    display: none;
}

.builder-guide-panel .guide-section {
    margin-bottom: 1.2rem;
}

.builder-guide-more {
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.35rem 0.7rem 0.15rem;
    background: var(--surface-soft);
}

.builder-guide-more > summary {
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-ink);
    padding: 0.35rem 0 0.45rem;
    list-style: none;
}

.builder-guide-more > summary::-webkit-details-marker {
    display: none;
}

.builder-guide-more > summary::before {
    content: "▸ ";
}

.builder-guide-more[open] > summary::before {
    content: "▾ ";
}

.builder-guide-more .guide-section:last-child {
    margin-bottom: 0.7rem;
}

.builder-finish-panel {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-top: 0.4rem;
}

.builder-finish-panel[hidden] {
    display: none !important;
}

.builder-finish-clear {
    display: flex;
    justify-content: flex-end;
}

/* ==========================================================================
   De-inlined structural classes (moved out of index.html inline style="")
   ========================================================================== */
.builder-grid-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    align-items: start;
    min-height: 0;
}

.builder-guide-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-right: 1px solid var(--line);
    padding-right: 1.5rem;
}

#builder-step-header {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
}

.guide-box {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.guide-section h4 {
    margin: 0 0 4px 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--muted);
}

.guide-section > p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ink);
}

/* Pitfall warning box (tokens replace old #801818 / #ffebeb / --red) */
.builder-guide-avoid {
    margin: 0;
    padding: 8px;
    border-left: 3px solid var(--danger);
    border-radius: 4px;
    background: var(--danger-soft);
    color: var(--danger-ink);
    font-size: 0.85rem;
    line-height: 1.4;
}

.builder-editor-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

.builder-editor-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.builder-draft-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

#lbl-bld-draft-text {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
}

/* WP2 editor chip — shown only when the active step's text came from the builder agent */
.ai-draft-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--accent-line);
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.ai-draft-chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--accent);
}

/* Placeholder alert box (tokens replace old #fff9e6 / #ffcc00 / #8a6d3b) */
.builder-placeholder-alert {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-left: 4px solid var(--warning);
    border-radius: 4px;
    background: var(--warning-soft);
    color: var(--warning-ink);
    font-size: 0.85rem;
}

#builder-textarea {
    width: 100%;
    flex: 0 0 auto;
    min-height: 220px;
    height: 260px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 1rem;
    line-height: 1.6;
    outline: none;
    resize: vertical;
    box-sizing: border-box;
    background: var(--surface);
    color: var(--ink);
}

.builder-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

#bld-word-info {
    font-size: 0.8rem;
    color: var(--muted);
}

.builder-step-nav {
    display: flex;
    gap: 0.5rem;
}

.builder-step-nav .secondary-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.builder-editor-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 0.2rem;
}

.builder-editor-actions .clear-btn {
    font-size: 0.85rem;
}

.builder-verify-btn {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 6px 16px;
    font-size: 0.85rem;
}

/* Checkbox + label rows (cloud vision, internal review) */
.cloud-vision-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}

#uploaded-files-container .cloud-vision-label {
    margin-bottom: 0.75rem;
}

.export-review-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
}

/* Cases tab header row */
.cases-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.cases-header > .primary-btn {
    flex-shrink: 0;
}

/* Required-field asterisk + settings key-status pill */
.required-mark {
    color: var(--danger);
}

.key-status {
    margin-left: 0.4rem;
    font-size: 0.8rem;
    opacity: 0.85;
}

@media (max-width: 768px) {
    .builder-grid-container {
        grid-template-columns: 1fr !important;
    }
    .builder-editor-panel {
        order: 1;
    }
    .builder-guide-panel {
        order: 2;
        border-right: none !important;
        border-bottom: none;
        border-top: 1px solid var(--border-color);
        padding-right: 0 !important;
        padding-top: 1.5rem;
        padding-bottom: 0;
    }
    .builder-evidence-header,
    .builder-file-drop,
    .builder-evidence-actions,
    .builder-file-row {
        align-items: stretch;
        flex-direction: column;
    }
    .builder-primary-actions {
        width: 100%;
        align-items: stretch;
    }
    .builder-evidence-actions .primary-btn,
    .builder-file-drop .secondary-btn {
        width: 100%;
    }

    .builder-file-row-controls,
    .builder-file-step-label {
        width: 100%;
    }

    .builder-file-step-select {
        flex: 1 1 auto;
    }

    .builder-case-map-header,
    .agent-workflow-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .builder-case-map-legend {
        flex-wrap: wrap;
    }

    .builder-progress-bar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        padding-bottom: 0.4rem;
    }

    .agent-workflow-track {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ============================================================
   CASE WORKSPACE DASHBOARD — Phase 1
   ============================================================ */

.cases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.case-card {
    background: var(--card-bg, #121215);
    border: 1px solid var(--line, #27272a);
    border-radius: 12px;
    padding: 1.25rem 1.3rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.case-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 12px 12px 0 0;
    background: var(--accent, #f59e0b);
}

.case-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(24, 24, 27, 0.1);
    border-color: var(--accent, #f59e0b);
}

.case-card[data-status="Open"]::before        { background: #f59e0b; }
.case-card[data-status="In Progress"]::before { background: var(--warning); }
.case-card[data-status="Submitted"]::before   { background: #a1a1aa; }
.case-card[data-status="Closed"]::before      { background: #10b981; }

.case-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.case-number {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted, #a1a1aa);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.case-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

.status-open        { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.status-in-progress { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.status-submitted   { background: rgba(161, 161, 170, 0.12); color: #d4d4d8; }
.status-closed      { background: rgba(16, 185, 129, 0.12); color: #34d399; }

.case-customer {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink, #f4f4f5);
    line-height: 1.3;
    word-break: break-word;
}

.case-part {
    font-size: 0.78rem;
    color: var(--muted, #a1a1aa);
    font-weight: 500;
}

.case-summary {
    font-size: 0.85rem;
    color: var(--ink, #f4f4f5);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.case-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--line, #27272a);
    font-size: 0.72rem;
    color: var(--muted, #a1a1aa);
}

.case-industry-tag {
    display: inline-block;
    background: #121215;
    color: #d4d4d8;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.case-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.3rem;
}

.case-open-btn {
    flex: 1;
    padding: 7px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 7px;
    border: 1px solid var(--accent-fill, #10b981);
    background: var(--accent-fill, #059669);
    color: #f4f4f5;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.case-open-btn:hover {
    background: var(--accent-fill-hover);
    border-color: var(--accent-fill-hover);
}

.case-delete-btn {
    padding: 7px 10px;
    font-size: 0.85rem;
    border-radius: 7px;
    border: 1px solid var(--line, #27272a);
    background: transparent;
    color: var(--muted, #a1a1aa);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.case-delete-btn:hover {
    color: #ef4444;
    background: rgba(255, 26, 92, 0.12);
    border-color: #fca5a5;
}

.case-status-select {
    font-size: 0.72rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 6px;
    background: var(--card-bg);
    color: var(--ink);
    cursor: pointer;
}

.active-case-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(16, 185, 129, 0.12) 100%);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 8px;
    font-size: 0.84rem;
    color: #fbbf24;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.active-case-banner strong { font-weight: 700; }

.active-case-banner .banner-close {
    margin-left: auto;
    cursor: pointer;
    font-size: 1.1rem;
    color: #fbbf24;
    background: none;
    border: none;
    padding: 0 4px;
}

.active-case-banner .banner-close:hover { color: #fbbf24; }

.cases-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted, #a1a1aa);
}

.cases-empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.cases-empty-state h3 {
    font-size: 1.25rem;
    color: var(--ink);
    margin: 0 0 0.5rem;
}

.cases-empty-state p {
    font-size: 0.9rem;
    margin: 0 0 1.5rem;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(24, 24, 27, 0.55);
    backdrop-filter: blur(3px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: modalFadeIn 0.15s ease;
}

@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
    background: var(--card-bg, #121215);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 24px 64px rgba(24, 24, 27, 0.2);
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.18s ease;
}

@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--muted);
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
}

.modal-close:hover { background: var(--line); color: var(--ink); }

.modal-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-footer {
    padding: 0 1.5rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--card-bg);
    outline: none;
    transition: border-color 0.15s;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.form-error {
    color: #dc2626;
    font-size: 0.82rem;
    padding: 6px 10px;
    background: rgba(255, 26, 92, 0.12);
    border-radius: 6px;
    border: 1px solid #fca5a5;
}

@media (max-width: 640px) {
    .cases-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   PHASE 2 — Per-Step Confidence Card
   ============================================================ */

.step-confidence-card {
    border: 1px solid var(--line, #27272a);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    background: var(--card-bg, #121215);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    font-size: 0.84rem;
    margin-bottom: 6px;
    animation: confCardIn 0.2s ease;
}

@keyframes confCardIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.conf-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.conf-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.conf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.conf-risk {
    font-size: 0.78rem;
    font-weight: 600;
}

.conf-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--muted, #a1a1aa);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.conf-dismiss:hover { background: var(--line); color: var(--ink); }

.conf-note {
    font-size: 0.82rem;
    color: var(--ink, #f4f4f5);
    line-height: 1.5;
    padding: 6px 10px;
    background: #121215;
    border-left: 3px solid #52525b;
    border-radius: 4px;
}

.conf-sources {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.conf-sources-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted, #a1a1aa);
    white-space: nowrap;
    padding-top: 2px;
}

.conf-source-tag {
    display: inline-block;
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conf-source-none {
    background: #121215;
    color: #a1a1aa;
    border-color: #27272a;
}

.conf-missing-list {
    font-size: 0.81rem;
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid #fde68a;
    border-radius: 7px;
    padding: 8px 12px;
    line-height: 1.5;
}

.conf-missing-list ul {
    margin: 6px 0 0 1rem;
    padding: 0;
}

.conf-missing-list li {
    margin-bottom: 2px;
}

.step-evidence-trace {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    padding: 0.8rem 0.9rem;
    margin-bottom: 0.35rem;
}

.step-evidence-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.step-evidence-header h3 {
    margin: 0;
    color: var(--ink);
    font-size: 0.86rem;
}

.step-evidence-count {
    flex: 0 0 auto;
    border: 1px solid var(--accent-line);
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    padding: 0.2rem 0.5rem;
    font-size: 0.64rem;
    font-weight: 750;
}

.step-evidence-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.55rem;
}

.step-evidence-source {
    max-width: 220px;
    overflow: hidden;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue-ink);
    padding: 0.2rem 0.48rem;
    font-size: 0.64rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.step-evidence-details {
    margin-top: 0.6rem;
    border-top: 1px solid var(--line);
    padding-top: 0.55rem;
}

.step-evidence-details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    color: var(--ink);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    list-style-position: inside;
}

.step-evidence-details summary small {
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 600;
}

.step-evidence-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.55rem;
}

.step-evidence-item {
    border-left: 2px solid #3f3f46;
    background: var(--surface-soft);
    padding: 0.5rem 0.6rem;
}

.step-evidence-item strong,
.step-evidence-item p,
.step-evidence-item small {
    display: block;
}

.step-evidence-item strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 0.66rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.step-evidence-item p {
    display: -webkit-box;
    margin: 0.18rem 0 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.step-evidence-item small {
    margin-top: 0.28rem;
    color: var(--warning-ink);
    font-size: 0.62rem;
}

.step-evidence-local-note {
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: 0.64rem;
    line-height: 1.4;
}

/* D6 verified before / after comparison */
.d6-validation-panel {
    border: 1px solid var(--accent-line);
    border-radius: 10px;
    background: var(--surface);
    padding: 0.9rem;
    margin-bottom: 0.35rem;
    animation: confCardIn 0.2s ease;
}

.d6-validation-header,
.d6-validation-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.d6-validation-header h3 {
    margin: 0;
    color: var(--ink);
    font-size: 0.95rem;
}

.d6-validation-clear,
.d6-add-to-draft {
    padding: 0.38rem 0.65rem;
    font-size: 0.72rem;
}

.d6-validation-help {
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.45;
}

.d6-validation-inputs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
    margin-top: 0.75rem;
}

.d6-validation-inputs label {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.24rem;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
}

.d6-validation-inputs input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    padding: 0.48rem 0.55rem;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.d6-validation-inputs input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.d6-validation-chart {
    margin-top: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 0.75rem;
}

.d6-chart-empty {
    color: var(--muted);
    font-size: 0.74rem;
    text-align: center;
    padding: 0.65rem;
}

.d6-validation-chart:not(.empty) .d6-chart-empty { display: none; }
.d6-validation-chart.empty .d6-chart-plot { display: none; }

.d6-chart-plot {
    display: flex;
    flex-direction: column;
    gap: 0.62rem;
}

.d6-chart-row {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) minmax(72px, auto);
    align-items: center;
    gap: 0.55rem;
}

.d6-chart-label,
.d6-chart-value {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
}

.d6-chart-value {
    color: var(--ink);
    text-align: right;
}

.d6-chart-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #1c1c21;
}

.d6-chart-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    transition: width 0.28s ease-out;
}

.d6-chart-fill.before { background: var(--warning); }
.d6-chart-fill.after { background: var(--accent); }
.d6-chart-fill.target {
    border: 1px dashed #52525b;
    background: #27272a;
}

.d6-validation-footer {
    align-items: flex-start;
    margin-top: 0.7rem;
}

.d6-validation-footer p {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.45;
}

.d6-add-to-draft:disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

@media (max-width: 640px) {
    .d6-validation-inputs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .d6-validation-header,
    .d6-validation-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .d6-chart-row {
        grid-template-columns: 50px minmax(0, 1fr);
    }

    .d6-chart-value {
        grid-column: 2;
        text-align: left;
    }
}

/* ============================================================
   PHASE 3 — OEM / Customer Template Selector
   ============================================================ */

.oem-template-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 8px 10px;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.12) 0%, #121215 100%);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}
.oem-template-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #fbbf24;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.oem-template-select {
    flex: 1;
    min-width: 180px;
    padding: 5px 10px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink, #f4f4f5);
    background: #121215;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.oem-template-select:focus {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.oem-template-active-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: #f59e0b;
    color: #f4f4f5;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: auto;
}

/* ============================================================
   PHASE 4b — AI Diagram Generator Panel
   ============================================================ */

.diagram-gen-section {
    border-top: 1px solid var(--line, #27272a);
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.diagram-type-select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--line, #27272a);
    border-radius: 6px;
    font-size: 0.8rem;
    background: var(--card-bg, #121215);
    color: var(--ink, #f4f4f5);
    cursor: pointer;
    outline: none;
}

.diagram-type-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.diagram-gen-btn {
    width: 100%;
    padding: 7px 10px;
    background: var(--accent-fill);
    color: #f4f4f5;
    border: none;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    letter-spacing: 0.01em;
}

.diagram-gen-btn:hover:not(:disabled) {
    background: var(--accent-fill-hover);
    transform: translateY(-1px);
}

.diagram-gen-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.diagram-gen-status {
    font-size: 0.75rem;
    min-height: 16px;
    color: var(--muted, #a1a1aa);
    text-align: center;
}

.diagram-preview-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 4px;
    animation: confCardIn 0.25s ease;
}

.diagram-preview-img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line, #27272a);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: zoom-in;
    transition: transform 0.2s;
}

.diagram-preview-img:hover {
    transform: scale(1.02);
}

.diagram-preview-actions {
    display: flex;
    gap: 0.4rem;
}

.diagram-action-btn {
    flex: 1;
    padding: 4px 6px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--line, #27272a);
    border-radius: 5px;
    background: var(--card-bg, #121215);
    color: var(--ink, #f4f4f5);
    cursor: pointer;
    transition: background 0.12s;
}

.diagram-action-btn:hover {
    background: var(--accent-soft);
}

/* Export Panel */
.export-panel {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    border-radius: 9px;
    margin-bottom: 0.5rem;
}

.export-panel-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-strong);
    white-space: nowrap;
}

.export-format-group {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    border: 0;
    padding: 0;
    margin: 0;
    min-width: 0;
}

.export-fmt-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 1px solid var(--accent-line);
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--accent-ink);
    background: var(--surface);
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s, border-color 0.12s;
    user-select: none;
}

.export-fmt-pill input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.export-fmt-pill:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.export-fmt-pill:has(input:checked) {
    background: var(--accent-fill);
    color: #f4f4f5;
    border-color: var(--accent-fill);
}

.export-title-input {
    flex: 1;
    min-width: 140px;
    max-width: 220px;
    height: 32px;
    padding: 5px 10px;
    border: 1px solid var(--accent-line);
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--ink);
    background: var(--surface);
    outline: none;
}

.export-title-input:focus { border-color: var(--accent); }

.pptx-template-control {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(16, 185, 129, 0.14);
}

.pptx-template-control > label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.pptx-style-select {
    min-width: 190px;
    max-width: 260px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #121215;
    color: var(--ink);
    font-size: 0.75rem;
}

.pptx-template-btn,
.pptx-template-clear {
    padding: 5px 9px;
    font-size: 0.75rem;
}

.pptx-template-name {
    max-width: 280px;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pptx-template-help {
    flex-basis: 100%;
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1.35;
}

.export-btn {
    padding: 5px 14px;
    background: var(--accent-fill);
    color: #f4f4f5;
    border: none;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}

.export-btn:hover:not(:disabled) { background: var(--accent-fill-hover); }
.export-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.export-status {
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Status tone classes (toggled via classList) — replace inline .style.color
   in the export + AI-diagram flows. Scoped so they never collide with the
   .stepper-step.status-* compound selectors elsewhere in this file. */
.export-status.status-success,
.diagram-gen-status.status-success { color: var(--success); }
.export-status.status-error,
.diagram-gen-status.status-error { color: var(--danger); }
.export-status.status-warn,
.diagram-gen-status.status-warn { color: var(--warning); }
.export-status.status-muted,
.diagram-gen-status.status-muted { color: var(--faint); }

.export-authenticity-note {
    flex-basis: 100%;
    color: var(--muted);
    font-size: 0.7rem;
    line-height: 1.35;
}

.autosave-status {
    align-items: center;
    margin-left: 10px;
    font-weight: 600;
}

.autosave-saving { color: var(--muted); }
.autosave-saved-local,
.autosave-saved-case { color: var(--success-ink); }
.autosave-error-local,
.autosave-error-case { color: var(--danger-ink); }

.active-case-details {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.1rem;
}

.active-case-details small {
    display: block;
    max-width: 720px;
    overflow: hidden;
    color: #fbbf24;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-item mark {
    border-radius: 3px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    padding: 0 0.08em;
}

.primary-btn:disabled,
.export-btn:disabled,
.secondary-btn:disabled {
    opacity: 0.52;
    box-shadow: none;
}

/* ─────────────────────────────────────────────
   Toast notifications (non-blocking alerts)
   ───────────────────────────────────────────── */
/* Notifications have reserved toolbar space; they never cover action buttons. */
#toast-host {
    position: static;
    flex: 1 0 100%;
    min-width: 0;
    width: 100%;
    height: 3rem;
    overflow: auto;
    overscroll-behavior: contain;
    display: block;
    border-top: 1px solid var(--line);
    padding-top: 5px;
    color: var(--muted);
    font-size: 12px;
}
#toast-host:empty::before {
    content: attr(data-idle);
    display: block;
    padding: 4px 0;
}


.toast {
    background: #0c0c0f;
    color: #f4f4f5;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    font-size: 0.9rem;
    line-height: 1.45;
    width: 100%;
    max-width: none;
    opacity: 1;
    transform: none;
    transition: none;
    overflow-wrap: anywhere;
}

.toast.show {
    opacity: 1;
}

.toast-error   { background: #b91c1c; }
.toast-success { background: #15803d; }
.toast-warn    { background: #b45309; }

/* ─────────────────────────────────────────────
   Professional icons — SVG nav icons + CSS status dots
   (replaces emoji glyphs)
   ───────────────────────────────────────────── */
.nav-links .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-links .icon svg {
    display: block;
}

.upload-icon svg,
.cases-empty-icon svg {
    display: inline-block;
    opacity: 0.55;
}

.case-delete-btn svg {
    display: block;
}

.case-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
    background: #27272a;
}

.case-status-badge.status-open .case-dot        { background: #f59e0b; }
.case-status-badge.status-in-progress .case-dot { background: var(--warning); }
.case-status-badge.status-submitted .case-dot   { background: #a1a1aa; }
.case-status-badge.status-closed .case-dot      { background: #22c55e; }

/* Defer paint work for long off-screen result lists without changing layout. */
@supports (content-visibility: auto) {
    .case-card,
    .pitfall-card,
    .search-item,
    .checklist-item,
    .step-evidence-item {
        content-visibility: auto;
        contain-intrinsic-size: auto 120px;
    }
}

@media (max-width: 640px) {
    .nav-links li {
        gap: 0.4rem;
        padding-inline: 0.6rem;
        font-size: 0.78rem;
    }

    .nav-links li .icon {
        width: 16px;
    }

    .main-content {
        padding-inline: 0.75rem;
    }

    .top-bar {
        margin-bottom: 0.75rem;
    }

    .zoom-control {
        display: none;
    }

    .home-btn {
        min-width: 42px;
        min-height: 42px;
        padding: 0.45rem 0.65rem;
    }

    .home-btn .home-text {
        display: none;
    }

    .builder-progress-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding-bottom: 0.7rem;
    }

    .progress-step-btn {
        min-height: 56px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .active-case-details small {
        max-width: calc(100vw - 110px);
    }

    #toast-host {
        right: 12px;
        bottom: 12px;
        left: 12px;
    }

    .toast {
        max-width: none;
    }
}

/* CJK floor: Traditional Chinese below 11px is illegible */
body.lang-zh .builder-health-score span,
body.lang-zh .builder-health-score small,
body.lang-zh .step-status-badge,
body.lang-zh .step-count-badge,
body.lang-zh .checklist-item-status,
body.lang-zh .goblin-dot-circle,
body.lang-zh .dtag,
body.lang-zh .ztag,
body.lang-zh .ref-open-icon,
body.lang-zh .ref-panel-kicker,
body.lang-zh .ref-num,
body.lang-zh .step-evidence-kicker,
body.lang-zh .builder-case-map-kicker,
body.lang-zh .agent-workflow-kicker,
body.lang-zh .d6-validation-kicker,
body.lang-zh .builder-case-map-legend,
body.lang-zh .step-meta,
body.lang-zh .agent-workflow-index,
body.lang-zh .agent-workflow-copy small,
body.lang-zh .case-status-badge,
body.lang-zh .case-industry-tag,
body.lang-zh .step-evidence-count,
body.lang-zh .step-evidence-source,
body.lang-zh .step-evidence-details summary small,
body.lang-zh .step-evidence-item strong,
body.lang-zh .step-evidence-item p,
body.lang-zh .step-evidence-item small,
body.lang-zh .step-evidence-local-note,
body.lang-zh .d6-validation-inputs label,
body.lang-zh .d6-chart-label,
body.lang-zh .d6-chart-value,
body.lang-zh .pptx-template-help {
    font-size: 11px;
}

/* ============ Motion foundation (animations layer) ============ */

/* Tokens */
:root {
    --motion-slow: 600ms;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Keyframes */
@keyframes m-pulse {
    0%, 100% { opacity: .4; }
    50% { opacity: 1; }
}

@keyframes m-sheen {
    from { background-position: 0% 0; }
    to { background-position: 200% 0; }
}

@keyframes m-ping {
    from { box-shadow: 0 0 0 0 rgba(16, 185, 129, .35); }
    to { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); }
}

@keyframes m-blink {
    50% { opacity: 0; }
}

@keyframes m-fade-up {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

@keyframes m-cell-sweep {
    0% { background-size: 0% 100%; }
    100% { background-size: 100% 100%; }
}

@keyframes m-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

/* Score gauge (conic-gradient ring, typed custom property for native transitions) */
@property --gauge-score {
    syntax: '<number>';
    initial-value: 0;
    inherits: false;
}

.m-gauge {
    --gauge-score: 0;
    --gauge-color: var(--success);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(var(--gauge-color) calc(var(--gauge-score) * 1%), var(--line) 0);
    display: grid;
    place-items: center;
    position: relative;
    transition: --gauge-score var(--motion-slow) var(--ease-out);
}

.m-gauge::after {
    content: "";
    position: absolute;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
    border-radius: 50%;
    background: var(--surface);
}

.m-gauge > * {
    position: relative;
    z-index: 1;
}

.m-gauge.m-gauge-lg {
    width: 96px;
    height: 96px;
}

.m-gauge.m-gauge-lg::after {
    width: calc(100% - 22px);
    height: calc(100% - 22px);
}

.m-gauge[data-band="danger"] { --gauge-color: var(--danger); }
.m-gauge[data-band="warning"] { --gauge-color: var(--warning); }
.m-gauge[data-band="success"] { --gauge-color: var(--success); }

.m-gauge-value {
    font-weight: 600;
    font-size: 1rem;
    color: var(--ink);
}

/* Phase track states (for .agent-workflow-step items) */
.m-phase-waiting {
    opacity: .55;
}

.m-phase-active {
    position: relative;
}

.m-phase-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
    animation: m-pulse 1.2s var(--ease-in-out) infinite;
}

.m-phase-done {
    opacity: 1;
}

.m-phase-done .m-phase-check {
    color: var(--success);
}

/* Progress bar */
.m-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.m-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-fill), var(--accent), var(--accent-fill));
    background-size: 200% 100%;
    transition: width .3s var(--ease-out);
    animation: m-sheen 1.6s linear infinite;
}

/* Utilities */
.m-fade-up {
    animation: m-fade-up var(--motion-base) var(--ease-out) both;
}

.m-stagger > * {
    animation: m-fade-up var(--motion-base) var(--ease-out) both;
    animation-delay: calc(var(--m-i, 0) * 40ms);
}

.m-ping-dot {
    position: relative;
}

.m-ping-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    animation: m-ping 1.4s var(--ease-out) infinite;
}

.m-breathe {
    animation: m-breathe 2.2s var(--ease-in-out) infinite;
}

.m-stream-cursor::after {
    content: "▍";
    animation: m-blink 1s steps(1) infinite;
    color: var(--accent-ink);
}

.m-bar-grow {
    transition: height var(--motion-slow) var(--ease-out), width var(--motion-slow) var(--ease-out);
}

/* Reduced motion: cover pseudo-elements not matched by the existing `*` rule above */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
    .m-gauge {
        transition: none;
    }
}

/* ============ Print stylesheet ============ */
@media print {
    body {
        background: #121215;
        color: #f4f4f5;
        display: block;
    }
    .sidebar,
    .top-bar,
    .nav-scrim,
    .nav-toggle-btn,
    .export-panel,
    .ref-open-tab,
    .reference-panel,
    .builder-evidence-panel,
    .agent-workflow-card,
    .builder-case-map-shell,
    .builder-guide-panel,
    .builder-editor-actions,
    .builder-editor-footer,
    #toast-host {
        display: none !important;
    }
    .app-container,
    .main-content,
    .tab-content {
        display: block;
        height: auto;
        overflow: visible;
        color: #f4f4f5;
    }
    .main-content {
        padding: 0;
    }
    /* Builder draft content prints full width */
    .builder-grid-container {
        display: block;
    }
    .card,
    .paper-card,
    .audit-container {
        border: 1px solid #3f3f46;
        box-shadow: none;
    }
    #builder-textarea {
        min-height: auto;
        height: auto;
        border: 1px solid #3f3f46;
        background: #121215;
        color: #f4f4f5;
        overflow: visible;
    }
}

/* Enterprise cockpit: restrained industrial hierarchy, self-hosted typography. */
:root {
    --bg: #1c1c21;
    --surface-soft: #121215;
    --ink: #f4f4f5;
    --muted: #d4d4d8;
    --line: #27272a;
    --font-sans: 'Inter', 'Noto Sans TC', sans-serif;
    --font-mono: 'Inter', 'Noto Sans TC', sans-serif;
    --radius-lg: 12px;
}
body { font-family: var(--font-sans); }
.sidebar { width: 220px; padding: 27px 15px 22px; background: #0c0c0f; border-right: 1px solid #3f3f46; }
.sidebar .logo { padding-left: 9px; margin-bottom: 38px; }
.sidebar .logo-brand { color: #fbbf24; font-size: 20px; letter-spacing: -.6px; }
.sidebar .logo-sub { color: #a1a1aa; font-size: 9px; letter-spacing: 1.8px; }
.sidebar .logo-icon { background: #10b981; color: #f4f4f5; border-radius: 8px; width: 34px; height: 34px; }
.sidebar .nav-links li { color: #a1a1aa; border-radius: 6px; font-size: 13px; padding: 12px 14px; }
.sidebar .nav-links li.active { color: #f4f4f5; background: #27272a; box-shadow: inset 3px 0 #10b981; }
.sidebar .nav-links li:hover { color: #f4f4f5; background: #27272a; }
.sidebar-spacer { flex: 1; min-height: 60px; }
.enterprise-sidebar-foot { padding: 16px 11px 0; border-top: 1px solid #3f3f46; color: #f4f4f5; font-size: 11px; }
.enterprise-sidebar-foot small { display: block; color: #a1a1aa; font-size: 10px; margin-top: 7px; }
.enterprise-live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #60cbb4; margin-right: 8px; }
.main-content { min-width: 0; padding: 0 36px 40px; }
.top-bar { margin: 0 -36px 25px; padding: 15px 36px; border-bottom: 1px solid var(--line); background: rgba(18, 18, 21, .96); min-height: 68px; }
.tab-content { max-width: 1440px; margin: 0 auto; }
.tab-content > header { margin-bottom: 21px; }
.tab-content > header h1 { font-size: 30px; font-weight: 650; letter-spacing: -1.1px; line-height: 1.25; }
.tab-content > header > p:not(.enterprise-eyebrow) { font-size: 13px; margin-top: 8px; max-width: 820px; color: var(--muted); }
.enterprise-eyebrow { color: #d4d4d8; font-size: 9px; font-weight: 700; letter-spacing: 1.35px; line-height: 1.6; margin: 0 0 8px; }
.enterprise-overview { border: 1px solid var(--line); border-radius: 12px; background: #121215; margin-bottom: 22px; padding: 22px 23px 0; box-shadow: 0 3px 12px #27272a04; }
.enterprise-overview-top { display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.enterprise-profiles { display: flex; gap: 5px; margin-top: 6px; }
.enterprise-profiles button { border: 1px solid transparent; background: transparent; padding: 9px 12px; text-align: left; color: #d4d4d8; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1.4; }
.enterprise-profiles button small { display: block; margin-top: 4px; font-size: 9px; color: #a1a1aa; font-weight: 450; }
.enterprise-profiles button[aria-pressed="true"] { border-color: #10b981; background: rgba(16, 185, 129, 0.12); color: #34d399; }
.enterprise-profiles button:hover { background: #1c1c21; }
.enterprise-status-tile { min-width: 205px; border-left: 1px solid var(--line); padding: 0 0 0 24px; }
.enterprise-status-tile > span { display: block; font-size: 9px; color: #a1a1aa; font-weight: 650; letter-spacing: .9px; }
.enterprise-status-tile strong { display: block; font-size: 22px; line-height: 1.5; font-weight: 600; letter-spacing: -.6px; }
.enterprise-status-tile small { font-size: 10px; color: var(--muted); display: block; }
.enterprise-sla { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.enterprise-sla-pill { display: flex; gap: 8px; align-items: center; border: 1px solid #27272a; background: #121215; border-radius: 5px; padding: 7px 10px; color: #d4d4d8; font-size: 10px; font-variant-numeric: tabular-nums; }
.enterprise-sla-pill b { font-weight: 650; color: #f4f4f5; }
.enterprise-sla-pill.overdue { background: rgba(245, 158, 11, 0.12); border-color: #edc5ae; color: #974720; }
.enterprise-operational-note { color: #d4d4d8; font-size: 10px; line-height: 1.5; margin: 8px 0 19px; }
.enterprise-readiness-heading { display: flex; justify-content: space-between; gap: 12px; font-size: 9px; color: #a1a1aa; padding: 15px 0 11px; border-top: 1px solid #27272a; }
.enterprise-readiness-heading > span:first-child { font-weight: 650; letter-spacing: 1px; }
.enterprise-readiness-rail { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); gap: 6px; padding-bottom: 20px; align-items: start; }
.enterprise-gate { min-width: 0; border: 1px solid #27272a; border-radius: 6px; background: #121215; }
.enterprise-gate summary { list-style: none; cursor: pointer; padding: 10px 9px; }
.enterprise-gate summary::-webkit-details-marker { display: none; }
.enterprise-gate summary strong { display: flex; align-items: center; justify-content: space-between; color: #f4f4f5; font-size: 12px; margin-bottom: 7px; }
.enterprise-gate summary strong:after { content: '+'; font-size: 13px; font-weight: 400; color: #a1a1aa; }
.enterprise-gate[open] summary strong:after { content: '−'; }
.enterprise-gate summary span { display: block; font-size: 9px; line-height: 1.45; }
.enterprise-gate.ready { border-color: #3f3f46; background: rgba(16, 185, 129, 0.12); }
.enterprise-gate.not-ready summary span { color: #924a30; }
.enterprise-gate.conditional summary span { color: #916024; }
.enterprise-gate.ready summary span { color: #34d399; }
.enterprise-gate-body { padding: 0 9px 10px; font-size: 10px; color: #d4d4d8; overflow-wrap: anywhere; }
.enterprise-gate-body ul { padding-left: 13px; }
.enterprise-gate-body li { margin: 6px 0; }
.enterprise-gate-body button { border: 0; padding: 6px 0 0; background: transparent; color: #34d399; cursor: pointer; text-decoration: underline; font-size: 10px; }
.enterprise-recurrence { border-top: 1px solid #27272a; margin: 0 -23px; padding: 12px 23px; background: #121215; font-size: 11px; color: #d4d4d8; border-radius: 0 0 12px 12px; }
.enterprise-recurrence.warning { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.enterprise-recurrence summary { cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.enterprise-recurrence ul { list-style: none; padding: 9px 0 0; }
.enterprise-recurrence li { display: flex; gap: 10px; align-items: baseline; border-top: 1px solid rgba(245, 158, 11, 0.12); padding: 9px 0; }
.enterprise-recurrence button { border: 0; background: none; color: inherit; text-decoration: underline; font-weight: 650; cursor: pointer; white-space: nowrap; }
.enterprise-error { padding: 12px 14px; background: rgba(255, 26, 92, 0.12); border: 1px solid #edbab1; color: #932f20; font-size: 12px; line-height: 1.6; margin: 10px 0; border-radius: 6px; white-space: pre-wrap; }
.enterprise-overview + .builder-evidence-panel { border-radius: 10px; box-shadow: none; border-color: var(--line); padding: 20px 23px; }
.builder-evidence-header h2, .builder-case-map-header h2 { font-size: 17px; letter-spacing: -.3px; }
.builder-evidence-header p, .builder-workspace-lead { font-size: 12px; }
.builder-file-drop { min-height: 78px; border: 1px dashed #3f3f46; background: #121215; }
.agent-workflow-card { padding: 13px 15px; margin-top: 16px; border-radius: 7px; background: #121215; }
.agent-workflow-header { margin-bottom: 10px; }
.agent-workflow-header h3 { font-size: 12px; }
.agent-workflow-note { font-size: 10px; }
.agent-workflow-kicker { font-size: 8px; }
.builder-progress-bar { gap: 4px; }
.progress-step-btn { border-radius: 6px; }
#builder-workspace { border-radius: 10px; border-color: var(--line); }
.builder-grid-container { grid-template-columns: minmax(170px, .27fr) minmax(0, 1fr); }
.builder-guide-panel { background: #121215; border-right: 1px solid var(--line); padding: 21px 17px; }
.builder-guide-panel h3 { font-size: 16px; }
.builder-guide-panel p, .builder-guide-avoid { font-size: 12px; line-height: 1.65; }
.builder-editor-body { padding: 22px; }
.enterprise-editor-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.enterprise-editor-toolbar .secondary-btn { font-size: 11px; padding: 7px 11px; }
.enterprise-count { display: inline-block; background: #1c1c21; padding: 1px 5px; margin-left: 7px; border-radius: 4px; font-size: 10px; }
.enterprise-feature-panel, .enterprise-review { border: 1px solid #3f3f46; border-radius: 7px; padding: 16px; margin: 0 0 17px; background: #121215; }
.enterprise-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.enterprise-section-title h3 { font-size: 14px; font-weight: 650; margin: 0; }
.enterprise-fineprint { font-size: 10px; line-height: 1.65; color: #a1a1aa; margin: 6px 0 12px; }
.enterprise-chip { display: inline-block; font-size: 9px; font-weight: 650; padding: 4px 6px; border: 1px solid #3f3f46; border-radius: 4px; color: #d4d4d8; white-space: nowrap; }
.enterprise-chip.E_SIGNED { background: rgba(16, 185, 129, 0.12); border-color: #3f3f46; color: #34d399; }
.enterprise-chip.HUMAN_REVIEWED { background: rgba(161, 161, 170, 0.12); border-color: #3f3f46; color: #d4d4d8; }
.enterprise-review-fields, .enterprise-d6-fields { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.enterprise-review-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
.enterprise-review label, .enterprise-d6-fields label, .enterprise-feature-panel label, .enterprise-drawer label { display: flex; flex-direction: column; gap: 5px; font-size: 10px; color: #d4d4d8; min-width: 0; }
.enterprise-review input, .enterprise-review select, .enterprise-d6-fields input, .enterprise-d6-fields select, .enterprise-feature-panel input, .enterprise-feature-panel select, .enterprise-feature-panel textarea, .enterprise-drawer input, .enterprise-drawer select, .enterprise-drawer textarea { width: 100%; border: 1px solid #3f3f46; border-radius: 4px; background: #121215; color: #f4f4f5; font-family: var(--font-sans); font-size: 12px; padding: 8px; min-height: 35px; line-height: 1.45; }
.enterprise-feature-panel textarea, .enterprise-drawer textarea { min-height: 68px; resize: vertical; }
.enterprise-feature-panel select[multiple], .enterprise-drawer select[multiple], .enterprise-d6-fields select[multiple] { min-height: 58px; padding: 3px; }
.enterprise-span-2 { grid-column: span 2; }
.enterprise-span-3 { grid-column: span 3; }
.enterprise-action-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.enterprise-action-row button { font-size: 11px; padding: 7px 11px; }
.enterprise-action-row > span { font-size: 10px; color: #d4d4d8; }
.enterprise-hypothesis { border: 1px solid #27272a; border-radius: 5px; margin: 9px 0; background: #121215; }
.enterprise-hypothesis summary { padding: 11px 12px; font-size: 12px; font-weight: 600; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.enterprise-hypothesis summary > span { color: #a1a1aa; font-size: 10px; font-weight: 400; }
.enterprise-hypothesis-body { padding: 0 12px 13px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; }
.enterprise-test-box { padding: 11px; border: 1px solid #27272a; border-radius: 4px; background: #121215; display: grid; gap: 9px; }
.enterprise-test-box h4 { font-size: 11px; }
.enterprise-test-box.off { border-left: 3px solid #a1a1aa; }
.enterprise-test-box.on { border-left: 3px solid #10b981; }
.enterprise-d6-fields { padding-top: 13px; margin-top: 13px; border-top: 1px solid #27272a; }
.enterprise-drawer-scrim { position: fixed; inset: 0; background: #27272a66; z-index: 400; backdrop-filter: blur(2px); }
.enterprise-drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(720px,95vw); z-index: 401; background: #121215; box-shadow: -12px 0 55px #27272a29; display: flex; flex-direction: column; }
.enterprise-drawer[hidden], .enterprise-drawer-scrim[hidden] { display: none; }
.enterprise-drawer-header { background: #121215; padding: 23px 25px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #3f3f46; }
.enterprise-drawer-header h2 { font-size: 22px; font-weight: 600; letter-spacing: -.6px; margin: 0; }
.enterprise-drawer-body { padding: 22px 25px 40px; overflow-y: auto; overscroll-behavior: contain; }
.enterprise-drawer-form { border: 1px solid #3f3f46; border-radius: 7px; padding: 15px; background: white; margin-bottom: 18px; }
.enterprise-drawer-form > summary { font-size: 13px; font-weight: 650; cursor: pointer; }
.enterprise-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding-top: 13px; }
.enterprise-evidence-card { padding: 17px; border: 1px solid #3f3f46; background: white; border-radius: 7px; margin-top: 12px; }
.enterprise-evidence-card h3 { font-size: 14px; margin: 7px 0; }
.enterprise-evidence-card p { font-size: 12px; color: #d4d4d8; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.enterprise-evidence-locator { font-size: 10px; color: #a1a1aa; padding: 8px 0; border-bottom: 1px solid #27272a; margin-bottom: 10px; }
.enterprise-evidence-card img { width: 100%; max-height: 260px; object-fit: contain; background: #121215; margin-top: 9px; border: 1px solid #3f3f46; }
.enterprise-table-wrap { overflow-x: auto; max-width: 100%; margin-top: 10px; }
.enterprise-table-wrap table { border-collapse: collapse; width: 100%; font-size: 11px; }
.enterprise-table-wrap th, .enterprise-table-wrap td { text-align: left; padding: 9px; border: 1px solid #27272a; vertical-align: top; }
.enterprise-table-wrap th { background: #1c1c21; font-weight: 600; white-space: nowrap; }
.enterprise-claim { display: block; text-align: left; border: 0; width: 100%; background: #1c1c21; color: #fbbf24; padding: 9px 10px; border-radius: 4px; margin-top: 6px; cursor: pointer; font: 11px/1.5 var(--font-sans); }
.enterprise-claim.contradicts { background: rgba(245, 158, 11, 0.12); color: #8d4d2d; }
.enterprise-empty { border: 1px dashed #3f3f46; padding: 25px 17px; font-size: 12px; line-height: 1.7; color: #a1a1aa; text-align: center; border-radius: 6px; }
.enterprise-pfmea-row { background: white; border: 1px solid #3f3f46; margin: 12px 0; border-radius: 5px; padding: 13px; }
.enterprise-pfmea-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.enterprise-redline { font-size: 11px; margin: 10px 0; border: 1px solid #27272a; border-radius: 4px; overflow: hidden; }
.enterprise-redline del { display: block; padding: 8px 10px; background: rgba(255, 26, 92, 0.12); color: #974c3d; }
.enterprise-redline ins { display: block; padding: 8px 10px; background: rgba(16, 185, 129, 0.12); color: #34d399; text-decoration: none; white-space: pre-wrap; overflow-wrap: anywhere; }
.enterprise-history-card { padding: 14px 16px; margin-top: 10px; background: white; border: 1px solid #3f3f46; border-left: 3px solid #3f3f46; border-radius: 5px; }
.enterprise-history-card.E_SIGNED { border-left-color: #339473; }
.enterprise-history-card.HUMAN_REVIEWED { border-left-color: #a1a1aa; }
.enterprise-history-card h3 { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 8px; }
.enterprise-history-card p, .enterprise-history-card summary { font-size: 11px; line-height: 1.7; color: #d4d4d8; }
.enterprise-hash { display: block; overflow-wrap: anywhere; font-size: 10px; color: #d4d4d8; font-variant-numeric: tabular-nums; margin: 5px 0; letter-spacing: .1px; }
.enterprise-history-card pre { white-space: pre-wrap; font: 11px/1.6 var(--font-sans); background: #121215; padding: 10px; border-radius: 4px; }
.enterprise-unsaved { color: #9d591e !important; }
.enterprise-invalid { border-color: #b84435 !important; }
.enterprise-highlight { outline: 2px solid #10b981; outline-offset: 4px; }
@media(min-width:1500px) { .main-content { padding-left: 48px; padding-right: 48px; } .top-bar { padding-left: 48px; padding-right: 48px; margin-left: -48px; margin-right: -48px; } }
@media(max-width:1150px) { .sidebar { width: 190px; } .main-content { padding: 0 22px 30px; } .top-bar { margin-left: -22px; margin-right: -22px; padding-left: 22px; padding-right: 22px; } .enterprise-overview-top { align-items: flex-start; } .enterprise-profiles { display: grid; grid-template-columns: 1fr 1fr; } .enterprise-readiness-rail { grid-template-columns: repeat(4,minmax(0,1fr)); } .builder-grid-container { grid-template-columns: minmax(150px,.28fr) minmax(0,1fr); } .enterprise-d6-fields { grid-template-columns: repeat(2,minmax(0,1fr)); } .enterprise-d6-fields .enterprise-span-3 { grid-column: span 2; } }
@media(max-width:850px) { .builder-grid-container { grid-template-columns: 1fr; } .builder-guide-panel { border-right: 0; border-bottom: 1px solid var(--line); } .enterprise-hypothesis-body { grid-template-columns: 1fr; } .enterprise-hypothesis-body .enterprise-span-2 { grid-column: auto; } .top-bar .industry-selector-container { max-width: 210px; } }
@media(max-width:760px) { .sidebar { width: 240px; } .main-content { padding: 0 15px 25px; } .top-bar { margin-left: -15px; margin-right: -15px; padding: 11px 15px; } .enterprise-overview { padding: 17px 15px 0; } .enterprise-overview-top { display: block; } .enterprise-status-tile { margin-top: 17px; padding: 13px 0 0; border-top: 1px solid var(--line); border-left: 0; } .enterprise-status-tile strong { font-size: 20px; } .enterprise-profiles { display: grid; grid-template-columns: repeat(2,1fr); } .enterprise-profiles button { border-color: #27272a; } .enterprise-readiness-heading { display: block; } .enterprise-readiness-heading span { display: block; margin-bottom: 4px; } .enterprise-recurrence { margin-left: -15px; margin-right: -15px; padding: 12px 15px; } .enterprise-readiness-rail { gap: 4px; } .enterprise-gate summary { padding: 9px 7px; } .enterprise-gate summary span { font-size: 8px; } .enterprise-review-fields, .enterprise-d6-fields, .enterprise-pfmea-fields { grid-template-columns: 1fr; } .enterprise-review-fields .enterprise-span-2, .enterprise-d6-fields .enterprise-span-2, .enterprise-d6-fields .enterprise-span-3, .enterprise-pfmea-fields .enterprise-span-2 { grid-column: auto; } .enterprise-drawer { width: 100%; } .enterprise-drawer-body, .enterprise-drawer-header { padding-left: 17px; padding-right: 17px; } .enterprise-form-grid { grid-template-columns: 1fr; } .enterprise-form-grid .enterprise-span-2 { grid-column: auto; } .enterprise-sla-pill { font-size: 9px; } .enterprise-recurrence li { flex-wrap: wrap; } .tab-content > header h1 { font-size: 27px; } }
@media(prefers-reduced-motion:reduce) { .enterprise-drawer-scrim { backdrop-filter: none; } }


/* Interaction surfaces: explicit layering, bounded scrolling, and no clipped actions. */
html.modal-open,
body.modal-open,
body.drawer-open { overflow: hidden; }
.top-bar.toolbar-tall { position: static; }
.tab-content [id] { scroll-margin-block-start: var(--toolbar-clearance, 12px); }
.modal-overlay { overflow: auto; overscroll-behavior: contain; }
.modal-box { max-height: 100%; min-height: 0; }
.modal-header,
.modal-footer { flex: 0 0 auto; }
.modal-header { gap: 12px; padding-bottom: 12px; }
.modal-header h2 { min-width: 0; overflow-wrap: anywhere; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.modal-footer { flex-wrap: wrap; padding-top: 12px; }
.modal-close,
.ref-panel-toggle { flex: 0 0 auto; min-width: 44px; min-height: 44px; }
.modal-box input,
.modal-box textarea,
.modal-box select { min-width: 0; max-width: 100%; }
.enterprise-drawer-scrim { z-index: 1100; }
.enterprise-drawer { z-index: 1101; max-width: 100%; min-height: 0; }
.enterprise-drawer-header { flex: 0 0 auto; gap: 12px; min-width: 0; }
.enterprise-drawer-header > div { min-width: 0; }
.enterprise-drawer-header h2 { overflow-wrap: anywhere; }
.enterprise-drawer-body { flex: 1 1 auto; min-height: 0; min-width: 0; }
.reference-panel { max-height: calc(100% - 82px); }
.ref-panel-header { flex: 0 0 auto; }
.ref-panel-body { min-height: 0; overscroll-behavior: contain; }

/* Text and controls wrap instead of widening mobile and enlarged-text layouts. */
.verify-tabs,
.builder-step-nav,
.builder-evidence-header,
.agent-workflow-header,
.enterprise-section-title,
.enterprise-hypothesis summary,
.enterprise-history-card h3,
.enterprise-recurrence summary,
.enterprise-sla-pill { flex-wrap: wrap; }
.verify-tabs,
.enterprise-sla-pill,
.enterprise-chip { max-width: 100%; }
.verify-tab-btn,
.primary-btn,
.secondary-btn { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.builder-verify-btn { height: auto; min-height: 36px; }
.enterprise-chip { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.enterprise-profiles { flex-wrap: wrap; }
.enterprise-overview-top { flex-wrap: wrap; }
.enterprise-overview-top > div,
.enterprise-section-title > *,
.enterprise-pfmea-row,
.enterprise-test-box,
.enterprise-claim,
.enterprise-evidence-card,
.enterprise-drawer-form,
.dashboard-grid > *,
.active-case-details { min-width: 0; max-width: 100%; }
.active-case-details small { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.enterprise-evidence-card h3,
.enterprise-evidence-locator,
.enterprise-error,
.enterprise-history-card pre,
.multi-files-nav li { overflow-wrap: anywhere; }
.oem-template-select,
.pptx-style-select,
.export-title-input { min-width: min(180px, 100%); max-width: 100%; }
.export-status { white-space: normal; overflow-wrap: anywhere; }
.enterprise-feature-panel input,
.enterprise-feature-panel select,
.enterprise-feature-panel textarea,
.enterprise-drawer input,
.enterprise-drawer select { min-width: 0; max-width: 100%; }

/* Persistent, calm feedback beside the current editor keeps the next step obvious. */
.enterprise-editor-context,
.enterprise-next-action { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.enterprise-editor-context { margin-bottom: 12px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.enterprise-editor-context strong { font-size: 13px; color: var(--ink); }
.enterprise-next-action { padding: 14px 0; border-top: 1px solid var(--line); }
.enterprise-next-action > div { flex: 1 1 240px; min-width: 0; }
.enterprise-next-action p { margin: 5px 0 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.enterprise-next-action strong,
.enterprise-next-action > span { font-size: 12px; }
.enterprise-next-action button { font-size: 12px; }
.enterprise-review { margin-top: 16px; }
.enterprise-status-tile small,
.enterprise-operational-note,
.enterprise-readiness-heading,
.enterprise-gate summary span,
.enterprise-gate-body,
.enterprise-gate-body button,
.enterprise-fineprint,
.enterprise-chip,
.enterprise-review label,
.enterprise-d6-fields label,
.enterprise-feature-panel label,
.enterprise-drawer label,
.enterprise-editor-context > span,
.enterprise-action-row > span { font-size: 12px; line-height: 1.55; }
.enterprise-eyebrow,
.enterprise-profiles button small { font-size: 11px; }
body.lang-zh .enterprise-gate summary span,
body.lang-zh .enterprise-gate-body,
body.lang-zh .enterprise-fineprint,
body.lang-zh .enterprise-review label,
body.lang-zh .enterprise-d6-fields label,
body.lang-zh .enterprise-feature-panel label,
body.lang-zh .enterprise-drawer label { font-size: 13px; line-height: 1.65; }
/* Progress remains visible without decorative pulsing, flashing or bouncing. */
.m-breathe,
.m-ping-dot::after,
.m-phase-active::before,
.m-stream-cursor::after,
.agent-workflow-card.is-running::before,
.m-progress-fill { animation: none; }
@media (max-width: 760px) {
    .builder-editor-body { padding: 14px; }
    .enterprise-feature-panel,
    .enterprise-review { padding: 12px; }
    .enterprise-status-tile { min-width: 0; width: 100%; }
    .enterprise-pfmea-fields .enterprise-span-2 { grid-column: auto; }
    .enterprise-drawer-header { padding-top: 16px; padding-bottom: 16px; }
    .stepper-card { padding: 14px !important; max-width: 100%; }
    .stepper-flow { flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
    .stepper-line { display: none; }
    .stepper-step { width: calc(25% - 6px); min-width: 58px; }
    .report-header-section,
    .detail-tabs { flex-wrap: wrap; max-width: 100%; }
    .wtc-item > div,
    .wtc-item strong,
    .submission-readiness-heading > div,
    .submission-readiness-heading strong,
    .readiness-blockers,
    .readiness-blockers strong,
    .dashboard-content,
    .dashboard-sidebar,
    .multi-result-container,
    .wtc-panel,
    .checklist-card,
    .markdown-body,
    .markdown-body pre,
    .deck-code,
    .fix-draft-container { min-width: 0; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
    .checklist-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (max-width: 480px) {
    .enterprise-readiness-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .enterprise-sla-pill { width: 100%; }
    .builder-step-nav { width: 100%; }
    .builder-step-nav button { flex: 1 1 100px; }
    .modal-overlay { padding: 8px; }
    .modal-header,
    .modal-body,
    .modal-footer { padding-inline: 16px; }
}

/* An intentionally opened guide is a modal surface; covered background actions are inert. */
.reference-backdrop { position: fixed; inset: 0; z-index: 980; background: rgba(24, 24, 27, 0.38); }
@media print { .reference-backdrop, #toast-host { display: none !important; } }

.enterprise-inline-action-error { flex-basis: 100%; margin: 4px 0 0; }


/* Active-case tools share the workbench width and respect native hidden state. */
.workbench-feature-panel { min-width: 0; margin-block: 1.25rem; }
.workbench-feature-panel[hidden] { display: none !important; }
.workbench-golden-cases { margin-block-end: 1rem; border: 1px solid var(--workspace-line, var(--border-color, #27272a)); border-radius: 12px; background: var(--workspace-surface, var(--surface, #121215)); }
.workbench-golden-cases > summary { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; cursor: pointer; font-weight: 650; }
.workbench-golden-cases > summary:focus-visible { outline: 3px solid var(--workspace-focus, #10b981); outline-offset: 3px; }
#golden-cases-panel { padding: 0 1.25rem 1.25rem; }
@media (max-width: 600px) {
  #golden-cases-panel { padding: 0 .75rem .75rem; }
  .workbench-golden-cases > summary { padding: .85rem .75rem; }
  .workspace-header-actions { flex-wrap: wrap; }
}

/* Generated proposals never share the editable or autosaved draft surface. */
.builder-generated-proposal[hidden] { display: none !important; }
.builder-generated-proposal { margin-block: 1rem; padding: 1rem; border: 1px solid var(--border-color, #777); border-radius: 10px; min-width: 0; }
.builder-generated-proposal > summary { cursor: pointer; font-weight: 650; }
#builder-generated-proposal-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 24rem; overflow: auto; font: inherit; }

/* Exact-report language review. Scoped to this native modal; source text is literal. */
.report-review-dialog {
    box-sizing: border-box; width: min(1040px, calc(100vw - 32px)); max-width: none;
    max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line, #d9e1dc); border-radius: 16px;
    background: var(--surface, #fff); color: var(--ink, #14201f);
    box-shadow: 0 24px 80px #0006; font: 16px/1.65 var(--font-sans, 'Segoe UI', 'Noto Sans TC', sans-serif);
    text-align: start; color-scheme: light dark;
}
.report-review-dialog::backdrop { background: #071613b8; }
.report-review-dialog *, .report-review-dialog *::before, .report-review-dialog *::after { box-sizing: border-box; }
.report-review-dialog :is(h2,h3,h4,h5,h6,p,pre) { margin: 0; }
.report-review-dialog h2 { font: inherit; font-size: 26px; font-weight: 700; line-height: 1.3; letter-spacing: -.02em; }
.report-review-dialog h3 { font: inherit; font-size: 21px; font-weight: 700; line-height: 1.4; }
.report-review-dialog :is(h4,h5,h6) { font: inherit; font-size: 17px; font-weight: 650; }
.report-review-dialog :is(button,input,summary):focus-visible { outline: 3px solid var(--accent, #16614f); outline-offset: 3px; }
.report-review-dialog .report-review-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 28px 32px 24px; border-bottom: 1px solid var(--line, #d9e1dc); }
.report-review-dialog .report-review-title { min-width: 0; }
.report-review-dialog .report-review-eyebrow { display: block; font-size: 13px; font-weight: 650; letter-spacing: .03em; color: var(--muted, #596663); margin-bottom: 6px; }
.report-review-dialog .report-review-body { padding: 24px 32px 32px; }
.report-review-dialog .report-review-intro { max-width: 84ch; margin-bottom: 24px; }
.report-review-dialog .report-review-summary { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(0, 3fr); gap: 24px; padding: 20px; border: 1px solid var(--line, #d9e1dc); border-radius: 10px; background: var(--surface-soft, #f5f7f4); }
.report-review-dialog .report-review-target strong { font-size: 20px; }
.report-review-dialog .report-review-path { display: block; color: var(--muted, #596663); font: 13px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; white-space: pre-wrap; }
.report-review-dialog :is(.report-review-findings,.report-review-fields,.report-review-audit) { margin-top: 32px; }
.report-review-dialog :is(.report-review-findings,.report-review-fields) > h3 { margin-bottom: 10px; }
.report-review-dialog .report-review-finding { margin-top: 16px; border: 1px solid var(--line, #d9e1dc); border-radius: 10px; padding: 20px; }
.report-review-dialog .report-review-finding > :is(p,pre,fieldset) { margin-top: 14px; }
.report-review-dialog .report-review-warning { padding: 16px; border-left: 4px solid var(--accent, #16614f); background: var(--surface-soft, #f5f7f4); font-weight: 600; }
.report-review-dialog .report-review-group { min-width: 0; margin-top: 24px; border-top: 1px solid var(--line, #d9e1dc); padding-top: 18px; }
.report-review-dialog .report-review-group > .report-review-field-label { font-size: 20px; }
.report-review-dialog .report-review-children { margin-top: 14px; padding-left: 16px; border-left: 2px solid var(--line, #d9e1dc); }
.report-review-dialog .report-review-children .report-review-children { padding-left: 0; border-left: 0; }
.report-review-dialog .report-review-children .report-review-group > .report-review-field-label { font-size: 17px; }
.report-review-dialog .report-review-field { min-width: 0; padding: 16px 0; border-bottom: 1px solid var(--line, #d9e1dc); }
.report-review-dialog .report-review-field-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.report-review-dialog .report-review-field-label { font-weight: 650; overflow-wrap: anywhere; }
.report-review-dialog .report-review-type { font-size: 12px; color: var(--muted, #596663); }
.report-review-dialog .report-review-value { display: block; min-height: 1.65em; max-height: none; max-width: 100%; overflow: visible; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; font: inherit; color: inherit; background: none; border: 0; padding: 0; }
.report-review-dialog .report-review-choices { min-width: 0; padding: 12px; border: 1px solid var(--line, #d9e1dc); border-radius: 8px; }
.report-review-dialog .report-review-choices legend { padding: 0 6px; font-size: 14px; font-weight: 600; }
.report-review-dialog .report-review-choice { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; margin: 0; padding: 12px; cursor: pointer; border-radius: 6px; }
.report-review-dialog .report-review-choice:hover { background: var(--surface-soft, #f5f7f4); }
.report-review-dialog .report-review-choice input { flex: 0 0 20px; width: 20px; height: 20px; margin: 4px 0 0; accent-color: var(--accent, #16614f); }
.report-review-dialog .report-review-choice-detail { display: grid; gap: 6px; min-width: 0; }
.report-review-dialog .report-review-literal { white-space: pre-wrap; overflow-wrap: anywhere; }
.report-review-dialog .report-review-note { font-size: 14px; color: var(--muted, #596663); }
.report-review-dialog .report-review-audit { border: 1px solid var(--line, #d9e1dc); border-radius: 10px; padding: 0 16px; }
.report-review-dialog .report-review-audit summary { min-height: 44px; padding: 12px 0; cursor: pointer; font-weight: 600; overflow-wrap: anywhere; }
.report-review-dialog .report-review-audit > p { margin: 8px 0 16px; }
.report-review-dialog .report-review-raw { max-height: none; overflow: visible; padding: 16px; margin-bottom: 16px; background: var(--surface-soft, #f5f7f4); color: inherit; border: 1px solid var(--line, #d9e1dc); border-radius: 6px; font: 13px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.report-review-dialog .report-review-footer { padding: 24px 32px; border-top: 1px solid var(--line, #d9e1dc); background: var(--surface, #fff); }
.report-review-dialog .report-review-consent { padding: 0; }
.report-review-dialog .report-review-footer > .report-review-note { margin: 12px 0 20px 32px; }
.report-review-dialog .report-review-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.report-review-dialog .report-review-button { min-height: 44px; min-width: 44px; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line-strong, #b6c5bd); background: var(--surface, #fff); color: var(--ink, #14201f); font: inherit; font-weight: 600; cursor: pointer; white-space: normal; }
.report-review-dialog .report-review-primary { background: #16614f; background: color-mix(in srgb, var(--accent, #16614f) 65%, #000); color: #fff; border-color: transparent; }
.report-review-dialog .report-review-button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 600px) {
    .report-review-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); border-radius: 12px; }
    .report-review-dialog :is(.report-review-header,.report-review-body,.report-review-footer) { padding: 20px 16px; }
    .report-review-dialog h2 { font-size: 23px; }
    .report-review-dialog .report-review-header { gap: 12px; }
    .report-review-dialog .report-review-summary { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
    .report-review-dialog .report-review-finding { padding: 16px; }
    .report-review-dialog .report-review-actions { flex-direction: column; }
    .report-review-dialog .report-review-actions button { width: 100%; }
}
@media (forced-colors: active) {
    .report-review-dialog :is(.report-review-button,.report-review-choice,.report-review-audit) { border: 1px solid ButtonText; }
    .report-review-dialog .report-review-button:disabled { color: GrayText; opacity: 1; }
}

.report-review-dialog .report-review-context > summary { min-height: 44px; padding: 10px 0; cursor: pointer; font-size: 16px; }
.report-review-dialog .report-review-context > summary:focus-visible { outline: 3px solid var(--accent, #16614f); outline-offset: 3px; }

@media print {
    .report-review-dialog, .report-review-dialog::backdrop { display: none !important; }
}

.report-review-dialog .report-review-properties { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.report-review-dialog .report-review-properties .report-review-field { padding: 12px 0; }
.report-review-dialog .report-review-properties .report-review-field-heading { display: block; }
.report-review-dialog .report-review-properties .report-review-value { font-size: 14px; }
@media (max-width: 600px) {
    .report-review-dialog .report-review-properties { grid-template-columns: 1fr; gap: 0; }
}
