/* Import Design System */
@import url('./design-system.css');

/* Import Functional Components */
@import url('./components.css');


/* CSS Variables for consistent styling (from v0.4) */
:root {
    --sage-border: 1px solid #e0e0e0;
    --sage-border-light: 1px solid #f0f0f0;
    --sage-border-input: 1px solid #ced4da;
    --sage-border-thick: 2px solid #e0e0e0;

    --text-body: 1rem;
    --text-large: 1.25rem;
    --text-medium: 1.125rem;
    --text-small: 0.875rem;
    --text-xsmall: 0.75rem;
    --text-xxsmall: 0.625rem;

    --mono-text: #333;
    --mono-text-secondary: #777;
    --mono-text-light: #999;

    --blue-border: #007bff;
    --blue-subtle: #e3f2fd;
    --blue-strong: #1976d2;

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

body {
    background-color: var(--bg-base, #f8f9fa);
    color: var(--text-muted, #999);
    overflow: hidden; /* Prevent page scrolling */
}
body, .text-body{
    font-family: var(--font-family-base);
    font-size: var(--text-body);
    line-height: 1.6;
    color: var(--text-muted, #999);
    font-weight: var(--font-weight-regular);
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.txt-secondary {
    font-size: var(--text-xsmall);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
}
.txt-tertiary {
    font-size: var(--text-xxsmall);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
}

/* ── App shell: two-column split (content + chat sidebar) ── */
#app-shell {
    display: flex;
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
}

#app {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header - flex item, no longer fixed */
#header-component {
    /* NAME: HeaderComponent */
    /* PURPOSE: Top header bar */
    flex-shrink: 0;
    z-index: var(--z-header, 1000);
    background: transparent;
    border-bottom: var(--border-ui);
    height: var(--header-height, 48px);
}

/* Header component styles now defined in components.css */

/* Tool button styling now uses standard .btn .btn-secondary */

/* Main content - flex: 1 fills available space */
#main-content {
    /* NAME: MainContent */
    /* PURPOSE: Main content area, fills space between header and footer */
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    width: 100%;
    overflow: hidden; /* Internal scrolling */
    min-height: 0; /* Allow shrinking in flex context */
    min-width: 0; /* Allow shrinking */
    position: relative; /* Ensure proper positioning */
}

/* Mega Menu - hidden by default, drops down from header */
.mega-menu {
    flex-shrink: 0;
    height: 0;
    overflow: hidden;
    background: var(--bg-base, #fff);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: var(--z-mega-menu, 900);
    pointer-events: none;
    transition: height 0.3s ease;
}

.mega-menu-page-header {
    position: sticky;
    top: -16px;
    display: flex;
    align-items: center;
    height: 48px;
    margin: -32px -46px 0;
    padding: 0 46px;
    background: var(--bg-raised);
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
    z-index: 1;
}

.mega-menu-tab-bar {
    flex: 1;
    height: 100%;
    border-bottom: var(--border-content-default);
}

.mega-menu-page-content {
    padding-top: 24px;
}

/* Wave 0 — Ingestion readout on the Overview tab (design-system tokens only) */
.ingestion-readout {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: var(--border-content-default);
}

.ingestion-readout-header {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #999);
    margin-bottom: 12px;
}

.ingestion-readout-empty {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted, #999);
}

.ingestion-readout-item {
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--bg-raised);
    border: var(--border-content-default);
    border-radius: var(--border-radius, 8px);
}

.ingestion-readout-item:last-child {
    margin-bottom: 0;
}

.ingestion-readout-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #111);
    margin-bottom: 6px;
}

.ingestion-readout-line {
    font-size: 13px;
    color: var(--text-secondary, #555);
    line-height: 1.5;
}

.ingestion-readout-samples {
    margin-top: 8px;
    padding-top: 8px;
    border-top: var(--border-content-default);
}

.ingestion-readout-sample {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 12px;
    color: var(--text-muted, #999);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* In-flight modeling progress (async ingestion — polls the status endpoint) */
.ingestion-progress {
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--bg-raised);
    border: var(--border-content-default);
    border-radius: var(--border-radius, 8px);
}

.ingestion-progress-summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #111);
    margin-bottom: 8px;
}

.ingestion-progress-error {
    font-size: 12px;
    color: var(--color-error, #b3261e);
    margin-bottom: 8px;
}

.ingestion-progress-packets {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ingestion-progress-packet {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 3px 0;
    font-size: 12px;
    color: var(--text-secondary, #555);
    flex-wrap: wrap;
}

.ingestion-progress-packet-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ingestion-progress-packet-status {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 11px;
}

.ingestion-progress-packet--done .ingestion-progress-packet-status {
    color: var(--color-success, #1a7f37);
}

.ingestion-progress-packet--in_progress .ingestion-progress-packet-status {
    color: var(--color-blue-400, #0969da);
}

.ingestion-progress-packet--pending .ingestion-progress-packet-status {
    color: var(--text-muted, #999);
}

.ingestion-progress-packet--failed .ingestion-progress-packet-status {
    color: var(--color-error, #b3261e);
}

.ingestion-progress-packet-cost {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 11px;
    color: var(--text-muted, #999);
}

.ingestion-progress-packet-error {
    flex-basis: 100%;
    font-size: 11px;
    color: var(--color-error, #b3261e);
}

/* Wave 1a — full ingestion detail (collapsible atom groups + gaps) */
.ingestion-detail {
    margin-top: 10px;
    padding-top: 8px;
    border-top: var(--border-content-default);
}

.ingestion-detail-toggle {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #111);
    cursor: pointer;
    list-style: revert;
    user-select: none;
}

.ingestion-detail-toggle:hover {
    color: var(--text-secondary, #555);
}

.ingestion-detail-body {
    margin-top: 10px;
}

.ingestion-gap-block {
    margin-bottom: 12px;
    padding: 8px 10px;
    background: var(--bg-raised);
    border: var(--border-content-default);
    border-radius: 6px;
}

.ingestion-gap-summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #555);
}

.ingestion-gap-record {
    margin-top: 6px;
    padding-top: 6px;
    border-top: var(--border-content-default);
}

.ingestion-gap-reason {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #111);
}

.ingestion-atom-group {
    margin-bottom: 12px;
}

.ingestion-atom-group-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #999);
    margin-bottom: 6px;
}

.ingestion-atom {
    padding: 6px 0;
    border-top: var(--border-content-default);
}

.ingestion-atom:first-of-type {
    border-top: none;
}

.ingestion-atom-content {
    font-size: 13px;
    color: var(--text-primary, #111);
    line-height: 1.5;
}

.ingestion-atom-quote {
    font-size: 12px;
    font-style: italic;
    color: var(--text-secondary, #555);
    line-height: 1.5;
    margin-top: 2px;
}

.ingestion-atom-meta {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 11px;
    color: var(--text-muted, #999);
    line-height: 1.5;
    margin-top: 2px;
    word-break: break-word;
}

/* Distillation Pass 1 topic map readout (Overview sibling section) */
.distilled-topics-readout {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: var(--border-content-default);
}

.distilled-topics-summary {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: var(--text-secondary, #555);
}

.distilled-topics-document {
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--bg-raised);
    border: var(--border-content-default);
    border-radius: var(--border-radius, 8px);
}

.distilled-topics-document:last-child {
    margin-bottom: 0;
}

.distilled-topics-document-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #111);
}

.distilled-topics-document-meta {
    margin-top: 2px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-muted, #999);
}

.distilled-topics-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.distilled-topic-item {
    border-top: var(--border-content-default);
}

.distilled-topic-item:first-child {
    border-top: none;
}

.distilled-topic-item--excluded .distilled-topic-name,
.distilled-topic-item--excluded .distilled-topic-metrics,
.distilled-topic-item--excluded .distilled-topic-summary,
.distilled-topic-item--excluded .distilled-topic-anchor-quote {
    color: var(--text-muted, #999);
}

.distilled-topic-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.distilled-topic-expand-btn {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 0;
    cursor: pointer;
}

.distilled-topic-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #111);
    line-height: 1.4;
}

.distilled-topic-metrics {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-secondary, #555);
}

.distilled-topic-scope {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary, #555);
    white-space: nowrap;
}

.distilled-topic-body {
    margin: 0 0 10px 0;
}

.distilled-topic-summary {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: var(--text-secondary, #555);
    line-height: 1.5;
}

.distilled-topic-anchors {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.distilled-topic-anchor-quote {
    margin: 0;
    padding: 0 0 0 10px;
    border-left: 2px solid var(--border-default, #ddd);
    font-size: 12px;
    font-style: italic;
    color: var(--text-secondary, #555);
    line-height: 1.5;
}

.distilled-topic-anchor-source,
.distilled-topic-anchor-empty {
    font-size: 11px;
    color: var(--text-muted, #999);
}

/* Category tier drill-down (primary placement + sparse cross-references) */
.distilled-category-item {
    border-top: var(--border-content-default);
}

.distilled-category-item:first-child {
    border-top: none;
}

.distilled-category-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.distilled-category-expand-btn {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 0;
    cursor: pointer;
}

.distilled-category-name {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary, #111);
    line-height: 1.4;
}

.distilled-category-metrics {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-secondary, #555);
}

.distilled-category-body {
    margin: 0 0 10px 0;
    padding-left: 14px;
    border-left: 2px solid var(--border-default, #ddd);
}

.distilled-category-summary {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: var(--text-secondary, #555);
    line-height: 1.5;
}

.distilled-category-members {
    margin: 0;
    padding: 0;
    list-style: none;
}

.distilled-category-crossrefs {
    margin-top: 8px;
    padding-top: 6px;
    border-top: var(--border-content-default);
}

.distilled-category-crossrefs-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #999);
    margin-bottom: 4px;
}

.distilled-category-crossref-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.distilled-category-crossref {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 2px 0;
    font-size: 12px;
    color: var(--text-muted, #999);
}

.distilled-category-crossref-name {
    color: var(--text-secondary, #555);
}

.distilled-category-crossref-note {
    font-size: 11px;
    font-style: italic;
    color: var(--text-muted, #999);
}

.mega-menu-close,
.mega-menu-expand {
    position: absolute;
    right: var(--layout-padding, 16px);
    z-index: 1;
}

.mega-menu-close {
    top: var(--layout-padding, 16px);
}

.mega-menu-expand {
    bottom: 16px;
}

.mega-menu-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: var(--layout-padding, 16px);
}

body.menu-expanded .mega-menu,
body.menu-full .mega-menu {
    border-bottom: var(--border-ui);
    pointer-events: all;
}

body.menu-expanded .mega-menu {
    height: var(--mega-menu-height, 40vh);
}

body.menu-full .mega-menu {
    height: calc(100vh - var(--header-height, 48px));
}

/* Hide main content when mega menu is full screen */
body.menu-full #main-content {
    display: none;
}

/* Footer Bar */
.footer-bar {
    flex-shrink: 0;
    height: var(--footer-height, 54px);
    background: transparent;
    border-top: none;
    z-index: var(--z-footer, 900);
    display: flex;
    align-items: center;
    padding: 0 var(--layout-padding, 16px);
    gap: 1.5rem;
}

/* Hide footer bar when empty (non-story pages) */
.footer-bar:empty {
    display: none;
}

/* Error message styles */
.error-message {
    /* Global error message styling */
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 1rem;
    color: #721c24;
    text-align: center;
}

.error-message h2 {
    margin-bottom: 0.5rem;
}

/* Button styles now defined in components.css */

/* Button hover and focus styles now in components.css */

/* All button styles now defined in components.css - removing duplicates */
/* Duplicate button styles removed - all button styles now in components.css */

/* Modal styles */
#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    pointer-events: none;
}

/* Modal components now defined in components.css */

/* Platform Switcher Modal — list of platform selection buttons.
   Form input + button uses the shared .modal-form .form-group / .form-group-row
   classes from components.css, so this only needs the list spacing and the
   "create new" section divider. Active state for .btn.selection is handled
   by the design-system tokens in components.css (no hardcoded colors). */
.platforms-list {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.platform-create {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: var(--border-content-default);
}

/* Class-based show/hide for modal-overlay (alternative to inline display:flex). */
.modal-overlay.is-open {
    display: flex;
}

/* Loading and error states */
.error-state, .loading-state {
    text-align: center;
    padding: 2rem;
}

.error-state {
    color: #dc3545;
}

.loading-state {
    color: var(--text-secondary, #666);
}


/* Story Builder Styles (from v0.4) */

/* Story Builder Container (from v0.4) */
.container_story-builder {
    width: 100%;
    height: 100vh;
    overflow: auto; /* Both horizontal and vertical scrolling */
    position: relative;
    padding: 64px 32px;
    box-sizing: border-box;
}

/* Platform homepage zero state — centered card on a dot-grid canvas. */
.platform-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    padding: 2rem;
    max-width: 420px;
}

.platform-empty__icon {
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.platform-empty__title {
    margin: 0;
    color: var(--text-primary);
}

.platform-empty__message {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Story flow zero state — centered card on a dot-grid canvas.
   Self-contained (flex centering) so it doesn't depend on parent positioning. */
.story-flow-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 100%;
    padding: 2rem;
    box-sizing: border-box;
}

.story-flow-empty__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    max-width: 420px;
}

.story-flow-empty__title {
    margin: 0;
    color: var(--text-primary);
}

.story-flow-empty__message {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.story-builder-container {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.story-builder-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.story-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    border-bottom: var(--border-default, 1px solid #e0e0e0);
    background: var(--bg-raised, white);
}

.story-title h2 {
    margin: 0 0 0.5rem 0;
}

.story-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary, #666);
}

.story-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.story-content {
    flex: 1;
    overflow: auto;
}

.flow-workspace {
    min-height: 100%;
    position: relative;
}

/* Flow styles moved to FlowRendererStyles.css */

/* Story Details Panel styles moved to StoryBuilderComponentStyles.css */

/* Story Details Toggle Button - will be replaced by footer bar in Phase 4 */
.story-details-toggle {
    position: fixed;
    top: calc(var(--header-height, 48px) + 16px);
    right: 20px;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.goal-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: var(--sage-border);
}

.goal-title {
    font-size: 1rem;
    color: var(--text-primary, #333);
    margin-bottom: 0.75rem;
}

.goal-item {
    font-size: 0.875rem;
    color: var(--text-secondary, #666);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

/* Story selection modal styles removed -- replaced by canvas homepage (StoryHomepageManager) */

/* Error States */
.error-message {
    text-align: center;
    padding: 1rem;
    color: #721c24;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
}

/* Empty and Error States */
.story-builder-empty,
.story-builder-new,
.story-builder-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.empty-state-content,
.new-story-content,
.error-content {
    max-width: 400px;
    padding: 2rem;
}

.empty-state-content h2,
.new-story-content h2,
.error-content h2 {
    margin-bottom: 1rem;
}

.empty-state-content p,
.new-story-content p,
.error-content p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

/* Stories list modal styles removed -- replaced by canvas homepage */

.no-stories,
.loading-stories,
.error-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.flow-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    text-align: center;
    border: 2px dashed var(--grey-lighter);
    border-radius: 0.5rem;
    margin: 1rem;
    background: var(--bg-base);
}

/* Add First Step Button - styled like a step */
.add-first-step-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 200px;
    height: 60px;
    background: var(--step-background, #f8f9fa);
    border: 2px dashed var(--border-color, #ddd);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary, #666);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 10px 0;
}

.add-first-step-btn:hover {
    background: var(--step-hover-background, #e9ecef);
    border-color: var(--primary-color, #007bff);
    color: var(--primary-color, #007bff);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.add-first-step-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.add-first-step-btn .step-icon {
    font-size: 1.1rem;
    font-weight: var(--font-weight-bold);
}

.add-first-step-btn .step-text {
    font-size: 0.9rem;
    font-weight: var(--font-weight-semibold);
}

/* Delete Warning Modal */
.delete-warning-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.delete-warning-modal {
    background: var(--bg-raised);
    border-radius: 8px;
    box-shadow: var(--shadow-raised);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.delete-warning-modal .modal-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--grey-lightest);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.delete-warning-modal .modal-header h3 {
    margin: 0;
    color: #dc3545;
    font-size: 1.25rem;
}

.delete-warning-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-warning-modal .modal-close:hover {
    color: var(--text-primary);
}

.delete-warning-modal .modal-body {
    padding: 1.5rem;
}

.delete-warning-modal .modal-body p {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.delete-warning-modal .dependency-list {
    background: var(--bg-base);
    border-left: 3px solid #dc3545;
    padding: 1rem;
    margin: 1rem 0;
    list-style: none;
}

.delete-warning-modal .dependency-list li {
    padding: 0.25rem 0;
    color: var(--text-secondary);
}

.delete-warning-modal .modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--grey-lightest);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.delete-warning-modal .btn-danger {
    background: #dc3545;
    color: white;
    border: 1px solid #dc3545;
}

.delete-warning-modal .btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}


/* Branch Menu Styles (Step menu styles are in FlowRendererStyles.css) */
.branch-menu-container {
    position: relative;
    display: inline-block;
    z-index: 50; /* Above add-step buttons (z-index: 25) */
}

.branch-menu-trigger {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--text-secondary, #666);
    transition: all 0.2s ease;
    line-height: 1;
}

.branch-menu-trigger:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary, #000);
}

.branch-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-raised);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    box-shadow: var(--shadow-raised);
    z-index: 1000;
    min-width: 100px;
    overflow: hidden;
}

.branch-menu-dropdown .menu-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary, #000);
    transition: background-color 0.2s ease;
}

.branch-menu-dropdown .menu-option:hover {
    background: rgba(0, 0, 0, 0.05);
}

.branch-menu-dropdown .menu-option[data-role="delete-branch-trigger"] {
    color: #dc3545;
}

.branch-menu-dropdown .menu-option[data-role="delete-branch-trigger"]:hover {
    background: #dc3545;
    color: white;
}

.flow-connections {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    /* Header responsive styles now defined in components.css */
    
    #main-content {
        padding: 1rem;
        margin-top: 80px; /* Adjust for taller mobile header */
    }
}

/* ===== ADMIN PAGE STYLES ===== */
.admin-page {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.admin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color-light);
    background: var(--grey-near-white);
    padding: 0 1rem;
}

.admin-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--grey-steel);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.admin-tab:hover {
    color: var(--grey-darker);
    background: var(--grey-lightest);
}

.admin-tab.active {
    color: var(--color1-600);
    border-bottom-color: var(--color1-500);
    background: var(--bg-raised);
}

.admin-tab-content {
    flex: 1;
    position: relative;
}

.design-system-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.admin-placeholder {
    padding: 2rem;
    text-align: center;
    color: var(--grey-steel);
}

.admin-placeholder h2 {
    color: var(--grey-darker);
    margin-bottom: 0.5rem;
}

/* ===== DESIGN SYSTEM PAGE COMPONENT STYLES ===== */
.design-system-page {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-raised);
}

.ds-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border-color-light);
    z-index: 100;
    padding: 1rem 2rem;
}

.ds-header-content {
    margin-bottom: 1rem;
}

.ds-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--grey-deep);
    margin: 0;
}

.ds-subtitle {
    color: var(--grey-steel);
    margin: 0.25rem 0 0 0;
    font-size: var(--font-size-sm);
}

.ds-nav {
    display: flex;
    gap: 0;
}

.ds-nav-item {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--grey-steel);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    font-size: var(--font-size-sm);
}

.ds-nav-item:hover {
    color: var(--grey-darker);
    background: var(--grey-near-white);
}

.ds-nav-item.active {
    color: var(--color1-600);
    border-bottom-color: var(--color1-500);
    background: var(--grey-near-white);
}

.ds-main {
    flex: 1;
    margin-top: 120px; /* Account for fixed header */
    padding: 2rem;
    overflow-y: auto;
}

.ds-main-integrated {
    margin-top: 0; /* No duplicate header in integrated mode */
    padding: 1rem;
}

.ds-section {
    display: none;
}

.ds-section.active {
    display: block;
}

.ds-section-header {
    margin-bottom: 2rem;
}

.ds-section-header h2 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--grey-deep);
    margin: 0 0 0.5rem 0;
}

.ds-section-header p {
    color: var(--grey-steel);
    margin: 0;
}

.ds-color-sections,
.ds-typography-sections {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.ds-color-section,
.ds-typography-section {
    border: 1px solid var(--border-color-light);
    border-radius: 8px;
    padding: 1.5rem;
    background: var(--grey-near-white);
}

.ds-color-section h3,
.ds-typography-section h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--grey-darker);
    margin: 0 0 1rem 0;
}

.ds-color-groups {
    display: grid;
    gap: 1rem;
}

.ds-placeholder-text {
    color: var(--grey-silver);
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

.ds-text-classes-section {
    max-width: 100%;
}

.ds-section-actions {
    margin-bottom: 2rem;
}

.ds-placeholder {
    text-align: center;
    padding: 3rem;
    color: var(--grey-steel);
}

.ds-placeholder h3 {
    color: var(--grey-darker);
    margin-bottom: 0.5rem;
}

/* Design System Color Cards */
.ds-custom-color-group {
    margin-bottom: 2rem;
}

.ds-custom-color-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color-light);
}

.ds-custom-color-header h4 {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--grey-darker);
}

.editable-hex {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--grey-steel);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.editable-hex:hover {
    background-color: var(--grey-lightest);
}

.ds-color-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0;
}

.ds-color-card {
    border: 0 solid #bbbbbb33;
    border-radius: 0px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ds-color-card:hover {
    
}

.ds-color-swatch {
    height: 80px;
    width: 100%;
}

.ds-color-info {
    padding: 0.5rem 0.5rem 0 0;
}

.ds-color-name {
    font-weight: var(--font-weight-semibold);
    color: var(--grey-darker);
    margin-bottom: 0.25rem;
    font-size: var(--font-size-sm);
}

.ds-color-value {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--grey-steel);
    margin-bottom: 0.25rem;
}

.ds-color-variable {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--grey-silver);
}

/* Alpha White Demo Background */
.alpha-white-demo {
    background: var(--grey-darker);
    border-color: var(--grey-steel);
}

.alpha-white-demo .ds-custom-color-header,
.alpha-white-demo .ds-color-name,
.alpha-white-demo .ds-color-value,
.alpha-white-demo .ds-color-variable {
    color: var(--grey-lightest);
}

.alpha-grey-demo .ds-custom-color-header,
.alpha-grey-demo .ds-color-value,
.alpha-grey-demo .ds-color-variable {
    color: var(--grey-lightest);
}

.alpha-grey-demo .ds-custom-color-header h4 {
    color: var(--grey-darker);
}

.alpha-grey-demo .ds-custom-color-header .editable-hex {
    color: var(--grey-dim);
}

.alpha-grey-demo .ds-color-name {
    color: var(--grey-lightest);
}

.alpha-grey-demo .editable-hex {
    color: var(--grey-lighter);
}

.alpha-grey-demo .editable-hex:hover {
    background-color: var(--grey-dim);
}

.alpha-white-demo .ds-custom-color-header h4 {
    color: var(--grey-lightest);
}

.alpha-white-demo .editable-hex {
    color: var(--grey-lighter);
}

.alpha-white-demo .editable-hex:hover {
    background-color: var(--grey-dim);
}

/* Inline Editor Styles */
.ds-inline-editor {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem;
    background: var(--grey-near-white);
    border-radius: 4px;
}

.ds-editor-content {
    flex: 1;
}

.ds-editor-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.ds-hex-input,
.ds-typography-input,
.ds-text-input {
    border: 1px solid var(--grey-lighter);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: var(--font-size-sm);
    font-family: var(--font-family-mono);
}

.ds-text-class-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 300px;
}

.ds-editor-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ds-editor-row label {
    min-width: 80px;
    font-size: var(--font-size-sm);
    color: var(--grey-steel);
}

.ds-close-btn,
.ds-reset-btn,
.ds-preview-btn,
.ds-save-btn {
    padding: 0.25rem 0.5rem;
    font-size: var(--font-size-sm);
    border-radius: 3px;
}

.ds-close-btn {
    padding: 0.25rem 0.4rem;
    font-weight: var(--font-weight-bold);
}

/* Notification Styles */
.ds-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    color: white;
    font-size: var(--font-size-sm);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.ds-notification-success {
    background-color: var(--color1-500);
}

.ds-notification-error {
    background-color: #dc3545;
}

.ds-notification-info {
    background-color: var(--grey-steel);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Editable Element States */
.editable-hex.editing,
.editable-typography-value.editing,
.editable-text-class.editing {
    background-color: var(--color1-100);
    border: 1px solid var(--color1-300);
}

/* Color Overview Styles */
.ds-color-overview {
    margin-bottom: 2rem;
}

.ds-overview-colors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.ds-overview-color-card {
    background: var(--bg-raised);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--shadow-raised);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ds-overview-swatch {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 1px solid var(--border-color-light);
    flex-shrink: 0;
}

.ds-overview-info {
    flex: 1;
}

.ds-overview-name {
    font-weight: var(--font-weight-semibold);
    color: var(--grey-deep);
    margin-bottom: 0.25rem;
    text-transform: capitalize;
}

.ds-overview-variable {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--grey-steel);
    margin-bottom: 0.25rem;
}

.ds-overview-value {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--grey-silver);
}

/* Typography Styles */
.ds-typography-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.ds-typography-section h3 {
    margin-bottom: 1rem;
    color: var(--grey-deep);
}

.ds-typography-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.ds-typography-card {
    background: var(--bg-raised);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-raised);
    border: 1px solid var(--border-color-light);
}

.ds-typography-sample {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--grey-near-white);
    border-radius: 4px;
    border: 1px solid var(--border-color-light);
    min-height: 2rem;
    display: flex;
    align-items: center;
}

.ds-typography-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ds-typography-name {
    font-weight: var(--font-weight-semibold);
    color: var(--grey-deep);
}

.ds-typography-variable {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--grey-steel);
}

.ds-typography-value {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--grey-silver);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ds-header {
        padding: 1rem;
    }
    
    .ds-main {
        margin-top: 140px;
        padding: 1rem;
    }
    
    .ds-nav {
        flex-wrap: wrap;
    }
    
    .ds-nav-item {
        padding: 0.5rem 1rem;
        font-size: var(--font-size-sm);
    }
    
    .ds-overview-colors {
        grid-template-columns: 1fr;
    }
    
    .ds-typography-grid {
        grid-template-columns: 1fr;
    }
}

/* CSS imports moved to the top of the file */

/* ===== DESIGN SYSTEM ADMIN PAGE LAYOUT ===== */
#design-system-container { 
    padding: 3rem;
    padding-bottom: 100px;
    overflow-y: auto;
}

.ds-section { 
    display: none; 
}

.ds-section.active { 
    display: block; 
}

/* Remove any default margins from the page */
#colors-section {
    margin: 0;
    padding: 0;
}

/* Add padding to ALL sections for proper spacing */
.ds-custom-color-group,
.ds-color-overview { 
    padding-left: 3rem; 
    padding-right: 3rem;
}

/* Page header gets padding */
#colors-section > div:first-child {
    padding-left: 3rem;
    padding-right: 3rem;
}

/* Editable hex values */
.editable-hex {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.editable-hex:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Inline Editor Styles - matching original implementation */
.ds-inline-editor {
    display: inline-block;
    margin-left: 8px;
}

/* Remove outline from form elements in inline editor */
.ds-inline-editor input {
    outline: none;
    box-shadow: none;
}

.ds-inline-editor input:focus {
    outline: none;
    box-shadow: none;
    border-color: #007bff;
}

.ds-inline-editor input:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Target specific browser defaults */
.ds-inline-editor input:-webkit-any-link:focus {
    outline: none;
}

.ds-inline-editor input::-moz-focus-inner {
    border: 0;
    outline: none;
}

/* Clean up color picker to be just the color swatch */
.ds-inline-editor input[type="color"] {
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    border-radius: 3px;
}

.ds-inline-editor input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border: none;
    border-radius: 2px;
}

.ds-inline-editor input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.ds-inline-editor input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 2px;
}

/* Ensure inline editor buttons use standard button styles */
.ds-inline-editor .btn {
    /* Inherits from main .btn, .btn-primary, .btn-secondary classes */
}

/* Typography Demo Styles (copied from original) */
.ds-typography-demo { 
    margin: 2rem 0; 
}

.ds-type-sample { 
    margin: 1.5rem 0; 
}

.ds-type-group { 
    display: grid; 
    grid-template-columns: 200px 1fr; 
    gap: 2rem; 
    margin-bottom: 3rem; 
    align-items: start; 
}

.ds-type-group h4 { 
    margin: 0; 
    color: var(--text-secondary); 
    font-size: 1rem; 
    font-weight: var(--font-weight-semibold); 
    position: sticky; 
    top: 80px; 
}

.ds-font-samples, 
.ds-weight-samples, 
.ds-size-samples, 
.ds-text-classes { 
    display: flex; 
    flex-direction: column; 
    gap: 1.5rem; 
}

.ds-font-sample, 
.ds-weight-sample, 
.ds-size-sample, 
.ds-text-class-sample { 
    padding: 0; 
    margin: 0; 
}



.editable-typography-value { 
    cursor: pointer; 
    padding: 0.25rem 0.5rem; 
    border-radius: 4px; 
    transition: background-color 0.2s ease; 
}

.editable-typography-value:hover { 
    background-color: var(--bg-lower); 
    color: var(--text-secondary); 
}

.ds-text-class-info {
    display: flex; 
    flex-direction: column; 
    gap: 0.25rem; 
    margin-bottom: 0.5rem;
}

.ds-text-class-properties {
    font-family: var(--font-family-mono); 
    font-size: var(--font-size-sm, 0.875rem); 
    color: var(--text-muted);
}

.editable-text-class { 
    cursor: pointer; 
    padding: 0.25rem 0.5rem; 
    border-radius: 4px; 
    transition: background-color 0.2s ease; 
}

.editable-text-class:hover { 
    background-color: var(--bg-lower); 
    color: var(--text-secondary); 
}

/* ============================================================
   Topic Popover (homepage topic zone click)
   ============================================================ */

.topic-popover {
    position: absolute;
    z-index: 1000;
    width: 260px;
    max-height: 320px;
    background: var(--bg-raised);
    border: var(--border-ui);
    border-radius: 10px;
    box-shadow: var(--shadow-raised);
    font-family: var(--font-family-base);
    overflow: hidden;
    animation: topic-popover-in 0.15s ease-out;
}

@keyframes topic-popover-in {
    from { opacity: 0; transform: translateY(4px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.topic-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 6px;
    border-bottom: 1px solid var(--border-color-light);
}

.topic-popover-name {
    font-size: 13px;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.topic-popover-close {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0 0 8px;
    flex-shrink: 0;
}
.topic-popover-close:hover {
    color: var(--text-primary);
}

.topic-popover-desc {
    padding: 4px 12px 6px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
}

.topic-popover-stories {
    list-style: none;
    margin: 0;
    padding: 4px 0 6px;
    max-height: 220px;
    overflow-y: auto;
}

.topic-popover-story {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background-color 0.12s ease;
}
.topic-popover-story:hover {
    background-color: #f4f6fa;
}

.topic-popover-story-icon {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--text-muted);
}

.topic-popover-story-name {
    font-size: 12.5px;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topic-popover-story:hover .topic-popover-story-name {
    color: #1a6dff;
}

.topic-popover-empty {
    padding: 12px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* Notification styles */
.ds-notification {
    font-family: var(--font-family-base);
}