/* Lore Lantern - Debug Panel Styles v3.0 */

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.hidden {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    padding: 0;  /* No padding for debug studio - full viewport */
    color: var(--text-primary);
}

/* Legacy container layout - adds padding back */
.debug-container {
    padding: 20px;
}

/* Container */
.debug-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

header h1 {
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.debug-badge {
    font-size: 0.6em;
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
}

.subtitle {
    opacity: 0.9;
    margin-top: 5px;
}

/* Panels */
.panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.panel h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.panel-header h2 {
    margin: 0;
    flex: 1;
}

/* Story Creation */
.story-creation-panel .form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.story-creation-panel label {
    font-weight: 500;
    color: var(--text-secondary);
}

.story-creation-panel select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.story-creation-panel input[type="text"] {
    flex: 1;
    min-width: 300px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.story-creation-panel input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.mic-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Buttons */
.primary-btn, .secondary-btn, .control-btn, .icon-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondary-btn {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.secondary-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

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

.control-btn {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.control-btn:hover:not(:disabled) {
    background: var(--border-color);
}

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

.icon-btn {
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1.1rem;
}

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

/* Story Details Panel */
.details-row {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
}

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

.story-info-card, .characters-card {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 15px;
}

.story-info-card h3, .characters-card h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item {
    display: flex;
    gap: 8px;
}

.info-item .label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 60px;
}

.info-item .value {
    color: var(--text-primary);
}

.info-item .value.mono {
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-all;
}

/* Playback Phase Badge */
.playback-phase-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.phase-pre_chapter {
    background: #dbeafe;
    color: #1e40af;
}

.phase-playing {
    background: #fef3c7;
    color: #d97706;
}

.phase-post_chapter {
    background: #d1fae5;
    color: #059669;
}

.phase-transitioning {
    background: #e0e7ff;
    color: #4338ca;
}

/* Status Badges */
.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-ready, .status-complete {
    background: #d1fae5;
    color: #059669;
}

.status-generating, .status-initializing {
    background: #fef3c7;
    color: #d97706;
}

.status-error {
    background: #fee2e2;
    color: #dc2626;
}

/* Characters Grid */
.characters-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.character-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    min-width: 140px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.character-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.char-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.char-role {
    font-size: 0.8rem;
    color: var(--primary-color);
    margin-bottom: 6px;
}

.char-traits {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.char-arc {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 6px;
    cursor: help;
}

.placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

/* Chapters Panel */
.chapter-tabs {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.chapter-tab {
    padding: 8px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chapter-tab:hover {
    background: white;
}

.chapter-tab.active {
    background: white;
    border-bottom-color: white;
    font-weight: 600;
    color: var(--primary-color);
}

.tab-status {
    font-size: 0.8rem;
}

/* Chapter Content */
.chapter-content-area {
    min-height: 300px;
}

.chapter-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-secondary);
}

.chapter-view {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chapter-header {
    margin-bottom: 15px;
}

.chapter-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.chapter-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.chapter-synopsis {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.chapter-prose {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.7;
    font-size: 1rem;
    white-space: pre-wrap;
}

.chapter-vocab {
    margin-top: 15px;
    padding: 10px;
    background: #fffbeb;
    border-radius: 6px;
    font-size: 0.9rem;
}

.vocab-word {
    background: #fef3c7;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: help;
    margin: 0 2px;
}

/* TTS Controls - Clear Step-by-Step Layout */
.tts-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.tts-section {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 12px;
}

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

.section-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.section-status {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
}

.section-status.ready {
    background: #dcfce7;
    color: #166534;
}

.section-status.cached {
    background: #dbeafe;
    color: #1e40af;
}

.section-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.tts-section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.action-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.action-btn.primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.action-btn.small {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.action-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Audio Player Box */
.audio-player-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
}

.player-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.player-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.player-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.player-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.progress-bar::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.time-display {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
    min-width: 90px;
}

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

.tts-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.ssml-viewer {
    margin-top: 15px;
}

.ssml-viewer summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 8px;
}

.ssml-viewer pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.8rem;
    max-height: 300px;
    overflow-y: auto;
}

/* Chat Panel */
.chat-panel {
    display: flex;
    flex-direction: column;
}

.discussion-indicator {
    background: var(--success-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.chat-history {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 15px;
    /* Removed max-height for flexibility */
    overflow-y: auto;
    resize: vertical;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-welcome {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px;
}

.chat-message {
    display: flex;
}

.message-narrator {
    justify-content: flex-start;
}

.message-user {
    justify-content: flex-end;
}

.message-system {
    justify-content: center;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
}

.message-narrator .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-left-radius: 4px;
}

.message-user .message-bubble {
    background: var(--border-color);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.system-bubble {
    background: white;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
}

.message-error .system-bubble {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

.message-sender {
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.9;
}

.message-text {
    line-height: 1.5;
}

.message-time {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 4px;
}

.audio-play-btn {
    margin-top: 8px;
    padding: 4px 10px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    color: white;
    font-size: 0.75rem;
    cursor: pointer;
}

.audio-play-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Chat Input */
.chat-input-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.chat-input-container input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: rgba(255,255,255,0.6);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Debug Panel */
.debug-panel {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.debug-panel summary {
    cursor: pointer;
    padding: 15px 20px;
    font-weight: 600;
    color: var(--text-secondary);
}

.debug-panel summary:hover {
    color: var(--text-primary);
}

.debug-content {
    padding: 0 20px 20px;
}

.debug-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
}

.debug-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

.debug-item .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.debug-item .value {
    font-size: 0.85rem;
    font-weight: 500;
}

.ws-connected { color: var(--success-color); }
.ws-disconnected { color: var(--text-secondary); }
.ws-error { color: var(--danger-color); }

.debug-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.json-viewer summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 8px 0;
}

.json-viewer pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

/* ==================== Profile Panel ==================== */
.profile-panel {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #bae6fd;
}

.profile-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #bae6fd;
}

.profile-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

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

.profile-header h3 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin: 0;
}

.profile-select-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.profile-select-row select {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
}

.profile-select-row select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.profile-badge {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Create Form */
.create-form {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.create-form input[type="text"],
.create-form input[type="number"],
.create-form select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.create-form input[type="text"] {
    min-width: 150px;
}

.create-form input[type="number"] {
    width: 100px;
}

/* Small button variant */
.small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Children Grid */
.children-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.child-profile-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 160px;
}

.child-profile-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.child-profile-card.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
}

.child-avatar {
    font-size: 2rem;
}

.child-info {
    display: flex;
    flex-direction: column;
}

.child-name {
    font-weight: 600;
    color: var(--text-primary);
}

.child-age {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.story-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: auto;
    padding: 2px 8px;
    background: var(--bg-color);
    border-radius: 10px;
}

/* Active Profile Summary */
.active-profile-summary {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px dashed #bae6fd;
}

.selected-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 2px solid #86efac;
    border-radius: 12px;
}

.selected-profile .profile-avatar {
    font-size: 2.5rem;
}

.selected-profile .profile-info {
    display: flex;
    flex-direction: column;
}

.selected-profile .profile-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.selected-profile .profile-age {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.ready-badge {
    margin-left: auto;
    padding: 6px 14px;
    background: var(--success-color);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 640px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5rem;
        flex-direction: column;
    }

    .story-creation-panel .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .story-creation-panel input[type="text"] {
        min-width: auto;
    }

    .chapter-meta {
        flex-direction: column;
        gap: 5px;
    }

    .tts-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .tts-status {
        margin-left: 0;
        text-align: center;
    }

    .profile-select-row {
        flex-direction: column;
    }

    .create-form {
        flex-direction: column;
        align-items: stretch;
    }

    .create-form input[type="text"],
    .create-form input[type="number"] {
        min-width: auto;
        width: 100%;
    }

    .selected-profile {
        flex-direction: column;
        text-align: center;
    }

    .ready-badge {
        margin-left: 0;
    }
}

/* ==================== DEBUG STUDIO SPLIT LAYOUT v6.0 ==================== */
/* Fixed height layout - proper debug panel with contained sections */

.debug-studio {
    height: 100vh;  /* Fixed to viewport height */
    display: flex;
    flex-direction: column;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;  /* Prevent page scroll - panels scroll internally */
}

.studio-header {
    padding: 8px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;  /* Don't shrink header */
}

.studio-header h1 {
    font-size: 1.2rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.split-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;  /* Take remaining space */
    min-height: 0;  /* Critical for flex children to shrink */
    gap: 0;
    overflow: hidden;
}

/* User Panel (Left) */
.user-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: var(--bg-color);
    overflow-y: auto;  /* Scroll when content overflows */
    border-right: 2px solid var(--border-color);
}

/* Observatory Panel (Right) */
.observatory-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: #1a1b26;
    overflow-y: auto;  /* Scroll when content overflows */
    color: #a9b1d6;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);  /* Terminal-like inset shadow */
}

.observatory-panel .panel {
    background: #24283b;
    border: 1px solid #414868;
    padding: 8px 10px;
    margin-bottom: 0;
    border-radius: 6px;
    /* Allow panels to shrink when needed */
}

.observatory-panel h3 {
    font-size: 0.7rem;
    color: #7aa2f7;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Compact Profile Panel */
.profile-panel.compact {
    padding: 12px;
}

.profile-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.profile-select-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex: 1;
}

.profile-select-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 60px;
}

.profile-select-group select {
    flex: 1;
    padding: 6px 10px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.children-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}

.children-grid.compact {
    flex: 1;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.children-grid.compact .child-profile-card {
    padding: 6px 12px;
    min-width: auto;
    font-size: 0.85rem;
}

.children-grid.compact .child-avatar {
    font-size: 1.2rem;
}

.active-profile {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
    padding: 8px 12px;
    background: #d1fae5;
    border-radius: 6px;
    font-size: 0.9rem;
}

.active-profile .age-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: #86efac;
    border-radius: 10px;
}

/* Story Input Panel */
.story-input-panel {
    padding: 12px;
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
}

.input-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Reader Panel */
.reader-panel {
    flex: 1;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    padding: 12px;
}

.reader-header {
    display: flex;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.reader-header .chapter-tabs {
    flex: 1;
    margin: 0;
    padding: 0;
    border: none;
}

.chapter-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    resize: vertical;
    min-height: 200px;
}

/* Chat Panel - Compact */
.user-panel .chat-panel {
    flex: 1;
    min-height: 150px;
    /* Removed max-height for resizable layout */
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.user-panel .chat-history {
    flex: 1;
    min-height: 100px;
    max-height: none;
}

/* ==================== OBSERVATORY COMPONENTS ==================== */

/* Pipeline */
.pipeline-stages {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.stage {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #1f2335;
    border-radius: 16px;
    font-size: 0.75rem;
    transition: all 0.3s;
}

.stage-icon {
    font-size: 0.8rem;
}

.stage-arrow {
    color: #565f89;
    font-size: 0.8rem;
}

.stage.active {
    background: #3b4261;
    color: #7aa2f7;
}

.stage.active .stage-icon {
    color: #7aa2f7;
    animation: pulse 1.5s infinite;
}

.stage.completed {
    background: #1f3d1f;
    color: #9ece6a;
}

.stage.completed .stage-icon {
    color: #9ece6a;
}

.stage.error {
    background: #3d1f1f;
    color: #f7768e;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Agents List */
.agents-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 140px;  /* Compact fixed height */
    overflow-y: auto;
}

.agent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: #1f2335;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.agent-status {
    width: 16px;
    text-align: center;
}

.agent-name {
    font-weight: 500;
    min-width: 120px;
}

.agent-task {
    color: #565f89;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-item.idle {
    opacity: 0.6;
}

.agent-item.working {
    background: #3b4261;
}

.agent-item.working .agent-status {
    color: #7aa2f7;
    animation: pulse 1s infinite;
}

.agent-item.working .agent-task {
    color: #7aa2f7;
}

.agent-item.completed .agent-status {
    color: #9ece6a;
}

.agent-item.completed .agent-task {
    color: #9ece6a;
}

.agent-item.error .agent-status {
    color: #f7768e;
}

.agent-item.error .agent-task {
    color: #f7768e;
}

/* Agent Columns - Side by Side Layout */
.agents-columns {
    display: flex;
    gap: 12px;
}

.agents-columns .agent-group {
    flex: 1;
}

.agent-group-label {
    display: block;
    font-size: 0.6rem;
    color: #565f89;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.agents-columns .agents-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agents-columns .agent-item {
    padding: 3px 6px;
    font-size: 0.7rem;
    border-radius: 3px;
    background: #1f2335;
    transition: all 0.2s;
}

.agents-columns .agent-item.idle {
    opacity: 0.5;
}

.agents-columns .agent-item.working {
    opacity: 1;
    background: #3b4261;
    color: #7aa2f7;
}

/* Agent verdict states for Round Table */
.agent-item.approve .agent-status { color: #9ece6a; }
.agent-item.approve { background: rgba(158, 206, 106, 0.1); opacity: 1; }
.agent-item.concern .agent-status { color: #e0af68; }
.agent-item.concern { background: rgba(224, 175, 104, 0.1); opacity: 1; }
.agent-item.block .agent-status { color: #f7768e; }
.agent-item.block { background: rgba(247, 118, 142, 0.15); opacity: 1; }

/* Model Stats */
.model-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.model-current {
    display: flex;
    gap: 10px;
    align-items: center;
}

.model-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #bb9af7;
}

.model-mode {
    padding: 2px 8px;
    background: #3b4261;
    border-radius: 10px;
    font-size: 0.75rem;
}

.model-metrics {
    display: flex;
    gap: 15px;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-label {
    font-size: 0.7rem;
    color: #565f89;
    text-transform: uppercase;
}

.metric-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: #c0caf5;
}

/* Chapter Timeline */
.chapter-timeline {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 100px;  /* Compact fixed height */
    overflow-y: auto;
}

.timeline-empty {
    color: #565f89;
    font-style: italic;
    font-size: 0.85rem;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    background: #1f2335;
    border-radius: 4px;
    font-size: 0.75rem;
}

.timeline-chapter {
    font-weight: 600;
    color: #bb9af7;
    min-width: 50px;
}

.timeline-phases {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}

.timeline-phase {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    background: #2a2f44;
    color: #565f89;
    transition: all 0.3s;
}

.timeline-phase.waiting {
    background: #2a2f44;
    color: #565f89;
}

.timeline-phase.working {
    background: #3d4a7a;
    color: #7aa2f7;
    animation: pulse 1s infinite;
}

.timeline-phase.done {
    background: #2d4a3a;
    color: #9ece6a;
}

.timeline-phase.error {
    background: #4a2d2d;
    color: #f7768e;
}

.timeline-time {
    font-size: 0.7rem;
    color: #565f89;
    min-width: 50px;
    text-align: right;
}

/* Round Table Timeline */
.roundtable-timeline {
    min-height: 50px;
    max-height: 180px;
    overflow-y: auto;
    resize: vertical;
}

.rt-empty {
    color: #565f89;
    font-style: italic;
    font-size: 0.85rem;
}

.rt-header {
    font-weight: 600;
    margin-bottom: 10px;
    color: #e0af68;
}

.rt-reviewers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.rt-reviewer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #1f2335;
    border-radius: 16px;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.rt-reviewer.pending .rt-status {
    animation: pulse 1s infinite;
}

.rt-reviewer.approved {
    background: #1f3d1f;
}

.rt-reviewer.concern {
    background: #3d3d1f;
}

.rt-reviewer.blocked {
    background: #3d1f1f;
}

/* Reviewer domain description */
.rt-domain {
    font-size: 0.65rem;
    color: #565f89;
    font-style: italic;
    display: none; /* Hidden by default, shown on hover or when expanded */
}

.rt-reviewer:hover .rt-domain,
.rt-reviewer.concern .rt-domain,
.rt-reviewer.blocked .rt-domain {
    display: block;
    margin-top: 2px;
}

/* Reviewer notes - shown inline for concern/block */
.rt-notes {
    font-size: 0.7rem;
    color: #a9b1d6;
    margin-top: 4px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    max-width: 280px;
    word-wrap: break-word;
    line-height: 1.4;
    border-left: 2px solid #565f89;
}

.rt-reviewer.blocked .rt-notes {
    background: rgba(255, 0, 0, 0.1);
    color: #f7768e;
    border-left-color: #f7768e;
}

.rt-reviewer.concern .rt-notes {
    background: rgba(255, 193, 7, 0.1);
    color: #e0af68;
    border-left-color: #e0af68;
}

/* Non-AI expert explanation for blocks */
.rt-explanation {
    font-size: 0.7rem;
    color: #7aa2f7;
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(122, 162, 247, 0.1);
    border-radius: 6px;
    max-width: 300px;
    line-height: 1.5;
    border-left: 2px solid #7aa2f7;
}

.rt-explanation strong {
    color: #bb9af7;
    display: block;
    margin-bottom: 4px;
}

/* Make reviewer cards vertical to accommodate notes */
.rt-reviewer.concern,
.rt-reviewer.blocked {
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 12px;
}

.rt-decision {
    font-weight: 500;
    padding: 6px 12px;
    background: #1f2335;
    border-radius: 6px;
    display: inline-block;
}

.rt-decision.approved {
    background: #1f3d1f;
    color: #9ece6a;
}

.rt-decision.revision {
    background: #3d3d1f;
    color: #e0af68;
}

.rt-decision.warning {
    background: #3d1f1f;
    color: #f7768e;
    border: 1px solid #f7768e;
}

.decision-warning {
    display: block;
    font-weight: bold;
}

.max-revisions-details {
    margin-top: 6px;
    font-size: 0.8rem;
    font-weight: normal;
}

.blockers-label {
    color: #a9b1d6;
}

.blockers-list {
    color: #f7768e;
    font-weight: 500;
}

/* Event Log */
.eventlog-panel {
    flex: 1;
    min-height: 120px;
    max-height: 280px;
    display: flex;
    flex-direction: column;
}

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

.eventlog-header h3 {
    margin: 0;
}

.eventlog-header .icon-btn.small {
    padding: 4px 8px;
    font-size: 0.75rem;
    opacity: 0.7;
}

.eventlog-header .icon-btn.small:hover {
    opacity: 1;
}

.event-count {
    background: #3b4261;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 8px;
}

.event-log {
    flex: 1;
    min-height: 80px;
    max-height: 200px;  /* Constrained height */
    overflow-y: auto;
    overflow-x: hidden;
    background: #1f2335;
    border-radius: 4px;
    padding: 6px;
    font-family: monospace;
    font-size: 0.7rem;
    resize: vertical;  /* Allow vertical resize */
}

.event-empty {
    color: #565f89;
    font-style: italic;
}

.event-entry {
    padding: 3px 0;
    border-bottom: 1px solid #2a2e42;
    transition: background 0.2s;
}

.event-entry:hover {
    background: #2a2e42;
}

.event-header {
    display: flex;
    gap: 8px;
    cursor: pointer;
}

.event-time {
    color: #565f89;
    min-width: 70px;
}

.event-type {
    color: #7aa2f7;
    min-width: 120px;
}

.event-summary {
    color: #c0caf5;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-details {
    margin-top: 6px;
    padding: 8px;
    background: #0d0e14;
    border-radius: 4px;
    font-size: 0.7rem;
    color: #9ece6a;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Event type colors */
.event-agent_started .event-type { color: #7aa2f7; }
.event-agent_completed .event-type { color: #9ece6a; }
.event-pipeline_stage .event-type { color: #bb9af7; }
.event-model_selected .event-type { color: #e0af68; }
.event-round_table_started .event-type { color: #f7768e; }
.event-structure_ready .event-type { color: #73daca; }
.event-character_ready .event-type { color: #ff9e64; }
.event-chapter_ready .event-type { color: #2ac3de; }
.event-conversation_context .event-type { color: #bb9af7; }
.event-max_revisions_exceeded .event-type { color: #f7768e; }
.event-max_revisions_exceeded { background: rgba(247, 118, 142, 0.1); }

/* Story Details in Observatory */
.observatory-panel .story-details-panel {
    background: #24283b;
    border: 1px solid #414868;
}

.observatory-panel .story-details-panel > summary {
    color: #7aa2f7;
    cursor: pointer;
    padding: 8px 10px;
    font-weight: 600;
}

/* Story Section - Overview */
.story-section {
    padding: 8px 10px;
    border-bottom: 1px solid #414868;
}

.story-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.story-title {
    font-size: 1rem;
    font-weight: 600;
    color: #c0caf5;
}

.story-meta-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.meta-tag {
    font-size: 0.65rem;
    padding: 2px 6px;
    background: #1f2335;
    border-radius: 3px;
    color: #9aa5ce;
}

.progress-bar-container {
    position: relative;
    height: 16px;
    background: #1f2335;
    border-radius: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #7aa2f7, #9ece6a);
    transition: width 0.3s;
}

.progress-label {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6rem;
    color: #c0caf5;
}

/* Story Subsections */
.story-subsection {
    border-bottom: 1px solid #414868;
}

.story-subsection > summary {
    padding: 6px 10px;
    font-size: 0.75rem;
    color: #9aa5ce;
    cursor: pointer;
}

.story-subsection > summary:hover {
    background: #1f2335;
}

/* Goals List */
.goals-list {
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.goal-item {
    padding: 6px 8px;
    background: #1f2335;
    border-radius: 4px;
    border-left: 3px solid #9ece6a;
}

.goal-concept {
    font-weight: 600;
    font-size: 0.75rem;
    color: #c0caf5;
}

.goal-description {
    font-size: 0.7rem;
    color: #9aa5ce;
    margin-top: 2px;
}

/* Characters Grid */
.characters-grid {
    padding: 6px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.character-card {
    padding: 6px 8px;
    background: #1f2335;
    border-radius: 4px;
    min-width: 100px;
    cursor: pointer;
    transition: all 0.2s;
}

.character-card:hover {
    background: #3b4261;
}

.character-card.major { border-left: 3px solid #f7768e; }
.character-card.supporting { border-left: 3px solid #7aa2f7; }
.character-card.minor { border-left: 3px solid #565f89; }

.char-name {
    font-weight: 600;
    font-size: 0.75rem;
    color: #c0caf5;
}

.char-role {
    font-size: 0.65rem;
    color: #bb9af7;
}

.char-traits {
    font-size: 0.6rem;
    color: #9aa5ce;
    margin-top: 2px;
}

/* Plot Threads */
.plot-threads-list {
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.plot-thread {
    padding: 4px 8px;
    background: #1f2335;
    border-radius: 3px;
    font-size: 0.7rem;
    display: flex;
    justify-content: space-between;
}

.plot-thread.setup { border-left: 3px solid #e0af68; }
.plot-thread.active { border-left: 3px solid #7aa2f7; }
.plot-thread.resolved { border-left: 3px solid #9ece6a; }

.thread-name { color: #c0caf5; }
.thread-status { color: #565f89; font-size: 0.6rem; }

/* Chapters Outline */
.chapters-outline {
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chapter-outline-item {
    padding: 6px 8px;
    background: #1f2335;
    border-radius: 4px;
    cursor: pointer;
}

.chapter-outline-item:hover {
    background: #3b4261;
}

.chapter-outline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapter-num {
    font-weight: 600;
    font-size: 0.7rem;
    color: #7aa2f7;
    min-width: 30px;
}

.chapter-title {
    flex: 1;
    font-size: 0.7rem;
    color: #c0caf5;
}

.chapter-status-icon {
    font-size: 0.7rem;
}

.chapter-synopsis {
    font-size: 0.65rem;
    color: #9aa5ce;
    margin-top: 4px;
    display: none;
}

.chapter-outline-item.expanded .chapter-synopsis {
    display: block;
}

/* Raw JSON */
.raw-json {
    padding: 8px;
    background: #0d0e14;
    border-radius: 4px;
    font-size: 0.6rem;
    color: #9ece6a;
    max-height: 200px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Legacy - keep for compatibility */
.story-meta {
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.meta-item {
    display: flex;
    gap: 6px;
}

.meta-item .label {
    color: #565f89;
    font-size: 0.8rem;
}

.meta-item .value {
    color: #c0caf5;
    font-size: 0.85rem;
}

.meta-item .value.mono {
    font-family: monospace;
    font-size: 0.75rem;
}

.characters-section {
    padding: 10px;
    border-top: 1px solid #414868;
}

.characters-section h4 {
    font-size: 0.8rem;
    color: #7aa2f7;
    margin-bottom: 8px;
}

.observatory-panel .characters-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.observatory-panel .character-card {
    background: #1f2335;
    border: 1px solid #414868;
    padding: 8px;
    min-width: 100px;
    font-size: 0.8rem;
}

.observatory-panel .char-name {
    color: #c0caf5;
}

.observatory-panel .char-role {
    color: #bb9af7;
}

/* Debug Controls in Observatory */
.observatory-panel .debug-controls {
    background: #24283b;
    border: 1px solid #414868;
}

.observatory-panel .debug-controls summary {
    color: #565f89;
    cursor: pointer;
    padding: 10px;
}

.observatory-panel .debug-row {
    padding: 10px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    gap: 4px;
    font-size: 0.8rem;
}

.status-item .label {
    color: #565f89;
}

.status-item .value {
    color: #c0caf5;
}

.observatory-panel .debug-actions {
    padding: 0 10px 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.observatory-panel .control-btn.small {
    padding: 4px 10px;
    font-size: 0.75rem;
    background: #3b4261;
    border: 1px solid #414868;
    color: #a9b1d6;
}

.observatory-panel .control-btn.small:hover:not(:disabled) {
    background: #4a5280;
}

.observatory-panel .json-viewer {
    padding: 10px;
}

.observatory-panel .json-viewer summary {
    color: #565f89;
    font-size: 0.8rem;
    padding: 6px 0;
}

.observatory-panel .json-viewer pre {
    background: #0d0e14;
    font-size: 0.7rem;
}

/* Text button variant */
.text-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
}

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

/* Responsive - Stack panels on mobile */
@media (max-width: 1024px) {
    .split-container {
        grid-template-columns: 1fr;
    }

    .user-panel {
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        /* Removed max-height - page scrolls naturally */
    }

    /* Observatory panel - no max-height constraint */
}
