/* ===== Theme variables =====
 * Defined per tab on body.tab-* and consumed by every themed component.
 * Tabs share the dark base; only the accent, stat-num, and a few derived
 * colors differ. Footer is intentionally outside the themed area.
 */
body.tab-ollama {
    --accent: #3b82f6;
    --accent-strong: #60a5fa;
    --accent-hover: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.18);
    --accent-border: rgba(96, 165, 250, 0.5);
    --accent-bg-deep: #1e3a8a;
    --accent-rank-fg: #bfdbfe;
    --accent-fg-on: #ffffff;
    --stat-num: #fde68a;
    --stat-divider: #fde68a;
    --tab-active-bg: linear-gradient(
        180deg,
        rgba(59, 130, 246, 0.22),
        rgba(59, 130, 246, 0.08)
    );
}
body.tab-openrouter {
    --accent: #a78bfa;
    --accent-strong: #c4b5fd;
    --accent-hover: #8b5cf6;
    --accent-soft: rgba(167, 139, 250, 0.18);
    --accent-border: rgba(196, 181, 253, 0.55);
    --accent-bg-deep: #4c1d95;
    --accent-rank-fg: #ddd6fe;
    --accent-fg-on: #ffffff;
    --stat-num: #fb923c;
    --stat-divider: #fed7aa;
    --stat-total: #fed7aa;
    --tab-active-bg: linear-gradient(
        180deg,
        rgba(167, 139, 250, 0.24),
        rgba(167, 139, 250, 0.08)
    );
}
body.tab-aa {
    --accent: #14b8a6;
    --accent-strong: #2dd4bf;
    --accent-hover: #0d9488;
    --accent-soft: rgba(20, 184, 166, 0.18);
    --accent-border: rgba(45, 212, 191, 0.55);
    --accent-bg-deep: #115e59;
    --accent-rank-fg: #99f6e4;
    --accent-fg-on: #ffffff;
    --stat-num: #34d399;
    --stat-divider: #a7f3d0;
    --stat-total: #6ee7b7;
    --tab-active-bg: linear-gradient(
        180deg,
        rgba(20, 184, 166, 0.22),
        rgba(20, 184, 166, 0.08)
    );
}
body.tab-home {
    --accent: #f59e0b;
    --accent-strong: #fbbf24;
    --accent-hover: #d97706;
    --accent-soft: rgba(245, 158, 11, 0.18);
    --accent-border: rgba(251, 191, 36, 0.55);
    --accent-bg-deep: #78350f;
    --accent-rank-fg: #fde68a;
    --accent-fg-on: #1f1206;
    --stat-num: #fde68a;
    --stat-divider: #fde68a;
    --stat-total: #fcd34d;
    --tab-active-bg: linear-gradient(
        180deg,
        rgba(245, 158, 11, 0.22),
        rgba(245, 158, 11, 0.08)
    );
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
        Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    color: #e5e7eb;
    background: #0b0d14;
}

a {
    color: #60a5fa;
    text-decoration: none;
    transition: color 0.1s;
}
a:hover {
    color: #93c5fd;
    text-decoration: underline;
}
a:visited {
    color: #60a5fa;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    overflow: hidden;
}

.layout {
    display: flex;
    flex-direction: row;
    flex: 1 1 auto;
    min-height: 0;
}

/* ===== Tab bar ===== */
#tab-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.4rem 0.6rem 0 0.6rem;
    background: #0b0d14;
    border-bottom: 1px solid #1f2937;
    position: relative;
}

.tab-btn {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    color: #9ca3af;
    padding: 0.4rem 0.85rem 0.55rem 0.85rem;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    line-height: 1.1;
    font-family: inherit;
    transition:
        background 0.12s,
        color 0.12s,
        border-color 0.12s;
}
.tab-btn:hover {
    color: #e5e7eb;
    background: #11151f;
}
.tab-btn[aria-pressed="true"] {
    color: var(--accent-strong);
    background: var(--tab-active-bg);
    border-color: var(--accent-border);
}

.tab-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tab-accent {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: transparent;
    pointer-events: none;
    transition: background 0.18s ease;
}
body.tab-ollama .tab-accent {
    background: var(--accent);
}
body.tab-openrouter .tab-accent {
    background: var(--accent);
}
body.tab-home .tab-accent {
    background: var(--accent);
}

/* ===== Sidebar (left tray) ===== */
#sidebar {
    flex: 0 0 320px;
    width: 320px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #0f1118;
    border-right: 1px solid #1f2937;
    overflow: hidden;
    transition:
        flex-basis 0.2s ease,
        width 0.2s ease,
        border-color 0.2s ease;
}

#sidebar:not(.open) {
    flex: 0 0 0;
    width: 0;
    border-right-color: transparent;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #1f2937;
    background: #0b0d14;
    flex: 0 0 auto;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s;
}

.sidebar-header:hover {
    background: #11151f;
}

.sidebar-header .icon-btn {
    pointer-events: none;
}

.sidebar-header:hover .icon-btn {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

.sidebar-header h2 {
    font-size: 14px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: 0.75rem 1rem;
    border-top: 1px solid #1f2937;
    background: #0b0d14;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

#clear-filters-btn,
#reset-all-btn {
    width: 100%;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #e5e7eb;
    padding: 0.5rem 0.75rem;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background 0.12s,
        border-color 0.12s,
        color 0.12s;
}
#clear-filters-btn:hover,
#reset-all-btn:hover {
    background: #374151;
    border-color: #6b7280;
    color: #f9fafb;
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #9ca3af;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.12s,
        border-color 0.12s,
        color 0.12s;
}
.icon-btn:hover {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

/* ===== Tray Sections ===== */
.tray-section {
    padding: 0.75rem 1rem 1rem;
    border-bottom: 1px solid #1f2937;
}
.tray-section:last-child {
    border-bottom: none;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}
.section-header h3 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
}

.reset-btn {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: 1px solid #374151;
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    transition:
        color 0.12s,
        border-color 0.12s,
        background 0.12s;
}
.reset-btn:hover {
    color: #e5e7eb;
    border-color: #6b7280;
    background: #1f2937;
}

/* ===== Main content area ===== */
#main {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1.25rem;
    overflow: hidden;
}

/* ===== Header ===== */
header {
    flex: 0 0 auto;
    background: #0b0d14;
    padding: 0.25rem 0 0.5rem;
    border-bottom: 1px solid #1f2937;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

#sidebar-open {
    flex: 0 0 auto;
}

h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #f9fafb;
    letter-spacing: -0.01em;
    flex: 0 0 auto;
}

#metadata {
    flex: 1 1 auto;
}

.header-stats {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    background: #111827;
    border: 1px solid #1f2937;
    min-width: 90px;
    line-height: 1.1;
}
.stat-num {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--stat-num);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.stat-label {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.15rem;
    font-weight: 600;
}

.stat-tag .stat-num {
    color: var(--stat-num);
}
.stat[data-stat="total"] .stat-num {
    color: var(--stat-total);
    opacity: 0.85;
    font-size: 1.05rem;
}

.stat-divider {
    align-self: center;
    font-size: 1.1rem;
    font-weight: 300;
    color: var(--stat-divider);
    padding: 0 0.2rem;
    line-height: 1;
    opacity: 0.55;
}

.stat-meta {
    align-self: center;
    font-size: 12px;
    color: #6b7280;
    margin-left: auto;
    padding: 0 0.4rem;
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.25rem 0 0.4rem;
}

.ctrl-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 12px;
    color: #6b7280;
    font-weight: 400;
}

#search {
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #f3f4f6;
    padding: 0.4rem 0.6rem;
    font-size: 14px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
#search:focus {
    border-color: var(--accent-strong);
}
#search::placeholder {
    color: #6b7280;
}

#page-size {
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #f3f4f6;
    padding: 0.35rem 0.45rem;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

/* ===== Column Toggle Pills ===== */
.column-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    transition:
        background 0.12s,
        border-color 0.12s,
        color 0.12s;
    white-space: nowrap;
}
.pill.on {
    background: var(--accent);
    color: var(--accent-fg-on);
    border-color: var(--accent);
}
.pill.on:hover {
    background: var(--accent-hover);
}
.pill.off {
    background: transparent;
    color: #9ca3af;
    border-color: #374151;
}
.pill.off:hover {
    color: #e5e7eb;
    border-color: #6b7280;
    background: #1f2937;
}

/* ===== Sort Columns list ===== */
.sort-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.sort-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px 5px 4px;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    font-size: 13px;
    color: #e5e7eb;
    cursor: grab;
    transition:
        background 0.08s,
        border-color 0.08s,
        opacity 0.08s;
}
.sort-item:hover {
    background: #2a3441;
    border-color: #6b7280;
}
.sort-item.dragging {
    opacity: 0.4;
    cursor: grabbing;
}
.sort-item.drop-target {
    border-color: var(--accent);
}

.sort-handle {
    flex: 0 0 auto;
    color: #6b7280;
    font-size: 14px;
    cursor: grab;
    padding: 0 2px;
    line-height: 1;
}

.sort-pos {
    flex: 0 0 auto;
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
}

.sort-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.sort-dir-btn {
    flex: 0 0 auto;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 4px;
    color: var(--accent-strong);
    width: 28px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.1s,
        border-color 0.1s;
}
.sort-dir-btn:hover {
    background: #1f2937;
    border-color: #6b7280;
}

.sort-remove {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: #6b7280;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        color 0.1s,
        background 0.1s;
}
.sort-remove:hover {
    color: #f87171;
    background: #1f2937;
}

.sort-empty {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    padding: 4px 6px;
}

.sort-add {
    margin-top: 4px;
}

#sort-add-select {
    width: 100%;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #d1d5db;
    padding: 6px 8px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}
#sort-add-select:hover {
    border-color: #6b7280;
}

/* ===== Filter sub-section spacing ===== */
#section-filters .filter-field {
    margin-bottom: 0.65rem;
}
#section-filters .filter-field:last-child {
    margin-bottom: 0;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    font-weight: 700;
}
.filter-label .hint {
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    font-size: 12px;
    color: #6b7280;
}

.filter-subsection {
    margin-top: 0.9rem;
    padding-top: 0.6rem;
    border-top: 1px dashed #1f2937;
}
.filter-subsection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    cursor: pointer;
    user-select: none;
}
.filter-subsection-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #6b7280;
}
.filter-subsection-chev {
    color: #6b7280;
    font-size: 10px;
    transition: transform 0.18s ease;
}
.filter-subsection.collapsed .filter-subsection-chev {
    transform: rotate(-90deg);
}
.filter-subsection.collapsed .filter-subsection-body {
    display: none;
}

/* ===== Tri-Select (Any / Yes / No) ===== */
.tri-select {
    display: flex;
    background: #1f2937;
    border-radius: 6px;
    border: 1px solid #374151;
    overflow: hidden;
}
.tri-opt {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    font-size: 13px;
    font-weight: 500;
    color: #9ca3af;
    cursor: pointer;
    transition:
        background 0.12s,
        color 0.12s;
    border-right: 1px solid #374151;
}
.tri-opt:last-child {
    border-right: none;
}
.tri-opt:hover {
    background: #374151;
    color: #e5e7eb;
}
.tri-opt.active-any {
    background: #065f46;
    color: #a7f3d0;
    font-weight: 600;
}
.tri-opt.active-yes {
    background: #065f46;
    color: #a7f3d0;
    font-weight: 600;
}
.tri-opt.active-no {
    background: #7f1d1d;
    color: #fca5a5;
    font-weight: 600;
}

/* ===== Multi-select dropdowns ===== */
.multi-select {
    position: relative;
}
.ms-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 13px;
    cursor: pointer;
    min-width: 140px;
    transition: border-color 0.12s;
}
.ms-trigger:hover {
    border-color: #6b7280;
}
.ms-trigger.open {
    border-color: var(--accent);
}
.ms-trigger .ms-caret {
    font-size: 10px;
    margin-left: 6px;
    transition: transform 0.15s;
}
.ms-trigger.open .ms-caret {
    transform: rotate(180deg);
}

.ms-drop {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    margin-top: 4px;
    background: #1f2937;
    border: 1px solid #4b5563;
    border-radius: 6px;
    max-height: 220px;
    overflow-y: auto;
    min-width: 160px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    display: none;
}
.ms-drop.show {
    display: block;
}
.ms-drop label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 13px;
    color: #e5e7eb;
    cursor: pointer;
    transition: background 0.08s;
}
.ms-drop label:hover {
    background: #374151;
}
.ms-drop input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.ms-drop .ms-any {
    padding: 7px 12px;
    font-size: 13px;
    color: #e5e7eb;
    cursor: pointer;
    transition: background 0.08s;
    font-style: italic;
}
.ms-drop .ms-any:hover {
    background: #374151;
}
.ms-drop .ms-any-active {
    background: #374151;
    color: var(--accent-strong);
}
.ms-drop .ms-sep {
    height: 1px;
    background: #4b5563;
    margin: 4px 0;
}

/* ===== Range inputs (numeric + date) ===== */
.range-group {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}
.range-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}
.range-input {
    flex: 1 1 0;
    min-width: 0;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #f3f4f6;
    padding: 5px 6px;
    font-size: 13px;
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    outline: none;
    transition: border-color 0.12s;
}
.range-input:focus {
    border-color: var(--accent-strong);
}
.range-input::placeholder {
    color: #6b7280;
}
.range-input::-webkit-outer-spin-button,
.range-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.range-input[type="number"] {
    -moz-appearance: textfield;
}
.range-input[type="date"] {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 12px;
    color-scheme: dark;
}
.range-sep {
    color: #6b7280;
    font-size: 12px;
    flex: 0 0 auto;
}
.range-unit {
    color: #9ca3af;
    font-size: 12px;
    font-weight: 600;
    flex: 0 0 auto;
    min-width: 18px;
    text-align: left;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 13px;
    color: #9ca3af;
}
.pagination button {
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 4px;
    color: #d1d5db;
    padding: 0.25rem 0.6rem;
    font-size: 13px;
    cursor: pointer;
    transition:
        background 0.12s,
        border-color 0.12s;
}
.pagination button:hover:not(:disabled) {
    background: #374151;
    border-color: #6b7280;
}
.pagination button:disabled {
    opacity: 0.3;
    cursor: default;
}
.pagination .page-info {
    font-weight: 600;
    color: #e5e7eb;
    min-width: 90px;
    text-align: center;
    font-size: 13px;
}

/* ===== Main & Table ===== */
main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-top: 0.5rem;
}
#table-container {
    flex: 1 1 auto;
    overflow: auto;
    border-radius: 8px;
    border: 1px solid #1f2937;
    background: #0f1118;
}
#models-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    font-size: 13px;
}
#models-table thead {
    position: sticky;
    top: 0;
    z-index: 20;
}
#models-table th {
    background: #111827;
    color: #9ca3af;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.55rem 0.7rem;
    border-bottom: 2px solid #1f2937;
    text-align: left;
    cursor: pointer;
    user-select: none;
    transition:
        color 0.1s,
        background 0.1s;
}
#models-table th:hover {
    color: #e5e7eb;
    background: #1f2937;
}
#models-table th .sort-arrow {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.1s;
    vertical-align: middle;
    color: var(--accent-strong);
}
#models-table th:hover .sort-arrow {
    opacity: 0.4;
}
#models-table th.sorted .sort-arrow {
    opacity: 1;
}
#models-table th.sorted {
    color: var(--accent-strong);
}
#models-table th .sort-rank {
    font-size: 9px;
    background: var(--accent-bg-deep);
    color: var(--accent-rank-fg);
    border-radius: 999px;
    padding: 1px 5px;
    font-weight: 700;
    line-height: 1.4;
}

#models-table td {
    padding: 0.45rem 0.7rem;
    border-bottom: 1px solid #1a1f2b;
    color: #d1d5db;
}
#models-table tbody tr {
    transition: background 0.08s;
}
#models-table tbody tr:nth-child(even) {
    background: #111827;
}
#models-table tbody tr:hover {
    background: #1f2937;
}

.col-model_id {
    color: #f3f4f6;
    font-family: "SF Mono", "Fira Code", monospace;
    font-weight: 500;
}
.col-updated {
    color: #9ca3af;
}
.col-context_window {
    color: #fbbf24;
}
.col-size_display {
    color: #34d399;
    font-weight: 600;
}
.col-size_bytes {
    color: #6b7280;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 12px;
}
.col-digest {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 12px;
    color: #c084fc;
}

/* Per-tab column accents. Keep the ollama family warm and the openrouter
 * family cool. These are subtle tints so columns still read as a group. */
body.tab-ollama .col-context_length {
    color: #fbbf24;
}
body.tab-ollama .col-name {
    color: #f3f4f6;
    font-weight: 600;
}
body.tab-ollama .col-pricing_prompt {
    color: #34d399;
    font-family: "SF Mono", "Fira Code", monospace;
}
body.tab-ollama .col-pricing_completion {
    color: #fbbf24;
    font-family: "SF Mono", "Fira Code", monospace;
}

body.tab-openrouter .col-context_length {
    color: #c4b5fd;
}
body.tab-openrouter .col-name {
    color: #f3f4f6;
    font-weight: 600;
}
body.tab-openrouter .col-pricing_prompt {
    color: #a7f3d0;
    font-family: "SF Mono", "Fira Code", monospace;
}
body.tab-openrouter .col-pricing_completion {
    color: #fed7aa;
    font-family: "SF Mono", "Fira Code", monospace;
}
body.tab-openrouter .col-tokenizer {
    color: #c4b5fd;
    font-size: 12px;
}
body.tab-openrouter .col-vendor {
    color: #93c5fd;
    font-weight: 500;
}
body.tab-openrouter .col-architecture_modality {
    color: #9ca3af;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 11px;
}
body.tab-openrouter .col-architecture_input_modalities,
body.tab-openrouter .col-architecture_output_modalities {
    color: #cbd5e1;
    font-size: 12px;
}

/* model_id is a link in openrouter and ollama */
.col-model_id a {
    text-decoration: none;
    transition:
        color 0.1s,
        border-color 0.1s;
}
.col-model_id a:hover {
    color: var(--accent-strong);
}

.cap-badge {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
}
.cap-badge.on {
    background: #34d399;
    box-shadow: 0 0 5px rgba(52, 211, 153, 0.5);
}
.cap-badge.off {
    background: #374151;
}

#models-table th.bool-col,
#models-table td.bool-col {
    text-align: center;
}

.col-list {
    display: inline-block;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}
.col-num {
    font-variant-numeric: tabular-nums;
    font-family: "SF Mono", "Fira Code", monospace;
}

/* ===== Footer (shared, unthemed) ===== */
footer {
    flex: 0 0 auto;
    background: #0b0d14;
    padding: 0.6rem 0 0.5rem;
    border-top: 1px solid #1f2937;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.footer-extras {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 12px;
}

.footer-promo-row {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.footer-promo {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: linear-gradient(
        135deg,
        rgba(30, 58, 138, 0.45),
        rgba(59, 130, 246, 0.2)
    );
    border: 1px solid rgba(96, 165, 250, 0.35);
    border-radius: 999px;
    text-decoration: none;
    color: #e5e7eb;
    line-height: 1.2;
    transition:
        background 0.15s,
        border-color 0.15s,
        transform 0.12s;
    white-space: nowrap;
}

.footer-promo:hover {
    background: linear-gradient(
        135deg,
        rgba(30, 58, 138, 0.65),
        rgba(59, 130, 246, 0.32)
    );
    border-color: #60a5fa;
}

.footer-promo-name {
    font-weight: 700;
    color: #f9fafb;
    letter-spacing: -0.01em;
}

.footer-promo-sep {
    color: #6b7280;
    font-weight: 400;
}

.footer-promo-tag {
    color: #cbd5e1;
}

.footer-links {
    list-style: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem 0.3rem;
    margin: 0;
    padding: 0;
}

.footer-links li {
    display: inline-flex;
    align-items: center;
}

.footer-links li + li::before {
    content: "\00B7";
    color: #4b5563;
    margin-right: 0.3rem;
}

.footer-links a {
    display: inline-block;
    padding: 0.25rem 0.45rem;
    color: #60a5fa;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    transition: color 0.1s;
}

.footer-links a:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.footer-links a:visited {
    color: #60a5fa;
}

.footer-attribution {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
    text-align: center;
}

.footer-attribution a {
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.1s;
}

.footer-attribution a:hover {
    color: #e5e7eb;
    text-decoration: none;
}

.footer-toggle {
    display: none;
    background: transparent;
    border: 1px solid transparent;
    color: #9ca3af;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition:
        background 0.12s,
        border-color 0.12s,
        color 0.12s,
        transform 0.18s;
}

.footer-toggle:hover {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

.footer-toggle-chevron {
    display: inline-block;
    font-size: 12px;
    line-height: 1;
    transition: transform 0.18s ease;
}

.footer-toggle[aria-expanded="true"] .footer-toggle-chevron {
    transform: rotate(180deg);
}

/* ===== Loading / Empty ===== */
#loading,
#no-results {
    text-align: center;
    padding: 3rem 2rem;
    font-size: 14px;
    color: #9ca3af;
}
.hidden {
    display: none !important;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #0b0d14;
}
::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

/* ===== Home tab button (with icon) ===== */
.tab-btn-home {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}
.tab-icon {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}

/* ===== Search view (cross-dataset) ===== */
#search-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: hidden;
}

.search-bar-wrap {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}
.search-bar-icon {
    position: absolute;
    left: 0.7rem;
    width: 16px;
    height: 16px;
    color: #6b7280;
    pointer-events: none;
}
#search-bar-input {
    flex: 1 1 auto;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 8px;
    color: #f3f4f6;
    padding: 0.6rem 4.6rem 0.6rem 2.2rem;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}
#search-bar-input:focus {
    border-color: var(--accent-strong);
}
#search-bar-input::placeholder {
    color: #6b7280;
}
.search-bar-submit {
    position: absolute;
    right: 0.5rem;
    background: var(--accent);
    color: var(--accent-fg-on);
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.1s,
        transform 0.1s;
    padding: 0;
}
.search-bar-submit:hover {
    background: var(--accent-hover);
}
.search-bar-submit:active {
    transform: scale(0.94);
}
.search-bar-submit:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 2px;
}
.search-bar-submit svg {
    width: 14px;
    height: 14px;
}
.search-bar-clear {
    position: absolute;
    right: 2.1rem;
    background: transparent;
    border: 1px solid transparent;
    color: #9ca3af;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.1s,
        color 0.1s;
}
.search-bar-clear:hover {
    background: #1f2937;
    color: #e5e7eb;
}

.search-results {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.search-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: #6b7280;
    font-size: 14px;
}

.search-section-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    flex: 1 1 auto;
    min-height: 0;
}

.search-source-column {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(75, 85, 99, 0.55) transparent;
    scrollbar-gutter: stable;
    padding: 2px 4px 2px 2px;
}
.search-source-column::-webkit-scrollbar {
    width: 6px;
}
.search-source-column::-webkit-scrollbar-track {
    background: transparent;
}
.search-source-column::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.55);
    border-radius: 999px;
}
.search-source-column:hover::-webkit-scrollbar-thumb {
    background: rgba(107, 114, 128, 0.85);
}

.search-source-column-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.5rem 0.45rem 0.5rem;
    margin: 0 -4px 0 -2px;
    border-bottom: 1px solid #1f2937;
    position: sticky;
    top: 0;
    z-index: 1;
    background: #0b0d14;
}
.search-source-column-ollama .search-source-column-header {
    border-bottom-color: rgba(96, 165, 250, 0.45);
}
.search-source-column-openrouter .search-source-column-header {
    border-bottom-color: rgba(196, 181, 253, 0.45);
}
.search-source-column-aa .search-source-column-header {
    border-bottom-color: rgba(45, 212, 191, 0.45);
}

.search-source-column-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
}

.search-source-column-chevron {
    margin-left: auto;
    display: none;
    color: #6b7280;
    font-size: 10px;
    line-height: 1;
    transition: transform 0.15s ease;
}
.search-source-column[aria-expanded="false"] .search-source-column-chevron,
.search-source-column.collapsed .search-source-column-chevron {
    transform: rotate(-90deg);
}

.search-source-column-body {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    min-width: 0;
}

.result-tile {
    background: #0f1118;
    border: 1px solid #1f2937;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.result-tile-source-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex: 0 0 auto;
}
.result-tile-source-badge.ollama {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
    border: 1px solid rgba(96, 165, 250, 0.4);
}
.result-tile-source-badge.openrouter {
    background: rgba(167, 139, 250, 0.18);
    color: #c4b5fd;
    border: 1px solid rgba(196, 181, 253, 0.45);
}
.result-tile-source-badge.aa {
    background: rgba(20, 184, 166, 0.18);
    color: #5eead4;
    border: 1px solid rgba(45, 212, 191, 0.45);
}

.search-source-column-header .result-tile-source-badge {
    font-size: 22px;
    padding: 6px 18px;
}

.result-tile-body {
    padding: 0.7rem 0.85rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* ID line: the primary identifier for the result, prominent. */
.result-tile-idline {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
    min-width: 0;
}
.result-tile-id {
    font-size: 20px;
    font-weight: 200;
    color: #f3f4f6;
    letter-spacing: -0.015em;
    line-height: 1.15;
    word-break: break-word;
    border-bottom: 1px dotted transparent;
    transition:
        color 0.1s,
        border-color 0.1s;
}
.result-tile-id:visited {
    color: #f3f4f6;
}
.result-tile-id:hover {
    color: var(--accent-strong);
    border-bottom-color: var(--accent-strong);
    text-decoration: none;
}
.result-tile-idname {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 500;
}
.result-tile-sub-sep {
    color: #4b5563;
    font-size: 12px;
    user-select: none;
}

/* Summary line: single inline row with all secondary attributes. */
.result-tile-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0.5rem;
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.55;
    min-width: 0;
}
.result-tile-summary-item {
    min-width: 0;
    word-break: break-word;
}
.result-tile-summary-item a {
    color: #93c5fd;
    border-bottom: 1px dotted #374151;
    transition:
        color 0.1s,
        border-color 0.1s;
}
.result-tile-summary-item a:hover {
    color: #bfdbfe;
    border-bottom-color: #93c5fd;
}
.result-tile-summary-sep {
    color: #4b5563;
    user-select: none;
}
.result-tile-summary-cap {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-transform: capitalize;
}
.result-tile-summary-cap.off {
    color: #4b5563;
}
.result-tile-summary-cap .result-tile-cap-dot {
    width: 6px;
    height: 6px;
    background: #374151;
    box-shadow: none;
}
.result-tile-summary-cap.on .result-tile-cap-dot {
    background: #fbbf24;
    box-shadow: 0 0 4px rgba(251, 191, 36, 0.5);
}
.result-tile-cap-label {
    letter-spacing: 0.01em;
}

/* Labeled field row and separate cap row (used by all three source tiles). */
.result-tile-fields,
.result-tile-caps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0.5rem;
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.55;
    min-width: 0;
}
.result-tile-field {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    min-width: 0;
}
.result-tile-field-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    white-space: nowrap;
}
.result-tile-field-value {
    color: #d1d5db;
    word-break: break-word;
    min-width: 0;
}
.result-tile-field-value.missing {
    color: #4b5563;
}
.result-tile-field-value a {
    color: #93c5fd;
    border-bottom: 1px dotted #374151;
    transition:
        color 0.1s,
        border-color 0.1s;
}
.result-tile-field-value a:hover {
    color: #bfdbfe;
    border-bottom-color: #93c5fd;
}

/* Per-source accent variable (used by id hover). */
.result-tile-source-ollama {
    --tile-accent: #60a5fa;
    --tile-accent-soft: rgba(59, 130, 246, 0.1);
}
.result-tile-source-openrouter {
    --tile-accent: #c4b5fd;
    --tile-accent-soft: rgba(167, 139, 250, 0.1);
}
.result-tile-source-aa {
    --tile-accent: #2dd4bf;
    --tile-accent-soft: rgba(20, 184, 166, 0.1);
}
.result-tile-id:hover {
    color: var(--tile-accent, var(--accent-strong));
    border-bottom-color: var(--tile-accent, var(--accent-strong));
}

/* Extra fields (collapsed by default). */
.result-tile-extra {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    column-gap: 1rem;
    row-gap: 0.45rem;
    padding: 0.85rem;
    border-top: 1px solid #1a1f2b;
}
.result-tile-extra-field {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.result-tile-extra-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    line-height: 1.2;
}
.result-tile-extra-value {
    font-size: 12.5px;
    color: #d1d5db;
    line-height: 1.3;
    word-break: break-word;
    min-width: 0;
}
.result-tile-extra-value a {
    color: #93c5fd;
    border-bottom: 1px dotted #374151;
}
.result-tile-extra-value a:hover {
    color: #bfdbfe;
    border-bottom-color: #93c5fd;
    text-decoration: none;
}

.result-tile-toggle {
    appearance: none;
    background: transparent;
    border: none;
    border-top: 1px solid #1a1f2b;
    color: #6b7280;
    padding: 0.4rem 0.85rem;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: inherit;
    transition:
        background 0.1s,
        color 0.1s;
}
.result-tile-toggle:hover {
    background: #111827;
    color: #e5e7eb;
}
.result-tile-toggle:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: -2px;
}
.result-tile-toggle-chevron {
    display: inline-block;
    font-size: 10px;
    line-height: 1;
    transition: transform 0.15s ease;
}
.result-tile-toggle[aria-expanded="true"] .result-tile-toggle-chevron {
    transform: rotate(180deg);
}
.result-tile-toggle-label {
    flex: 1 1 auto;
}

.result-tile-field-with-info {
    position: relative;
}
.result-tile-info-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #374151;
    color: #d1d5db;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    border: none;
    padding: 0;
    margin-left: 4px;
    cursor: pointer;
    font-family: inherit;
}
.result-tile-info-trigger:hover {
    background: #4b5563;
    color: #f3f4f6;
}
.result-tile-info-trigger:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 1px;
}
.result-tile-info-popover {
    position: fixed;
    z-index: 1000;
    background: #1f2937;
    color: #e5e7eb;
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 10px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    max-width: 280px;
    width: max-content;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}
.result-tile-info-popover::before {
    content: "";
    position: absolute;
    top: -4px;
    left: 12px;
    width: 8px;
    height: 8px;
    background: #1f2937;
    transform: rotate(45deg);
}
.result-tile-info-popover.hidden {
    display: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 200;
        width: 85vw;
        max-width: 320px;
        height: 100dvh;
        flex-basis: 85vw;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.6);
    }
    #sidebar:not(.open) {
        transform: translateX(-100%);
        flex-basis: 0;
        width: 0;
    }
    #main {
        padding: 0.6rem 0.75rem;
        width: 100%;
    }
    h1 {
        font-size: 1.15rem;
    }
    .header-row {
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
    }
    #metadata {
        flex: 1 0 100%;
        order: 3;
    }
    .header-stats {
        gap: 0.4rem;
        row-gap: 0.4rem;
    }
    .stat {
        min-width: 0;
        padding: 0.3rem 0.6rem;
    }
    .stat-num {
        font-size: 1.2rem;
    }
    .stat[data-stat="total"] .stat-num {
        font-size: 0.95rem;
    }
    .stat-meta {
        flex-basis: 100%;
        margin-left: 0;
        padding: 0;
    }

    footer {
        padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
    }
    .footer-extras {
        width: 100%;
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .footer-promo-row {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    .footer-promo {
        flex: 1 1 auto;
        justify-content: center;
        padding: 0.55rem 0.8rem;
        font-size: 13px;
        white-space: normal;
        text-align: center;
    }
    .footer-toggle {
        display: inline-flex;
        flex: 0 0 auto;
    }
    .footer-links {
        display: none;
        flex-direction: column;
        gap: 0;
        padding: 0.25rem 0.25rem 0;
        border-top: 1px solid #1f2937;
    }
    .footer-links.expanded {
        display: flex;
    }
    .footer-links li + li::before {
        content: none;
        margin-right: 0;
    }
    .footer-links a {
        display: block;
        padding: 0.55rem 0.6rem;
        font-size: 14px;
    }

    .result-tile-body {
        padding: 0.6rem 0.7rem 0.55rem;
        gap: 0.25rem;
    }
    .result-tile-id {
        font-size: 18px;
    }
    .result-tile-summary {
        font-size: 11.5px;
    }
    .result-tile-extra {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        column-gap: 0.75rem;
        padding: 0.7rem;
    }
    .result-tile-toggle {
        padding: 0.35rem 0.7rem;
        font-size: 11px;
    }

    .search-section-columns {
        display: flex;
        flex-direction: column;
    }
    .search-source-column {
        flex: 1 1 0;
        min-height: 0;
    }
    .search-source-column.collapsed {
        flex: 0 0 auto;
    }
    .search-source-column-header {
        position: static;
        cursor: pointer;
        user-select: none;
    }
    .search-source-column-header:focus-visible {
        outline: 2px solid var(--accent-strong);
        outline-offset: -2px;
    }
    .search-source-column-chevron {
        display: inline-block;
    }
    .search-source-column.collapsed .search-source-column-body {
        display: none;
    }
}
