/*
 * MelodicLabs | Main Stylesheet
 * Design System: Netscape Simplicity
 */

/* ==========================================================================
   1. Core Colors & Variables
   ========================================================================== */

:root {
    /* Base Colors */
    --primary-bg: #1a1a1a;
    --secondary-bg: #2d2d2d;
    --accent-primary: #228B22;      /* Green - primary actions */
    --text-primary: #ccc;
    --text-secondary: #cccccc;
    --border-base: #404040;
    
    /* State Colors */
    --success: #32CD32;             /* Bright green - success states */
    --warning: #FFA500;             /* Orange - warnings */
    --error: #f44336;               /* Red - errors */
    --real-data: #00ff00;           /* Bright green - live data indicator */
    
    /* Reference Underline System (from alpha prototype) */
    --ref-green: #228B22;           /* Primary references */
    --ref-orange: #FF8C00;          /* Navigation/active states */
    --ref-blue: #6495ED;            /* Information/links */
    --ref-purple: #DD88FF;          /* Special/AI states */
}

/* ==========================================================================
   2. Global Styles & Typography
   ========================================================================== */

/* General Reset & Body */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100vh; /* Fallback for browsers that don't support dvh */
    height: 100dvh; /* Dynamic Viewport Height - fixes "cut off" on mobile/laptops */
    width: 100vw;  /* Force viewport width */
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent body scroll, handle inside containers */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--primary-bg, #1a1a1a);
    color: var(--text-primary, #ccc);
    line-height: 1.6;
}

/* Headings with Reference Underlines */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary, #ccc);
    margin-bottom: 0.75rem;
    line-height: 1.3;
    padding-bottom: 0.25rem;
}
h1 { font-size: 2rem; border-bottom: 2px solid var(--ref-orange); }
h2 { font-size: 1.75rem; border-bottom: 2px solid var(--ref-blue); }
h3 { font-size: 1.5rem; border-bottom: 2px solid var(--ref-green); }

/* Paragraphs & Links */
p {
    margin-bottom: 1rem;
}

a {
    color: var(--ref-blue);
    text-decoration: none;
    border-bottom: 1px dotted var(--ref-blue);
}

a:hover {
    color: white;
    border-bottom-color: white;
}

/* Lists */
ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Blockquotes (for AI/Liner Notes) */
blockquote {
    margin: 1rem 0;
    padding: 1rem;
    border-left: 4px solid var(--ref-purple);
    font-style: italic;
}

/* Styled Scrollbars */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: var(--primary-bg, #1a1a1a);
}
::-webkit-scrollbar-thumb {
    background: var(--border-base, #404040);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--ref-green, #228B22);
}

/* ==========================================================================
   3. Layout Architecture
   ========================================================================== */

/* Header */
.header {
    grid-area: header;
    padding: 2vh 2vw;
    border-bottom: 2px solid var(--ref-orange);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Base mobile layout (320px+) */
/* Base Desktop Layout (Default) */
.app-container {
    display: grid;
    grid-template-areas: 
        "header header"
        "discovery conversation";
    grid-template-columns: 30vw 66vw; /* Adjusted for better balance */
    grid-template-rows: auto 1fr;
    width: 100vw;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Dynamic Viewport Height */
    gap: 2vh 2vw;
    padding: 2vh 2vw;
    overflow: hidden;
}

/* Ensure discovery panel is visible by default in desktop */
.discovery-panel {
    grid-area: discovery;
    display: flex !important; /* Force display in grid layout */
    flex-direction: column;
    border: 1px solid var(--border-base);
    background: var(--secondary-bg);
    overflow: hidden;
    min-height: 0; /* Crucial for nested scrolling */
}

/* Mobile layout (max-width: 768px) */
@media (max-width: 768px) {
    .app-container {
        grid-template-areas: 
            "header"
            "discovery"
            "conversation"
            "curation";
        grid-template-rows: auto 1fr auto auto;
        grid-template-columns: 1fr;
        gap: 1vh;
        padding: 1vh 2vw;
    }
}

/* ==========================================================================
   4. Component Specifications
   ========================================================================== */

/* 4.1. Conversational AI Interface (WebLLM) */
.conversation-panel {
    grid-area: conversation;
    border: 1px solid var(--border-base);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 80vh;
    max-height: 100%;
    overflow: hidden;
}

.conversation-header {
    padding: 2vh 2vw;
    border-bottom: 2px solid var(--ref-green);
    display: flex;
    align-items: center;
    gap: 1vw;
}

.ai-status-indicator {
    width: 12px;
    height: 12px;
    background: var(--success);
}

.conversation-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2vh 2vw;
    scroll-behavior: smooth;
    min-height: 0;
    max-height: 40vh;
    max-width: 100%;
}

/* Scrollbar styling for conversation messages */
.conversation-messages::-webkit-scrollbar {
    width: 10px;
}

.conversation-messages::-webkit-scrollbar-track {
    background: var(--primary-bg, #1a1a1a);
}

.conversation-messages::-webkit-scrollbar-thumb {
    background: var(--border-base, #404040);
    border-radius: 5px;
}

.conversation-messages::-webkit-scrollbar-thumb:hover {
    background: var(--ref-green, #228B22);
}

.message {
    margin-bottom: 2vh;
    padding: 1.5vh 1.5vw;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
}

.message p {
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.message.user {
    border-left: 3px solid var(--ref-blue);
    margin-left: 4vw;
}

.message.ai {
    border-left: 3px solid var(--ref-green);
    margin-right: 4vw;
}

.conversation-input {
    border-top: 1px solid var(--border-base);
    padding: 2vh 2vw;
    flex-shrink: 0;
}

.conversation-input textarea {
    width: 100%;
    min-height: 10vh;
    background: var(--primary-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-base);
    border-bottom: 2px solid var(--ref-green);
    padding: 1.5vh 1.5vw;
    resize: vertical;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
}

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

/* 4.2. Discovery Panel */
.discovery-panel {
    grid-area: discovery;
    border: 1px solid var(--border-base);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 80vh;
    max-height: 100%;
    overflow: hidden;
}

.discovery-header {
    padding: 2vh 2vw;
    border-bottom: 2px solid var(--ref-blue);
    display: flex;
    justify-content: center;
    align-items: center;
}

.discovery-progress {
    display: flex;
    align-items: center;
    gap: 1vw;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-stage {
    padding: 0.5vh 1vw;
    font-weight: 600;
    font-size: 0.8rem;
}

.progress-stage.active {
    background: var(--accent-primary);
    color: white;
}

.progress-stage.completed {
    background: var(--success);
    color: white;
}

.progress-stage.pending {
    background: var(--border-base);
    color: var(--text-secondary);
}

.track-list {
    flex: 1;
    overflow-y: auto;
    padding: 2vh 2vw;
    min-height: 0; /* Allow flex shrinking */
}

/* ==========================================================================
   Track Discovery & Management (Netscape Simplicity)
   ========================================================================== */

/* Discovery Tracks Container */
.discovery-tracks {
    padding: 1rem;
    border: 1px solid var(--border-base);
    max-height: 400px;
    overflow-y: auto;
}

/* Individual Track Items */
.track-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 1px; /* Minimal separation */
    background: var(--primary-bg);
    border-left: 3px solid transparent;
}

.track-item:hover {
    border-left-color: var(--border-base);
}

/* Track States (using only border-left colors) */
.track-item.liked {
    border-left-color: var(--ref-green);
}

.track-item.seed {
    border-left-color: var(--ref-blue);
}

.track-item.protected {
    border-left-color: var(--ref-orange);
}

/* Track Info */
.track-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.track-title {
    font-weight: 600;
    color: var(--text-primary);
}

.track-artist {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.track-genre {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Track Actions (text links only) */
.track-actions {
    display: flex;
    gap: 0.5rem;
}

.track-actions .ref-link {
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid transparent;
}

.track-actions .ref-link:hover {
    border-color: currentColor;
}

/* 4.3. Auto-Complete Math Visualization */
.autocomplete-panel {
    background: rgba(34, 139, 34, 0.1);
    border: 1px solid var(--ref-green);
    padding: 1rem;
    margin: 1rem 0;
}

.autocomplete-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--ref-green);
    font-weight: 600;
}

.math-formula {
    font-family: 'Monaco', 'Consolas', monospace;
    background: var(--primary-bg);
    padding: 0.5rem;
    margin: 0.5rem 0;
    border-left: 3px solid var(--ref-green);
}

.playlist-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.playlist-card {
    background: var(--primary-bg);
    padding: 0.75rem;
    border-top: 2px solid var(--ref-purple);
    font-size: 0.85rem;
}

/* 4.4. OAuth Session States */
.oauth-panel {
    border: 1px solid var(--border-base);
    padding: 1.5rem;
    text-align: center;
}

.oauth-panel.import-phase {
    border-color: var(--ref-blue);
}

.oauth-panel.offline-phase {
    border-color: var(--ref-green);
}

.oauth-panel.export-phase {
    border-color: var(--ref-orange);
}

.session-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.session-indicator.import {
    background: rgba(100, 149, 237, 0.2);
    color: var(--ref-blue);
    border: 1px solid var(--ref-blue);
}

.session-indicator.offline {
    background: rgba(34, 139, 34, 0.2);
    color: var(--ref-green);
    border: 1px solid var(--ref-green);
}

.session-indicator.export {
    background: rgba(255, 140, 0, 0.2);
    color: var(--ref-orange);
    border: 1px solid var(--ref-orange);
}

.auto-logout-timer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Playlist Import Section */
.playlist-import-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(34, 139, 34, 0.1);
    border: 1px solid var(--ref-green);
    border-radius: 8px;
}

.playlist-import-section h3 {
    color: var(--ref-green);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.playlist-url-input {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    align-items: center;
}

.playlist-url-input input {
    flex: 1;
    padding: 0.75rem;
    background: var(--secondary-bg);
    border: 1px solid var(--border-base);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.playlist-url-input input:focus {
    outline: none;
    border-color: var(--ref-green);
    box-shadow: 0 0 0 2px rgba(34, 139, 34, 0.2);
}

.playlist-url-input input::placeholder {
    color: var(--text-secondary);
}

.supported-services {
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.playlist-import-status {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(100, 149, 237, 0.1);
    border: 1px solid var(--ref-blue);
    border-radius: 4px;
}

.import-options {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-base);
}

/* 4.5. Reference Underline System (for Interactive Links) */
.ref-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    padding-bottom: 1px;
}

.ref-link.primary {
    border-bottom-color: var(--ref-green);
}

.ref-link.navigation {
    border-bottom-color: var(--ref-orange);
}

.ref-link.info {
    border-bottom-color: var(--ref-blue);
}

.ref-link.ai {
    border-bottom-color: var(--ref-purple);
}

.ref-link:hover {
    color: white;
    border-bottom-width: 3px;
}

/* 4.6. Rendered Liner Notes (Markdown View) */
.liner-notes-container {
    grid-area: curation;
    border: 1px solid var(--border-base);
    padding: 1.5rem 2rem;
    color: var(--text-primary);
    height: 100%;
    overflow-y: auto;
}

.liner-notes-container h1 {
    border-bottom-color: var(--ref-orange);
}

.liner-notes-container h2 {
    border-bottom-color: var(--ref-blue);
}

.liner-notes-container h3 {
    border-bottom-color: var(--ref-green);
}

.liner-notes-container .discovery-story blockquote {
    border-left-color: var(--ref-purple);
    font-style: italic;
    color: var(--text-secondary);
}

.liner-notes-container .key-discoveries ul {
    list-style-type: none;
    padding-left: 0;
}

.liner-notes-container .key-discoveries li {
    padding: 0.5rem;
    border-left: 3px solid var(--ref-green);
    background: var(--primary-bg);
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   5. Mobile & Accessibility
   ========================================================================== */

/* 5.1. Typography Scale */
.text-xl { font-size: 1.25rem; }
.text-lg { font-size: 1.125rem; }
.text-base { font-size: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

@media (min-width: 768px) {
    .text-xl { font-size: 1.5rem; }
    .text-lg { font-size: 1.25rem; }
}

@media (min-width: 1024px) {
    .text-xl { font-size: 1.75rem; }
    .text-lg { font-size: 1.375rem; }
}

/* 5.2. Touch-Friendly Sizing */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 767px) {
    .track-item {
        padding: 1rem 0.75rem;
    }
    
    .conversation-input textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* 5.3. Accessibility */
.focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (prefers-contrast: high) {
    :root {
        --border-base: #666;
        --text-primary: #fff;
        --text-secondary: #eee;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   6. Phase Management System
   ========================================================================== */

/* Phase indicator in header */
.phase-indicator {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.phase-stage {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-base);
    color: var(--text-secondary);
}

.phase-stage.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Phase-based layout */
.app-container[data-phase="import"] {
    grid-template-areas: 
        "header"
        "oauth";
    grid-template-rows: auto 1fr;
}

.app-container[data-phase="offline"] {
    grid-template-areas: 
        "header"
        "conversation"
        "discovery";
    grid-template-rows: auto 1fr 1fr;
}

@media (min-width: 768px) {
    .app-container[data-phase="offline"] {
        grid-template-areas: 
            "header header"
            "discovery conversation";
        grid-template-columns: 1fr 1fr;
    }
}

.app-container[data-phase="export"] {
    grid-template-areas: 
        "header"
        "export"
        "liner-notes";
    grid-template-rows: auto auto 1fr;
}

/* ==========================================================================
   7. Seeds System
   ========================================================================== */

.seeds-section {
    border-bottom: 1px solid var(--border-base);
    padding: 1rem;
}

.seeds-section h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.seeds-section.hidden {
    display: none;
}

.seed-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.seed-item {
    background: var(--primary-bg);
    border: 1px solid var(--ref-blue);
    padding: 0.5rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.seed-item .remove-seed {
    color: var(--ref-orange);
    cursor: pointer;
    font-weight: bold;
}

.seed-item .remove-seed:hover {
    color: white;
}

/* ==========================================================================
   8. Interaction Counter & Controls
   ========================================================================== */

.interaction-counter {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pool-controls {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
}

/* ==========================================================================
   9. Import/Export Phases
   ========================================================================== */

.oauth-panel {
    grid-area: oauth;
}

.import-status {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--ref-blue);
}

.import-progress {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.export-panel {
    grid-area: export;
    border: 1px solid var(--border-base);
    padding: 1.5rem;
}

.final-results {
    text-align: center;
}

/* ==========================================================================
   10. AI Suggested Seeds (Clickable in Chat)
   ========================================================================== */

.suggested-seed {
    color: var(--ref-blue);
    border-bottom: 1px dotted var(--ref-blue);
    cursor: pointer;
    padding: 0.125rem 0.25rem;
    margin: 0 0.125rem;
}

.suggested-seed:hover {
    color: white;
    border-bottom-color: white;
    background: rgba(100, 149, 237, 0.1);
}

.suggested-seed.added {
    color: var(--ref-green);
    border-bottom-color: var(--ref-green);
    background: rgba(34, 139, 34, 0.1);
}

.current-seeds {
    color: var(--ref-blue);
    font-weight: 600;
}

/* Curation preference indicators */
.suggested-seed[data-curation] {
    color: var(--ref-purple);
    border-bottom-color: var(--ref-purple);
    font-weight: 500;
}

.suggested-seed[data-curation]:hover {
    color: white;
    border-bottom-color: white;
    background: rgba(221, 136, 255, 0.1);
}

.suggested-seed[data-curation].added {
    color: var(--ref-purple);
    border-bottom-color: var(--ref-purple);
    background: rgba(221, 136, 255, 0.2);
}

/* No content states (text-only) */
.no-seeds {
    color: var(--text-secondary);
    font-style: italic;
    padding: 1rem;
    text-align: center;
    border-left: 3px solid var(--border-base);
}

.loading-message {
    color: var(--text-secondary);
    padding: 1rem;
    text-align: center;
    font-style: italic;
}

/* Pool info display */
.pool-info {
    padding: 0.75rem;
    border-top: 1px solid var(--border-base);
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ==========================================================================
   Mobile Track Interactions
   ========================================================================== */

@media (max-width: 767px) {
    .track-item {
        grid-template-columns: 1fr;
        grid-gap: 0.5rem;
        padding: 1rem 0.75rem;
    }
    
    .track-actions {
        justify-self: start;
        margin-top: 0.5rem;
    }
    
    .seeds-container {
        max-height: 150px;
    }
}

/* ==========================================================================
   Curation Strategy Display (Text-only)
   ========================================================================== */

.curation-preferences {
    border: 1px solid var(--border-base);
    padding: 1rem;
    margin: 1rem 0;
}

.curation-preferences h3 {
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--ref-purple);
}

.suggested-seed {
    border-bottom: 2px solid transparent;
    cursor: pointer;
    padding: 0.25rem 0;
}

.suggested-seed[data-curation="artist-focused"] {
    border-bottom-color: var(--ref-green);
}

.suggested-seed[data-curation="genre-balanced"] {
    border-bottom-color: var(--ref-blue);
}

.suggested-seed[data-curation="diversity-wide"] {
    border-bottom-color: var(--ref-purple);
}

.suggested-seed:hover {
    color: white;
    border-bottom-width: 3px;
}

/* ==========================================================================
   AI Provider Selector
   ========================================================================== */

.ai-provider-select {
    background: var(--secondary-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-base);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    margin-right: 0.5rem;
    cursor: pointer;
}

.ai-provider-select:focus {
    outline: none;
    border-color: var(--ref-blue);
}

.ai-provider-select option {
    background: var(--primary-bg);
    color: var(--text-primary);
}

/* ==========================================================================
   Phase Files Panel
   ========================================================================== */

.phase-files-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: var(--primary-bg);
    border-left: 1px solid var(--border-base);
    z-index: 1000;
    overflow-y: auto;
    padding: 1rem;
}

.phase-files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-base);
}

.phase-files-header h2 {
    color: var(--text-primary);
    font-size: 1.2rem;
}

.phase-files-list {
    margin-bottom: 2rem;
}

.phase-file-item {
    background: var(--secondary-bg);
    border: 1px solid var(--border-base);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.phase-file-item h3 {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.phase-file-item p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.phase-file-actions {
    display: flex;
    gap: 0.5rem;
}

.phase-file-editor {
    background: var(--secondary-bg);
    border: 1px solid var(--border-base);
    border-radius: 8px;
    padding: 1rem;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-base);
}

.editor-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

#phase-file-content {
    width: 100%;
    height: 400px;
    background: var(--primary-bg);
    border: 1px solid var(--border-base);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 0.5rem;
    resize: vertical;
}

#phase-file-content:focus {
    outline: none;
    border-color: var(--ref-blue);
}

/* ==========================================================================
   New Navigation & Modal Styles
   ========================================================================== */

.nav-links-box {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    padding-bottom: 0.25rem;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: white;
    border-bottom-color: var(--accent-primary);
}

.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--secondary-bg);
    min-width: 160px;
    box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
    z-index: 1000;
    border: 1px solid var(--border-base);
    border-radius: 4px;
}

.nav-dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: var(--text-primary);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: var(--border-base);
    color: white;
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.8); 
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--secondary-bg);
    margin: 5% auto; 
    padding: 2rem;
    border: 1px solid var(--border-base);
    width: 90%; 
    max-width: 1200px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    position: relative;
}

.close-modal {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

/* Publisher Styles */
.publish-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.publish-controls {
    background: var(--secondary-bg);
    padding: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-base);
}

.publish-controls h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    background: #111;
    border: 1px solid var(--border-base);
    color: #fff;
    border-radius: 4px;
}

.publish-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 8px;
    padding: 20px;
}

.preview-card {
    text-align: center;
}

.preview-card img {
    max-width: 100%;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    margin-bottom: 20px;
}
