:root {
    --bg-base: #090b10;
    --bg-surface: rgba(16, 20, 31, 0.75);
    --bg-elevated: rgba(26, 32, 48, 0.85);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(139, 92, 246, 0.35);
    
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.35);
    --secondary: #3b82f6;
    --cyan: #06b6d4;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --timer-green: #10b981;
    --timer-yellow: #f59e0b;
    --timer-red: #ef4444;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

/* Subtle background ambient mesh */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    left: 20%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -20%;
    right: 10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Base Glass Panels */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* App Container */
#app-container {
    position: relative;
    z-index: 1;
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 290px;
    height: 100%;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
}

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

.logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-orb {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    box-shadow: 0 0 16px var(--primary-glow);
}

.logo-group h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-section-title {
    padding: 16px 20px 8px 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

.loading-history {
    padding: 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
}

.session-item.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.3);
}

.session-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.session-item-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item-date {
    font-size: 0.72rem;
    color: var(--text-dim);
}

.session-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.session-item:hover .session-item-actions {
    opacity: 1;
}

/* Buttons */
.icon-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 12px var(--primary-glow);
}

.mini-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mini-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.mini-icon-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px var(--primary-glow);
    transition: all 0.2s ease;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

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

.secondary-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.control-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

#commit-now-btn {
    background: rgba(139, 92, 246, 0.18);
    color: #c4b5fd;
    border-color: rgba(139, 92, 246, 0.4);
}

#commit-now-btn:hover {
    background: rgba(139, 92, 246, 0.32);
    border-color: rgba(139, 92, 246, 0.6);
}

.danger-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.danger-btn:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 0 12px var(--danger-glow);
}

/* Main Area */
#main-area {
    flex: 1;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

.screen.active {
    display: flex;
}

/* Setup Screen */
#setup-screen {
    justify-content: center;
    align-items: center;
    padding: 24px;
    overflow-y: auto;
}

.setup-card {
    width: 100%;
    max-width: 620px;
    border-radius: var(--radius-lg);
    padding: 36px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    animation: fadeIn 0.4s ease-out;
}

.setup-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setup-badge {
    align-self: flex-start;
    padding: 4px 12px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #c4b5fd;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setup-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.setup-header p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.setup-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-group label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
}

.label-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-weight: 400;
}

.text-input, .custom-select, .textarea-input {
    width: 100%;
    background: rgba(10, 12, 18, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.92rem;
    transition: all 0.2s ease;
    outline: none;
}

.text-input:focus, .custom-select:focus, .textarea-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    background: rgba(10, 12, 18, 0.85);
}

.textarea-input {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

/* Preset Chips */
.preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover {
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.3);
    color: #e9d5ff;
}

.chip.active {
    background: rgba(139, 92, 246, 0.25);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

/* My Personas Section */
.my-personas-section {
    margin-top: 10px;
}

.my-personas-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.my-personas-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Persona chips (user-saved, with delete button) */
.persona-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 6px 14px;
    cursor: pointer;
}

.persona-chip-name {
    pointer-events: none;
}

.persona-chip-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    border-radius: 50%;
    transition: color 0.15s ease, background 0.15s ease;
}

.persona-chip-delete:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.12);
}

/* Save Persona Button */
.save-persona-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.save-persona-btn {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--radius-full);
    padding: 5px 14px;
    color: #c4b5fd;
    font-size: 0.8rem;
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-persona-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
    color: white;
}

/* Active Session Screen (Top Bar) */
.top-bar {
    margin: 16px 24px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.title-with-rename {
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-with-rename h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-main);
}

.session-meta-tags {
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-tag {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-weight: 500;
}

.meta-tag.status-live {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--timer-green);
    box-shadow: 0 0 8px var(--timer-green);
    animation: pulse 1.5s infinite;
}

.center-call-status {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.timer-display {
    font-size: 1.9rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--timer-green);
    letter-spacing: -0.5px;
    transition: color 0.5s ease;
}

.timer-phase {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

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

.glow-btn {
    animation: pulseGlow 2s infinite;
}

.progress-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--timer-green);
    transition: width 1s linear, background-color 0.5s ease;
}

/* Main Content Area (Centered View) */
.main-content {
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    overflow: hidden;
    gap: 20px;
    padding: 0 24px 20px 24px;
}

/* Center Conversation Column */
.conversation-column {
    flex: 1;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
}

.conversation-header {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(10, 12, 18, 0.4);
}

.conv-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.conv-header-right {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Scrollable Messages Container (SCROLL FIX) */
.transcript-messages {
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.transcript-empty {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    max-width: 340px;
}

.empty-icon {
    font-size: 2.5rem;
    opacity: 0.6;
}

.transcript-empty h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.transcript-empty p {
    font-size: 0.88rem;
    line-height: 1.5;
}

/* Chat Bubbles */
.transcript-bubble {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    max-width: 82%;
    word-break: break-word;
    animation: bubbleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.transcript-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(99, 102, 241, 0.22));
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #e0e7ff;
    border-bottom-right-radius: 4px;
}

.transcript-bubble.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

.bubble-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.transcript-bubble.user .bubble-header {
    color: #93c5fd;
}

.transcript-bubble.assistant .bubble-header {
    color: #c4b5fd;
}

.bubble-content {
    font-size: 0.94rem;
    line-height: 1.55;
}

.bubble-content p {
    margin-bottom: 8px;
}

.bubble-content p:last-child {
    margin-bottom: 0;
}

.bubble-content ul, .bubble-content ol {
    margin: 8px 0 8px 20px;
}

.bubble-content li {
    margin-bottom: 4px;
}

.bubble-content h1, .bubble-content h2, .bubble-content h3, .bubble-content h4 {
    margin: 12px 0 6px 0;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.bubble-content h1 { font-size: 1.2rem; }
.bubble-content h2 { font-size: 1.08rem; }
.bubble-content h3 { font-size: 0.98rem; }

.bubble-content code {
    font-family: var(--font-mono);
    font-size: 0.86rem;
}

.bubble-content :not(pre) > code {
    background: rgba(255, 255, 255, 0.1);
    color: #f3e8ff;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.bubble-content pre {
    background: rgba(10, 14, 23, 0.85) !important;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin: 10px 0;
    overflow-x: auto;
}

.bubble-content pre code {
    background: transparent !important;
    padding: 0;
    border: none;
    font-size: 0.84rem;
    line-height: 1.45;
}

.bubble-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--text-muted);
    font-style: italic;
}

.bubble-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.85rem;
}

.bubble-content th, .bubble-content td {
    padding: 6px 10px;
    border: 1px solid var(--border-subtle);
    text-align: left;
}

.bubble-content th {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-weight: 600;
}

/* Inline Mermaid Diagram Cards */
.mermaid-diagram-card {
    margin: 14px 0;
    border-radius: var(--radius-md);
    overflow: visible;
    background: rgba(10, 14, 24, 0.85);
    border: 1px solid rgba(139, 92, 246, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.mermaid-diagram-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: rgba(139, 92, 246, 0.12);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: #c4b5fd;
    letter-spacing: 0.3px;
}

.mermaid-badge {
    font-size: 0.68rem;
    background: rgba(139, 92, 246, 0.25);
    color: #e9d5ff;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(139, 92, 246, 0.4);
    text-transform: uppercase;
    font-weight: 700;
}

.mermaid-diagram-svg {
    padding: 20px 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: auto;
    min-height: 80px;
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.03) 0%, transparent 80%);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Force mermaid SVG to scale properly */
.mermaid-diagram-svg svg {
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.mermaid-loading {
    color: var(--text-dim);
    font-size: 0.82rem;
    padding: 12px;
}

/* Embedded Visual Cards Inside Conversation */
.embedded-visual-card {
    margin-top: 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
}

.visual-card-title {
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--cyan);
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--border-subtle);
}

.visual-card-body {
    padding: 12px;
    overflow-x: auto;
}

.visual-card-body pre {
    margin: 0;
    background: transparent !important;
}

.visual-card-body code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* Side Visual Canvas */
.visual-canvas {
    flex: 1;
    height: 100%;
    min-height: 0;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
}

.canvas-header {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(10, 12, 18, 0.4);
}

.canvas-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.canvas-placeholder {
    margin: auto;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* End Screen */
#end-screen {
    justify-content: center;
    align-items: center;
    padding: 24px;
    overflow-y: auto;
}

.end-panel {
    width: 100%;
    max-width: 680px;
    border-radius: var(--radius-lg);
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.4s ease-out;
}

.end-panel-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.check-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--timer-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
}

.end-panel-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
}

.summary-content {
    background: rgba(10, 12, 18, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 24px;
    line-height: 1.65;
    font-size: 0.95rem;
    max-height: 50vh;
    overflow-y: auto;
}

.summary-content h1, .summary-content h2, .summary-content h3 {
    margin-top: 18px;
    margin-bottom: 8px;
    color: #c4b5fd;
}

.summary-content p {
    margin-bottom: 12px;
}

.summary-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 30px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

.actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* Modal Backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-card {
    width: 100%;
    max-width: 440px;
    border-radius: var(--radius-lg);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.94); }
    to { opacity: 1; transform: scale(1); }
}

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

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

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 16px var(--primary-glow); }
    50% { box-shadow: 0 0 28px rgba(139, 92, 246, 0.6); }
}

/* --- Sidebar Header Actions --- */
.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- Setup Header Badge Row & Settings Pill --- */
.setup-badge-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.settings-pill-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.settings-pill-btn:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.35);
    color: #c4b5fd;
}

.settings-pill-btn.configured {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
}

.label-action-link {
    font-size: 0.76rem;
    color: var(--primary);
    text-decoration: none;
    transition: opacity 0.2s;
}

.label-action-link:hover {
    text-decoration: underline;
    opacity: 0.85;
}

/* --- Settings Modal Specifics --- */
.settings-modal-card {
    max-width: 520px;
    padding: 24px 28px;
    gap: 14px;
}

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

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-icon {
    font-size: 1.25rem;
}

.settings-subtitle {
    font-size: 0.8rem !important;
    color: var(--text-dim) !important;
    line-height: 1.4;
    margin-top: -6px;
}

.settings-tabs {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.25);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.settings-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.settings-tab-btn:hover {
    color: var(--text-main);
}

.settings-tab-btn.active {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.settings-tab-pane {
    display: none;
    flex-direction: column;
    gap: 14px;
    animation: fadeIn 0.2s ease;
}

.settings-tab-pane.active {
    display: flex;
}

.input-with-toggle {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
}

.input-with-toggle .text-input {
    padding-right: 42px;
}

.toggle-visibility-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-visibility-btn:hover {
    color: var(--text-main);
}

.label-required {
    color: #f87171;
}

.field-hint {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ==========================================================================
   RESPONSIVE STYLES
   Breakpoints: tablet ≤900px | mobile-landscape ≤640px | mobile ≤480px
   ========================================================================== */

/* --- Tablet (≤900px): Collapse sidebar, shrink top bar --- */
@media (max-width: 900px) {
    .sidebar {
        width: 220px;
    }

    .setup-card {
        padding: 28px 22px;
    }

    .setup-header h1 {
        font-size: 1.5rem;
    }

    .top-bar {
        margin: 10px 14px;
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .center-call-status {
        order: -1;
        width: 100%;
        align-items: center;
    }

    .timer-display {
        font-size: 1.5rem;
    }

    .controls {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
    }

    .control-btn, .danger-btn {
        padding: 7px 11px;
        font-size: 0.8rem;
    }

    .main-content {
        padding: 0 14px 14px 14px;
        gap: 12px;
    }

    .transcript-messages {
        padding: 16px;
    }

    .transcript-bubble {
        max-width: 90%;
    }

    /* Visual canvas becomes bottom panel on tablet */
    .visual-canvas {
        max-width: 260px;
    }
}

/* --- Mobile Landscape / Small Tablet (≤640px): Hide sidebar, single column --- */
@media (max-width: 640px) {
    html, body {
        overflow: auto;
    }

    #app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    /* Sidebar collapses to a slim top strip */
    .sidebar {
        width: 100%;
        height: auto;
        border-radius: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        flex-direction: row;
        align-items: center;
        padding: 0;
        flex-shrink: 0;
    }

    .sidebar-header {
        flex: 1;
        border-bottom: none;
        padding: 12px 16px;
    }

    .sidebar-section-title {
        display: none;
    }

    .session-list {
        display: none;
    }

    #main-area {
        flex: unset;
        height: auto;
        min-height: calc(100vh - 60px);
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    .screen {
        height: auto;
        min-height: calc(100vh - 60px);
        overflow: visible;
    }

    /* Setup screen */
    #setup-screen {
        padding: 16px;
        align-items: stretch;
    }

    .setup-card {
        max-width: 100%;
        padding: 20px 16px;
        gap: 18px;
        border-radius: var(--radius-md);
    }

    .setup-header h1 {
        font-size: 1.35rem;
    }

    .setup-header p {
        font-size: 0.88rem;
    }

    .setup-badge-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .chip {
        font-size: 0.76rem;
        padding: 5px 11px;
    }

    .text-input, .custom-select, .textarea-input {
        font-size: 0.88rem;
        padding: 10px 13px;
    }

    .primary-btn {
        width: 100%;
        padding: 13px 20px;
        font-size: 0.95rem;
    }

    /* Session screen */
    #session-screen {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 60px);
    }

    .top-bar {
        margin: 8px 10px;
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 6px;
        border-radius: var(--radius-md);
    }

    .session-info {
        flex: 1;
        min-width: 0;
    }

    .title-with-rename h2 {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
    }

    .center-call-status {
        order: -1;
        width: 100%;
        padding: 4px 0;
    }

    .timer-display {
        font-size: 1.35rem;
    }

    .timer-phase {
        font-size: 0.68rem;
    }

    .controls {
        flex-wrap: wrap;
        gap: 5px;
        width: 100%;
        justify-content: flex-start;
    }

    .control-btn, .danger-btn {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    .main-content {
        flex: 1;
        flex-direction: column;
        padding: 0 10px 12px 10px;
        gap: 10px;
        height: auto;
        overflow: visible;
    }

    /* Conversation column full width */
    .conversation-column {
        max-width: 100%;
        margin: 0;
        height: auto;
        min-height: 400px;
        max-height: 60vh;
    }

    .transcript-messages {
        padding: 12px;
        gap: 12px;
    }

    .transcript-bubble {
        max-width: 95%;
        padding: 11px 14px;
    }

    .bubble-content {
        font-size: 0.9rem;
    }

    .bubble-content pre {
        font-size: 0.78rem;
        overflow-x: auto;
    }

    /* Visual canvas becomes a bottom sheet */
    .visual-canvas {
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 45vh;
        flex: unset;
    }

    .canvas-body {
        max-height: calc(45vh - 50px);
    }

    /* Mermaid diagrams — scrollable on small screens */
    .mermaid-diagram-svg {
        overflow-x: auto;
        padding: 12px 10px;
    }

    .mermaid-diagram-svg svg {
        min-width: 280px;
    }

    /* End screen */
    #end-screen {
        padding: 16px;
        align-items: stretch;
    }

    .end-panel {
        max-width: 100%;
        padding: 24px 16px;
        gap: 18px;
    }

    .end-panel-header h2 {
        font-size: 1.35rem;
    }

    .summary-content {
        padding: 16px;
        font-size: 0.88rem;
        max-height: 40vh;
    }

    .actions {
        flex-direction: column;
        gap: 8px;
    }

    .actions button {
        width: 100%;
    }

    /* Modals — full width on mobile */
    .modal-backdrop {
        padding: 12px;
        align-items: flex-end;
    }

    .modal-card {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 22px 18px;
    }

    .settings-modal-card {
        max-width: 100%;
        max-height: 92vh;
        overflow-y: auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .settings-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .settings-tab-btn {
        font-size: 0.75rem;
        padding: 7px 8px;
        white-space: nowrap;
    }

    .modal-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-actions button {
        width: 100%;
    }
}

/* --- Mobile Portrait (≤480px): Extra tightening --- */
@media (max-width: 480px) {
    .setup-header h1 {
        font-size: 1.2rem;
    }

    .logo-group h2 {
        font-size: 1rem;
    }

    .title-with-rename h2 {
        font-size: 0.88rem;
        max-width: 120px;
    }

    .timer-display {
        font-size: 1.2rem;
    }

    .control-btn, .danger-btn {
        padding: 5px 9px;
        font-size: 0.74rem;
    }

    .transcript-bubble {
        max-width: 98%;
        padding: 10px 12px;
    }

    .bubble-content {
        font-size: 0.86rem;
    }

    .preset-chips {
        gap: 6px;
    }

    .chip {
        font-size: 0.72rem;
        padding: 4px 10px;
    }

    .mermaid-diagram-card {
        margin: 8px 0;
    }

    .conversation-column {
        max-height: 55vh;
    }
}
