/* =========================================================
   Polynomial MLP Explorer — Page-specific styles
   Extends website/css/style.css
   ========================================================= */

/* ---- Tab Navigation ---- */
.explorer-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border-color);
    margin: 3rem 0 0 0;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.7rem 1.4rem;
    border: none;
    border-bottom: 3px solid transparent;
    background: none;
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-base);
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: var(--background-accent);
    border-radius: 6px 6px 0 0;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--background-accent);
    border-radius: 6px 6px 0 0;
}

.tab-btn i { font-size: 0.85rem; }

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeInTab 0.2s ease-out;
    padding-top: 2rem;
}

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

.detail-panel-section {
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 2rem;
    background: var(--background-accent);
    margin-top: 1.5rem;
}

/* ---- Target / Polynomial Selector ---- */
.poly-selector {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}

.poly-btn {
    padding: 0.55rem 1.4rem;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    background: transparent;
    color: var(--primary-color);
    font-family: var(--font-primary);
    font-size: 1.05rem;
    cursor: pointer;
    transition: all var(--transition-base);
    font-weight: 600;
}

.poly-btn:hover {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
}

.poly-btn.active {
    background: var(--primary-color);
    color: white;
}

/* ---- API wakeup notice ---- */
.api-notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 0.875rem 1.25rem;
    margin-bottom: 1.5rem;
    color: #92400e;
    font-size: 0.95rem;
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #92400e;
    animation: dot-bounce 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ---- Stats Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--background-accent);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem 1rem;
    text-align: center;
    transition: box-shadow var(--transition-base);
}

.stat-card:hover {
    box-shadow: 0 4px 16px var(--shadow-md);
}

.stat-card.cert-yes  { border-top: 3px solid #2e7d32; }
.stat-card.cert-no   { border-top: 3px solid #c62828; }
.stat-card.cert-undecided { border-top: 3px solid #f57c00; }

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.1;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.loading-placeholder .stat-value {
    color: var(--border-color);
}

/* ---- Charts ---- */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .charts-row { grid-template-columns: 1fr; }
}

.chart-box {
    background: var(--background-accent);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
}

.chart-box h4 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    background: var(--background-accent);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 110px;
    flex: 1 1 110px;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.filter-group select,
.filter-group input[type="number"] {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    background: white;
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(44,82,130,0.12);
}

/* ---- Config Table ---- */
.table-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.table-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
}

.table-empty {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
}

.table-empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

.config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.config-table thead {
    background: var(--primary-color);
    color: white;
}

.config-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    cursor: default;
}

.config-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.config-table th.sortable:hover {
    background: var(--primary-light);
}

.config-table th.sorted-asc::after  { content: ' ▲'; font-size: 0.7em; }
.config-table th.sorted-desc::after { content: ' ▼'; font-size: 0.7em; }

.config-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.config-table tbody tr:hover {
    background: var(--background-accent);
}

.config-table tbody tr.selected {
    background: rgba(26,54,93,0.06);
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.config-table td {
    padding: 0.65rem 1rem;
    vertical-align: middle;
}

/* Certificate badges in table */
.cert-pill {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.cert-pill.CERTIFIED_YES   { background: #e8f5e9; color: #2e7d32; }
.cert-pill.CERTIFIED_NO    { background: #ffebee; color: #c62828; }
.cert-pill.UNDECIDED       { background: #fff3e0; color: #e65100; }
.cert-pill.NUMERICALLY_YES { background: #e3f2fd; color: #1565c0; }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.page-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.page-btn:hover    { background: var(--background-accent); }
.page-btn.active   { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ---- Cert math notation ---- */
.cert-math {
    font-size: 1rem;
    color: var(--primary-color);
    margin: 0.3rem 0 0.4rem 0;
    font-style: italic;
}

.cert-sub-list {
    margin: 0.4rem 0 0 1.2rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.stat-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-style: italic;
}

/* ---- Network graph extras ---- */
.graph-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--primary-color);
    margin-bottom: 0.4rem;
    font-weight: 700;
}

.arch-summary {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    font-family: var(--font-mono);
    background: var(--background-accent);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.arch-summary span { white-space: nowrap; }
.arch-summary strong { color: var(--primary-color); }

.graph-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-line {
    display: inline-block;
    width: 28px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.active  { background: #1d4ed8; }
.legend-line.passive { background: #bbb; border-top: 2px dashed #bbb; height: 0; }

/* ---- Detail Panel ---- */

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

.detail-header h3 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--primary-color);
    margin: 0;
}

.close-detail {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    padding: 0.25rem;
}

.close-detail:hover { color: var(--accent-color); }

/* Architecture Info */
.detail-arch-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.arch-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    min-width: 90px;
}

.arch-chip-val {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
}

.arch-chip-lbl {
    font-size: 0.74rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.2rem;
}

/* Certificate detail */
.detail-cert {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.detail-cert-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.detail-cert-status .cert-badge {
    font-size: 0.85rem;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.detail-cert-status .cert-badge.CERTIFIED_YES   { background: #e8f5e9; color: #2e7d32; }
.detail-cert-status .cert-badge.CERTIFIED_NO    { background: #ffebee; color: #c62828; }
.detail-cert-status .cert-badge.UNDECIDED       { background: #fff3e0; color: #e65100; }
.detail-cert-status .cert-badge.NUMERICALLY_YES { background: #e3f2fd; color: #1565c0; }

.detail-cert-reason {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.cert-checks {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Run selector */
.run-selector-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.run-btns {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.run-btn {
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.88rem;
    transition: all var(--transition-fast);
}

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

/* Detail visuals layout */
.detail-visuals {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .detail-visuals { grid-template-columns: 1fr; }
}

/* Network Graph */
.network-graph-box {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
}

.graph-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.threshold-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#weight-threshold { width: 100px; }

#network-graph {
    width: 100%;
    height: 320px;
    display: block;
}

/* Node / edge styles applied via D3 (defined here for reference) */
.node-input circle  { fill: #e3f2fd; stroke: #1565c0; stroke-width: 2; }
.node-hidden circle { fill: #f3e5f5; stroke: #6a1b9a; stroke-width: 2; }
.node-output circle { fill: #e8f5e9; stroke: #2e7d32; stroke-width: 2; }

.edge-active  { stroke: #1565c0; stroke-width: 2.5; fill: none; }
.edge-passive { stroke: #aaa; stroke-width: 1; stroke-dasharray: 4,4; fill: none; }

/* Training chart */
.training-chart-box {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
}

.training-chart-box h4 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

/* Monomial Table */
.monomial-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.monomial-section h4 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

.monomial-table-wrapper {
    overflow-x: auto;
}

.monomial-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.monomial-table th {
    background: var(--background-accent);
    border-bottom: 2px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    text-align: right;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.monomial-table th:first-child { text-align: left; }

.monomial-table td {
    padding: 0.45rem 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.monomial-table td:first-child {
    text-align: left;
    font-family: var(--font-primary);
    font-style: italic;
}

.monomial-table tr.target-nonzero td:first-child {
    font-weight: 700;
    color: var(--primary-color);
}

/* Recovered polynomial — detail panel */
.recovered-poly {
    background: var(--primary-dark);
    color: #a5d6a7;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
}

.recovered-poly-label {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    color: #81c784;
    display: block;
    margin-bottom: 0.4rem;
}

.recovered-poly-math {
    font-size: 1.1rem;
    color: #e8f5e9;
    overflow-x: auto;
}

/* Table column — recovered polynomial */
.config-table td.target-poly-cell {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--primary-color);
    white-space: nowrap;
}

.config-table td.poly-cell {
    font-size: 0.82rem;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

.config-table td.poly-cell:hover {
    white-space: normal;
    overflow: visible;
    background: var(--background-accent);
    position: relative;
    z-index: 1;
}

/* ---- Theory tab — tighter layout ---- */
#tab-theory .content-section {
    margin-bottom: 1rem;
}

#tab-theory .section-header {
    margin-bottom: 1rem;
}

#tab-theory .section-header h3 {
    font-size: 1.6rem;
    margin-bottom: 0.2rem;
}

#tab-theory .section-lead {
    font-size: 1rem;
    margin-bottom: 0;
}

/* ---- Math Intro Grid ---- */
.math-intro-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.math-intro-grid .cert-legend {
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .math-intro-grid { grid-template-columns: 1fr; }
    .math-intro-grid .cert-legend { grid-column: auto; }
}

.math-block {
    background: var(--background-accent);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
}

.math-block h4 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.math-block p { font-size: 0.93rem; line-height: 1.6; margin-bottom: 0.4rem; }

.math-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.9rem 0;
}

.math-list, .target-list {
    margin: 0.5rem 0 0.5rem 1.2rem;
    font-size: 0.95rem;
    line-height: 1.8;
}

/* Certificate legend — 2×2 grid inside the full-width block */
.cert-legend {
    display: flex;
    flex-direction: column;
}

.cert-legend h4 {
    margin-bottom: 0.75rem;
}

.cert-legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .cert-legend-grid { grid-template-columns: 1fr; }
}

.cert-legend .cert-item {
    border-left: 4px solid transparent;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0;
    border-radius: 0 6px 6px 0;
}

.cert-item .cert-badge {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
}

.cert-item p { font-size: 0.85rem; color: var(--text-secondary); margin: 0; }

.cert-item.cert-yes    { border-color: #2e7d32; background: #f1f8e9; }
.cert-item.cert-yes .cert-badge { background: #e8f5e9; color: #2e7d32; }

.cert-item.cert-no     { border-color: #c62828; background: #fff5f5; }
.cert-item.cert-no .cert-badge { background: #ffebee; color: #c62828; }

.cert-item.cert-undecided { border-color: #e65100; background: #fff8f0; }
.cert-item.cert-undecided .cert-badge { background: #fff3e0; color: #e65100; }

.cert-item.cert-numerically { border-color: #1565c0; background: #f0f7ff; }
.cert-item.cert-numerically .cert-badge { background: #e3f2fd; color: #1565c0; }

/* ---- Custom Train Form ---- */
.custom-train-layout {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.train-form {
    background: var(--background-accent);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    max-width: 720px;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-row-submit {
    align-items: center;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

/* Override global .btn.secondary — designed for dark hero; use bordered style on light surfaces */
.filter-bar .btn.secondary,
.filter-actions .btn.secondary,
.train-form .btn.secondary,
.content-section .btn.secondary {
    background: white;
    color: var(--primary-color);
    border-color: var(--border-color);
    box-shadow: none;
}

.filter-bar .btn.secondary:hover,
.filter-actions .btn.secondary:hover,
.train-form .btn.secondary:hover,
.content-section .btn.secondary:hover {
    background: var(--background-accent);
    border-color: var(--primary-light);
    transform: none;
}

/* Export CSV button gets a distinct teal-ish tone to stand out from Reset */
#export-csv {
    background: white;
    color: #2b6cb0;
    border-color: #bee3f8;
}

#export-csv:hover {
    background: #ebf8ff;
    border-color: #2b6cb0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 110px;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.form-group label small {
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-weight: 400;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    background: white;
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(44,82,130,0.12);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.train-result-area {
    background: var(--background-accent);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.75rem;
    min-height: 200px;
}

.ct-save-notice {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}
.ct-save-notice.saved    { background: #dcfce7; color: #166534; }
.ct-save-notice.not-saved { background: #fef3c7; color: #92400e; }

.train-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-secondary);
    text-align: center;
}

.api-wakeup-sub {
    font-size: 0.85rem;
    color: #92400e;
}

/* ---- Spinner ---- */
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.spinner.large {
    width: 44px;
    height: 44px;
    border-width: 4px;
}

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

/* ---- Buttons (small) ---- */
.btn-sm {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

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

/* ---- Zero-set cross-section plots ---- */
.zero-set-section {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.zero-set-heading {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0 0 0.9rem 0;
    letter-spacing: 0.02em;
}

.zero-set-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.zs-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.zs-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
}

.zs-wrap canvas {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: block;
    width: 200px;
    height: 200px;
}

.zs-leg-item {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.zs-leg-item::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 3px;
    flex-shrink: 0;
}

.zs-global-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem 1.5rem;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
}

.zs-leg-target::before  { background: #d9640a; }

.zs-leg-learned::before {
    background: repeating-linear-gradient(
        90deg, #1a365d 0px, #1a365d 4px, transparent 4px, transparent 8px
    );
    height: 3px;
    width: 24px;
    margin-bottom: 1px;
}

.zs-leg-pos::before {
    background: rgb(210,228,252);
    border: 1px solid rgba(0,0,0,0.12);
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.zs-leg-neg::before {
    background: rgb(253,240,188);
    border: 1px solid rgba(0,0,0,0.12);
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

/* ---- Responsive tweaks ---- */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-direction: column; }
    .poly-selector { gap: 0.5rem; }
    .poly-btn { font-size: 0.9rem; padding: 0.45rem 0.9rem; }
    #detail-panel { padding: 1rem; }
}
