/* ============================================
   Playground Main Styles
   ============================================ */

:root {
    /* Light Theme Variables */
    --playground-bg-primary: #f5f8fa;
    --playground-bg-secondary: #ffffff;
    --playground-bg-tertiary: #ebf2f9;
    --playground-bg-hover: #f0f4f8;

    --playground-text-primary: #1e3a5f;
    --playground-text-secondary: #5a7a9d;
    --playground-text-tertiary: #8ca3bd;

    --playground-border: rgba(30, 58, 95, 0.12);
    --playground-border-hover: rgba(30, 58, 95, 0.24);

    --playground-accent: #2c4a6e;
    --playground-accent-hover: #1e3a5f;
    --playground-accent-light: rgba(44, 74, 110, 0.1);

    --playground-shadow-sm: 0 1px 3px rgba(30, 58, 95, 0.08);
    --playground-shadow-md: 0 4px 6px rgba(30, 58, 95, 0.1);
    --playground-shadow-lg: 0 10px 15px rgba(30, 58, 95, 0.15);

    --playground-success: #10b981;
    --playground-warning: #f59e0b;
    --playground-error: #ef4444;

    --playground-left-panel-width: 340px;
    --playground-gap: 16px;

    --transition-speed: 0.2s;
}

/* Dark Theme */
[data-theme="dark"] {
    --playground-bg-primary: #0f172a;
    --playground-bg-secondary: #1e293b;
    --playground-bg-tertiary: #334155;
    --playground-bg-hover: #293548;

    --playground-text-primary: #f1f5f9;
    --playground-text-secondary: #cbd5e1;
    --playground-text-tertiary: #94a3b8;

    --playground-border: rgba(241, 245, 249, 0.12);
    --playground-border-hover: rgba(241, 245, 249, 0.24);

    --playground-accent: #60a5fa;
    --playground-accent-hover: #3b82f6;
    --playground-accent-light: rgba(96, 165, 250, 0.15);

    --playground-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --playground-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --playground-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);

    --playground-success: #34d399;
    --playground-warning: #fbbf24;
    --playground-error: #f87171;
}

/* ============================================
   Base Layout
   ============================================ */

body {
    background-color: var(--playground-bg-primary);
    color: var(--playground-text-primary);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.hidden {
    display: none !important;
}

.playground-shell {
    position: relative;
    padding: 32px clamp(16px, 5vw, 60px) 48px;
    overflow: hidden;
}

.playground-frame {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    z-index: 1;
}

.playground-ambient {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.ambient-blob {
    position: absolute;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.45;
    transform: translate3d(0, 0, 0);
}

.blob-one {
    top: -120px;
    right: 5%;
    background: rgba(102, 126, 234, 0.4);
}

.blob-two {
    bottom: -160px;
    left: -60px;
    background: rgba(239, 68, 68, 0.35);
}

.blob-three {
    top: 20%;
    left: 35%;
    background: rgba(16, 185, 129, 0.3);
}

.playground-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 24px;
    padding: 0 8px;
}

.header-text {
    max-width: 720px;
}

.header-text .eyebrow {
    font-size: 12px;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--playground-text-tertiary);
    margin-bottom: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.header-text h1 {
    font-size: clamp(24px, 4vw, 40px);
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--playground-text-primary);
}

.header-text .subhead {
    font-size: 16px;
    color: var(--playground-text-secondary);
    line-height: 1.6;
    max-width: 640px;
}

.header-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
}

.stat-chip {
    min-width: 130px;
    border-radius: 14px;
    padding: 14px 18px;
    background: var(--playground-bg-secondary);
    border: 1px solid var(--playground-border);
    box-shadow: var(--playground-shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--playground-text-primary);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--playground-text-tertiary);
}

.playground-auth {
    position: relative;
}

.auth-summary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--playground-border);
    background-color: var(--playground-bg-secondary);
    color: var(--playground-text-primary);
    font-weight: 500;
    box-shadow: var(--playground-shadow-sm);
    cursor: pointer;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.auth-summary:hover {
    transform: translateY(-1px);
    box-shadow: var(--playground-shadow-md);
}

.auth-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.auth-name {
    font-size: 14px;
}

.auth-credits {
    font-size: 12px;
    color: var(--playground-text-tertiary);
}

.auth-arrow {
    font-size: 12px;
    color: var(--playground-text-tertiary);
}

.auth-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 220px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--playground-border);
    background-color: var(--playground-bg-secondary);
    box-shadow: var(--playground-shadow-lg);
    display: none;
    z-index: 10;
}

.auth-menu.open {
    display: block;
    animation: dropdownSlide 0.2s var(--ease-smooth);
}

.auth-menu-section {
    margin-bottom: 12px;
}

.auth-user-email {
    font-size: 13px;
    color: var(--playground-text-secondary);
    margin-bottom: 4px;
}

.auth-user-credits {
    font-size: 14px;
    font-weight: 600;
    color: var(--playground-text-primary);
}

.auth-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-button {
    border: 1px solid var(--playground-border);
    border-radius: 10px;
    padding: 10px 14px;
    background-color: var(--playground-bg-tertiary);
    color: var(--playground-text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-align: center;
}

.auth-button:hover {
    background-color: var(--playground-bg-hover);
}

.auth-button-primary {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
}

.auth-button-danger {
    border-color: rgba(239, 68, 68, 0.2);
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.playground-container {
    display: flex;
    height: clamp(720px, calc(100vh - 220px), 920px);
    gap: var(--playground-gap);
    padding: var(--playground-gap);
    background-color: var(--playground-bg-secondary);
    border-radius: 28px;
    border: 1px solid var(--playground-border);
    box-shadow: var(--playground-shadow-lg);
}

/* Image Playground Variant */
body.image-playground-active .playground-frame {
    max-width: 1680px;
}

body.image-playground-active .playground-container {
    padding: clamp(16px, 2vw, 32px);
    gap: clamp(16px, 2vw, 32px);
}

body.image-playground-active #playground-tab {
    padding: clamp(12px, 2vw, 24px);
}

body.image-playground-active #playground-tab .interface-container {
    padding: 0;
}

/* ============================================
   Left Panel
   ============================================ */

.left-panel {
    width: var(--playground-left-panel-width);
    min-width: var(--playground-left-panel-width);
    background-color: var(--playground-bg-secondary);
    border: 1px solid var(--playground-border);
    border-radius: 12px;
    box-shadow: var(--playground-shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
}

.panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    gap: 24px;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--playground-border);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--playground-border-hover);
}

/* Section Titles */
.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--playground-text-tertiary);
    margin-bottom: 12px;
}

/* ============================================
   Model Selector
   ============================================ */

.model-selector-section {
    flex-shrink: 0;
}

.model-selector {
    position: relative;
}

.model-selector-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--playground-bg-tertiary);
    border: 1px solid var(--playground-border);
    border-radius: 8px;
    color: var(--playground-text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.model-selector-button:hover {
    background-color: var(--playground-bg-hover);
    border-color: var(--playground-border-hover);
}

.model-selector-button:focus {
    outline: none;
    border-color: var(--playground-accent);
    box-shadow: 0 0 0 3px var(--playground-accent-light);
}

.selected-model-name {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-icon {
    flex-shrink: 0;
    color: var(--playground-text-secondary);
    transition: transform var(--transition-speed) ease;
}

.model-selector-button.active .dropdown-icon {
    transform: rotate(180deg);
}

/* Model Dropdown */
.model-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: var(--playground-bg-secondary);
    border: 1px solid var(--playground-border);
    border-radius: 8px;
    box-shadow: var(--playground-shadow-lg);
    z-index: 1000;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.model-dropdown.hidden {
    display: none;
}

.model-search-wrapper {
    padding: 12px;
    border-bottom: 1px solid var(--playground-border);
}

.model-search {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--playground-bg-tertiary);
    border: 1px solid var(--playground-border);
    border-radius: 6px;
    color: var(--playground-text-primary);
    font-size: 14px;
    transition: all var(--transition-speed) ease;
}

.model-search:focus {
    outline: none;
    border-color: var(--playground-accent);
    box-shadow: 0 0 0 3px var(--playground-accent-light);
}

.model-search::placeholder {
    color: var(--playground-text-tertiary);
}

.model-list {
    overflow-y: auto;
    max-height: 340px;
}

.model-list::-webkit-scrollbar {
    width: 6px;
}

.model-list::-webkit-scrollbar-track {
    background: transparent;
}

.model-list::-webkit-scrollbar-thumb {
    background: var(--playground-border);
    border-radius: 3px;
}

.model-category {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--playground-text-tertiary);
    background-color: var(--playground-bg-tertiary);
    border-bottom: 1px solid var(--playground-border);
}

.model-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border-bottom: 1px solid var(--playground-border);
}

.model-item:last-child {
    border-bottom: none;
}

.model-item:hover {
    background-color: var(--playground-bg-hover);
}

.model-item.selected {
    background-color: var(--playground-accent-light);
    border-left: 3px solid var(--playground-accent);
}

.model-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--playground-text-primary);
    margin-bottom: 4px;
}

.model-item-description {
    font-size: 12px;
    color: var(--playground-text-secondary);
    line-height: 1.4;
}

.model-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--playground-text-tertiary);
}

.model-item-badge {
    padding: 2px 6px;
    background-color: var(--playground-accent-light);
    color: var(--playground-accent);
    border-radius: 4px;
    font-weight: 500;
}

/* ============================================
   Parameters Section
   ============================================ */

.parameters-section {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.parameters-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.parameters-container::-webkit-scrollbar {
    width: 6px;
}

.parameters-container::-webkit-scrollbar-track {
    background: transparent;
}

.parameters-container::-webkit-scrollbar-thumb {
    background: var(--playground-border);
    border-radius: 3px;
}

.parameter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.parameter-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--playground-text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.parameter-value {
    font-size: 12px;
    color: var(--playground-text-tertiary);
    font-weight: 400;
}

.parameter-input,
.parameter-select,
.parameter-textarea {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--playground-bg-tertiary);
    border: 1px solid var(--playground-border);
    border-radius: 6px;
    color: var(--playground-text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-speed) ease;
}

.parameter-input:focus,
.parameter-select:focus,
.parameter-textarea:focus {
    outline: none;
    border-color: var(--playground-accent);
    box-shadow: 0 0 0 3px var(--playground-accent-light);
}

.parameter-textarea {
    min-height: 80px;
    resize: vertical;
}

.parameter-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--playground-bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

.parameter-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--playground-accent);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.parameter-slider::-webkit-slider-thumb:hover {
    background: var(--playground-accent-hover);
    transform: scale(1.1);
}

.parameter-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--playground-accent);
    cursor: pointer;
    border: none;
    transition: all var(--transition-speed) ease;
}

.parameter-slider::-moz-range-thumb:hover {
    background: var(--playground-accent-hover);
    transform: scale(1.1);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--playground-text-tertiary);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 13px;
    line-height: 1.5;
}

/* ============================================
   Left Panel Actions
   ============================================ */

.left-panel-actions {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--playground-border);
}

.action-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border: 1px solid var(--playground-border);
}

.action-button.secondary {
    background-color: var(--playground-bg-tertiary);
    color: var(--playground-text-primary);
}

.action-button.secondary:hover {
    background-color: var(--playground-bg-hover);
    border-color: var(--playground-border-hover);
}

.action-button svg {
    flex-shrink: 0;
}

/* ============================================
   Right Panel
   ============================================ */

.right-panel {
    flex: 1;
    background-color: var(--playground-bg-secondary);
    border: 1px solid var(--playground-border);
    border-radius: 12px;
    box-shadow: var(--playground-shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 4px;
    padding: 12px;
    border-bottom: 1px solid var(--playground-border);
    background-color: var(--playground-bg-tertiary);
}

.tab-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background-color: transparent;
    border: none;
    border-radius: 6px;
    color: var(--playground-text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.tab-button:hover {
    background-color: var(--playground-bg-hover);
    color: var(--playground-text-primary);
}

.tab-button.active {
    background-color: var(--playground-bg-secondary);
    color: var(--playground-accent);
    box-shadow: var(--playground-shadow-sm);
}

.tab-button svg {
    flex-shrink: 0;
}

/* Tab Content */
.tab-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.tab-pane {
    display: none;
    height: 100%;
    min-height: 0;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.interface-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-gutter: stable;
}

/* Welcome State */
.welcome-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
}

.welcome-content svg {
    margin-bottom: 24px;
    color: var(--playground-accent);
    opacity: 0.6;
}

.welcome-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--playground-text-primary);
    margin-bottom: 12px;
}

.welcome-content p {
    font-size: 15px;
    color: var(--playground-text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.model-categories {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.category-chip {
    padding: 8px 16px;
    background-color: var(--playground-accent-light);
    color: var(--playground-text-primary);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* API View */
.api-view-container {
    height: 100%;
    overflow: auto;
    padding: 24px;
}

.api-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--playground-text-tertiary);
    text-align: center;
    padding: 40px;
}

.api-empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.api-empty-state p {
    font-size: 14px;
    line-height: 1.6;
}

/* ============================================
   Theme Toggle
   ============================================ */

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    background-color: var(--playground-bg-tertiary);
    border: 1px solid var(--playground-border);
    border-radius: 8px;
    cursor: pointer;
}

.theme-option {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
}

.theme-option:hover {
    background-color: var(--playground-bg-hover);
}

.theme-option.active {
    background-color: var(--playground-accent);
    color: white;
}

.nav-theme-toggle {
    margin-left: 12px;
    margin-right: 8px;
}

.header .theme-toggle {
    background-color: rgba(255, 255, 255, 0.85);
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] .header .theme-toggle {
    background-color: rgba(15, 23, 42, 0.85);
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.header .theme-toggle .theme-option {
    color: inherit;
}

/* ============================================
   Modal
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    pointer-events: none;
}

.modal.hidden {
    display: none !important;
}

.modal:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 0;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    background-color: var(--playground-bg-secondary);
    border: 1px solid var(--playground-border);
    border-radius: 12px;
    box-shadow: var(--playground-shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 1;
    pointer-events: auto;
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--playground-text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--playground-text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-speed) ease;
}

.modal-close:hover {
    background-color: var(--playground-bg-hover);
    color: var(--playground-text-primary);
}

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

#session-history-modal .modal-content {
    max-width: min(1180px, calc(100vw - 64px));
    width: min(1100px, calc(100vw - 64px));
    max-height: min(90vh, 920px);
    height: min(90vh, 860px);
    border-radius: 24px;
    box-shadow: var(--playground-shadow-lg);
}

#session-history-modal .modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.history-modal-body {
    display: grid;
    grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
    gap: 16px;
    min-height: 320px;
}

.history-list-column {
    border-right: 1px solid var(--playground-border);
    padding-right: 12px;
    overflow-y: auto;
}

.history-detail-column {
    border: 1px solid var(--playground-border);
    border-radius: 12px;
    padding: 16px;
    background-color: var(--playground-bg-secondary);
    overflow-y: auto;
}

#session-history-modal .history-modal-body {
    flex: 1;
    min-height: 0;
    padding: 32px;
    grid-template-columns: minmax(320px, 0.55fr) minmax(0, 2.2fr);
    gap: 32px;
}

#session-history-modal .history-modal-body::after {
    content: '';
    display: block;
    width: 100%;
    height: 0;
}

#session-history-modal .history-list-column {
    padding-right: 20px;
    padding-left: 4px;
    min-height: 0;
}

#session-history-modal .history-detail-column {
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--playground-shadow-sm);
    min-height: 180px;
    display: flex;
    flex-direction: column;
}

#session-history-modal .history-entry {
    padding: 16px;
}

#session-history-modal .history-detail-body {
    flex: 1;
    overflow-y: auto;
    margin-top: 16px;
    min-height: 100px;
}

.history-detail-column.hidden {
    display: none;
}

.history-entry {
    border: 1px solid var(--playground-border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    background-color: var(--playground-bg-secondary);
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--transition-speed) ease;
}

.history-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.history-entry:focus,
.history-entry:hover {
    border-color: var(--playground-accent);
    outline: none;
}

.history-entry.active {
    border-color: var(--playground-accent);
    box-shadow: 0 0 0 3px var(--playground-accent-light);
}

.history-entry-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.history-entry-submeta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--playground-text-tertiary);
}

.history-entry-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-row-link {
    border: none;
    background: transparent;
    color: var(--playground-text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color var(--transition-speed) ease, background-color var(--transition-speed) ease;
}

.history-row-link:hover {
    color: var(--playground-accent);
    background-color: var(--playground-accent-light);
}

.history-entry-prompt {
    font-weight: 600;
    margin: 8px 0 4px;
    color: var(--playground-text-primary);
}

.history-entry-response {
    margin: 0;
    color: var(--playground-text-secondary);
    font-size: 13px;
}

.history-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.history-detail-header h3 {
    margin: 0;
    font-size: 16px;
}

.history-detail-meta {
    margin-top: 4px;
    font-size: 13px;
    color: var(--playground-text-secondary);
}

.history-detail-body {
    font-size: 14px;
    color: var(--playground-text-primary);
    line-height: 1.6;
}

.history-chat-preview {
    border: 1px solid var(--playground-border);
    border-radius: 10px;
    padding: 12px;
    background-color: var(--playground-bg-primary);
    margin-bottom: 12px;
}

.history-attachments {
    margin-bottom: 16px;
}

.history-attachments-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    margin: 0 0 6px;
    color: var(--playground-text-tertiary);
}

.history-attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
}

.history-attachment {
    position: relative;
    border: 1px solid var(--playground-border);
    border-radius: 10px;
    overflow: hidden;
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--playground-bg-primary);
    text-decoration: none;
    color: var(--playground-text-primary);
}

.history-attachment img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.history-attachment-badge {
    position: absolute;
    right: 8px;
    bottom: 8px;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    background-color: rgba(0, 0, 0, 0.65);
    color: #fff;
}

.history-attachment-fallback {
    font-size: 22px;
    opacity: 0.65;
}

.history-attachment.file {
    flex-direction: column;
    gap: 6px;
    padding: 12px;
}

.history-attachment-label {
    font-size: 12px;
    text-align: center;
    color: var(--playground-text-secondary);
}

.history-chat-line {
    margin-bottom: 10px;
}

.history-chat-line:last-child {
    margin-bottom: 0;
}

.history-chat-line span {
    font-weight: 600;
    color: var(--playground-text-secondary);
    display: block;
    margin-bottom: 2px;
}

.history-detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.history-open-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--playground-accent);
    text-decoration: none;
}

.history-open-link svg {
    stroke: currentColor;
}

.history-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background-color: var(--playground-bg-tertiary);
    font-size: 11px;
    color: var(--playground-text-secondary);
}

.history-pill--status {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: rgba(59, 130, 246, 0.12);
    color: var(--playground-accent);
}

.history-pill--status.status-completed,
.history-pill--status.status-complete {
    background-color: rgba(16, 185, 129, 0.18);
    color: #059669;
}

.history-pill--status.status-processing,
.history-pill--status.status-running,
.history-pill--status.status-in-progress {
    background-color: rgba(251, 191, 36, 0.2);
    color: #b45309;
}

.history-pill--status.status-queued,
.history-pill--status.status-pending {
    background-color: rgba(96, 165, 250, 0.2);
    color: #1d4ed8;
}

.history-pill--status.status-failed,
.history-pill--status.status-error {
    background-color: rgba(248, 113, 113, 0.2);
    color: #b91c1c;
}

.history-empty {
    padding: 40px 0;
    text-align: center;
    color: var(--playground-text-tertiary);
}

@media (max-width: 768px) {
    .history-modal-body {
        grid-template-columns: 1fr;
    }

    .history-list-column {
        border-right: none;
        padding-right: 0;
    }
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1200px) {
    :root {
        --playground-left-panel-width: 300px;
    }
}

@media (max-width: 968px) {
    .playground-header {
        flex-direction: column;
        gap: 18px;
    }

    .header-stats {
        justify-content: flex-start;
    }

    .playground-container {
        flex-direction: column;
        height: auto;
        min-height: 0;
    }

    .left-panel {
        width: 100%;
        min-width: auto;
        max-height: 400px;
    }

    .right-panel {
        min-height: 500px;
    }
}

@media (max-width: 640px) {
    .playground-shell {
        padding: 16px;
    }

    .playground-container {
        padding: 12px;
        gap: 12px;
    }

    .panel-content {
        padding: 16px;
    }

    .tab-button span {
        display: none;
    }

    .action-button span {
        display: none;
    }

    .left-panel-actions {
        gap: 6px;
    }
}
