/* Exam Viewer — ข้อสอบธรรมบท (public, read-only)
   ออกแบบใหม่ ๘ ต.ค. ๒๕๖๙: หัวสั้น + แถบกลับคลังข้อสอบ · แท็บแบบ segmented · แถบกรองติดบน ·
   รายการจัดกลุ่มตามปี (พับได้) · แถวเป็นการ์ดบนมือถือ — ธีมคราม เดียวกับ /exam-bank */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&display=swap');

:root {
    --ev-primary: #4f46e5;
    --ev-primary-light: #6366f1;
    --ev-primary-dark: #3730a3;
    --ev-primary-wash: #eef2ff;
    --ev-accent: #4f46e5;
    --ev-accent-light: #eef2ff;
    --ev-bg: #f8fafc;
    --ev-card-bg: #ffffff;
    --ev-surface-2: #f1f5f9;
    --ev-text: #0f172a;
    --ev-text-soft: #475569;
    --ev-text-muted: #64748b;
    --ev-border: #e2e8f0;
    --ev-past-accent: #4f46e5;
    --ev-predict-accent: #2563eb;
    --ev-pdf: #b91c1c;
    --ev-font: 'Sarabun', sans-serif;
}

* { box-sizing: border-box; }

body {
    background: var(--ev-bg) !important;
    font-family: var(--ev-font);
    color: var(--ev-text);
    margin: 0;
    padding: 0;
}

#app { overflow-x: clip; }

/* ── Back bar (ยกหน้าตาจาก .eb-backbar ของ /exam-bank) ── */
.ev-backbar { background: rgba(255,255,255,.7); border-bottom: 1px solid #e0e7ff; }
.ev-backbar-inner {
    max-width: 1040px; margin: 0 auto; padding: .55rem 1rem;
    display: flex; align-items: center; gap: .75rem; min-width: 0;
}
.ev-back-link {
    display: inline-flex; align-items: center; gap: .45rem; flex-shrink: 0;
    padding: .38rem .8rem; border-radius: 999px; border: 1px solid #c7d2fe;
    background: #fff; color: var(--ev-primary); font-size: .85rem; font-weight: 700;
    text-decoration: none; transition: all .15s;
}
.ev-back-link:hover { background: var(--ev-primary-wash); border-color: var(--ev-primary); color: var(--ev-primary); }
.ev-backbar-sub { color: var(--ev-text-muted); font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Container */
.ev-container {
    max-width: 1040px;
    margin: 0 auto;
    padding: 1rem 1rem 3rem;
}

/* ── Page head ── */
.ev-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1.25rem; margin: .2rem 0 1rem; }
.ev-head-text { flex: 1 1 20rem; min-width: 0; }
.ev-head h1 { margin: 0; font-size: clamp(1.5rem, 4.4vw, 2rem); font-weight: 800; color: var(--ev-text); letter-spacing: -.01em; line-height: 1.25; }
.ev-head h1 span { color: var(--ev-primary); }
.ev-head p { margin: .3rem 0 0; font-size: .9rem; color: var(--ev-text-muted); line-height: 1.6; }
.ev-head-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ev-text-toggle, .ev-head-link {
    display: inline-flex; align-items: center; gap: .35rem; min-height: 38px;
    padding: .35rem .8rem; border-radius: 10px; border: 1px solid var(--ev-border);
    background: #fff; color: var(--ev-text-soft); font: inherit; font-size: .85rem; font-weight: 700;
    text-decoration: none; cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.ev-text-toggle-big { font-size: 1.15em; margin-left: -.15rem; }
.ev-text-toggle:hover, .ev-head-link:hover { border-color: #a5b4fc; color: var(--ev-primary); }
.ev-text-toggle[aria-pressed="true"] { background: var(--ev-primary-wash); border-color: var(--ev-primary); color: var(--ev-primary); }

/* ── Tabs: segmented control ── */
.ev-tabs {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px;
    background: var(--ev-surface-2); border: 1px solid var(--ev-border); border-radius: 12px; padding: 3px;
    margin-bottom: .9rem;
}
.ev-tab {
    min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem .6rem; border: 0; border-radius: 9px; background: transparent;
    color: var(--ev-text-muted); font: inherit; font-size: .92rem; font-weight: 700; cursor: pointer;
    white-space: nowrap; transition: color .15s, background .15s;
}
.ev-tab:hover { color: var(--ev-primary); }
.ev-tab.is-active { background: #fff; color: var(--ev-primary); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.ev-tab-label { overflow: hidden; text-overflow: ellipsis; }
.ev-tab-count {
    font-size: .74rem; font-weight: 700; color: var(--ev-text-muted); background: rgba(100,116,139,.12);
    padding: 0 .4rem; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.ev-tab.is-active .ev-tab-count { background: var(--ev-primary-wash); color: var(--ev-primary); }

/* ── Sticky filter bar ── */
.ev-toolbar {
    position: sticky; top: 0; z-index: 40;
    margin: 0 -1rem .6rem; padding: .55rem 1rem;
    background: rgba(248,250,252,.92); backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid transparent;
}
.ev-toolbar-row { display: flex; gap: .5rem; align-items: stretch; }
.ev-search {
    flex: 1 1 auto; min-width: 0; position: relative; display: flex; align-items: center; margin: 0;
}
.ev-search i { position: absolute; left: .75rem; color: var(--ev-text-muted); font-size: .9rem; pointer-events: none; }
.ev-search input {
    width: 100%; min-height: 42px; padding: .5rem .8rem .5rem 2.2rem;
    border: 1px solid var(--ev-border); border-radius: 12px; background: #fff;
    font: inherit; font-size: .95rem; color: var(--ev-text);
}
.ev-search input:focus { outline: none; border-color: var(--ev-primary-light); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.ev-tool-btn {
    flex: none; display: inline-flex; align-items: center; gap: .4rem; min-height: 42px;
    padding: .45rem .85rem; border: 1px solid var(--ev-border); border-radius: 12px; background: #fff;
    color: var(--ev-text-soft); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.ev-tool-btn:hover { border-color: #a5b4fc; color: var(--ev-primary); }
.ev-tool-btn.is-on { border-color: var(--ev-primary); color: var(--ev-primary); background: var(--ev-primary-wash); }
.ev-tool-chev { font-size: .75rem; }
.ev-tool-export { color: #047857; }
.ev-tool-export:hover { border-color: #6ee7b7; color: #047857; background: #ecfdf5; }

.ev-filter-count {
    background: var(--ev-primary); color: #fff; font-size: .75rem; line-height: 1.5;
    padding: 0 .45rem; border-radius: 999px; font-weight: 700;
}

.ev-filter-panel {
    margin-top: .55rem; background: #fff; border: 1px solid var(--ev-border); border-radius: 14px;
    padding: .8rem; box-shadow: 0 10px 30px -12px rgba(15,23,42,.18);
}
.ev-filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.ev-filter-wide { grid-column: span 2; }
.ev-filter-group label {
    display: block; font-size: .8rem; font-weight: 700; color: var(--ev-text-muted); margin-bottom: .25rem;
}
.ev-filter-group select {
    width: 100%; padding: 7px 10px; border: 1px solid var(--ev-border); border-radius: 8px;
    font-size: .9rem; color: var(--ev-text); background: white; font-family: var(--ev-font); appearance: auto;
}
.ev-filter-group select:focus,
.ev-filter-group input[type="text"]:focus {
    outline: none; border-color: var(--ev-primary-light); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}
.ev-filter-group input[type="text"] {
    width: 100%; padding: 7px 10px; border: 1px solid var(--ev-border); border-radius: 8px;
    font-size: .9rem; color: var(--ev-text); background: white; font-family: var(--ev-font);
}
.ev-filter-actions {
    display: flex; justify-content: flex-end; gap: .5rem; margin-top: .7rem; padding-top: .6rem;
    border-top: 1px solid var(--ev-border);
}
.ev-btn-reset, .ev-btn-done {
    display: inline-flex; align-items: center; gap: .35rem; min-height: 36px;
    padding: .3rem .9rem; border-radius: 10px; font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer;
}
.ev-btn-reset { border: 1px solid var(--ev-border); background: #fff; color: var(--ev-text-muted); }
.ev-btn-reset:hover { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.ev-btn-done { border: 1px solid var(--ev-primary); background: var(--ev-primary); color: #fff; }
.ev-btn-done:hover { background: var(--ev-primary-dark); }

/* Results info */
.ev-results-info {
    display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem;
    margin: 0 0 .6rem; font-size: .88rem; color: var(--ev-text-muted);
}
.ev-results-info b { color: var(--ev-text); font-variant-numeric: tabular-nums; }
.ev-results-tools { margin-left: auto; display: inline-flex; gap: .2rem; }
.ev-link-btn {
    border: 0; background: none; padding: .25rem .4rem; border-radius: 6px; cursor: pointer;
    font: inherit; font-size: .85rem; font-weight: 700; color: var(--ev-primary);
}
.ev-link-btn:hover { background: var(--ev-primary-wash); }

/* ── Year groups ── */
.ev-groups { display: grid; gap: .6rem; }
.ev-group { background: #fff; border: 1px solid var(--ev-border); border-radius: 14px; overflow: hidden; }
.ev-group.is-open { border-color: #c7d2fe; }
.ev-group-h { margin: 0; font-size: inherit; }
.ev-group-toggle {
    width: 100%; display: flex; align-items: center; gap: .3rem .75rem; flex-wrap: wrap;
    padding: .75rem 1rem; border: 0; background: #fff; font: inherit; text-align: left; cursor: pointer; color: var(--ev-text);
}
.ev-group-toggle:hover { background: #fafbff; }
.ev-group-year { font-size: 1.05rem; font-weight: 800; color: var(--ev-text); font-variant-numeric: tabular-nums; }
.ev-group.is-open .ev-group-year { color: var(--ev-primary); }
.ev-group-sub { flex: 1 1 10rem; min-width: 0; font-size: .82rem; color: var(--ev-text-muted); font-weight: 600; }
.ev-group-count {
    margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--ev-text-soft);
    background: var(--ev-surface-2); padding: .1rem .55rem; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.ev-group-chev { color: var(--ev-text-muted); transition: transform .2s; }
.ev-group.is-open .ev-group-chev { transform: rotate(180deg); color: var(--ev-primary); }
.ev-group-body { border-top: 1px solid var(--ev-border); padding: .25rem 0 .4rem; }

.ev-set + .ev-set { border-top: 1px solid var(--ev-border); }
.ev-set-h {
    display: flex; flex-wrap: wrap; align-items: center; gap: .35rem;
    padding: .65rem 1rem .25rem; font-size: .82rem;
}
.ev-set-class { font-weight: 800; color: var(--ev-primary-dark); background: var(--ev-primary-wash); padding: .05rem .55rem; border-radius: 999px; }
.ev-set-subject { font-weight: 800; color: var(--ev-text); }
.ev-set-round { color: var(--ev-text-muted); font-weight: 600; }
.ev-set-round::before, .ev-set-subject + .ev-set-round::before { content: "· "; }

.ev-rows { list-style: none; margin: 0; padding: 0; }
.ev-row {
    display: grid; grid-template-columns: 3.4rem minmax(0, 1fr) 9.5rem auto;
    align-items: center; gap: .25rem .9rem;
    padding: .55rem 1rem; border-top: 1px solid #f1f5f9;
}
.ev-set-h + .ev-rows .ev-row:first-child { border-top: 0; }
.ev-row:hover { background: #fafbff; }
.is-predict .ev-row { grid-template-columns: minmax(0, 1fr) 9.5rem auto; }
.ev-row-q {
    justify-self: start; font-size: .78rem; font-weight: 800; color: var(--ev-text-soft);
    background: var(--ev-surface-2); padding: .1rem .5rem; border-radius: 6px; white-space: nowrap;
}
.ev-row-main { min-width: 0; }
.ev-row-story { font-weight: 700; color: var(--ev-text); line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-row-sent { font-size: .86rem; color: var(--ev-text-muted); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-row-by { font-size: .8rem; color: var(--ev-predict-accent); font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.ev-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-size: .84rem; white-space: nowrap; }
.ev-row-book { font-weight: 800; color: var(--ev-primary); background: var(--ev-primary-wash); padding: .05rem .5rem; border-radius: 6px; }
.ev-row-page { color: var(--ev-text-soft); font-weight: 600; font-variant-numeric: tabular-nums; }
.ev-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; }

.ev-act {
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 34px;
    padding: .25rem .65rem; border-radius: 9px; border: 1px solid; font-size: .82rem; font-weight: 700;
    text-decoration: none; white-space: nowrap; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.ev-act-pdf { color: var(--ev-pdf); background: #fff; border-color: #fecaca; }
.ev-act-pdf:hover { background: var(--ev-pdf); border-color: var(--ev-pdf); color: #fff; }
.ev-act-book { color: var(--ev-primary); background: #fff; border-color: #c7d2fe; }
.ev-act-book:hover { background: var(--ev-primary); border-color: var(--ev-primary); color: #fff; }
.ev-pdf-missing { font-size: .8rem; color: var(--ev-text-muted); white-space: nowrap; padding: 0 .2rem; }

.ev-more {
    display: block; width: calc(100% - 2rem); margin: .5rem 1rem .3rem; min-height: 40px;
    border: 1px dashed #c7d2fe; border-radius: 10px; background: #fafbff; color: var(--ev-primary);
    font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer;
}
.ev-more span { color: var(--ev-text-muted); font-weight: 600; }
.ev-more:hover { background: var(--ev-primary-wash); border-style: solid; }

/* Loading / Empty */
.ev-loading, .ev-empty { text-align: center; padding: 50px 20px; color: var(--ev-text-muted); }
.ev-loading i, .ev-empty i { font-size: 2rem; display: block; margin-bottom: 10px; }
.ev-loading i { color: var(--ev-accent); }
.ev-empty i { color: #cbd5e1; }
.ev-empty-text { font-size: 1rem; font-weight: 700; color: var(--ev-text-soft); }
.ev-empty-sub { font-size: .9rem; margin-top: 4px; }

@keyframes ev-spin { to { transform: rotate(360deg); } }
.ev-spinner { animation: ev-spin 1s linear infinite; display: inline-block; }

/* ── Tablet / phone: rows become compact cards ── */
@media (max-width: 760px) {
    .ev-row, .is-predict .ev-row {
        display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; padding: .7rem 1rem;
    }
    .ev-row-q { order: 1; }
    .ev-row-meta { order: 2; }
    .ev-row-actions { order: 3; margin-left: auto; }
    .ev-row-main { order: 4; flex: 1 1 100%; }
    .ev-row-story { white-space: normal; }
    .ev-row-sent { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}
@media (max-width: 560px) {
    .ev-container { padding: .75rem 1rem 2.5rem; }
    .ev-backbar-inner { padding: .5rem 1rem; }
    .ev-toolbar { padding: .5rem 1rem; }
    .ev-tabs { margin-bottom: .75rem; }
    .ev-tab { flex-direction: column; gap: 0; padding: .4rem .2rem; font-size: .84rem; line-height: 1.35; }
    .ev-tab > .bi { display: none; }
    .ev-tab-count { font-size: .7rem; padding: 0 .35rem; }
    .ev-tool-btn { padding: .45rem .7rem; }
    .ev-tool-export .ev-tool-label { display: none; }
    .ev-filter-grid { grid-template-columns: 1fr 1fr; }
    .ev-filter-wide { grid-column: 1 / -1; }
    .ev-group-toggle { padding: .7rem .85rem; }
    .ev-group-sub { order: 5; flex-basis: 100%; }
    .ev-set-h { padding: .6rem .85rem .2rem; }
    .ev-row, .is-predict .ev-row { padding: .65rem .85rem; }
    .ev-act-book .ev-act-text { display: none; }
    .ev-act-book { padding: .25rem .55rem; }
    .ev-more { width: calc(100% - 1.7rem); margin: .5rem .85rem .3rem; }
}

/* Multiselect dropdown */
.ev-multiselect {
    position: relative;
}

.ev-ms-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--ev-border);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--ev-text);
    background: white;
    font-family: var(--ev-font);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.ev-ms-trigger:hover {
    border-color: var(--ev-primary-light);
}

.ev-ms-trigger i {
    font-size: 0.875rem;
    color: var(--ev-text-muted);
}

.ev-ms-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ev-ms-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--ev-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 50;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
}

.ev-ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--ev-text);
    transition: background 0.1s;
    user-select: none;
}

.ev-ms-option:hover {
    background: #f5f7ff;
}

.ev-ms-option input[type="checkbox"] {
    accent-color: var(--ev-primary);
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.ev-ms-actions {
    padding: 4px 6px;
    border-top: 1px solid var(--ev-border);
    margin-top: 4px;
}

.ev-ms-clear {
    width: 100%;
    padding: 5px;
    border: none;
    background: none;
    color: var(--ev-text-muted);
    font-size: 0.875rem;
    font-family: var(--ev-font);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}

.ev-ms-clear:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* ========== Analysis Dashboard ========== */

.ev-analysis {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ev-analysis-filter {
    display: flex;
    gap: 10px;
}

.ev-analysis-filter .ev-filter-group {
    min-width: 180px;
}

.ev-analysis-filter select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--ev-border);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--ev-text);
    background: white;
    font-family: var(--ev-font);
}

.ev-analysis-filter label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ev-text-muted);
    margin-bottom: 3px;
}

/* Stat Cards */
.ev-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.ev-stat-card {
    background: var(--ev-card-bg);
    border: 1px solid var(--ev-border);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}

.ev-stat-card.ev-stat-highlight {
    background: linear-gradient(135deg, #f5f7ff, #eef2ff);
    border-color: var(--ev-primary-light);
}

.ev-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ev-primary);
    line-height: 1.2;
}

.ev-stat-label {
    font-size: 0.875rem;
    color: var(--ev-text-muted);
    margin-top: 4px;
}

/* Chart Boxes */
.ev-chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ev-chart-box {
    background: var(--ev-card-bg);
    border: 1px solid var(--ev-border);
    border-radius: 10px;
    padding: 16px;
}

.ev-chart-box.ev-chart-full {
    width: 100%;
}

.ev-chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ev-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ev-chart-title i {
    font-size: 1.1rem;
}

/* Cross-class Analysis */
.ev-cross-desc {
    font-size: 0.88rem;
    color: var(--ev-text-muted);
    margin-bottom: 12px;
}

.ev-empty-mini {
    text-align: center;
    padding: 20px;
    color: var(--ev-text-muted);
    font-size: 0.9rem;
}

.ev-cross-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ev-cross-item {
    padding: 10px 14px;
    border: 1px solid var(--ev-border);
    border-left: 3px solid var(--ev-primary-light);
    border-radius: 8px;
    background: #f5f7ff;
}

.ev-cross-story {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ev-text);
}

.ev-cross-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: color 0.15s;
}

.ev-cross-toggle:hover {
    color: var(--ev-primary);
}

.ev-cross-class-tags {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.ev-cross-tag-sm {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--ev-accent-light);
    color: var(--ev-primary);
}

.ev-cross-book {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--ev-text-muted);
}

.ev-cross-overlap-box {
    margin-top: 8px;
    padding: 8px 10px;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 6px;
}

.ev-cross-overlap-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 4px;
}

.ev-cross-overlap-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 3px 0;
    font-size: 0.875rem;
}

.ev-cross-overlap-pages {
    font-weight: 600;
    color: #b45309;
    background: white;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
}

.ev-cross-details {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ev-cross-class-group {
    padding: 6px 0;
    border-top: 1px solid #e5e7eb;
}

.ev-cross-class-group:first-child {
    border-top: none;
    padding-top: 0;
}

.ev-cross-class-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 0.875rem;
    color: var(--ev-text-muted);
}

.ev-cross-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--ev-accent-light);
    color: var(--ev-primary);
    min-width: 70px;
    text-align: center;
}

.ev-cross-entry {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0 3px 12px;
    font-size: 0.875rem;
    flex-wrap: wrap;
    border-bottom: 1px solid #f3f4f6;
}

.ev-cross-entry:last-child {
    border-bottom: none;
}

/* Analysis responsive */
@media (max-width: 768px) {
    .ev-analysis-filter {
        flex-wrap: wrap;
    }

    .ev-analysis-filter .ev-filter-group {
        min-width: 0;
        flex: 1 1 calc(50% - 5px);
    }

    .ev-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .ev-chart-row {
        grid-template-columns: 1fr;
    }

    .ev-stat-value {
        font-size: 1.3rem;
    }
}

@media (max-width: 576px) {
    .ev-analysis-filter .ev-filter-group {
        flex: 1 1 calc(50% - 5px);
    }
}

@media (max-width: 576px) {
    .ev-stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .ev-stat-card {
        padding: 10px 12px;
    }

    .ev-stat-value {
        font-size: 1.1rem;
    }

    .ev-chart-box {
        padding: 12px;
    }
}

/* ========== Story Coverage Map ========== */

.ev-coverage-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ev-coverage-item {
    padding: 12px 14px;
    border: 1px solid var(--ev-border);
    border-radius: 10px;
    background: #f5f7ff;
}

.ev-coverage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 4px;
}

.ev-coverage-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ev-coverage-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ev-text);
}

.ev-coverage-book {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 1px 8px;
    border-radius: 4px;
    background: var(--ev-accent-light);
    color: var(--ev-primary);
}

.ev-coverage-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    color: var(--ev-text-muted);
}

.ev-coverage-pct {
    font-weight: 700;
    color: #dc2626;
}

.ev-coverage-pct.ev-coverage-mid {
    color: #d97706;
}

.ev-coverage-pct.ev-coverage-full {
    color: #16a34a;
}

/* Toggle switch for predictions */
.ev-coverage-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 4px;
}

.ev-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.ev-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ev-switch-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.ev-switch-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.ev-switch input:checked + .ev-switch-slider {
    background: #d97706;
}

.ev-switch input:checked + .ev-switch-slider::before {
    transform: translateX(16px);
}

.ev-switch-label {
    font-size: 0.875rem;
    color: var(--ev-text);
    font-weight: 500;
}

/* The main coverage bar */
.ev-coverage-bar {
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--ev-border);
    background: white;
}

.ev-coverage-segment {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2px;
    transition: opacity 0.15s;
    overflow: hidden;
}

.ev-seg-tested {
    cursor: pointer;
    background: transparent;
}

.ev-seg-tested:hover {
    opacity: 0.85;
}

.ev-seg-predicted {
    cursor: pointer;
    background: transparent;
}

.ev-seg-predicted:hover {
    opacity: 0.85;
}

.ev-seg-empty {
    background: white;
}

/* Intensity fill layer (set via inline style) */
.ev-seg-fill {
    position: absolute;
    inset: 0;
    z-index: 0;
}

/* Prediction overlay: gold stripe on top half */
.ev-seg-fill-pred {
    inset: 0 0 50% 0;
    z-index: 1;
    border-bottom: 1px solid rgba(255,255,255,0.4);
}

/* Prediction-only segment (no exam): fill full height */
.ev-seg-predicted:not(.ev-seg-tested) .ev-seg-fill-pred {
    inset: 0;
    border-bottom: none;
}

/* Count badge on segment */
.ev-seg-count {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 0.875rem;
    color: rgba(255,255,255,0.85);
    font-weight: 700;
    z-index: 1;
}

.ev-seg-label {
    font-size: 0.875rem;
    color: white;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    z-index: 1;
    position: relative;
}

.ev-seg-empty .ev-seg-label {
    color: var(--ev-text-muted);
    font-size: 0.875rem;
    text-shadow: none;
}

/* Scale numbers under bar */
.ev-coverage-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--ev-text-muted);
    margin-top: 2px;
    padding: 0 2px;
}

/* Detail panel when segment clicked */
.ev-coverage-detail {
    position: relative;
    margin-top: 8px;
    padding: 8px 10px;
    background: white;
    border: 1px solid var(--ev-border);
    border-radius: 8px;
}

.ev-coverage-detail-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    color: #6b7280;
    font-size: 0.875rem;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s;
}

.ev-coverage-detail-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.ev-coverage-detail-head {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--ev-primary);
    margin-bottom: 6px;
}

.ev-coverage-detail-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    font-size: 0.875rem;
    flex-wrap: wrap;
    border-bottom: 1px solid #f3f4f6;
}

.ev-coverage-detail-item:last-child {
    border-bottom: none;
}

.ev-coverage-subject {
    background: #eef2ff;
    color: #6d28d9;
    font-size: 0.875rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.ev-coverage-round {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.875rem;
    padding: 1px 6px;
    border-radius: 4px;
}

.ev-coverage-pages {
    color: var(--ev-text);
    font-size: 0.875rem;
    font-weight: 500;
}

.ev-coverage-sentences {
    width: 100%;
    padding-left: 4px;
    margin-top: 2px;
}

.ev-coverage-sentence {
    color: #6b21a8;
    font-size: 0.875rem;
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline;
}

.ev-coverage-sentence.ev-sentence-end {
    color: #9333ea;
}

/* Prediction detail items */
.ev-coverage-pred-divider {
    font-size: 0.875rem;
    font-weight: 600;
    color: #d97706;
    padding: 6px 0 2px;
    margin-top: 4px;
    border-top: 1px dashed #fbbf24;
}

.ev-pred-item {
    border-left: 3px solid #f59e0b;
    padding-left: 8px;
    margin-left: 2px;
}

.ev-pred-badge {
    background: #fef3c7;
    color: #b45309;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
}

.ev-pred-name {
    font-weight: 600;
    color: #92400e;
    font-size: 0.875rem;
}

/* Coverage responsive */
@media (max-width: 768px) {
    .ev-coverage-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .ev-coverage-bar {
        height: 28px;
    }

    .ev-seg-label {
        font-size: 0.875rem;
    }

    .ev-coverage-sentence {
        max-width: none;
    }
}

@media (max-width: 576px) {
    .ev-coverage-item {
        padding: 8px 10px;
    }

    .ev-coverage-bar {
        height: 24px;
    }

    .ev-coverage-meta {
        gap: 6px;
        font-size: 0.875rem;
    }
}

/* ========== Prediction Accuracy ========== */

.ev-accuracy-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.ev-accuracy-card {
    background: #f5f7ff;
    border: 1px solid var(--ev-border);
    border-radius: 10px;
    padding: 14px 16px;
    transition: box-shadow 0.2s;
}

.ev-accuracy-card:hover {
    box-shadow: 0 2px 8px rgba(91, 33, 182, 0.1);
}

.ev-accuracy-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--ev-text);
    margin-bottom: 6px;
}

.ev-accuracy-stats {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.ev-accuracy-hit {
    font-weight: 700;
    color: #16a34a;
}

.ev-accuracy-total {
    color: var(--ev-text-muted);
}

.ev-accuracy-pct {
    font-weight: 700;
    color: var(--ev-primary);
    margin-left: 2px;
}

.ev-accuracy-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--ev-border);
    border-radius: 4px;
    overflow: hidden;
}

.ev-accuracy-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ev-primary), var(--ev-primary-light));
    border-radius: 4px;
    transition: width 0.4s ease;
    min-width: 2px;
}

/* Detail expandable section */
.ev-accuracy-detail {
    border: 1px solid var(--ev-border);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}

.ev-accuracy-detail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f5f7ff, #e0e7ff);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ev-primary);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.ev-accuracy-detail-title:hover {
    background: linear-gradient(135deg, #e0e7ff, #eef2ff);
}

.ev-accuracy-detail-title i {
    font-size: 0.875rem;
    transition: transform 0.2s;
}

.ev-accuracy-items {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ev-accuracy-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--ev-border);
    background: white;
    align-items: center;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.ev-accuracy-item.ev-hit {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.ev-accuracy-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ev-accuracy-icon {
    flex-shrink: 0;
    font-size: 1rem;
    color: #16a34a;
}

.ev-accuracy-icon.ev-miss {
    color: #dc2626;
    opacity: 0.5;
}

.ev-accuracy-item-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ev-accuracy-story {
    font-weight: 500;
    color: var(--ev-text);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ev-accuracy-year {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--ev-accent-light);
    color: var(--ev-primary);
}

.ev-accuracy-class {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    background: #f0fdf4;
    color: #15803d;
}

.ev-accuracy-match-info {
    grid-column: 1 / -1;
    font-size: 0.875rem;
    color: #16a34a;
    padding-left: 28px;
    font-weight: 500;
}

/* Accuracy responsive */
@media (max-width: 768px) {
    .ev-accuracy-summary {
        grid-template-columns: 1fr;
    }

    .ev-accuracy-item {
        grid-template-columns: 1fr;
    }

    .ev-accuracy-item-right {
        padding-left: 28px;
    }

    .ev-accuracy-story {
        max-width: none;
    }
}

@media (max-width: 576px) {
    .ev-accuracy-card {
        padding: 10px 12px;
    }

    .ev-accuracy-items {
        padding: 6px;
    }

    .ev-accuracy-item {
        padding: 6px 10px;
    }
}

/* ========== Book Selector ========== */

.ev-book-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.ev-book-btn {
    padding: 6px 14px;
    border: 2px solid var(--ev-border);
    border-radius: 8px;
    background: white;
    font-family: var(--ev-font);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ev-text);
    cursor: pointer;
    transition: all 0.15s;
}

.ev-book-btn:hover {
    border-color: var(--ev-primary-light);
    background: var(--ev-accent-light);
}

.ev-book-btn.active {
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

@media (max-width: 576px) {
    .ev-book-selector {
        gap: 4px;
    }

    .ev-book-btn {
        padding: 5px 10px;
        font-size: 0.875rem;
    }
}

/* ========== Chart Legend ========== */

.ev-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.ev-chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ev-text);
}

.ev-chart-legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ========== Forecast ========== */

.ev-forecast-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ev-forecast-card {
    background: var(--ev-card-bg);
    border: 1px solid var(--ev-border);
    border-radius: 10px;
    padding: 16px;
}

.ev-forecast-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ev-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ev-forecast-header i {
    font-size: 1.1rem;
}

.ev-forecast-r2 {
    padding: 8px 12px;
    background: #ecfdf5;
    border: 1px solid #86efac;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #166534;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ev-forecast-r2.ev-forecast-r2-unknown {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

.ev-forecast-books {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ev-forecast-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ev-forecast-bar-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ev-text);
    min-width: 42px;
    text-align: right;
}

.ev-forecast-bar {
    flex: 1;
    height: 20px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
}

.ev-forecast-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.ev-forecast-bar-pct {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--ev-text);
    min-width: 36px;
    text-align: right;
}

.ev-forecast-stories {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--ev-border);
}

.ev-forecast-stories-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ev-primary);
    margin-bottom: 6px;
}

.ev-forecast-story {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 0.875rem;
    flex-wrap: wrap;
}

.ev-forecast-story-rank {
    font-weight: 700;
    color: var(--ev-primary);
    min-width: 18px;
}

.ev-forecast-story-name {
    font-weight: 500;
    color: var(--ev-text);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ev-forecast-story-pct {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--ev-primary);
}

.ev-forecast-story-count {
    font-size: 0.875rem;
    font-weight: 600;
    background: #eef2ff;
    color: #6d28d9;
    padding: 1px 6px;
    border-radius: 4px;
}

.ev-forecast-story-year {
    font-size: 0.875rem;
    color: var(--ev-text-muted);
}

.ev-forecast-tag-pred {
    font-size: 0.875rem;
    font-weight: 700;
    background: #fef3c7;
    color: #b45309;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid #fbbf24;
}

.ev-forecast-story-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    color: var(--ev-primary);
    background: var(--ev-accent-light);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s;
    margin-left: auto;
    flex-shrink: 0;
}

.ev-forecast-story-link:hover {
    background: var(--ev-accent);
    color: white;
}

/* Page-level forecast cards */
.ev-forecast-page-card {
    background: var(--ev-card-bg);
    border: 1px solid var(--ev-border);
    border-radius: 10px;
    padding: 16px;
}

.ev-forecast-page-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ev-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ev-forecast-page-title i {
    font-size: 1rem;
}

.ev-forecast-page-book {
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--ev-accent-light);
    color: var(--ev-primary);
    padding: 2px 8px;
    border-radius: 4px;
}

.ev-forecast-page-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ev-forecast-page-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ev-forecast-page-range {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ev-text);
    min-width: 80px;
    white-space: nowrap;
}

.ev-forecast-page-meta {
    font-size: 0.875rem;
    color: var(--ev-text-muted);
    white-space: nowrap;
}

.ev-forecast-page-story {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ev-primary);
    background: var(--ev-accent-light);
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* Forecast reason button & detail */
.ev-forecast-reason-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--ev-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ev-forecast-reason-btn:hover,
.ev-forecast-reason-btn.active {
    color: var(--ev-primary);
    background: var(--ev-accent-light);
}

.ev-forecast-reason {
    background: #f8f5ff;
    border: 1px solid #e9e0ff;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 2px 0 8px 0;
    animation: ev-slide-down 0.2s ease;
}

@keyframes ev-slide-down {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.ev-forecast-reason-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.ev-forecast-reason-tag {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.ev-forecast-reason-tag.recent {
    background: #dcfce7;
    color: #166534;
}

.ev-forecast-reason-tag.mid {
    background: #fef3c7;
    color: #92400e;
}

.ev-forecast-reason-tag.old {
    background: #f1f5f9;
    color: #475569;
}

.ev-forecast-reason-score {
    font-size: 0.875rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--ev-accent-light);
    color: var(--ev-primary);
}

.ev-forecast-reason-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ev-text-muted);
    margin-bottom: 6px;
}

.ev-forecast-reason-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ev-forecast-reason-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    padding: 3px 6px;
    border-radius: 4px;
}

.ev-forecast-reason-item.recent {
    background: rgba(22, 163, 74, 0.06);
}

.ev-forecast-reason-item.mid {
    background: rgba(217, 119, 6, 0.06);
}

.ev-forecast-reason-item.old {
    background: rgba(100, 116, 139, 0.06);
}

.ev-forecast-reason-year {
    font-weight: 700;
    color: var(--ev-text);
    min-width: 36px;
}

.ev-forecast-reason-pages {
    color: var(--ev-text-muted);
    min-width: 70px;
}

.ev-forecast-reason-story {
    color: var(--ev-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.ev-forecast-reason-class {
    font-size: 0.875rem;
    color: var(--ev-text-muted);
    background: #f1f5f9;
    padding: 0 5px;
    border-radius: 3px;
}

.ev-forecast-reason-weight {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--ev-text-muted);
    margin-left: auto;
}

/* Forecast responsive */
@media (max-width: 768px) {
    .ev-forecast-grid {
        grid-template-columns: 1fr;
    }

    .ev-forecast-story-name {
        max-width: none;
    }

    .ev-forecast-page-row {
        flex-wrap: wrap;
    }

    .ev-forecast-page-story {
        max-width: none;
    }

    .ev-forecast-reason-story {
        max-width: none;
    }

    .ev-forecast-reason-item {
        flex-wrap: wrap;
    }
}

@media (max-width: 576px) {
    .ev-forecast-card {
        padding: 10px 12px;
    }

    .ev-forecast-page-card {
        padding: 10px 12px;
    }
}

/* Evidence-based reading forecast */
[v-cloak] { display: none; }
.ev-evidence-note { background: #fff; border: 1px solid var(--ev-border); border-left: 4px solid var(--ev-primary); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.ev-evidence-note h2 { font-size: 1.4rem; margin: 0 0 12px; }
.ev-evidence-note p, .ev-forecast-body p { margin: 8px 0 14px; }
.ev-evidence-note, .ev-forecast-body { font-size: 1rem; line-height: 1.7; }
.ev-forecast-body { padding: 18px; overflow-wrap: anywhere; }
.ev-forecast-body h4 { font-size: 1.0625rem; font-weight: 600; margin: 20px 0 12px; }
.ev-forecast-header { margin: 0; line-height: 1.6; }
.ev-forecast-grid { align-items: start; }
.ev-forecast-body .ev-forecast-bar-row { display: grid; grid-template-columns: 4rem minmax(30px, 1fr) 5rem; gap: 10px; margin: 10px 0; }
.ev-forecast-body .ev-forecast-bar-fill { background: var(--ev-primary); }
.ev-validation { border-block: 1px solid var(--ev-border); margin-top: 22px; padding: 0 0 16px; }
.ev-validation-year { display: grid; gap: 4px; border-top: 1px solid var(--ev-border); padding: 12px 0; }
.ev-quality-warning { color: #82400a; background: #fffbeb; padding: 10px 12px; border-radius: 8px; }
.ev-reading-select { display: grid; gap: 8px; margin-top: 20px; }
.ev-reading-select select { width: 100%; padding: 10px; font: inherit; border: 1px solid var(--ev-border); border-radius: 8px; background: white; }
.ev-reading-list { padding-left: 24px; }
.ev-reading-list li { margin: 14px 0; padding-left: 4px; }
.ev-reading-list span, .ev-reading-range > span { display: block; color: #555; font-size: 0.875rem; }
.ev-reading-range { border-top: 1px solid var(--ev-border); padding: 14px 0; }
.ev-reading-range a, .ev-reading-list a { display: inline-block; padding: 4px 0; }
.ev-forecast-body a, .ev-evidence-note a { color: var(--ev-primary-dark); text-decoration: underline; text-underline-offset: 3px; }
.ev-forecast-body summary, .ev-evidence-note summary { cursor: pointer; padding: 8px 0; }
.ev-data-quality { border-top: 1px solid var(--ev-border); padding-top: 12px; }
#app a:focus-visible, #app button:focus-visible, #app select:focus-visible, #app summary:focus-visible, #app input:focus-visible { outline: 3px solid #6366f1; outline-offset: 2px; }
#app .ev-tab:focus-visible, #app .ev-group-toggle:focus-visible { outline-offset: -3px; }
/* Explicit rem sizes also grow; applies to every viewer tab. */
#app.ev-large-text { --ev-reading-size: 1.1875rem; }
#app.ev-large-text .ev-container :is(p, span, strong, a, button, label, select, input, summary, li, td, th, div.ev-row-story, div.ev-row-sent, div.ev-row-by, div.ev-ms-text) { font-size: max(1.1875rem, 1em); line-height: 1.7; }
#app.ev-large-text .ev-container :is(h2, h3, h4) { font-size: 1.375rem; line-height: 1.6; }
@media (max-width: 700px) { .ev-forecast-grid { grid-template-columns: minmax(0, 1fr); } .ev-forecast-body { padding: 14px; } }
.ev-forecast-card:only-child { grid-column: 1 / -1; }
@media (max-width: 640px) {
    .ev-tab { min-height: 46px; }
}

.ev-study-done { display: inline-block; color: #276237; font-size: 1rem; line-height: 1.7; }

/* Multiselect trigger is a <button> in the list filters (keyboard reachable) */
button.ev-ms-trigger { text-align: left; font-weight: 500; min-height: 40px; border-radius: 8px; gap: .4rem; }
button.ev-ms-trigger[aria-expanded="true"] { border-color: var(--ev-primary-light); }
.ev-more-groups { width: 100%; margin: .2rem 0 0; min-height: 46px; background: #fff; line-height: 1.5; padding: .5rem 1rem; }
.ev-more-groups span { display: block; font-size: .8rem; }
@media (max-width: 560px) {
    .ev-group-toggle { flex-wrap: nowrap; }
    .ev-group-sub { order: 0; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.ev-group-year { white-space: nowrap; }
@media (max-width: 560px) {
    .ev-act-pre { display: none; }
    .ev-act { min-height: 34px; padding: .2rem .55rem; }
    .ev-row-actions { gap: .3rem; }
}
@media (max-width: 560px) { .is-predict .ev-group-sub { display: none; } }
.ev-evidence-note h2 { font-weight: 800; color: var(--ev-text); font-size: 1.25rem; }
.ev-evidence-note { border-radius: 14px; }
