:root {
    --color-orange: #f0b531;
    --color-blue: #262944;
    --color-light-blue: #86d5e4;
    --color-white: #ffffff;
    --color-gray-50: #fafafa;
    --color-gray-100: #f7f7f8;
    --color-gray-200: #e5e5e7;
    --color-gray-300: #d1d1d6;
    --color-gray-500: #9ca3af;
    --color-gray-600: #6e6e73;
    --color-gray-700: #48484a;
    --color-gray-800: #3a3a3c;
    --color-gray-900: #1c1c1e;
    --color-error: #ff4444;
    --color-success: #44bb44;
    --color-text-secondary: #6b7280;

    /* Semantic colors */
    --color-primary: #2563eb;
    --color-orange-hover: #e0a520;
    --color-danger-hover: #dd3333;
    --color-reasoning: #c0392b;
    --color-warning-text: #b45309;
    --color-warning-dark: #6d4c00;

    /* Code block colors — dark bg in both modes */
    --color-code-bg: #0d1117;
    --color-code-text: #e6edf3;
    --color-code-header: #161b22;
    --color-code-border: #30363d;
    --color-code-muted: #8b949e;
    --color-code-keyword: #ff7b72;
    --color-code-string: #a5d6ff;
    --color-code-comment: #8b949e;
    --color-code-number: #79c0ff;
    --color-code-function: #d2a8ff;
    --color-code-type: #79c0ff;
    --color-code-lang: #8b949e;

    /* Semantic state backgrounds */
    --color-error-bg: #fff0f0;
    --color-info-bg: #f0f5ff;
    --color-success-bg: #e8f5e9;
    --color-success-border: #a5d6a7;
    --color-success-dark: #2e7d32;
    --color-success-text: #155724;
    --color-success-bg-hover: #c8e6c9;
    --color-warning-bg: #fff3cd;
    --color-warning-bg-light: #fff8e1;
    --color-warning-border: #ffe082;
    --color-warning-text-alt: #856404;
    --color-running-bg: #e3f2fd;
    --color-active-blue: #1565c0;
    --color-active-bg: rgba(21, 101, 192, 0.06);
    --color-skip-bg: #fff3e0;
    --color-skip-border: #ffb74d;
    --color-skip-text: #e65100;
    --color-unskip-bg: #e8f5e9;
    --color-unskip-border: #66bb6a;
    --color-unskip-text: #2e7d32;
    --color-active-item-bg: #eff6ff;

    /* Inline code */
    --color-inline-code-bg: rgba(0, 0, 0, 0.08);
    --color-inline-code-text: var(--color-gray-900);

    /* Manual content code */
    --color-manual-code-text: #e8e8e8;

    /* Page headings */
    --color-page-title: var(--color-blue);

    /* Links */
    --color-link: #2563eb;

    /* Tooltips (always dark bg, light text) */
    --color-tooltip-bg: #1c1c1e;
    --color-tooltip-text: #f7f7f8;
}

[data-theme="dark"] {
    --color-orange: #f0b531;
    --color-blue: #1e2038;
    --color-light-blue: #86d5e4;
    --color-white: #1c1c1e;
    --color-gray-50: #232326;
    --color-gray-100: #2a2a2d;
    --color-gray-200: #3a3a3d;
    --color-gray-300: #5a5a5d;
    --color-gray-500: #8a8a8d;
    --color-gray-600: #a0a0a3;
    --color-gray-700: #c0c0c3;
    --color-gray-800: #d8d8db;
    --color-gray-900: #ececef;
    --color-error: #ff6b6b;
    --color-success: #55cc55;
    --color-text-secondary: #9ca3af;

    --color-primary: #5b9aff;
    --color-orange-hover: #d4a020;
    --color-danger-hover: #ff5555;
    --color-reasoning: #e8706a;
    --color-warning-text: #e8a040;
    --color-warning-dark: #e8a040;

    /* Code block colors — GitHub dark */
    --color-code-bg: #0d1117;
    --color-code-text: #e6edf3;
    --color-code-header: #161b22;
    --color-code-border: #30363d;
    --color-code-muted: #8b949e;
    --color-code-keyword: #ff7b72;
    --color-code-string: #a5d6ff;
    --color-code-comment: #8b949e;
    --color-code-number: #79c0ff;
    --color-code-function: #d2a8ff;
    --color-code-type: #79c0ff;
    --color-code-lang: #8b949e;

    --color-error-bg: #3a1c1c;
    --color-info-bg: #1c2440;
    --color-success-bg: #1c3a1c;
    --color-success-border: #2e7d32;
    --color-success-dark: #66bb6a;
    --color-success-text: #81c784;
    --color-success-bg-hover: #254025;
    --color-warning-bg: #3a3018;
    --color-warning-bg-light: #332c16;
    --color-warning-border: #806020;
    --color-warning-text-alt: #e8c040;
    --color-running-bg: #1c2a40;
    --color-active-blue: #5b9aff;
    --color-active-bg: rgba(91, 154, 255, 0.1);
    --color-skip-bg: #3a2c16;
    --color-skip-border: #806020;
    --color-skip-text: #ffb060;
    --color-unskip-bg: #1c3a1c;
    --color-unskip-border: #2e7d32;
    --color-unskip-text: #66bb6a;
    --color-active-item-bg: #1c2440;

    --color-inline-code-bg: rgba(255, 255, 255, 0.12);
    --color-inline-code-text: #ececef;

    --color-manual-code-text: #e8e8e8;

    --color-page-title: var(--color-orange);

    --color-link: #5b9aff;

    --color-tooltip-bg: #1c1c1e;
    --color-tooltip-text: #f7f7f8;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-gray-100);
    color: var(--color-gray-800);
    line-height: 1.5;
}

a {
    color: var(--color-link);
}

input, select, textarea {
    background: var(--color-white);
    color: var(--color-gray-900);
}

.sidebar a {
    color: inherit;
}

.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background: var(--color-blue);
    color: #ffffff;
    padding: 20px 0 0 0;
    flex-shrink: 0;
    height: 100vh;
    overflow: hidden;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
}

.sidebar-collapsed {
    width: 60px;
}

.sidebar-collapsed .sidebar-header h1 {
    display: none;
}

.sidebar-collapsed .sidebar-brand {
    justify-content: center;
}

.sidebar-collapsed .sidebar-logo {
    width: 40px;
    margin-right: 0;
}

/* Sidebar toggle button (bottom) */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px;
    background: none;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

/* Collapsed: top-level icons only */
.sidebar-collapsed .menu-category {
    margin-bottom: 2px;
    position: relative;
}

.sidebar-collapsed > nav > .menu-category > .menu-category-header > .menu-category-label,
.sidebar-collapsed > nav > .menu-category > .menu-category-header > .menu-category-arrow {
    display: none;
}

.sidebar-collapsed > nav > .menu-category > .menu-category-header {
    padding: 10px;
    justify-content: center;
}

/* Flyout menu for collapsed sidebar */
.sidebar-collapsed > nav > .menu-category > .menu-items {
    position: absolute;
    left: 60px;
    top: 0;
    min-width: 220px;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--color-blue);
    border-radius: 0 8px 8px 0;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.3);
    padding: 8px 0;
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s, visibility 0.15s;
}

.sidebar-collapsed > nav > .menu-category:hover > .menu-items {
    visibility: visible;
    opacity: 1;
}

/* Flyout title */
.sidebar-collapsed > nav > .menu-category > .menu-items::before {
    content: attr(data-label);
    display: block;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-orange);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 4px;
}

/* Reset flyout submenu padding */
.sidebar-collapsed > nav > .menu-category > .menu-items .submenu {
    padding-left: 0;
}

.sidebar-collapsed > nav > .menu-category > .menu-items .menu-category-header {
    padding: 8px 16px;
    justify-content: flex-start;
}

.sidebar-collapsed > nav > .menu-category > .menu-items .menu-item {
    padding: 8px 16px 8px 24px;
}

.sidebar-collapsed > nav > .menu-category > .menu-items .submenu .menu-item {
    padding-left: 32px;
}

/* Collapsed: icon-only indicators – hide text and stop button to
   prevent overflow in the narrow 60 px column. */
.sidebar-collapsed .sidebar-indicators {
    align-items: center;
    padding: 8px 0;
}

.sidebar-collapsed .download-indicator {
    padding: 4px 0;
}

.sidebar-collapsed .download-indicator-link {
    padding: 6px 0;
    display: flex;
    justify-content: center;
}

.sidebar-collapsed .download-indicator-header {
    margin-bottom: 0;
    justify-content: center;
}

.sidebar-collapsed .download-indicator-title,
.sidebar-collapsed .download-indicator-url,
.sidebar-collapsed .autotest-indicator-log,
.sidebar-collapsed .autotest-indicator-stop {
    display: none;
}

.sidebar-header {
    padding: 0 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.sidebar-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: 8px;
    margin-right: 8px;
    flex-shrink: 0;
}

.sidebar-header h1 {
    font-size: 26px;
    color: var(--color-orange);
    font-weight: 700;
}

.sidebar nav {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.menu-category {
    margin-bottom: 8px;
}

.menu-category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.menu-category-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.menu-category-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-category-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.menu-category-header.active {
    color: var(--color-orange);
}

.menu-category-arrow {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.menu-category-arrow.expanded {
    transform: rotate(90deg);
}

.menu-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.menu-items.expanded {
    max-height: 1000px;
}

.menu-item {
    display: block;
    padding: 8px 20px 8px 36px;
    cursor: pointer;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s;
    text-decoration: none;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.menu-item.active {
    background: rgba(240, 181, 49, 0.15);
    color: var(--color-orange);
    border-left: 3px solid var(--color-orange);
    padding-left: 33px;
}

.submenu {
    padding-left: 16px;
}

.submenu .menu-category-header {
    font-size: 14px;
    padding: 8px 20px 8px 36px;
}

.submenu .menu-item {
    padding-left: 52px;
}

.submenu .submenu .menu-item {
    padding-left: 68px;
}

/* A menu-item that has nested children (collapsible group). */
.menu-item-parent {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-item-parent .menu-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Children of a parent menu-item nest one level deeper than their parent. */
.submenu .menu-item-children .menu-item {
    padding-left: 68px;
}

.main-content {
    flex: 1;
    padding: 30px 30px 20px 30px;
    overflow-y: auto;
    height: 100vh;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 24px;
    color: var(--color-page-title);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--color-gray-600);
    font-size: 14px;
}

.card {
    background: var(--color-white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--color-gray-200);
    margin-bottom: 20px;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    padding: 12px 16px;
    background: var(--color-gray-100);
    color: var(--color-gray-600);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-gray-200);
}

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

th.sortable-th:hover {
    background: var(--color-gray-200);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-gray-200);
    color: var(--color-gray-800);
}

tr:hover td {
    background: var(--color-gray-100);
}

tr.selected td {
    background: rgba(240, 181, 49, 0.15);
    border-bottom-color: var(--color-orange);
}

tr.selected:hover td {
    background: rgba(240, 181, 49, 0.2);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-gray-800);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    font-size: 14px;
    transition:
            border-color 0.2s,
            box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-light-blue);
    box-shadow: 0 0 0 3px rgba(134, 213, 228, 0.2);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-orange);
    color: var(--color-blue);
}

.btn-primary:hover {
    background: var(--color-orange-hover);
}

.btn-primary:disabled {
    background: var(--color-gray-300);
    color: var(--color-gray-600);
    cursor: not-allowed;
}

.btn-danger {
    background: var(--color-error);
    color: #ffffff;
}

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

.btn-secondary {
    background: var(--color-gray-200);
    color: var(--color-gray-800);
}

.btn-secondary:hover {
    background: var(--color-gray-300);
}

.status-box {
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    padding: 16px;
    margin-top: 16px;
    font-family: "Monaco", "Menlo", monospace;
    font-size: 13px;
    max-height: 300px;
    overflow-y: auto;
}

.status-box .status-line {
    padding: 4px 0;
    color: var(--color-gray-800);
}

.status-box .status-line.error {
    color: var(--color-error);
}

.status-box .status-line.success {
    color: var(--color-success);
}

.download-progress {
    margin-top: 16px;
}

.download-progress-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-page-title);
    margin-bottom: 6px;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: rgba(255, 68, 68, 0.1);
    color: var(--color-error);
    border: 1px solid rgba(255, 68, 68, 0.2);
}

.alert-success {
    background: rgba(68, 187, 68, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(68, 187, 68, 0.2);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-yes {
    background: rgba(68, 187, 68, 0.15);
    color: var(--color-success);
}

.badge-no {
    background: rgba(110, 110, 115, 0.15);
    color: var(--color-gray-600);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-gray-600);
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--color-gray-800);
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--color-gray-600);
}

.loading::after {
    content: "";
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-gray-300);
    border-top-color: var(--color-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 12px;
}

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

.model-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.model-meta-item {
    padding: 12px;
    background: var(--color-gray-100);
    border-radius: 6px;
    overflow: hidden;
    min-width: 0;
}

.model-meta-item label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--color-gray-600);
    letter-spacing: 0.5px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.model-meta-item span {
    display: block;
    font-size: 14px;
    color: var(--color-gray-800);
    margin-top: 4px;
    word-break: break-all;
    overflow-wrap: break-word;
}

.model-meta-wide {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-meta-wide .model-meta-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
}

.model-meta-wide .model-meta-item label {
    flex-shrink: 0;
    min-width: 200px;
    max-width: 300px;
}

.model-meta-wide .model-meta-item span {
    flex: 1;
    margin-top: 0;
}

.token-display {
    background: var(--color-gray-100);
    border-radius: 6px;
    padding: 16px;
    margin-top: 16px;
    font-family: "Monaco", "Menlo", monospace;
    font-size: 12px;
    word-break: break-all;
    user-select: all;
}

/* Home Page Styles */
.home-page {
    max-width: 1200px;
    margin: 0 auto;
}

.hero-section {
    text-align: center;
    margin-bottom: 40px;
}

.hero-banner {
    width: 100%;
    max-width: 900px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

.hero-tagline {
    font-size: 20px;
    color: var(--color-gray-600);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.feature-card {
    background: var(--color-white);
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--color-gray-200);
    transition:
            transform 0.2s,
            box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.feature-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 18px;
    color: var(--color-page-title);
    margin-bottom: 8px;
    font-weight: 600;
}

.feature-card p {
    font-size: 14px;
    color: var(--color-gray-600);
    line-height: 1.5;
}

.home-cta {
    text-align: center;
    padding: 24px;
    background: var(--color-white);
    border-radius: 12px;
    border: 1px solid var(--color-gray-200);
}

.home-cta p {
    font-size: 16px;
    color: var(--color-gray-600);
    margin: 0;
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-gray-200);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover:not(:disabled) {
    color: var(--color-gray-800);
}

.tab.active {
    color: var(--color-orange);
    border-bottom-color: var(--color-orange);
}

.tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Documentation Styles */
.doc-layout {
    display: flex;
    gap: 24px;
}

.doc-content {
    flex: 1;
    min-width: 0;
}

.doc-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
    align-self: flex-start;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.doc-sidebar-content {
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
    padding: 16px;
}

.doc-index-section {
    margin-bottom: 16px;
}

.doc-index-section:last-child {
    margin-bottom: 0;
}

.doc-index-header {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: var(--color-page-title);
    margin-bottom: 8px;
    text-decoration: none;
}

.doc-index-header:hover {
    text-decoration: underline;
}

.doc-index-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-index-section li {
    margin-bottom: 4px;
}

.doc-index-section li a {
    color: var(--color-gray-600);
    text-decoration: none;
    font-size: 14px;
}

.doc-index-section li a:hover {
    color: var(--color-orange);
    text-decoration: underline;
}

.doc-index-header.active {
    color: var(--color-orange);
}

.doc-index-section li a.active {
    color: var(--color-orange);
    font-weight: 600;
}

@media (max-width: 900px) {
    .doc-layout {
        flex-direction: column;
    }

    .doc-sidebar {
        position: static;
        width: 100%;
        max-height: none;
        order: -1;
    }
}

.doc-section {
    margin-top: 24px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-gray-200);
}

/* Add spacing above h4 within cards (e.g., "Authentication" sections) */
.card h4 {
    margin-top: 24px;
}

.doc-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.doc-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-page-title);
    margin-bottom: 8px;
}

.doc-description {
    font-size: 14px;
    color: var(--color-gray-600);
    margin-top: 8px;
    line-height: 1.5;
}

.example-label {
    margin-top: 16px;
    margin-bottom: 4px;
    font-size: 14px;
    color: var(--color-gray-800);
}

.code-block {
    background: var(--color-code-bg);
    border: 1px solid var(--color-code-border);
    border-radius: 6px;
    padding: 12px 16px;
    overflow: auto;
    max-height: 600px;
    font-family: "SF Mono", "Monaco", "Inconsolata", "Fira Code", monospace;
    font-size: 13px;
    color: var(--color-code-text);
    margin: 0;
}

.code-block code {
    white-space: pre;
}

.doc-list {
    margin-top: 12px;
    padding-left: 20px;
    font-size: 14px;
    color: var(--color-gray-600);
    line-height: 1.8;
}

.doc-list li {
    margin-bottom: 4px;
}

/* Code block container with header */
.code-block-container {
    margin: 16px 0;
    position: relative;
}

.code-block-header {
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    padding: 8px 8px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    gap: 12px !important;
    min-height: auto !important;
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    z-index: 10 !important;
}

.code-block-header:has(.code-block-toggle) {
    position: relative !important;
    background: var(--color-code-header) !important;
    border: 1px solid var(--color-code-border) !important;
    border-bottom: none !important;
    border-radius: 6px 6px 0 0 !important;
    padding: 12px 16px !important;
    min-height: 44px !important;
    justify-content: space-between !important;
}

.code-block-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-block-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--color-code-bg);
    border: 1px solid var(--color-code-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-code-text);
    transition: all 0.2s;
}

.code-block-toggle:hover {
    background: var(--color-code-header);
    border-color: var(--color-code-border);
}

.code-block-toggle svg {
    transition: transform 0.2s;
}

.code-block-line-count {
    font-size: 12px;
}

.code-copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--color-code-header);
    border: 1px solid var(--color-code-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-code-muted);
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.code-copy-btn svg {
    fill: var(--color-code-muted);
}

.code-copy-btn:hover {
    background: var(--color-orange);
    border-color: var(--color-orange);
    color: #ffffff;
}

.code-copy-btn:hover svg {
    fill: #ffffff;
}

.copy-feedback {
    opacity: 0;
    transition: opacity 0.2s;
    display: none;
}

.copy-feedback.show {
    opacity: 1;
    display: block;
}

/* Go code blocks with Prism styling */
.code-go {
    border-radius: 6px !important;
    padding: 16px !important;
    overflow-x: auto !important;
    font-family: "SF Mono", "Monaco", "Inconsolata", "Fira Code", monospace !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    margin: 0 !important;
    background: var(--color-code-bg) !important;
    color: var(--color-code-text) !important;
    border: 1px solid var(--color-code-border) !important;
    max-height: none !important;
    transition: max-height 0.3s ease !important;
    overflow-y: hidden !important;
}

/* Go code blocks inside container (with copy button header) */
.code-block-container .code-go {
    padding-top: 40px !important;
}

/* When header has toggle button, adjust code block */
.code-block-header:has(.code-block-toggle) + .code-go {
    border-radius: 0 0 6px 6px !important;
    border-top: none !important;
    padding-top: 16px !important;
}

.code-go.collapsed {
    max-height: 120px !important;
    overflow: hidden !important;
}

.code-go code {
    white-space: pre;
    font-family: inherit;
}

/* Regular code blocks (standalone, without CodeBlock component) */
.code-block {
    border-radius: 6px;
    padding: 16px !important;
    overflow-x: auto;
    font-family: "SF Mono", "Monaco", "Inconsolata", "Fira Code", monospace;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
    border: 1px solid var(--color-code-border);
    background: var(--color-code-bg);
    color: var(--color-code-text);
    max-height: none;
    transition: max-height 0.3s ease;
}

/* Code blocks inside container (with copy button header) */
.code-block-container .code-block {
    padding-top: 40px !important;
}

/* When header has toggle button, adjust code block */
.code-block-header:has(.code-block-toggle) + .code-block {
    border-radius: 0 0 6px 6px;
    border-top: none;
    padding-top: 16px !important;
}

.code-block.collapsed {
    max-height: 120px;
    overflow: hidden;
}

.code-block code {
    white-space: pre;
}

/* Override prism-tomorrow base colours so our GitHub theme wins */
code[class*="language-"],
pre[class*="language-"] {
    color: var(--color-code-text) !important;
}

code[class*="language-"] {
    background: none !important;
}

/* Prism token overrides — GitHub themed */
.code-go .token.keyword,
.code-block .token.keyword,
.token.keyword { color: var(--color-code-keyword) !important; }

.code-go .token.string,
.code-block .token.string,
.token.string { color: var(--color-code-string) !important; }

.code-go .token.comment,
.code-block .token.comment,
.token.comment { color: var(--color-code-comment) !important; }

.code-go .token.number,
.code-block .token.number,
.token.number { color: var(--color-code-number) !important; }

.code-go .token.function,
.code-block .token.function,
.token.function { color: var(--color-code-function) !important; }

.code-go .token.class-name,
.code-block .token.class-name,
.token.class-name { color: var(--color-code-type) !important; }

.code-go .token.builtin,
.code-block .token.builtin,
.token.builtin { color: var(--color-code-type) !important; }

.code-go .token.operator,
.code-block .token.operator,
.token.operator { color: var(--color-code-text) !important; }

.code-go .token.punctuation,
.code-block .token.punctuation,
.token.punctuation { color: var(--color-code-text) !important; }

/* CLI docs flags table */
.flags-table {
    width: 100%;
    margin: 12px 0;
    border-collapse: collapse;
    font-size: 15px;
}

.flags-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--color-gray-100);
    color: var(--color-gray-600);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--color-gray-200);
}

.flags-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-gray-200);
    color: var(--color-gray-800);
}

.flags-table code {
    background: var(--color-gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.doc-section h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-gray-700);
    margin: 16px 0 8px 0;
}

/* Sidebar Indicator Stack (downloads + automated testing) */
.sidebar-indicators {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-indicators .download-indicator {
    margin-top: 0;
}

/* Download Indicator */
.download-indicator {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.download-indicator-link {
    display: block;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    text-decoration: none;
    color: #ffffff;
    transition: background 0.2s;
}

.download-indicator-link:hover {
    background: rgba(255, 255, 255, 0.15);
}

.download-indicator-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.download-indicator-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.download-indicator-icon {
    font-size: 14px;
    font-weight: bold;
}

.download-indicator-icon.success {
    color: var(--color-success);
}

.download-indicator-icon.error {
    color: var(--color-error);
}

.download-indicator-title {
    font-size: 13px;
    font-weight: 600;
}

.download-indicator-url {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Autotest Indicator */
.autotest-indicator-link {
    display: flex;
    align-items: center;
    gap: 8px;
}

.autotest-indicator-top {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: #ffffff;
}

.autotest-indicator-top:hover .download-indicator-header {
    opacity: 0.85;
}

.autotest-indicator-stop {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: var(--color-error);
    font-size: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.autotest-indicator-stop:hover {
    background: rgba(255, 255, 255, 0.2);
}

.autotest-indicator-log {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* Chat Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-gray-200);
    margin-bottom: 16px;
    flex-shrink: 0;
}

.chat-header h2 {
    margin: 0;
    font-size: 24px;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-header-right {
    display: flex;
    gap: 8px;
}

.chat-model-selector-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-model-info {
    display: flex;
    gap: 12px;
    padding-left: 2px;
}

.chat-model-select {
    padding: 8px 12px;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
    background: var(--color-white);
}

.chat-draft-indicator,
.chat-draft-label {
    font-size: 12px;
    color: var(--color-amber-600, #d97706);
    white-space: nowrap;
}

.chat-template-label {
    font-size: 12px;
    color: var(--color-gray-600, #4b5563);
    white-space: nowrap;
}

.chat-system-prompt {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 16px;
    background: var(--color-gray-100);
    border-radius: 8px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.chat-system-prompt label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-gray-600);
}

.chat-system-prompt-input {
    width: 100%;
    min-height: 72px;
    max-height: 25vh;
    padding: 8px 10px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.5;
    box-sizing: border-box;
}

.chat-system-prompt-input:focus {
    outline: none;
    border-color: var(--color-blue);
}

.chat-settings {
    display: flex;
    gap: 16px;
    padding: 8px 16px;
    background: var(--color-gray-100);
    border-radius: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.chat-setting {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-setting label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-gray-600);
}

.chat-setting input {
    width: 100px;
    padding: 6px 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 14px;
}

.chat-setting select {
    padding: 6px 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 14px;
}

.chat-grammar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 16px;
    background: var(--color-gray-100);
    border-radius: 8px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.chat-grammar label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-gray-600);
}

.chat-grammar-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.chat-grammar-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-grammar-field select {
    padding: 6px 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 14px;
}

.chat-grammar-preset {
    flex: 1;
}

.chat-setting-grammar select,
.chat-setting-grammar-preset select {
    min-width: 100px;
}

.chat-grammar-editor {
    padding: 0 16px 4px;
    flex-shrink: 0;
}

.chat-messages-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
}

.chat-scroll-bottom-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--color-gray-200);
    background: var(--color-white);
    color: var(--color-gray-600);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 10;
    transition: background 0.15s, color 0.15s;
}

.chat-scroll-bottom-btn:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-900);
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-gray-600);
}

.chat-empty p {
    margin: 4px 0;
}

.chat-empty-hint {
    font-size: 14px;
    color: var(--color-gray-300);
}

.chat-message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 8px;
}

.chat-message-user {
    background: var(--color-blue);
    color: #ffffff;
}

.chat-message-assistant {
    background: var(--color-gray-100);
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    opacity: 0.7;
}

.chat-header-actions {
    display: flex;
    gap: 6px;
}

.chat-edit-btn {
    background: none;
    border: 1px solid currentColor;
    color: inherit;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.chat-message:hover .chat-edit-btn {
    opacity: 1;
}

.chat-edit-btn:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.15);
}

.chat-edit-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-edit-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.5;
    color: var(--color-gray-800);
    background: var(--color-white);
}

.chat-edit-textarea:focus {
    outline: none;
    border-color: var(--color-orange);
}

.chat-edit-actions {
    display: flex;
    gap: 8px;
}

.chat-message-reasoning {
    margin-bottom: 8px;
    background: rgba(192, 57, 43, 0.08);
    border-radius: 4px;
    border-left: 3px solid rgba(192, 57, 43, 0.4);
    font-size: 14px;
}

.chat-reasoning-summary {
    padding: 8px 12px;
    color: var(--color-reasoning);
    font-style: italic;
    cursor: pointer;
    user-select: none;
}

.chat-reasoning-summary:hover {
    background: rgba(192, 57, 43, 0.05);
}

.chat-reasoning-content {
    padding: 4px 12px 8px;
    color: var(--color-text-secondary);
    overflow-x: auto;
}

.chat-message-tool-calls {
    margin: 8px 0;
    padding: 8px;
    background: rgba(68, 187, 68, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--color-success);
}

.chat-tool-call {
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
    font-size: 13px;
    color: var(--color-gray-800);
    padding: 4px 0;
    word-break: break-all;
}

.chat-message-content {
    word-break: break-word;
    line-height: 1.6;
}

.chat-message-content code {
    background: var(--color-inline-code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
    font-size: 0.9em;
}

.chat-message-content pre {
    background: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 16px;
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
    margin: 0;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
}

.chat-message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.chat-message-content pre .code-keyword {
    color: var(--color-code-keyword);
}

.chat-message-content pre .code-string {
    color: var(--color-code-string);
}

.chat-message-content pre .code-comment {
    color: var(--color-code-comment);
}

.chat-message-content pre .code-number {
    color: var(--color-code-number);
}

.chat-message-content pre .code-function {
    color: var(--color-code-function);
}

.chat-message-content pre .code-type {
    color: var(--color-code-type);
}

/* Chat code block wrapper for CodeBlock component */
.chat-code-block-wrapper {
    margin: 12px 0;
}

.chat-code-block-wrapper .code-block-container {
    margin: 0;
}

.chat-code-block-wrapper .code-block-header {
    background: var(--color-code-header) !important;
    border-color: var(--color-code-bg) !important;
}

.chat-code-block-wrapper .code-block-toggle {
    background: var(--color-code-bg) !important;
    border-color: var(--color-code-border) !important;
    color: var(--color-code-muted) !important;
}

.chat-code-block-wrapper .code-block-toggle:hover {
    background: var(--color-code-header) !important;
    border-color: var(--color-code-border) !important;
}

.chat-code-block-wrapper .code-copy-btn {
    background: var(--color-code-bg) !important;
    border-color: var(--color-code-border) !important;
    color: var(--color-code-muted) !important;
}

.chat-code-block-wrapper .code-copy-btn:hover {
    background: var(--color-orange) !important;
    border-color: var(--color-orange) !important;
    color: var(--color-blue) !important;
}

.chat-code-block-wrapper .code-go,
.chat-code-block-wrapper .code-block {
    background: var(--color-code-bg) !important;
    border-color: var(--color-code-header) !important;
}

/* Keep old styles for backward compatibility if needed */
.chat-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-code-header);
    padding: 8px 16px;
    border-radius: 8px 8px 0 0;
    margin-top: 12px;
    margin-bottom: 0;
}

.chat-code-lang {
    color: var(--color-code-lang);
    font-size: 12px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
}

.chat-code-header + pre {
    margin-top: 0;
    border-radius: 0 0 8px 8px;
}

.chat-message-usage {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--color-gray-200);
    font-size: 12px;
    color: var(--color-gray-600);
    font-family: monospace;
}

.chat-message-user .chat-message-usage {
    border-top-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
}

.chat-input-form {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--color-gray-300);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
}

.chat-input:focus {
    outline: none;
    border-color: var(--color-orange);
}

.chat-input:disabled {
    background: var(--color-gray-100);
    cursor: not-allowed;
}

.chat-input-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Markdown styles for chat messages */
.markdown-h1 {
    font-size: 1.5em;
    font-weight: 700;
    margin: 16px 0 8px 0;
    color: var(--color-gray-800);
    border-bottom: 1px solid var(--color-gray-200);
    padding-bottom: 4px;
}

.markdown-h2 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 14px 0 6px 0;
    color: var(--color-gray-800);
}

.markdown-h3 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 12px 0 4px 0;
    color: var(--color-gray-800);
}

.markdown-paragraph {
    margin: 8px 0;
    line-height: 1.6;
}

.markdown-list {
    margin: 8px 0;
    padding-left: 24px;
}

.markdown-list-ordered {
    list-style-type: decimal;
}

.markdown-list-item {
    margin: 4px 0;
    line-height: 1.5;
}

.markdown-bold {
    font-weight: 600;
    color: var(--color-gray-800);
}

.markdown-italic {
    font-style: italic;
}

.markdown-blockquote {
    border-left: 3px solid var(--color-orange);
    padding-left: 12px;
    margin: 12px 0;
    color: var(--color-gray-600);
    font-style: italic;
}

.markdown-link {
    color: var(--color-light-blue);
    text-decoration: none;
}

.markdown-link:hover {
    text-decoration: underline;
}

.inline-code {
    background: var(--color-gray-200);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
    font-size: 0.9em;
}

/* Chat file attachments */
.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.chat-input-row .chat-input {
    flex: 1;
    min-width: 0;
}

.chat-input-buttons {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex-shrink: 0;
}

.chat-attach-btn {
    padding: 8px 12px;
    font-size: 18px;
    flex-shrink: 0;
    height: fit-content;
}

.chat-attachments-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: var(--color-gray-100);
    border-radius: 8px;
    flex-shrink: 0;
    max-width: 200px;
    overflow-y: auto;
}

.chat-attachment-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
    font-size: 11px;
    position: relative;
    flex: 1;
    min-height: 0;
}

.chat-attachment-chip-image {
    width: 100%;
    flex: 1;
    min-height: 0;
    object-fit: contain;
    border-radius: 4px;
}

.chat-attachment-chip-audio {
    font-size: 24px;
    flex: 1;
    display: flex;
    align-items: center;
}

.chat-attachment-chip-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-attachment-chip-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: 50%;
    color: var(--color-gray-600);
    cursor: pointer;
    font-size: 14px;
    width: 20px;
    height: 20px;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-attachment-chip-remove:hover {
    color: var(--color-error);
    border-color: var(--color-error);
}

.chat-message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-attachment-preview {
    max-width: 200px;
}

.chat-attachment-image {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    border: 1px solid var(--color-gray-200);
}

.chat-attachment-audio {
    padding: 8px 12px;
    background: var(--color-gray-100);
    border-radius: 8px;
    font-size: 13px;
}

/* Chat advanced settings */
.chat-setting-button {
    align-self: flex-end;
    display: flex;
    gap: 8px;
}

.chat-advanced-toggle {
    background: none;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--color-gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.chat-advanced-toggle:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
}

.chat-reset-defaults {
    background: none;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--color-gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.chat-reset-defaults:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
}

.chat-advanced-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--color-gray-200);
}

.chat-setting-checkbox {
    display: flex;
    align-items: center;
}

.chat-setting-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.chat-setting-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.chat-setting-changed label {
    color: var(--color-orange);
}

.chat-setting-changed input,
.chat-setting-changed select {
    border-color: var(--color-orange);
}

.chat-setting-default {
    margin-left: 4px;
    color: var(--color-orange);
    font-size: 8px;
    vertical-align: middle;
    cursor: help;
}

/* Chat layout with history panel */
.chat-layout {
    display: flex;
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    overflow: hidden;
}

.chat-layout > .chat-container {
    flex: 1;
    min-width: 0;
    height: auto;
    max-height: none;
}

/* Chat History Panel */
.chat-history-panel {
    width: 0;
    overflow: hidden;
    background: var(--color-white);
    border-right: 1px solid var(--color-gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s ease;
}

.chat-history-panel-open {
    width: 320px;
}

.chat-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--color-gray-200);
    flex-shrink: 0;
    font-weight: 600;
    font-size: 16px;
}

.chat-history-header button {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--color-gray-600);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.chat-history-header button:hover {
    color: var(--color-gray-800);
}

.chat-history-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--color-gray-200);
    flex-shrink: 0;
    font-size: 13px;
    color: var(--color-gray-600);
}

.chat-history-select-all {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-gray-600);
}

.chat-history-select-all input {
    cursor: pointer;
}

.chat-history-delete-btn {
    background: none;
    border: 1px solid var(--color-error);
    color: var(--color-error);
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: auto;
}

.chat-history-delete-btn:hover {
    background: var(--color-error);
    color: #ffffff;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-history-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-gray-100);
    transition: background 0.15s;
}

.chat-history-item:hover {
    background: var(--color-gray-100);
}

.chat-history-item-selected {
    background: rgba(240, 181, 49, 0.08);
}

.chat-history-item-selected:hover {
    background: rgba(240, 181, 49, 0.14);
}

.chat-history-item-checkbox {
    margin-top: 3px;
    flex-shrink: 0;
    cursor: pointer;
}

.chat-history-item-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.chat-history-item-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item-model {
    font-size: 11px;
    color: var(--color-gray-600);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item-date {
    font-size: 11px;
    color: var(--color-gray-300);
    margin-top: 2px;
}

.chat-history-item-copy {
    background: none;
    border: 1px solid var(--color-gray-300);
    color: var(--color-gray-600);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-history-item:hover .chat-history-item-copy {
    opacity: 1;
}

.chat-history-item-copy:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
}

.chat-history-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--color-gray-300);
    font-size: 14px;
    padding: 32px;
}

/* VRAM Calculator */
.form-card {
    background: var(--color-white);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    font-size: 14px;
    transition:
            border-color 0.2s,
            box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-light-blue);
    box-shadow: 0 0 0 3px rgba(134, 213, 228, 0.2);
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    color: var(--color-gray-600);
}

.vram-loading-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 14px 18px;
    background: rgba(255, 165, 0, 0.08);
    border: 1px solid rgba(255, 165, 0, 0.25);
    border-radius: 8px;
    color: var(--color-orange);
    font-size: 14px;
    font-weight: 500;
}

.vram-loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 165, 0, 0.25);
    border-top-color: var(--color-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

.vram-results {
    margin-top: 20px;
}

.vram-results h3 {
    margin-bottom: 16px;
    color: var(--color-page-title);
}

.vram-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.vram-result-item {
    background: var(--color-gray-100);
    padding: 16px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vram-result-label {
    font-size: 12px;
    color: var(--color-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vram-result-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-gray-800);
}

.vram-result-total {
    font-size: 24px;
    color: var(--color-orange);
}

/* --- Reusable key/value table (replaces boxed grid) --- */
.kv-table {
    display: grid;
    grid-template-columns: max-content 1fr;
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-white);
    margin: 0;
    padding: 0;
}

.kv-table dd {
    margin: 0;
}

.kv-row {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    gap: 64px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-gray-200);
}

.kv-row:last-child {
    border-bottom: none;
}

.kv-row:nth-child(even) {
    background: var(--color-gray-50);
}

.kv-row:hover {
    background: var(--color-gray-200);
}

.kv-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-gray-700);
    white-space: pre-line;
}

.kv-value {
    font-size: 14px;
    color: var(--color-gray-900);
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* --- Metadata sections --- */
.meta-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.meta-section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
}

.meta-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-blue);
    margin: 0;
}

[data-theme="dark"] .meta-section-title {
    color: var(--color-light-blue);
}

/* --- Model card raw metadata toggle --- */
.model-card-raw-toggle {
    margin-top: 32px;
}

.model-card-raw-toggle > summary {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-muted);
    cursor: pointer;
    list-style: revert;
    margin-bottom: 16px;
}

[data-theme="dark"] .model-card-raw-toggle > summary {
    color: var(--color-muted);
}

/* --- Controls row (VRAM dropdowns + reusable) --- */
.controls-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.control-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 200px;
    flex: 1;
}

.control-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- VRAM hero stat --- */
.vram-hero {
    border: 1px solid var(--color-gray-200);
    background: var(--color-gray-50);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    border-left: 4px solid var(--color-orange);
}

.vram-hero-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-gray-600);
    margin-bottom: 4px;
}

.vram-hero-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-gray-900);
}

.vram-breakdown {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.vram-breakdown-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-gray-800);
    margin: 0 0 8px 0;
}

@media (min-width: 900px) {
    .vram-breakdown {
        grid-template-columns: 1fr 1fr;
    }
}

.page-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 22px;
    gap: 20px;
}

.page-header-with-action h2 {
    margin-bottom: 8px;
}

.page-header-with-action .page-description {
    margin-bottom: 0;
}

.vram-formula-content {
    white-space: pre-wrap;
    font-family: "SF Mono", "Monaco", "Consolas", monospace;
    font-size: 13px;
    line-height: 1.5;
    background: var(--color-gray-100);
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--color-white);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-content.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-gray-200);
}

.modal-header h3 {
    margin: 0;
    color: var(--color-page-title);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: var(--color-gray-600);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition:
            background-color 0.2s,
            color 0.2s;
}

.modal-close:hover {
    background-color: var(--color-gray-200);
    color: var(--color-gray-800);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Confirm Dialog */
.confirm-dialog {
    max-width: 400px;
}

.confirm-dialog-body {
    padding: 24px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-gray-800);
}

.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 24px 20px;
}

/* Chat History Toggle */
.chat-history-toggle {
    border: 1px solid var(--color-gray-300);
    background: var(--color-white);
    color: var(--color-gray-700);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.chat-history-toggle-on {
    border-color: rgba(68, 187, 68, 0.6);
    color: var(--color-success);
}

.chat-history-toggle-off {
    border-color: rgba(255, 68, 68, 0.6);
    color: var(--color-error);
}

/* Manual content styling */
.manual-content h1,
.manual-content h2,
.manual-content h3,
.manual-content h4,
.manual-content h5 {
    scroll-margin-top: 80px;
}

.manual-content h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-page-title);
    margin: 32px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-gray-200);
}

.manual-content h1:first-child {
    margin-top: 0;
}

.manual-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-page-title);
    margin: 32px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-gray-200);
}

.manual-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-gray-800);
    margin: 24px 0 12px 0;
}

.manual-content h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-gray-700);
    margin: 20px 0 10px 0;
}

.manual-content h4::before {
    content: "● ";
    color: var(--color-orange);
}

.manual-content h5 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-gray-700);
    margin: 16px 0 8px 0;
}

.manual-content p {
    font-size: 16px;
    margin: 12px 0;
    line-height: 1.7;
}

.manual-content ul,
.manual-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.manual-content li {
    font-size: 16px;
    margin: 6px 0;
    line-height: 1.6;
}

.manual-content blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--color-orange);
    background: var(--color-gray-100);
    color: var(--color-gray-700);
}

.manual-content hr {
    margin: 32px 0;
    border: none;
    border-top: 1px solid var(--color-gray-200);
}

.manual-content img {
    max-width: 100%;
    height: auto;
}

.manual-content table {
    margin: 16px 0;
}

.manual-content pre {
    margin: 16px 0;
}

.manual-content :not(pre) > code {
    color: var(--color-inline-code-text);
    background: var(--color-inline-code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.manual-content pre.code-block {
    background: var(--color-code-bg);
    border: 1px solid var(--color-code-border);
    border-radius: 6px;
    padding: 16px;
}

.manual-content pre.code-block code {
    color: var(--color-code-text);
    background: transparent;
}

/* =============================================================================
   Playground
   ============================================================================= */

.playground-container {
    padding: 20px;
    max-width: 3600px;
}

.playground-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.playground-header h2 {
    font-size: 24px;
    color: var(--color-gray-800);
}

.playground-header-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: var(--color-gray-600);
}

.playground-layout {
    display: flex;
    gap: 24px;
    height: calc(100vh - 140px);
}

.playground-mode-selector {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.playground-mode-selector-resizable .resizable-panel-content {
    gap: 8px;
}

.playground-model-config {
    background: var(--color-white);
    border-radius: 8px;
    border: 1px solid var(--color-gray-200);
    padding: 16px;
    margin-bottom: 8px;
}

.playground-model-config .form-group {
    margin-bottom: 12px;
}

.playground-model-config .form-group:last-child {
    margin-bottom: 0;
}

.playground-model-config .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 4px;
}

.playground-model-config .form-group select,
.playground-model-config .form-group input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 13px;
    background: var(--color-white);
}

.playground-system-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px;
    font-size: 0.8em;
    color: var(--color-gray-500);
    border-top: 1px solid var(--color-gray-200);
}

/* ── Model Selector (reusable tree-based selector) ── */
.model-selector {
    --ms-item-height: 34px;
    max-height: calc(var(--ms-item-height) * 8);
    overflow-y: auto;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    background: var(--color-white);
}

.model-selector-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.model-selector-item {
    display: flex;
    align-items: center;
    width: 100%;
    height: var(--ms-item-height);
    padding: 0 10px;
    border: none;
    border-bottom: 1px solid var(--color-gray-200);
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-gray-800);
    text-align: left;
    transition: background 0.1s;
}

.model-selector > .model-selector-group:last-child .model-selector-item:last-child,
.model-selector > .model-selector-item:last-child,
.model-selector > [role="treeitem"]:last-child {
    border-bottom: none;
}

.model-selector-item:hover:not(:disabled) {
    background: var(--color-gray-100);
}

.model-selector-item.active {
    background: var(--color-active-item-bg);
    color: var(--color-active-blue);
    font-weight: 600;
}

.model-selector-item:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    z-index: 1;
}

.model-selector-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Group header (chevron + label) ── */
.model-selector-group-header {
    gap: 6px;
    font-weight: 500;
}

.model-selector-chevron {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 8px;
    color: var(--color-gray-500);
    transition: transform 0.15s ease;
    cursor: pointer;
    border-radius: 3px;
}

.model-selector-chevron:hover {
    color: var(--color-gray-800);
    background: var(--color-gray-200);
}

.model-selector-chevron.expanded {
    transform: rotate(90deg);
}

/* ── Variant subitems (indented) ── */
.model-selector-subitem {
    padding-left: 32px;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.model-selector-subitem.active {
    color: var(--color-active-blue);
}

/* ── Extra items (e.g., "New…") ── */
.model-selector-extra {
    font-style: italic;
    color: var(--color-gray-600);
}

.model-selector-extra.active {
    color: var(--color-active-blue);
}

.model-selector-empty {
    padding: 8px 10px;
    font-size: 13px;
    color: var(--color-gray-500);
}

.playground-mode-btn {
    padding: 10px 16px;
    border: 1px solid var(--color-gray-200);
    border-radius: 6px;
    background: var(--color-white);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-gray-600);
    text-align: left;
    transition: all 0.15s;
    white-space: nowrap;
}

.playground-mode-btn:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
}

.playground-mode-btn.active {
    background: var(--color-blue);
    color: #ffffff;
    border-color: var(--color-blue);
}

.playground-setup {
    width: 320px;
    flex-shrink: 0;
    overflow-y: auto;
    background: var(--color-white);
    border-radius: 8px;
    border: 1px solid var(--color-gray-200);
    padding: 20px;
}

.playground-setup h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--color-gray-800);
}

.playground-setup h4 {
    font-size: 14px;
    margin: 16px 0 8px;
    color: var(--color-gray-600);
    border-top: 1px solid var(--color-gray-200);
    padding-top: 12px;
}

.playground-setup .form-group {
    margin-bottom: 12px;
}

.playground-setup .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 4px;
}

.playground-setup .form-group select,
.playground-setup .form-group input[type="number"],
.playground-setup .form-group input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 13px;
    background: var(--color-white);
}

.playground-setup .checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

.playground-textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
}

.playground-textarea.monospace {
    font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
    font-size: 12px;
}

.playground-session-controls {
    margin-top: 16px;
}

.playground-session-controls .btn {
    width: 100%;
}

.playground-pull-form {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--color-gray-100);
    border: 1px solid var(--color-gray-200);
    border-radius: 6px;
}

.playground-pull-form .form-group {
    margin-bottom: 8px;
}

.playground-pull-toggle {
    margin-bottom: 8px;
    font-size: 12px;
}

.playground-pull-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.playground-pull-status {
    margin-top: 12px;
    max-height: 150px;
    overflow-y: auto;
    font-size: 12px;
}

.playground-error {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--color-error-bg);
    border: 1px solid var(--color-error);
    border-radius: 4px;
    color: var(--color-error);
    font-size: 13px;
}

.playground-session-info {
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--color-gray-100);
    border-radius: 4px;
    font-size: 12px;
    color: var(--color-gray-600);
    word-break: break-all;
}

.playground-test {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    border-radius: 8px;
    border: 1px solid var(--color-gray-200);
    overflow: hidden;
    min-height: 0;
    min-width: 0;
}

.playground-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-gray-200);
    background: var(--color-gray-100);
}

.playground-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-gray-600);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.playground-tab:hover {
    color: var(--color-gray-800);
}

.playground-tab.active {
    color: var(--color-page-title);
    border-bottom-color: var(--color-page-title);
    background: var(--color-white);
}

.playground-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.playground-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.playground-messages {
    flex: 1;
    overflow-y: auto;
    margin: 12px 0;
    min-height: 200px;
    max-height: calc(100vh - 420px);
    border: 1px solid var(--color-gray-200);
    border-radius: 4px;
    padding: 12px;
}

.playground-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 6px;
}

.playground-message-user {
    background: var(--color-gray-100);
}

.playground-message-assistant {
    background: var(--color-info-bg);
}

.playground-message-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-gray-600);
    margin-bottom: 4px;
}

.playground-message-content {
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.playground-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.playground-input-row .playground-textarea {
    flex: 1;
}

.playground-input-row .btn {
    flex-shrink: 0;
    height: fit-content;
}

.playground-tools .form-group {
    margin-bottom: 12px;
}

.playground-tools .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 4px;
}

.playground-tools input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 13px;
}

.playground-tool-results {
    margin-top: 16px;
    padding: 12px;
    background: var(--color-gray-100);
    border-radius: 6px;
}

.playground-tool-results h4 {
    margin-bottom: 8px;
    font-size: 14px;
}

.playground-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    margin-right: 8px;
}

.playground-badge.success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.playground-badge.fail {
    background: var(--color-warning-bg);
    color: var(--color-warning-text-alt);
}

.playground-tool-call {
    margin-top: 8px;
    padding: 8px;
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: 4px;
}

.playground-tool-call pre {
    margin: 4px 0;
    font-size: 12px;
    white-space: pre-wrap;
}

.playground-tool-call small {
    color: var(--color-gray-600);
}

.playground-inspector .form-group {
    margin-bottom: 12px;
}

.playground-inspector .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 4px;
}

.playground-inspector input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 13px;
}

.playground-rendered-prompt {
    margin-top: 16px;
}

.playground-prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.playground-prompt-header h4 {
    font-size: 14px;
}

.playground-prompt-text {
    background: var(--color-code-bg);
    color: var(--color-code-text);
    border: 1px solid var(--color-code-border);
    padding: 16px;
    border-radius: 6px;
    font-size: 12px;
    font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

/* Automated Testing Panel – flex chain for viewport containment */
.playground-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.playground-autotest {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.playground-autotest-section {
    margin-bottom: 4px;
}

.playground-autotest-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-gray-700);
    margin-bottom: 8px;
}

.playground-autotest-checkboxes {
    display: flex;
    gap: 16px;
}

.playground-autotest-checkboxes label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

.playground-autotest-baseline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.playground-autotest-baseline .form-group {
    margin-bottom: 0;
}

.playground-autotest-baseline .form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 2px;
}

.playground-autotest-baseline .form-group input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 12px;
}

.playground-autotest-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.playground-autotest-repair {
    padding: 8px 12px;
    background: var(--color-warning-bg-light);
    border: 1px solid var(--color-warning-border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--color-warning-dark);
}

.playground-autotest-results {
    margin-top: 4px;
}

/* Scroll wrapper for the results table – constrained height, both-axis scroll */
.playground-autotest-table-scroll {
    overflow: auto;
    max-height: 60vh;
    border: 1px solid var(--color-gray-200);
    border-radius: 4px;
    overscroll-behavior: contain;
}

.playground-autotest-results table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

/* Sticky header row */
.playground-autotest-results th {
    text-align: left;
    padding: 6px 8px;
    background: var(--color-gray-100);
    border-bottom: 2px solid var(--color-gray-300);
    font-weight: 600;
    color: var(--color-gray-700);
    font-size: 11px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 20;
}

.playground-autotest-results th.sortable-th {
    cursor: pointer;
    user-select: none;
}

.playground-autotest-results th.sortable-th:hover {
    background: var(--color-gray-200);
}

.playground-autotest-results td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--color-gray-200);
    white-space: nowrap;
}

/* Sticky first column (run #) */
.playground-autotest-results th:first-child,
.playground-autotest-results td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
}

.playground-autotest-results td:first-child {
    box-shadow: 1px 0 0 var(--color-gray-200);
}

/* Top-left corner: sticky in both directions */
.playground-autotest-results th:first-child {
    z-index: 30;
    box-shadow: 1px 0 0 var(--color-gray-200);
}

/* Row backgrounds — drive ALL cell backgrounds via --row-bg so sticky cells
   never show transparent gaps and global tr:hover td is fully neutralised. */
.playground-autotest-results tbody tr {
    --row-bg: var(--color-white);
}

.playground-autotest-results tbody tr:nth-child(even) {
    --row-bg: var(--color-gray-50);
}

.playground-autotest-results tr:hover {
    --row-bg: var(--color-gray-100);
}

.playground-autotest-results tr.autotest-best-row {
    --row-bg: var(--color-success-bg);
}

.playground-autotest-results tr.autotest-best-row:hover {
    --row-bg: var(--color-success-bg-hover);
}

.playground-autotest-results tr.autotest-running-row {
    --row-bg: var(--color-running-bg);
}

/* Apply --row-bg to every cell (overrides global tr:hover td too) */
.playground-autotest-results tbody td,
.playground-autotest-results tr:hover td {
    background: var(--row-bg);
}

/* Detail/expansion rows: disable sticky first-column (they use colspan) */
.playground-autotest-results tr.autotest-detail-row > td {
    position: static;
    left: auto;
    z-index: auto;
    box-shadow: none;
    background: var(--color-gray-50);
}

.playground-autotest-best {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--color-success-bg);
    border: 1px solid var(--color-success-border);
    border-radius: 6px;
}

.playground-autotest-best h4 {
    font-size: 14px;
    color: var(--color-success-dark);
    margin-bottom: 8px;
}

.playground-autotest-best-params {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
}

.playground-autotest-best-params span {
    color: var(--color-gray-700);
}

.playground-autotest-best-params strong {
    color: var(--color-gray-900);
}

.playground-autotest-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--color-gray-600);
}

.playground-autotest-progress-text {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.playground-autotest-prompt-progress {
    opacity: 0.7;
}

.playground-autotest-progress-bar {
    width: 100%;
    height: 28px;
    background: var(--color-gray-200);
    border-radius: 14px;
    position: relative;
    display: flex;
    align-items: center;
}

.playground-autotest-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--color-blue) 0%, color-mix(in srgb, var(--color-blue) 80%, var(--color-light-blue)) 100%);
    border-radius: 14px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.playground-autotest-progress-label {
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    padding: 0 10px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.playground-autotest-progress-label-outside {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-page-title);
    white-space: nowrap;
    padding-left: 8px;
}

/* In-progress trial row */
.autotest-running-row {
    background: color-mix(in srgb, var(--color-blue) 4%, transparent);
}

.playground-autotest-spinner-inline {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid var(--color-gray-300);
    border-top-color: var(--color-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 4px;
    vertical-align: middle;
}

/* Trial row expand/collapse */
.autotest-trial-row:hover {
    background: var(--color-gray-100);
}

.autotest-detail-row {
    background: var(--color-gray-50);
}

.autotest-detail-row:hover {
    background: var(--color-gray-50);
}

.autotest-detail-row > td {
    padding: 0 !important;
    border-bottom: 2px solid var(--color-gray-300);
}

.autotest-detail-content {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.autotest-detail-empty {
    padding: 12px;
    color: var(--color-gray-600);
    font-size: 12px;
    font-style: italic;
}

.autotest-detail-log {
    border: 1px solid var(--color-gray-200);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--color-gray-50);
    font-family: monospace;
    font-size: 11px;
    margin-bottom: 8px;
}

.autotest-detail-log-body {
    max-height: 160px;
    overflow-y: auto;
}

button.autotest-detail-log-header {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
}

button.autotest-detail-log-header:focus-visible {
    outline: 2px solid rgba(240, 181, 49, 0.55);
    outline-offset: 2px;
    border-radius: 4px;
}

.autotest-detail-log-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 4px;
    font-family: var(--font-sans, system-ui, sans-serif);
}

.autotest-detail-scenarios-section {
    border: 1px solid var(--color-gray-200);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--color-gray-50);
}

.autotest-detail-scenarios-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.autotest-detail-running-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-active-blue);
    padding: 4px 0;
}

.autotest-detail-running-indicator--expanded {
    margin-left: 8px;
    margin-bottom: 4px;
}

.autotest-detail-log-entry {
    display: flex;
    gap: 8px;
    padding: 1px 0;
    line-height: 1.5;
}

.autotest-detail-log-time {
    color: var(--color-gray-400);
    flex-shrink: 0;
}

.autotest-detail-log-msg {
    color: var(--color-gray-700);
}

.autotest-detail-active {
    border: 1px solid var(--color-active-blue);
    border-radius: 6px;
    padding: 10px 12px;
    background: var(--color-active-bg);
}

.autotest-detail-active-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-active-blue);
    margin-bottom: 6px;
}

.autotest-detail-active-prompt {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: 12px;
    color: var(--color-gray-700);
    padding: 4px 0;
}

.autotest-detail-active-scenario {
    font-weight: 600;
    color: var(--color-gray-800);
}

.autotest-detail-active-id {
    font-family: monospace;
    color: var(--color-active-blue);
}

.autotest-detail-active-repeat {
    color: var(--color-gray-500);
    font-size: 11px;
}

.autotest-detail-active-preview {
    flex-basis: 100%;
    font-size: 11px;
    color: var(--color-gray-500);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 600px;
}

.autotest-detail-scenario {
    border: 1px solid var(--color-gray-200);
    border-radius: 6px;
    overflow: hidden;
}

.autotest-detail-scenario-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 12px;
    background: var(--color-gray-100);
    border-bottom: 1px solid var(--color-gray-200);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-700);
}

.autotest-detail-scenario-name {
    font-size: 13px;
    color: var(--color-gray-900);
}

.autotest-detail-prompts {
    display: flex;
    flex-direction: column;
}

.autotest-detail-prompt {
    border-bottom: 1px solid var(--color-gray-200);
    padding: 10px 12px;
}

.autotest-detail-prompt:last-child {
    border-bottom: none;
}

.autotest-detail-prompt.collapsed .autotest-detail-prompt-header {
    margin-bottom: 0;
}

.autotest-detail-prompt-header--clickable {
    cursor: pointer;
    user-select: none;
}

.autotest-detail-prompt-header--clickable:focus-visible {
    outline: 2px solid rgba(240, 181, 49, 0.55);
    outline-offset: 2px;
    border-radius: 4px;
}

.autotest-detail-prompt-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.autotest-detail-prompt-toggle {
    width: 12px;
    flex: 0 0 12px;
    font-size: 10px;
    color: var(--color-gray-600);
    line-height: 1;
}

.autotest-detail-prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 12px;
    min-width: 0;
}

.autotest-detail-prompt-id {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-gray-600);
    font-family: monospace;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autotest-detail-prompt-duration {
    font-size: 11px;
    color: var(--color-gray-600);
    font-family: monospace;
    white-space: nowrap;
}

.autotest-detail-prompt-usage-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--color-gray-700);
    font-family: monospace;
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autotest-detail-prompt-score {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.autotest-detail-prompt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}

.autotest-detail-field {
    min-width: 0;
}

.autotest-detail-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-gray-600);
    margin-bottom: 2px;
}

.autotest-detail-value {
    font-size: 12px;
    color: var(--color-gray-900);
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
}

.autotest-detail-toolcall code {
    font-size: 11px;
    background: var(--color-gray-100);
    padding: 2px 4px;
    border-radius: 3px;
    word-break: break-all;
}

.autotest-detail-usage {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--color-gray-700);
}

.autotest-detail-notes {
    font-size: 11px;
    color: var(--color-warning-text);
}

.playground-autotest-config-param {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.playground-autotest-config-param input[type="text"] {
    padding: 4px 6px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 12px;
}

.playground-autotest-config-warning {
    font-size: 12px;
    color: var(--color-warning-dark);
    margin-bottom: 8px;
}

/* Reorder / Skip controls for queued trials */
.autotest-actions-cell {
    cursor: default;
    white-space: nowrap;
    padding: 4px 6px !important;
}

.autotest-queue-controls {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.autotest-queue-btn {
    padding: 2px 6px !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    min-width: 0 !important;
    border: 1px solid var(--color-gray-300) !important;
    background: var(--color-white) !important;
    color: var(--color-gray-600) !important;
    border-radius: 3px !important;
    cursor: pointer;
}

.autotest-queue-btn:hover:not(:disabled) {
    background: var(--color-gray-100) !important;
    border-color: var(--color-gray-400) !important;
    color: var(--color-gray-800) !important;
}

.autotest-queue-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.autotest-drag-handle {
    cursor: grab;
    font-size: 14px;
    color: var(--color-gray-500);
    user-select: none;
    padding: 0 4px;
    line-height: 1;
}

.autotest-drag-handle:hover {
    color: var(--color-gray-800);
}

.autotest-drag-handle.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.autotest-dragging-row {
    opacity: 0.4;
}

.autotest-dragover-row {
    box-shadow: 0 -2px 0 0 var(--color-primary) inset;
}

.autotest-skip-btn {
    padding: 2px 8px !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    min-width: 0 !important;
    border: 1px solid var(--color-gray-300) !important;
    background: var(--color-white) !important;
    color: var(--color-gray-600) !important;
    border-radius: 3px !important;
    cursor: pointer;
    margin-left: 2px;
}

.autotest-skip-btn:hover {
    background: var(--color-skip-bg) !important;
    border-color: var(--color-skip-border) !important;
    color: var(--color-skip-text) !important;
}

.autotest-unskip-btn {
    padding: 2px 8px !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    min-width: 0 !important;
    border: 1px solid var(--color-gray-300) !important;
    background: var(--color-white) !important;
    color: var(--color-gray-600) !important;
    border-radius: 3px !important;
    cursor: pointer;
}

.autotest-unskip-btn:hover {
    background: var(--color-unskip-bg) !important;
    border-color: var(--color-unskip-border) !important;
    color: var(--color-unskip-text) !important;
}

/* Skipped trial row styling */
.playground-autotest-results tr.autotest-skipped-row {
    --row-bg: var(--color-gray-50);
    opacity: 0.6;
}

.playground-autotest-results tr.autotest-skipped-row:hover {
    --row-bg: var(--color-gray-100);
    opacity: 0.8;
}

/* Fluid grid for playground config/sampling fields — 1 to 4 columns */
.playground-config-grid-fluid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

@media (min-width: 520px) {
    .playground-config-grid-fluid {
        grid-template-columns: repeat(1, 1fr);
    }
}

@media (min-width: 820px) {
    .playground-config-grid-fluid {
        grid-template-columns: repeat(1, 1fr);
    }
}

@media (min-width: 1100px) {
    .playground-config-grid-fluid {
        grid-template-columns: repeat(1, 1fr);
    }
}

.playground-config-grid-fluid .form-group {
    margin-bottom: 0;
}

.playground-config-grid-fluid .form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 2px;
}

.playground-config-grid-fluid .form-group input:not([type="checkbox"]):not([type="radio"]),
.playground-config-grid-fluid .form-group select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 12px;
    background: var(--color-white);
}

.playground-config-grid-fluid .checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
}

.playground-moe-custom {
    padding: 8px 0;
}

.playground-moe-shortcuts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.playground-moe-shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    cursor: pointer;
}

.playground-moe-shortcut-hint {
    font-size: 0.8em;
    opacity: 0.5;
    font-family: monospace;
}

.playground-moe-overrides-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.playground-moe-override-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--color-bg-secondary, #1a1a2e);
    border-radius: 4px;
    font-size: 0.85em;
}

.playground-moe-override-item code {
    flex: 1;
    font-size: 0.9em;
}

.playground-moe-override-remove {
    background: none;
    border: none;
    color: var(--color-text-secondary, #999);
    cursor: pointer;
    font-size: 1.2em;
    padding: 0 4px;
    line-height: 1;
}

.playground-moe-override-remove:hover {
    color: var(--color-danger, #f44336);
}

/* Phase 1: VRAM Fit Indicator */
.playground-vram-fit {
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.82em;
    line-height: 1.4;
}

.playground-vram-fit--fits {
    background: rgba(76, 175, 80, 0.12);
    color: #66bb6a;
}

.playground-vram-fit--tight {
    background: rgba(255, 152, 0, 0.12);
    color: #ffa726;
}

.playground-vram-fit--wont_fit {
    background: rgba(244, 67, 54, 0.12);
    color: #ef5350;
}

.playground-vram-fit-detail {
    opacity: 0.7;
    font-size: 0.9em;
}

/* Phase 4: MoE Guidance Banner */
.playground-moe-guide {
    margin-bottom: 16px;
    border: 1px solid var(--color-gray-300, #333);
    border-radius: 8px;
    overflow: hidden;
}

.playground-moe-guide-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--color-bg-secondary, #1a1a2e);
    color: var(--color-gray-900);
    font-weight: 600;
    font-size: 0.95em;
}

.playground-moe-guide-icon {
    font-size: 1.2em;
}

.playground-moe-guide-body {
    padding: 12px 14px;
    font-size: 0.88em;
    line-height: 1.6;
}

.playground-moe-guide-hw {
    margin-bottom: 10px;
    opacity: 0.85;
}

.playground-moe-guide-estimates {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.playground-moe-guide-estimate {
    display: flex;
    align-items: center;
    gap: 8px;
}

.playground-moe-guide-badge {
    font-size: 0.78em;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.playground-moe-guide-badge--ok {
    background: rgba(76, 175, 80, 0.15);
    color: #66bb6a;
}

.playground-moe-guide-badge--no {
    background: rgba(244, 67, 54, 0.15);
    color: #ef5350;
}

.playground-moe-guide-apply {
    margin-top: 4px;
    font-size: 0.9em;
}

.playground-param-group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-500);
    margin: 12px 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.playground-param-group-title:first-child,
.playground-sampling-params .playground-param-group-title:first-of-type {
    margin-top: 8px;
}

.playground-sampling-params {
    margin: 12px 0;
}

.playground-sampling-params summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-gray-700);
    padding: 8px 0;
    user-select: none;
}

.playground-autotest-baseline-inputs {
    margin-top: 8px;
}

.playground-autotest-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.playground-autotest-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-gray-600);
    padding: 8px 0;
}

.playground-autotest-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--color-gray-300);
    border-top-color: var(--color-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.playground-autotest-best-details {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    font-size: 13px;
    margin-top: 8px;
}

.playground-effective-config {
    margin-top: 8px;
}

.playground-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 4px;
}

.playground-config-item {
    font-size: 11px;
}

.playground-config-key {
    color: var(--color-gray-500);
}

.playground-config-value {
    font-weight: 600;
}

/* Sweep parameter rows (config sweep in autotest) */
.playground-sweep-params {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.playground-sweep-group-title {
    grid-column: 1 / -1;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.playground-sweep-advanced {
    grid-column: 1 / -1;
}

.playground-sweep-advanced > summary {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    margin: 8px 0;
}

.playground-sweep-advanced > .playground-sweep-params {
    margin-top: 4px;
}

.playground-sweep-group-title:first-child {
    margin-top: 0;
}

.playground-sweep-param {
    padding: 8px 10px;
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: 6px;
}

.playground-sweep-param-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--color-gray-700);
}

.sweep-catalog-hint {
    font-weight: 400;
    font-size: 11px;
    color: var(--color-gray-500);
    cursor: help;
    border-bottom: 1px dotted var(--color-gray-400);
}

.param-tooltip-wrapper {
    display: inline-flex;
    align-items: center;
    margin-left: 2px;
}

.param-tooltip-icon {
    font-size: 13px;
    color: var(--color-gray-400);
    cursor: help;
    line-height: 1;
    transition: color 0.15s;
}

.param-tooltip-wrapper:hover .param-tooltip-icon {
    color: var(--color-primary);
}

.param-tooltip-text {
    display: none;
    position: fixed;
    width: 300px;
    padding: 10px 12px;
    background: var(--color-tooltip-bg);
    color: var(--color-tooltip-text);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    pointer-events: none;
    white-space: normal;
}

.param-tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: var(--arrow-left, 12px);
    border: 5px solid transparent;
    border-top-color: var(--color-tooltip-bg);
}

.param-tooltip-wrapper:hover .param-tooltip-text {
    display: block;
}

.playground-sweep-param-values {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 4px 8px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 12px;
    background: var(--color-white);
}

.playground-sweep-param-range {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
}

.playground-sweep-param-range-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 60px;
}

.playground-sweep-param-range-label {
    font-size: 10px;
    color: var(--color-gray-500);
    line-height: 1;
}

.playground-sweep-param-range input[type="number"] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 12px;
    background: var(--color-white);
}

.playground-sweep-option-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
    padding-left: 22px;
}

.playground-sweep-option-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    color: var(--color-gray-600);
}

/* Inline options row for radio/checkbox groups */
.playground-inline-options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.playground-inline-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--color-gray-700);
}

/* ---- Playground History ---- */

.playground-history-container {
    padding: 16px;
}

.playground-history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.playground-history-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--color-gray-800);
}

.playground-history-empty {
    padding: 24px;
    text-align: center;
    color: var(--color-gray-500);
    font-size: 13px;
    border: 1px dashed var(--color-gray-300);
    border-radius: 8px;
}

.playground-history-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid var(--color-gray-200);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--color-white);
}

.playground-history-item > input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.playground-history-item-content {
    flex: 1;
    min-width: 0;
}

.playground-history-item:hover {
    border-color: var(--color-blue);
    background: var(--color-gray-50);
}

.playground-history-item.active {
    border-color: var(--color-blue);
    background: var(--color-active-item-bg);
}

.playground-history-item-model {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-gray-800);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playground-history-item-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--color-gray-500);
}

.playground-history-item-mode {
    font-weight: 500;
    color: var(--color-gray-600);
}

.playground-history-item-stats {
    font-size: 11px;
    color: var(--color-gray-400);
    margin-top: 2px;
}

.playground-history-delete {
    flex-shrink: 0;
    align-self: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.playground-history-item:hover .playground-history-delete {
    opacity: 1;
}

/* ── Catalog Filter Sidebar ── */
.catalog-filter-sidebar-panel .resizable-panel-content {
    gap: 6px;
}

.catalog-filter-section {
    background: var(--color-white);
    border-radius: 8px;
    border: 1px solid var(--color-gray-200);
    padding: 14px 16px;
}

.catalog-filter-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.catalog-filter-section-header h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-gray-800);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin: 0;
}

.catalog-filter-section-header .chevron {
    font-size: 10px;
    color: var(--color-gray-500);
    transition: transform 0.15s ease;
}

.catalog-filter-section-header .chevron.expanded {
    transform: rotate(90deg);
}

.catalog-filter-options {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    min-height: 0;
}

.catalog-filter-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-gray-900);
    cursor: pointer;
    padding: 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.catalog-filter-options label:hover {
    color: var(--color-primary);
}

.catalog-filter-options input[type="checkbox"] {
    flex-shrink: 0;
}

.catalog-filter-radio {
    display: flex;
    gap: 2px;
    margin-top: 8px;
}

.catalog-filter-radio button {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--color-gray-300);
    background: var(--color-white);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-gray-800);
    transition: all 0.15s;
}

.catalog-filter-radio button:first-child {
    border-radius: 4px 0 0 4px;
}

.catalog-filter-radio button:last-child {
    border-radius: 0 4px 4px 0;
}

.catalog-filter-radio button.active {
    background: var(--color-blue);
    color: #ffffff;
    border-color: var(--color-blue);
}

.catalog-range-row {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: 8px;
}

.catalog-range-row label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-gray-800);
    width: 32px;
    flex-shrink: 0;
}

.catalog-range-row input[type="number"] {
    width: 68px;
    padding: 5px 6px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 14px;
    background: var(--color-white);
    color: var(--color-gray-900);
    -moz-appearance: textfield;
}

.catalog-range-row input[type="number"]::-webkit-outer-spin-button,
.catalog-range-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.catalog-range-row select {
    padding: 5px 6px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 14px;
    background: var(--color-white);
    color: var(--color-gray-900);
}

.catalog-dual-range {
    position: relative;
    height: 28px;
    display: flex;
    align-items: center;
    margin-top: 6px;
}

.catalog-dual-range-track {
    position: absolute;
    left: 7px;
    right: 7px;
    height: 4px;
    background: var(--color-gray-300);
    border-radius: 2px;
}

.catalog-dual-range-fill {
    position: absolute;
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
}

.catalog-dual-range input[type="range"] {
    position: absolute;
    left: 0;
    width: 100%;
    height: 28px;
    margin: 0;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    z-index: 2;
}

.catalog-dual-range input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
}

.catalog-dual-range input[type="range"]::-webkit-slider-thumb {
    pointer-events: all;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    margin-top: -5px;
}

.catalog-dual-range input[type="range"]::-moz-range-track {
    height: 4px;
    background: transparent;
    border: none;
}

.catalog-dual-range input[type="range"]::-moz-range-thumb {
    pointer-events: all;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.catalog-filter-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
}

.catalog-match-count {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-gray-800);
    text-align: center;
}

.catalog-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

/* ── Resizable Panel ── */
.resizable-panel {
    position: relative;
    display: flex;
}

.resizable-panel-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.resizable-panel-handle {
    width: 6px;
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    margin-left: 4px;
}

.resizable-panel-handle::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2px;
    width: 2px;
    border-radius: 1px;
    background: var(--color-gray-300);
    transition: background 0.15s ease;
}

.resizable-panel-handle:hover::after,
.resizable-panel-handle:active::after {
    background: var(--color-primary);
}

/* ── Catalog Main Content ── */
.catalog-main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 20px;
}

/* ── Catalog Table ── */
.catalog-table-wrap {
    max-height: 40vh;
    overflow: auto;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
}

.catalog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.catalog-table th {
    position: sticky;
    top: 0;
    background: var(--color-gray-100);
    text-align: left;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--color-gray-300);
    white-space: nowrap;
}

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

.catalog-table-sortable:hover {
    color: var(--color-gray-800);
}

.catalog-table-sort-indicator {
    font-size: 10px;
}

.catalog-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--color-gray-200);
    color: var(--color-gray-800);
    white-space: nowrap;
}

.catalog-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.catalog-table tbody tr:not(.active):hover {
    background: var(--color-gray-100);
}

.catalog-table tbody tr.active,
.catalog-table tbody tr.active:hover {
    background: #1565c0 !important;
    font-weight: 600;
}

.catalog-table tbody tr.active td,
.catalog-table tbody tr.active:hover td {
    color: #ffffff !important;
    background: transparent !important;
}

[data-theme="dark"] .catalog-table tbody tr.active,
[data-theme="dark"] .catalog-table tbody tr.active:hover {
    background: #1e5bb8 !important;
}

.catalog-table-cell-ellipsis {
    display: inline-block;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* ── Resource Budget usage bars ─────────────────────────────────────────── */
.usage-bar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.usage-bar-row {
    display: grid;
    grid-template-columns: 160px 1fr 240px;
    align-items: center;
    gap: 12px;
    font-size: 12px;
}

.usage-bar-label {
    color: var(--color-gray-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-theme="dark"] .usage-bar-label {
    color: var(--color-gray-300);
}

.usage-bar-sublabel {
    color: var(--color-gray-500);
    font-weight: normal;
}

.usage-bar-track {
    position: relative;
    width: 100%;
    height: 14px;
    background: var(--color-gray-200);
    border: 1px solid var(--color-gray-300);
    border-radius: 7px;
    overflow: hidden;
}

[data-theme="dark"] .usage-bar-track {
    background: var(--color-gray-800);
    border-color: var(--color-gray-700);
}

.usage-bar-fill {
    height: 100%;
    border-radius: 6px 0 0 6px;
    transition: width 0.3s ease;
}

.usage-bar-fill-low {
    background: var(--color-success);
}

.usage-bar-fill-mid {
    background: var(--color-orange);
}

.usage-bar-fill-high {
    background: var(--color-error);
}

.usage-bar-cap-marker {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: var(--color-gray-900);
    transform: translateX(-1px);
}

[data-theme="dark"] .usage-bar-cap-marker {
    background: var(--color-gray-100);
}

.usage-bar-readout {
    text-align: right;
    color: var(--color-gray-700);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

[data-theme="dark"] .usage-bar-readout {
    color: var(--color-gray-300);
}

.usage-bar-used {
    font-weight: 600;
}

.usage-bar-sep,
.usage-bar-pct {
    color: var(--color-gray-500);
}

/* ========================================================================== */
/* Translator (Bucky → Apps → Translator)                                     */

.translator-page {
    padding: 24px;
    width: 100%;
    box-sizing: border-box;
}

.translator-grid {
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 16px;
    margin-top: 16px;
}

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

.translator-card {
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-300);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.translator-card h3 {
    margin: 0 0 4px 0;
    font-size: 15px;
    color: var(--color-gray-800);
}

.translator-card label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-gray-700);
    margin: 4px 0 2px 0;
}

.translator-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    background: var(--color-white);
    color: var(--color-gray-900);
}

.translator-textarea:focus {
    outline: none;
    border-color: var(--color-light-blue);
    box-shadow: 0 0 0 3px rgba(134, 213, 228, 0.2);
}

.translator-drop {
    border: 2px dashed var(--color-gray-300);
    border-radius: 8px;
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    background: var(--color-white);
    color: var(--color-gray-600);
    transition: background 0.15s, border-color 0.15s;
}

.translator-drop:hover,
.translator-drop-over {
    background: rgba(134, 213, 228, 0.08);
    border-color: var(--color-light-blue);
    color: var(--color-gray-800);
}

.translator-drop-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.translator-mic-row {
    display: flex;
    gap: 8px;
}

.translator-input-preview {
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    padding: 10px;
    background: var(--color-white);
}

.translator-input-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.translator-input-source {
    background: var(--color-gray-200);
    color: var(--color-gray-700);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.translator-audio {
    width: 100%;
}

.translator-submit-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.translator-result {
    margin-top: 16px;
}

.translator-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.translator-result-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.translator-text {
    background: var(--color-white);
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    max-height: 360px;
    overflow: auto;
    color: var(--color-gray-900);
}

.translator-meta {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.translator-meta td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--color-gray-200);
    vertical-align: top;
}

.translator-meta td:first-child {
    color: var(--color-gray-600);
    width: 180px;
    white-space: nowrap;
}

.translator-meta tr:last-child td {
    border-bottom: none;
}

.translator-segments {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 6px;
}

.translator-segments th,
.translator-segments td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-gray-200);
    text-align: left;
    vertical-align: top;
}

.translator-segments th {
    background: var(--color-gray-100);
    color: var(--color-gray-600);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-light-blue, #2196f3);
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--color-gray-800);
}

@media print {
    .app {
        height: auto;
        overflow: visible;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        height: auto;
        overflow: visible;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
/* ============================================================== */
/* Accuracy app                                                   */
/* ============================================================== */

.accuracy-setup {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.accuracy-source-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.accuracy-filename {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.accuracy-source {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
  resize: vertical;
}

.accuracy-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.accuracy-error-cell {
  color: var(--color-error);
  font-size: 0.85rem;
}

/* Selection label ("Select a Function:") with the functions count + sort
   control inline on the same row. */
.accuracy-label-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 6px;
}

/* The selection label ("Select a Function:" / "Select Functions:"). Styled
   explicitly so Batch (not wrapped in a .form-group) matches the others. */
.accuracy-label-row > label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-gray-800);
  margin-bottom: 0;
}

.accuracy-functions-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Shared label style for the selection words ("Select a Function:",
   "Models …", "N functions", "Sort by:") so they match throughout. */
.accuracy-count,
.accuracy-functions-meta label,
.accuracy-compare-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-gray-800);
  white-space: nowrap;
}

.accuracy-functions-meta label {
  margin-bottom: 0;
}

/* The inline "Sort by" select. Kept compact and styled explicitly (border +
   radius) so it looks identical in every mode, including Batch where it isn't
   inside a .form-group. */
.accuracy-functions-meta select {
  width: auto;
  padding: 4px 8px;
  font-size: 0.85rem;
  border: 1px solid var(--color-gray-300);
  border-radius: 6px;
}

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

.accuracy-sort {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.accuracy-sort label {
  font-size: 0.85rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.accuracy-sort select {
  width: auto;
}

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

.accuracy-random {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.accuracy-batch-run {
  margin-left: auto;
}

.accuracy-func-grid {
  column-width: 240px;
  column-gap: 1rem;
  max-height: 320px;
  overflow: auto;
  padding: 0.5rem;
  border: 1px solid var(--color-code-border);
  border-radius: 6px;
}

.accuracy-func-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  break-inside: avoid;
  margin-bottom: 0.25rem;
  cursor: pointer;
}

.accuracy-func-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.accuracy-func-loc {
  flex: 0 0 auto;
  color: var(--color-muted);
  font-size: 0.75rem;
}

.accuracy-func-line {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--color-muted);
  font-size: 0.75rem;
}

.accuracy-result {
  margin-top: 1rem;
}

.accuracy-result-header,
.accuracy-batch-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.accuracy-batch-summary {
  margin-top: 1rem;
}

.accuracy-match {
  font-weight: 600;
  font-size: 0.9rem;
}

.accuracy-match-good { color: var(--color-success-text); }
.accuracy-match-mid  { color: var(--color-warning-text); }
.accuracy-match-bad  { color: var(--color-error); }

.accuracy-diff {
  border: 1px solid var(--color-code-border);
  border-radius: 6px;
  overflow-x: auto;
  background: var(--color-code-bg);
}

.accuracy-diff pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  /* Shrink-to-fit the widest line (but never below the visible width) so
     every line's background can span the full horizontal scroll width. */
  display: inline-block;
  min-width: 100%;
}

.accuracy-diff-line {
  display: flex;
  white-space: pre;
  padding: 0 0.5rem;
  /* Fill the pre's width so each row's background covers the full scroll
     width, not just the visible portion. */
  min-width: 100%;
}

.accuracy-diff-gutter {
  width: 1.25rem;
  flex-shrink: 0;
  color: var(--color-muted);
  user-select: none;
}

.accuracy-diff-context .accuracy-diff-text {
  color: var(--color-code-text);
}

.accuracy-diff-add {
  background: var(--color-success-bg);
}

.accuracy-diff-add .accuracy-diff-text,
.accuracy-diff-add .accuracy-diff-gutter {
  color: var(--color-success-text);
}

.accuracy-diff-del {
  background: var(--color-error-bg);
}

.accuracy-diff-del .accuracy-diff-text,
.accuracy-diff-del .accuracy-diff-gutter {
  color: var(--color-error);
}

.accuracy-row-clickable {
  cursor: pointer;
}

/* Compare mode */
.accuracy-compare-label {
  display: block;
  margin: 0.75rem 0 0.4rem;
}

.accuracy-compare-results {
  margin-top: 1rem;
}

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

/* Stacked layout: one full-width card per row so a long diff never has to
   compete horizontally with another model's diff. */
.accuracy-compare-grid.stacked {
  grid-template-columns: 1fr;
}

.accuracy-compare-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.accuracy-compare-layout {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}

.accuracy-compare-card {
  border: 1px solid var(--color-gray-200);
  border-radius: 8px;
  padding: 12px;
  background: var(--color-white);
  min-width: 0;
}

.accuracy-compare-winner {
  border-color: var(--color-success-text);
  box-shadow: 0 0 0 1px var(--color-success-text);
}

.accuracy-compare-tied {
  border-color: var(--color-warning-text);
  box-shadow: 0 0 0 1px var(--color-warning-text);
}

.accuracy-compare-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.accuracy-compare-model {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accuracy-compare-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-success-text);
  background: var(--color-success-bg);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  margin-left: auto;
  white-space: nowrap;
}

.accuracy-compare-badge-tied {
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
}

/* Accuracy diff title + key */
.accuracy-diff-wrap {
  margin-top: 0.5rem;
}

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

.accuracy-diff-title {
  font-weight: 600;
  font-size: 0.85rem;
}

.accuracy-diff-key {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.accuracy-diff-key-item {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
}

.accuracy-diff-key-item.accuracy-diff-del {
  color: var(--color-error);
  background: var(--color-error-bg);
}

.accuracy-diff-key-item.accuracy-diff-add {
  color: var(--color-success-text);
  background: var(--color-success-bg);
}

/* Accuracy manual result: match% lined up with model/token stats */
.accuracy-result-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.accuracy-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 0.35rem 0 0.6rem;
}

.accuracy-fields strong {
  color: var(--color-gray-800);
}
