/* 
   MAVERICK "DARK JOURNALIST" AESTHETIC
   Fully Responsive: Mobile → Tablet → Desktop
*/

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%            { transform: translateY(-6px); }
}

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    --bg-color: #080808;
    --surface-color: #121212;
    --surface-hover: #1a1a1a;

    --text-primary: #fcfcfc;
    --text-secondary: #888888;
    --text-tertiary: #444444;

    --accent-red: #ea3323;
    --accent-red-glow: rgba(234, 51, 35, 0.25);

    --border-color: #222222;
    --border-light: rgba(255, 255, 255, 0.08);

    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Inter', sans-serif;

    --border-radius-lg: 20px;
    --border-radius-md: 14px;
    --border-radius-sm: 8px;
    --transition: all 0.28s cubic-bezier(0.25, 0.8, 0.25, 1);

    /* Layout tokens */
    --nav-height: 72px;        /* bottom nav (mobile/tablet) */
    --header-height: 64px;
    --sidebar-width: 260px;    /* desktop persistent sidebar */
    --content-max: 720px;      /* max readable content width */
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    height: 100%;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
    /* Custom Scrollbars */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

button { cursor: pointer; font-family: var(--font-sans); }

/* ============================================
   APP SHELL
   ============================================ */
.app-container {
    width: 100%;
    min-height: 100vh;
    background: radial-gradient(ellipse at top, #141414 0%, var(--bg-color) 70%);
    display: flex;
    flex-direction: row; /* sidebar + content side-by-side */
    position: relative;
}

/* On mobile/tablet the drawer is off-canvas, content fills full width */
.app-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    overflow: hidden;
}

/* ============================================
   TOP NAVIGATION
   ============================================ */
.top-nav {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(8, 8, 8, 0.9);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    white-space: nowrap;
}

.active-project-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-red);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(234, 51, 35, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(234, 51, 35, 0.25);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
}
.menu-btn:hover { color: var(--accent-red); background: rgba(255,255,255,0.05); }

/* ============================================
   SCREEN MANAGEMENT — MOBILE FIRST (slide)
   ============================================ */
.screen-wrapper {
    display: flex;
    width: 300%;
    flex: 1;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    height: calc(100vh - var(--header-height) - var(--nav-height));
    overflow: hidden;
}

.screen {
    width: 33.333%;
    height: 100%;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 28px 20px 40px;
    opacity: 0.3;
    transition: opacity 0.3s ease;
    -webkit-overflow-scrolling: touch;
}
.screen.active { opacity: 1; }

/* ============================================
   CAPTURE SCREEN
   ============================================ */
.hero-section {
    margin-bottom: 36px;
}

.headline {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 7vw, 3.2rem);
    line-height: 1.1;
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: -1px;
}
.headline span { font-style: italic; color: var(--text-secondary); }

.subheadline {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 300;
    max-width: 480px;
}

.action-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 48px;
}

/* ============================================
   RECORD BUTTON
   ============================================ */
.record-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-color);
    padding: 32px 24px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.record-container:hover { border-color: rgba(255,255,255,0.12); }
.record-container.recording {
    border-color: var(--accent-red);
    box-shadow: 0 0 40px var(--accent-red-glow), inset 0 0 30px rgba(234,51,35,0.04);
}

.record-btn {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: transparent;
    border: 2.5px solid var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 18px;
    transition: var(--transition);
    padding: 0;
    outline: none;
}
.record-btn:active { transform: scale(0.94); }
.record-container.recording .record-btn {
    border-color: var(--accent-red);
    box-shadow: 0 0 20px var(--accent-red-glow);
}

.record-inner {
    width: 66px;
    height: 66px;
    background: var(--accent-red);
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: inset 0 0 8px rgba(0,0,0,0.2);
}
.record-container.recording .record-inner {
    border-radius: 14px;
    transform: scale(0.54);
}

.status-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: color 0.3s;
}
.record-container.recording .status-text { color: var(--accent-red); }

/* Waveform */
.wave-container {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    margin-top: 14px;
}
.wave-container.hidden { display: none; }
.bar {
    width: 3px;
    background: var(--accent-red);
    border-radius: 2px;
    animation: wave 1.2s ease-in-out infinite;
}
.bar:nth-child(1) { height: 8px;  animation-delay: 0.1s; }
.bar:nth-child(2) { height: 18px; animation-delay: 0.2s; }
.bar:nth-child(3) { height: 26px; animation-delay: 0.3s; }
.bar:nth-child(4) { height: 18px; animation-delay: 0.4s; }
.bar:nth-child(5) { height: 8px;  animation-delay: 0.5s; }

@keyframes wave {
    0%, 100% { transform: scaleY(0.4); opacity: 0.7; }
    50%       { transform: scaleY(1);   opacity: 1; }
}

/* Subtitle strip */
.subtitle-strip {
    margin-top: 16px;
    background: rgba(0,0,0,0.4);
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}
.subtitle-strip.hidden { display: none; }

/* Language Override */
.language-selection-mini {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.language-selection-mini:hover { opacity: 1; }
.language-selection-mini select {
    background: transparent;
    color: var(--text-primary);
    border: none;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}

/* ============================================
   DIVIDER
   ============================================ */
.divider {
    display: flex;
    align-items: center;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 500;
    gap: 0;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}
.divider span { padding: 0 16px; }

/* ============================================
   UPLOAD DROPZONE
   ============================================ */
.upload-container {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(18,18,18,0.4);
    position: relative;
    overflow: hidden;
}
.upload-container:hover, .upload-container.dragover {
    border-color: var(--text-secondary);
    background: rgba(255,255,255,0.03);
}
.upload-icon {
    margin-bottom: 14px;
    color: var(--text-tertiary);
    transition: var(--transition);
}
.upload-container:hover .upload-icon {
    color: var(--text-primary);
    transform: translateY(-3px);
}
.upload-content h3 {
    font-weight: 500;
    font-size: 1.05rem;
    margin-bottom: 6px;
}
.upload-content p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.browse-link {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ============================================
   RECENT FILES
   ============================================ */
.recent-files h2 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    margin-bottom: 16px;
    font-style: italic;
    color: var(--text-secondary);
}
.file-list { display: flex; flex-direction: column; gap: 12px; }

.file-card {
    background: var(--surface-color);
    padding: 16px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}
.file-card:hover {
    border-color: rgba(255,255,255,0.1);
    background: var(--surface-hover);
    transform: translateY(-1px);
}
.file-icon { color: var(--text-tertiary); display: flex; align-items: center; flex-shrink: 0; }
.file-info { flex-grow: 1; min-width: 0; }
.file-info h4 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-info .meta { font-size: 0.72rem; color: var(--text-tertiary); }

.export-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    transition: var(--transition);
    flex-shrink: 0;
}
.export-btn:hover {
    background: var(--text-primary);
    color: var(--bg-color);
    border-color: var(--text-primary);
}

/* ============================================
   MARKER TRAY
   ============================================ */
.marker-tray-container {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 20px;
    margin-bottom: 20px;
    animation: slideUp 0.35s ease-out;
}
.marker-tray-container.hidden { display: none; }

.marker-tray-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.marker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.marker-grid.mini {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.marker-grid.mini .marker-btn {
    padding: 8px 4px;
    font-size: 0.58rem;
}

.marker-btn {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
}
.marker-btn::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--c, transparent);
}
.marker-btn:hover {
    background: var(--surface-hover);
    border-color: var(--c, --border-color);
}
.marker-btn:active {
    transform: scale(0.95);
    background: rgba(var(--c), 0.15);
}

/* ============================================
   REVIEW SCREEN
   ============================================ */
/* ---- Review screen: sticky controls, scrolling transcript only ---- */
#screen-review {
    display: flex;
    flex-direction: column;
    overflow: hidden;       /* stop the whole screen from scrolling */
    padding-bottom: 0;
}
#screen-review .screen-header {
    flex-shrink: 0;
    margin-bottom: 8px;
    padding-bottom: 0;
}
#screen-review .screen-header h2 { font-size: 1.2rem; margin-bottom: 2px; }
#screen-review .screen-header .meta { font-size: 0.72rem; }
#screen-review .review-player-container {
    flex-shrink: 0;
    padding: 8px;
    margin-bottom: 8px;
}
#screen-review .visual-timeline { height: 40px; margin-bottom: 8px; }
#screen-review .marker-tray-container {
    flex-shrink: 0;
    margin-bottom: 8px;
    padding: 6px 10px;
}
#screen-review .marker-tray-header { font-size: 0.65rem; margin-bottom: 4px; }
#screen-review .marker-grid.mini button { padding: 4px 8px; font-size: 0.65rem; }
#screen-review .transcript-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;          /* allow flex child to shrink below content size */
}
.screen-header { margin-bottom: 20px; }

.screen-header h2 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    margin-bottom: 4px;
}
.screen-header .meta { font-size: 0.8rem; color: var(--text-tertiary); }

.review-player-container {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px;
    margin-bottom: 20px;
    position: relative;
}

.visual-timeline {
    width: 100%;
    height: 60px;
    background: #111;
    border-radius: var(--border-radius-sm);
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.playhead {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: #fff;
    left: 0;
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 0 10px #fff;
}

.marker-track {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 15px;
    z-index: 10;
    pointer-events: none;
    background: rgba(255,255,255,0.03);
}

.marker-dot {
    position: absolute;
    top: 50%;
    width: 6px;
    height: 12px;
    background: var(--c);
    border-radius: 2px;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 5px var(--c);
    opacity: 0.9;
    z-index: 15;
}

.waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0.4;
}

.review-audio-element {
    width: 100%;
    height: 34px;
    filter: invert(1) hue-rotate(180deg) brightness(1.2);
    opacity: 0.9;
}

.transcript-container {
    flex: 1;
    min-height: 200px;
    position: relative; /* needed for absolute popover positioning */
}

.transcript-flow {
    line-height: 2.1;
    font-size: 1.05rem;
    color: var(--text-secondary);
    padding-bottom: 80px;
}
.transcript-flow.rtl { direction: rtl; text-align: right; }

.word {
    display: inline-block;
    padding: 1px 3px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: var(--font-serif);
}
.word:hover { background: var(--surface-hover); color: var(--text-primary); }
.word.highlighted {
    background: rgba(255, 255, 255, 0.08);
    border-bottom: 2px solid var(--text-primary);
    color: var(--text-primary);
}

.marker-inline {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--c);
    display: inline-block;
    vertical-align: middle;
    margin: 0 4px;
    box-shadow: 0 0 4px var(--c);
    cursor: pointer;
    transition: transform 0.2s;
}
.marker-inline:hover { transform: scale(1.4); }

/* ============================================
   STATUS / PROCESSING UI
   ============================================ */
.status-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    min-height: 260px;
    gap: 8px;
}

.status-label {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.status-sub {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    display: block;
}

.status-action-btn {
    margin-top: 20px;
    background: transparent;
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: var(--transition);
}
.status-action-btn:hover {
    background: var(--accent-red);
    color: #fff;
}

/* Progress Bar */
.progress-bar-wrap {
    width: 100%;
    max-width: 280px;
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 22px;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-red), #ff6b57);
    border-radius: 2px;
    transition: width 0.6s ease;
}

/* Pulse dot */
.pulse-dot {
    width: 9px; height: 9px;
    background: var(--accent-red);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-red-glow);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%   { transform: scale(1);   opacity: 1; }
    50%  { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(1);   opacity: 1; }
}

/* Narrative Prompt & Enhanced Chat Input */
.prompt-container {
    margin-bottom: 24px;
}
.prompt-container label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 8px;
    letter-spacing: 0.1em;
}
#narrativePrompt, #chatInput {
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid #1f2937;
    border-radius: 12px;
    color: #f3f4f6;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    transition: all 0.2s ease;
}
#narrativePrompt:focus, #chatInput:focus {
    background: rgba(255,255,255,0.06);
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
#chatInput {
    padding-right: 60px; /* Space for Send button if overlapped, adjust as needed */
}
.chat-input-area {
    position: relative;
    padding: 16px;
    background: #0a0a0a;
    border-top: 1px solid #1f2937;
}
.chat-input-area #sendChatBtn {
    position: absolute;
    right: 28px;
    bottom: 28px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
}

/* ============================================
   DESIGN / AGENT SCREEN
   ============================================ */
.agent-split-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 1px;
    background: var(--border-color);
}
.agent-chat-panel, .script-builder-panel {
    background: var(--bg-color);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-header, .script-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-header h3, .script-header h3 {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-style: italic;
}
.agent-avatar {
    width: 30px; height: 30px;
    background: var(--accent-red);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    margin-right: 10px;
    flex-shrink: 0;
}
.agent-info { flex: 1; }
.agent-info h3 { font-family: var(--font-serif); font-size: 1rem; }
.agent-info .status { font-size: 0.72rem; color: var(--text-tertiary); }

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.msg {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: break-word;
}
.msg.agent {
    align-self: flex-start;
    background: var(--surface-color);
    border-bottom-left-radius: 4px;
}
.msg.user {
    align-self: flex-end;
    background: var(--accent-red);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-input-area {
    padding: 12px 14px;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.chat-input-area input {
    flex: 1;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input-area input:focus { border-color: rgba(255,255,255,0.2); }
#sendChatBtn {
    background: var(--text-primary);
    color: #000;
    border: none;
    padding: 0 18px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
}

.script-timeline { flex: 1; overflow-y: auto; padding: 16px; }
.script-placeholder { color: var(--text-tertiary); text-align: center; margin-top: 40px; font-style: italic; font-size: 0.88rem; }
.export-json-btn {
    background: var(--accent-red);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.script-segment {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    animation: slideUp 0.3s ease-out;
}
.seg-order {
    background: var(--bg-color);
    color: var(--text-secondary);
    width: 22px; height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}
.seg-text { font-size: 0.84rem; color: var(--text-primary); line-height: 1.4; }

/* ============================================
   BOTTOM NAVIGATION (mobile + tablet)
   ============================================ */
.bottom-nav {
    height: var(--nav-height);
    background: rgba(8,8,8,0.95);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 12px;
    flex-shrink: 0;
    z-index: 100;
}
.nav-item {
    background: none;
    border: none;
    color: var(--text-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 20px;
    border-radius: 12px;
    transition: var(--transition);
    flex: 1;
}
.nav-item span {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.nav-item.active { color: var(--accent-red); }
.nav-item:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }

/* ============================================
   PROJECT DRAWER (overlay on mobile/tablet)
   ============================================ */
.project-drawer {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100%;
    background: #0d0d0d;
    z-index: 2000;
    transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
    border-right: 1px solid var(--border-color);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.project-drawer.open { transform: translateX(300px); }

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(3px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.drawer-overlay.visible { opacity: 1; visibility: visible; }

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.drawer-header h3 { font-family: var(--font-serif); font-size: 1.4rem; }
.close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.8rem;
    line-height: 1;
    transition: color 0.2s;
}
.close-btn:hover { color: var(--text-primary); }

.new-project-btn-compact {
    width: 100%;
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 20px;
    transition: var(--transition);
}
.new-project-btn-compact:hover { background: #c8281a; }

/* Sidebar Screen Navigation */
.sidebar-nav {
    display: none; /* hidden on mobile — bottom nav handles it */
    flex-direction: column;
    gap: 2px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px 12px;
    border-radius: 8px;
    text-align: left;
    transition: var(--transition);
    letter-spacing: 0.2px;
}
.sidebar-nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-secondary); }
.sidebar-nav-item.active { color: var(--accent-red); background: rgba(234,51,35,0.08); }

.project-list-container { flex: 1; overflow-y: auto; }

.project-item {
    padding: 14px;
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}
.project-item:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.06); }
.project-item.active { background: rgba(234,51,35,0.1); border-color: rgba(234,51,35,0.35); }
.project-item h4 { font-size: 0.9rem; margin-bottom: 3px; }
.project-item span { font-size: 0.72rem; color: var(--text-tertiary); }

/* ============================================
   MARKER EDITOR POPOVER
   ============================================ */
.marker-editor-popover {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}
.marker-editor-popover.hidden { display: none; }
.popover-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 16px;
    width: min(90vw, 340px);
}
.popover-content h4 { margin-bottom: 18px; font-family: var(--font-serif); }
.category-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.category-options .opt {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    transition: var(--transition);
}
.category-options .opt:hover { border-color: rgba(255,255,255,0.2); background: var(--surface-hover); }
.close-popover {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 10px;
    letter-spacing: 1px;
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden { display: none !important; }
.loading-text { color: var(--text-tertiary); font-size: 0.85rem; padding: 12px 0; }

@keyframes slideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@keyframes fadeIn {
    from { opacity: 0; } to { opacity: 1; }
}

/* ============================================
   TABLET BREAKPOINT  ≥ 640px
   ============================================ */
@media (min-width: 640px) {
    :root {
        --header-height: 68px;
        --nav-height: 72px;
    }

    .top-nav { padding: 0 32px; }
    .logo { font-size: 1.55rem; }
    .active-project-label { max-width: 200px; }

    .screen { padding: 36px 32px 48px; }

    /* Wider headline */
    .headline { font-size: clamp(2.4rem, 6vw, 3.6rem); }
    .subheadline { font-size: 1rem; }

    /* 2-column action layout on tablet */
    .action-panel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        align-items: start;
    }
    .action-panel .divider {
        grid-column: 1 / -1;
        display: none; /* no OR divider in 2-col layout */
    }
    .action-panel .upload-container { height: 100%; }

    /* Marker grid — more columns on tablet */
    .marker-grid { grid-template-columns: repeat(4, 1fr); }
    .marker-grid.mini { gap: 8px; }

    /* Design screen: side by side on tablet */
    .agent-split-view { flex-direction: row; }
    .agent-chat-panel { flex: 1.2; }
    .script-builder-panel { flex: 0.8; }

    /* Wider drawer */
    .project-drawer { width: 320px; left: -320px; }
    .project-drawer.open { transform: translateX(320px); }

    /* Transcript font slightly larger */
    .transcript-flow { font-size: 1.1rem; }
}

/* ============================================
   DESKTOP BREAKPOINT  ≥ 1080px
   Persistent sidebar replaces drawer + bottom nav
   ============================================ */
@media (min-width: 1080px) {
    :root {
        --nav-height: 0px; /* Bottom nav hidden on desktop */
    }

    body { overflow: hidden; }

    /* Full-height app */
    .app-container {
        flex-direction: row;
        height: 100vh;
        overflow: hidden;
    }

    /* Persistent sidebar */
    .project-drawer {
        position: relative;
        left: 0;
        width: var(--sidebar-width);
        height: 100vh;
        border-right: 1px solid var(--border-color);
        transform: none !important;
        z-index: 10;
        flex-shrink: 0;
        padding-top: 0;
        display: flex;
        flex-direction: column;
    }
    .project-drawer::before {
        content: 'Projects';
        display: block;
        font-family: var(--font-serif);
        font-size: 1.1rem;
        font-style: italic;
        color: var(--text-secondary);
        padding: 20px 20px 16px;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 16px;
    }
    .drawer-header { display: none; } /* Hide the header with close btn */
    .drawer-overlay { display: none !important; } /* No overlay on desktop */

    /* Main content area */
    .app-content-area {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
        min-width: 0;
    }

    /* Hide bottom nav on desktop */
    .bottom-nav { display: none; }

    /* Top nav spans full width */
    .top-nav {
        width: 100%;
        padding: 0 28px;
    }

    /* Screen wrapper fills remaining space */
    .screen-wrapper {
        height: calc(100vh - var(--header-height));
        flex: 1;
    }

    .screen { padding: 40px 48px 60px; }

    /* Wider content max */
    .hero-section { max-width: var(--content-max); }
    .action-panel { max-width: var(--content-max); }
    .headline { font-size: clamp(2.8rem, 4vw, 4rem); }

    /* Desktop: action panel single column centered */
    .action-panel {
        grid-template-columns: 1fr;
        max-width: 560px;
    }
    .action-panel .divider { display: flex; }
    
    /* Desktop Design screen: equal columns */
    .agent-split-view { flex-direction: row; }
    .agent-chat-panel { flex: 1; }
    .script-builder-panel { flex: 1; }

    /* Transcript wider */
    .transcript-flow { font-size: 1.15rem; max-width: 800px; }

    /* Nav items replace with top-level tab nav */
    /* (sidebar handles navigation — menu btn hidden on large screens) */
    .menu-btn { display: none; }

    /* Show sidebar screen navigation */
    .sidebar-nav { display: flex; }

    /* Remove top padding on drawer (header takes that space) */
    .project-drawer { padding-top: 20px; }
}

/* ============================================
   LARGE DESKTOP  ≥ 1400px
   ============================================ */
@media (min-width: 1400px) {
    :root { --sidebar-width: 300px; }

    .screen { padding: 48px 64px 80px; }

    .action-panel {
        grid-template-columns: 1fr 1fr;
        max-width: 900px;
        gap: 24px;
    }
    .action-panel .divider { display: none; }
}

/* ============================================
   SAFE AREA (notch phones, iOS)
   ============================================ */
@supports (padding: max(0px)) {
    .top-nav   { padding-top: max(0px, env(safe-area-inset-top)); }
    .bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    }
}

/* ============================================
   MARKER EDITOR POPOVER
   ============================================ */
.marker-editor-popover {
    position: absolute;
    z-index: 500;
    min-width: 200px;
    pointer-events: auto;
}
.marker-editor-popover.hidden { display: none; }

.popover-content {
    background: #1c1c1c;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--border-radius-md);
    padding: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4);
    backdrop-filter: blur(12px);
}

.popover-content h4 {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.marker-name-input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-family: var(--font-sans);
    outline: none;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}
.marker-name-input:focus { border-color: rgba(255,255,255,0.25); }

.category-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 10px;
}

.opt {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: var(--text-secondary);
    padding: 6px 4px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.opt::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--c, transparent);
    border-radius: 6px 0 0 6px;
}
.opt:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.2);
}
.opt.active {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.25);
    color: var(--text-primary);
}

.popover-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.delete-marker-btn {
    flex: 1;
    background: rgba(234,51,35,0.12);
    border: 1px solid rgba(234,51,35,0.3);
    color: var(--accent-red);
    border-radius: 6px;
    padding: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    transition: var(--transition);
}
.delete-marker-btn:hover {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
}

.close-popover {
    flex: 1;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-tertiary);
    border-radius: 6px;
    padding: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    transition: var(--transition);
}
.close-popover:hover {
    border-color: rgba(255,255,255,0.2);
    color: var(--text-secondary);
}

