:root {
    --text: #1e2a3a;
    --text-secondary: #5c6b7a;
    --bg: #ffffff;
    --bg-secondary: #f5f7fa;
    --bg-explain: #f0f5ff;
    --bg-example: #f8f9fb;
    --border: #d1d9e0;
    --accent: #0076d6;
    --accent-hover: #005fad;
    --accent-light: #e8f2fc;
    --max-width: 920px;
    --radius: 6px;
    --radius-sm: 4px;
    --radius-pill: 9999px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", Menlo, Monaco, Consolas, monospace;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.65;
}

/* Header */
header {
    background: var(--accent);
    width: 100%;
    padding: 2rem 1.5rem 0;
}
header h1 {
    max-width: var(--max-width);
    margin: 0 auto;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
}
.subtitle {
    max-width: var(--max-width);
    margin: 0.15rem auto 1.25rem;
    color: rgba(255,255,255,0.75);
    font-size: 0.95rem;
}

/* Tabs */
.tabs {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    gap: 0;
    border-bottom: none;
    background: none;
    border-radius: 0;
    padding: 0;
}
.tab {
    background: none;
    border: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.65rem 1.25rem;
    cursor: pointer;
    color: rgba(255,255,255,0.65);
    border-radius: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: 0;
    transition: color 0.15s, border-color 0.15s;
}
.tab.active {
    background: none;
    color: #ffffff;
    border-bottom-color: #ffffff;
}
.tab:hover:not(.active) {
    color: rgba(255,255,255,0.9);
}

/* Main */
main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem 0;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

h2 {
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--text);
}
p { margin-bottom: 0.75rem; }

/* Pipeline diagram */
.pipeline-diagram {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.pipeline-title {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: center;
}
.pipeline-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}
.pipeline-node {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
}
.pipeline-node.input-node {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.pipeline-node.output-node {
    background: var(--text);
    color: white;
    border-color: var(--text);
}
.pipeline-node.rewrite-node {
    background: white;
    border: 1.5px dashed var(--accent);
    color: var(--accent);
}
.pipeline-optional {
    font-weight: 400;
    font-size: 0.72rem;
    opacity: 0.7;
}
.pipeline-node.small {
    font-size: 0.78rem;
    padding: 0.25rem 0.6rem;
}
.pipeline-node.qualitative-node {
    background: white;
    border: 1.5px dashed #6d28d9;
    color: #6d28d9;
}
.pipeline-box {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem 0.75rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}
.pipeline-box.quantitative-box {
    border-color: var(--accent);
}
.pipeline-box.qualitative-box {
    border-color: #6d28d9;
}
.pipeline-box-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}
.pipeline-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    background: var(--accent-light);
    color: var(--accent);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    margin-left: 0.3rem;
    vertical-align: middle;
}
.pipeline-badge.api-key {
    background: #ede9fe;
    color: #6d28d9;
}
.pipeline-arrow {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1;
}
.pipeline-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    max-width: 100%;
}
.pipeline-fork {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    width: 100%;
}
.pipeline-fork-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    max-width: 14rem;
}
.pipeline-node.guide-rewrite-node {
    background: white;
    border: 1.5px dashed #6d28d9;
    color: #6d28d9;
}

/* Form elements */
label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 0.3rem;
    margin-top: 1rem;
}
textarea {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    resize: vertical;
    line-height: 1.5;
    background: white;
}
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}
/* Drop zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--bg-secondary);
    margin-top: 0.5rem;
}
.drop-zone:hover, .drop-zone-active {
    border-color: var(--accent);
    background: var(--accent-light);
}
.drop-zone-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}
.drop-zone-prompt p {
    margin-bottom: 0.25rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.drop-zone-browse {
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
    margin: 0;
    padding: 0;
    display: inline;
}
.drop-zone-hint {
    font-size: 0.76rem !important;
    color: var(--text-secondary);
}

/* File list */
.file-list {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.file-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.75rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
}
.file-item-name {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-item-size {
    font-size: 0.76rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.file-item-remove {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
    transition: color 0.15s;
}
.file-item-remove:hover {
    color: #dc2626;
}

/* Analysis mode selector */
.analysis-modes {
    margin: 1.25rem 0 0.5rem;
}
.analysis-mode-title {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.analysis-mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}
.mode-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s;
    font-family: var(--font);
}
.mode-btn:hover {
    border-color: var(--accent);
}
.mode-btn.active {
    border-color: var(--accent);
    background: var(--accent-light);
}
.mode-label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 0.15rem;
}
.mode-desc {
    display: block;
    font-size: 0.76rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.mode-desc code {
    background: var(--bg-secondary);
    padding: 0.05rem 0.25rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}
.api-key-section {
    margin-top: 0.8rem;
    padding: 0.85rem 1rem;
    background: #faf5ff;
    border: 1px solid #e4d5f7;
    border-radius: var(--radius);
}
.api-key-label {
    display: block;
    font-weight: 600;
    font-size: 0.82rem;
    color: #6d28d9;
    margin-bottom: 0.4rem;
}
.api-key-input-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.api-key-input {
    flex: 1;
    padding: 0.4rem 0.65rem;
    border: 1px solid #e4d5f7;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: white;
    color: var(--text);
    transition: border-color 0.15s;
}
.api-key-input:focus {
    outline: none;
    border-color: #6d28d9;
    box-shadow: 0 0 0 2px rgba(109, 40, 217, 0.1);
}
.api-key-toggle {
    padding: 0.4rem 0.65rem;
    background: white;
    border: 1px solid #e4d5f7;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.76rem;
    color: #6d28d9;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.api-key-toggle:hover {
    background: #faf5ff;
}
.api-key-hint {
    margin-top: 0.35rem;
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--text-secondary);
}
.api-key-hint a {
    color: #6d28d9;
}

/* Buttons */
.primary-btn {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.55rem 1.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.secondary-btn {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.4rem 1rem;
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.secondary-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.secondary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Loading */
.loading { text-align: center; padding: 2rem 0; }
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-msg {
    transition: opacity 0.3s;
    min-height: 1.4em;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Step indicator */
.step-indicator {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}
.step-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: white;
}
.step-dot.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.step-dot.visited {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}
.step-dot:hover { border-color: var(--accent); }
.github-dot {
    width: auto;
    height: 30px;
    padding: 0 0.6rem;
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    text-decoration: none;
    margin-left: 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}
.github-dot:hover {
    background: var(--accent-hover, #4338ca);
    border-color: var(--accent-hover, #4338ca);
}

/* Step content */
.step-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text);
}

/* Explanation card */
.explain-card {
    background: var(--bg-explain);
    padding: 0.9rem 1.15rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    line-height: 1.65;
}
.explain-card p { margin-bottom: 0.4rem; }
.explain-card p:last-child { margin-bottom: 0; }

/* Example card */
.example-card {
    background: var(--bg-example);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
    margin-bottom: 1.5rem;
}
.example-title {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}
.example-passages {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.example-passage { font-size: 0.84rem; line-height: 1.65; }
.passage-label {
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}
.example-passage blockquote {
    font-style: italic;
    color: var(--text);
    padding: 0.55rem 0.7rem;
    background: white;
    border-radius: var(--radius-sm);
    margin: 0;
    border: 1px solid var(--border);
}
.example-annotation {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    font-style: italic;
}
/* Metric grid (vocabulary step) */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.6rem;
    margin: 1.25rem 0;
}
.metric-card {
    border-radius: var(--radius);
    padding: 0.75rem 0.4rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
    border: 2px solid transparent;
    color: white;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    user-select: none;
}
.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.metric-card.active {
    border-color: var(--text);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.metric-card-abbr {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1;
}
.metric-card-label {
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    opacity: 0.92;
}
.metric-card-range {
    font-size: 0.58rem;
    font-weight: 600;
    opacity: 0.7;
    margin-top: 0.1rem;
}
.metric-detail {
    background: var(--bg-explain);
    padding: 1rem 1.15rem;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0 1rem;
    font-size: 0.88rem;
    line-height: 1.65;
    animation: fadeSlideIn 0.15s ease;
}
.metric-detail-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.4rem;
    color: var(--text);
}
.metric-range-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    margin-top: 0.6rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
}
.metric-example-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.65;
}
.metric-example-label {
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-bottom: 0.3rem;
}
/* TikZ diagram box inside metric detail panels */
.tikz-diagram-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    margin-top: 0.75rem;
    text-align: center;
    overflow-x: auto;
}
.tikz-diagram-box svg { max-width: 100%; height: auto; }
.tikz-diagram-box pre { white-space: pre-wrap; word-break: break-word; }
.tikz-diagram-label {
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

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

/* Results section within a step */
.step-results { margin-top: 1.25rem; }
.step-results h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

/* Step navigation */
.step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.step-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Results data */
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.results-meta {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
}

/* Chart */
.chart-section { margin: 1.5rem 0; }
.chart-container { max-width: 400px; margin: 0 auto; }
.dominant-styles {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-weight: 600;
}

/* Data tables */
.result-section { margin: 0.75rem 0; }
.result-section summary {
    font-weight: 700;
    cursor: pointer;
    padding: 0.4rem 0;
    font-size: 0.88rem;
}
.result-section .content {
    padding: 0.5rem 0 0.5rem 0.5rem;
    font-size: 0.88rem;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.84rem;
}
th, td {
    text-align: left;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
th { font-weight: 600; }
td:last-child { font-family: var(--font-mono); font-size: 0.8rem; }

/* Style guide rendered markdown */
.style-guide-rendered {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    font-size: 0.88rem;
    line-height: 1.7;
}
.style-guide-rendered h1 {
    font-size: 1.1rem;
    margin: 0 0 0.75rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
}
.style-guide-rendered h2 {
    font-size: 0.95rem;
    margin: 1.25rem 0 0.5rem;
    color: var(--text);
}
.style-guide-rendered h3 {
    font-size: 0.88rem;
    margin: 1rem 0 0.35rem;
}
.style-guide-rendered ul, .style-guide-rendered ol {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}
.style-guide-rendered li {
    margin-bottom: 0.3rem;
}
.style-guide-rendered p {
    margin-bottom: 0.6rem;
}
.style-guide-rendered strong {
    color: var(--text);
}
.style-guide-rendered code {
    background: var(--bg-secondary);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.style-guide-rendered em {
    color: var(--text-secondary);
}

/* Rewrite */
.rewrite-intro {
    margin-bottom: 0.5rem;
    font-size: 0.92rem;
}
.rewrite-source-selector {
    margin: 1.25rem 0 0.5rem;
}
.rewrite-source-title {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.rewrite-source-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}
.rewrite-source-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s;
    font-family: var(--font);
}
.rewrite-source-btn:hover {
    border-color: var(--accent);
}
.rewrite-source-btn.active {
    border-color: var(--accent);
    background: var(--accent-light);
}
.rewrite-source-panel {
    margin-top: 0.75rem;
}
.rewrite-analysis-summary {
    background: var(--bg-explain);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.rewrite-analysis-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.rewrite-analysis-summary p {
    font-size: 0.85rem;
    color: var(--text);
    margin: 0;
}
.rewrite-no-analysis {
    color: var(--text-secondary);
    font-size: 0.88rem;
    padding: 0.75rem 0;
}
.label-optional {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.rewrite-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    gap: 1rem;
    margin-top: 1rem;
}
.rewrite-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}
.rewrite-col label {
    margin-top: 0;
}
.rewrite-col textarea {
    flex: 1;
    min-height: 280px;
    resize: vertical;
    overflow-y: auto;
}
.rewrite-output {
    flex: 1;
    background: white;
    padding: 1.15rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    line-height: 1.65;
    border: 1px solid var(--border);
    min-height: 280px;
    overflow-y: auto;
    resize: vertical;
}
.rewrite-output h1 { font-size: 1.1rem; margin: 0 0 0.75rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.rewrite-output h2 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
.rewrite-output h3 { font-size: 0.88rem; margin: 1rem 0 0.35rem; }
.rewrite-output ul, .rewrite-output ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.rewrite-output li { margin-bottom: 0.3rem; }
.rewrite-output p { margin-bottom: 0.6rem; }
.rewrite-output strong { color: var(--text); }
.rewrite-output code { background: var(--bg-secondary); padding: 0.1rem 0.3rem; border-radius: 3px; font-family: var(--font-mono); font-size: 0.8rem; }
.rewrite-output pre { background: var(--bg-secondary); padding: 0.75rem 1rem; border-radius: var(--radius-sm); overflow-x: auto; margin-bottom: 0.75rem; }
.rewrite-output pre code { background: none; padding: 0; font-size: 0.78rem; }
.rewrite-output .mermaid {
    background: white;
    padding: 0.5rem;
    text-align: center;
    overflow-x: auto;
    margin-bottom: 0.75rem;
    /* Reset inherited properties so mermaid's own theme controls the look */
    color: initial;
    font-family: "trebuchet ms", verdana, arial, sans-serif;
    font-size: 16px;
    line-height: normal;
}
.rewrite-output .mermaid svg { max-width: 100%; height: auto; }
.rewrite-output .mermaid svg * { margin: initial; padding: initial; box-sizing: initial; }
.rewrite-output .diagram-block { position: relative; margin-bottom: 0.75rem; }
.rewrite-output .diagram-label {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.rewrite-output .diagram-block pre { border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm); margin-bottom: 0; }
.rewrite-output-placeholder {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.85rem;
}
.rewrite-output-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Example callout */
.example-callout {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    background: var(--bg-explain);
    border-radius: var(--radius-sm);
    text-align: center;
}
.example-callout p {
    margin-bottom: 0.75rem;
    font-size: 0.88rem;
}
.example-callout .primary-btn {
    margin-top: 0;
}

/* Whitelist explainer */
.whitelist-explainer {
    margin: 0.75rem 0 0.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
}
.whitelist-explainer summary {
    padding: 0.65rem 1rem;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text);
}
.whitelist-explainer summary:hover {
    color: var(--accent);
}
.whitelist-explainer-body {
    padding: 0 1rem 1rem;
    font-size: 0.85rem;
    line-height: 1.65;
}
.whitelist-explainer-body p {
    margin-bottom: 0.6rem;
}
.whitelist-diagram {
    margin: 0.75rem 0;
    padding: 1rem;
}
.whitelist-diagram .pipeline-node.small {
    text-align: left;
    font-weight: 500;
}
.whitelist-diagram .pipeline-fork-branch {
    max-width: 18rem;
}

/* Diagrams stripped badge */
.diagrams-stripped-badge {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.diagrams-stripped-ok {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}
.diagrams-stripped-warn {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Prose fabricated numbers badge */
.prose-fabricated-badge {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    cursor: help;
}
.prose-fabricated-ok {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}
.prose-fabricated-warn {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

/* Inline fabricated number highlighting */
.fabricated-number {
    background: #fef3c7;
    color: #92400e;
    padding: 0 0.15em;
    border-radius: 2px;
    border-bottom: 2px solid #f59e0b;
}
.fabricated-marker {
    font-size: 0.7em;
    color: #d97706;
    margin-left: 0.1em;
    cursor: help;
    vertical-align: super;
}

/* Extraction panel */
.extraction-panel {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}
.extraction-panel summary {
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
}
.extraction-panel summary:hover {
    color: var(--text-primary);
}
.extraction-body {
    padding: 0 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.extraction-section h4 {
    margin: 0 0 0.35rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}
.extraction-section .empty-msg {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8rem;
}
.extraction-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.extraction-table th,
.extraction-table td {
    text-align: left;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.extraction-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.extraction-table td:first-child {
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
}
.extraction-table .context-cell {
    color: var(--text-secondary);
    font-size: 0.78rem;
}
.extraction-container-block {
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
}
.extraction-container-block .container-type {
    font-weight: 600;
    font-size: 0.76rem;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.extraction-container-block pre {
    margin: 0;
    font-size: 0.76rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 10rem;
    overflow-y: auto;
    color: var(--text-primary);
}
.extraction-counts {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.extraction-count-badge {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* Example selector */
.example-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.example-selector-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}
.example-selector-pills {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.example-pill {
    font-size: 0.76rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}
.example-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.example-pill.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Error */
.error {
    color: #9a2c2c;
    background: #fef2f2;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    border: 1px solid #fecaca;
    font-weight: 600;
    font-size: 0.88rem;
}

/* File upload */
.file-upload {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0.25rem 0;
}
.upload-label {
    text-decoration: underline;
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
}

/* JSON actions */
.json-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

/* Profile summary grid */
.profile-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.profile-section-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    background: var(--bg);
    transition: box-shadow 0.15s;
}
.profile-section-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.profile-section-absent {
    opacity: 0.5;
}
.profile-section-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}
.profile-section-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.4rem;
}
.profile-section-highlight {
    font-size: 0.82rem;
    color: var(--accent);
    font-weight: 500;
}
.profile-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Footer */
footer {
    max-width: var(--max-width);
    margin: 3rem auto 0;
    padding: 0 1.5rem 2rem;
}
footer p { font-size: 0.82rem; color: var(--text-secondary); }
footer a { color: var(--accent); }

/* Responsive */
@media (max-width: 600px) {
    .chart-container { max-width: 100%; }
    .example-passages { grid-template-columns: 1fr; }
    .pipeline-grid { flex-direction: column; align-items: center; }
    .pipeline-fork { flex-direction: column; align-items: center; }
    .pipeline-fork-branch { max-width: 100%; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .analysis-mode-options { grid-template-columns: 1fr; }
    .rewrite-source-options { grid-template-columns: 1fr; }
    .rewrite-columns { grid-template-columns: 1fr; }
    .tabs { gap: 0; }
    .tab { font-size: 0.82rem; padding: 0.5rem 0.7rem; }
}

/* Utility */
.hidden { display: none !important; }
