/* WonderTales Internal Web Theme - Premium Pink/White Theme */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Clean Light Color Palette */
    --bg-main: #F8F9FC;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F1F5F9;
    --border-color: #E2E8F0;

    --primary: #FF5D8F;       /* Rose/Pink Accent */
    --primary-hover: #FF3D73;
    --primary-light: #FFEBF0;

    --success: #10B981;       /* Emerald */
    --success-hover: #059669;
    --success-light: rgba(16, 185, 129, 0.1);

    --warning: #F59E0B;       /* Amber */
    --warning-hover: #D97706;
    --warning-light: rgba(245, 158, 11, 0.1);

    --danger: #EF4444;        /* Rose */
    --danger-hover: #DC2626;
    --danger-light: rgba(239, 68, 68, 0.1);

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.03);
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App shell layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Left Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: width 0.25s ease;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 10px;
}

.sidebar-brand img {
    height: 38px;
    width: auto;
    min-width: 0;
}

.sidebar-collapse-toggle {
    flex: 0 0 auto;
}

.sidebar-collapse-toggle i {
    width: 18px;
    height: 18px;
}

.sidebar-brand span {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-menu {
    flex: 1;
    padding: 12px 16px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 16px 16px 8px 16px;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.92rem;
    transition: var(--transition-smooth);
    min-height: 40px;
}

.sidebar-item a:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-hover);
}

.sidebar-item.active a {
    color: var(--primary);
    background-color: var(--primary-light);
    font-weight: 600;
}

.sidebar-item a i {
    width: 18px;
    height: 18px;
    stroke-width: 2px;
}

/* Sidebar alert/feedback banner */
.sidebar-feedback-card {
    background: linear-gradient(135deg, #FFEBF0 0%, #FFF0F5 100%);
    border: 1px solid rgba(255, 93, 143, 0.15);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 16px;
    position: relative;
}

.sidebar-feedback-card .badge-warning {
    position: absolute;
    top: -10px;
    left: 16px;
    background-color: var(--primary);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8rem;
    box-shadow: 0 2px 4px rgba(255, 93, 143, 0.4);
}

.sidebar-feedback-card p {
    font-size: 0.78rem;
    color: #475569;
    line-height: 1.35;
    margin-bottom: 10px;
}

.sidebar-feedback-card a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-profile-widget .user-info {
    min-width: 0;
    flex: 1;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.logout-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.sidebar-notification-btn {
    position: relative;
}

.notification-dot {
    background-color: var(--primary);
    border-radius: 50%;
    height: 6px;
    position: absolute;
    right: 5px;
    top: 5px;
    width: 6px;
}

.app-sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.app-sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0 12px;
}

.app-sidebar-collapsed .sidebar-brand img,
.app-sidebar-collapsed .sidebar-section-title,
.app-sidebar-collapsed .sidebar-feedback-card,
.app-sidebar-collapsed .sidebar-item a span,
.app-sidebar-collapsed .sidebar-footer .user-info {
    display: none;
}

.app-sidebar-collapsed .sidebar-menu {
    padding: 12px 10px;
    align-items: center;
}

.app-sidebar-collapsed .sidebar-item {
    width: 100%;
}

.app-sidebar-collapsed .sidebar-item a {
    justify-content: center;
    gap: 0;
    padding: 10px 0;
}

.app-sidebar-collapsed .sidebar-footer {
    padding: 12px 8px;
}

.app-sidebar-collapsed .sidebar-footer .user-profile-widget {
    justify-content: center;
    gap: 8px;
}

/* Top Header */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.app-sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

.header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
}

.page-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.header-project-title {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.header-project-title .page-title {
    max-width: min(34vw, 520px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    min-width: 0;
}

.header-actions .save-status {
    flex: 0 1 150px;
    min-width: 80px;
}

/* User Widget Top Right */
.user-dropdown-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.user-dropdown-widget:hover {
    background-color: var(--bg-surface-hover);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.icon-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.icon-button:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

/* Content wrapper */
.content-body {
    flex: 1;
    padding: 32px;
}

@media (max-width: 1200px) {
    .header {
        padding: 0 20px;
        gap: 16px;
    }

    .header > div:first-child {
        min-width: 0;
    }

    .page-title {
        font-size: 1.12rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-actions {
        gap: 10px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .user-dropdown-widget {
        padding: 6px;
    }

    .user-dropdown-widget .user-name {
        display: none;
    }

    .content-body {
        padding: 20px;
    }
}

/* Visual Project Grid & Cards */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    margin-top: 12px;
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}

.section-header a {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.section-header a:hover {
    color: var(--primary);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.project-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(255, 93, 143, 0.2);
}

.project-card-banner {
    height: 140px;
    width: 100%;
    background-color: #E2E8F0;
    background-size: cover;
    background-position: center;
    position: relative;
}

.project-tag-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
}

.project-tag-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Tag specific colors */
.tag-background { background-color: #4ADE80; color: #FFFFFF; } /* Green */
.tag-story { background-color: #3B82F6; color: #FFFFFF; }      /* Blue */
.tag-character { background-color: #06B6D4; color: #FFFFFF; }  /* Cyan */
.tag-audio { background-color: #F97316; color: #FFFFFF; }      /* Orange */

.project-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.project-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-card-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.project-card-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
}

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

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

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

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

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

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

/* Metrics stats-card layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stats-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
}

.stats-card:hover {
    border-color: rgba(255, 93, 143, 0.2);
}

.stats-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.stats-value {
    font-size: 2rem;
    font-weight: 800;
    margin: 8px 0 4px 0;
    color: var(--text-primary);
}

/* Tables styling */
.table-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--bg-main);
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background-color: var(--bg-main);
}

/* Editor Specific Styles */
.story-editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.story-editor-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.story-editor-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

.save-status {
    color: var(--text-muted);
    flex: 1 1 120px;
    font-size: 0.8rem;
    min-width: 96px;
    text-align: right;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    gap: 24px;
    height: calc(100vh - var(--header-height) - 64px);
}

.story-flow-editor {
    display: grid;
    grid-template-rows: minmax(300px, 46vh) minmax(340px, 1fr);
    gap: 16px;
    min-height: calc(100vh - var(--header-height) - 110px);
    perspective: 1200px;
}

.flow-graph-panel,
.flow-bottom-panel {
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(226, 232, 240, 0.86);
    border-radius: var(--radius-md);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.flow-graph-panel {
    display: flex;
    flex-direction: column;
}

.flow-graph-header {
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 14px 16px;
}

.flow-graph-header h2 {
    font-size: 1rem;
    font-weight: 800;
}

.flow-graph-header p {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 2px;
}

.flow-graph-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.flow-graph-canvas {
    background:
        radial-gradient(circle at 12px 12px, rgba(255, 93, 143, 0.08) 1px, transparent 1px),
        linear-gradient(135deg, rgba(255, 235, 240, 0.7), rgba(248, 250, 252, 0.94));
    background-size: 28px 28px, auto;
    flex: 1;
    overflow: auto;
    position: relative;
}

.flow-graph-lines,
.flow-graph-nodes {
    inset: 0 auto auto 0;
    position: absolute;
}

.flow-graph-lines {
    overflow: visible;
    pointer-events: auto;
    z-index: 1;
}

.flow-graph-nodes {
    min-height: 100%;
    min-width: 100%;
    pointer-events: none;
    z-index: 2;
}

.flow-edge {
    cursor: pointer;
    fill: none;
    pointer-events: stroke;
    stroke: rgba(16, 185, 129, 0.72);
    stroke-linecap: round;
    stroke-width: 3.5;
    transition: stroke-width 0.25s ease-out, stroke 0.25s ease-out;
}

.flow-edge-hit {
    cursor: pointer;
    fill: none;
    pointer-events: stroke;
    stroke: transparent;
    stroke-linecap: round;
    stroke-width: 18;
}

.flow-edge:hover,
.flow-edge.selected {
    stroke: var(--primary);
    stroke-width: 5;
}

.flow-edge.invalid {
    stroke: rgba(239, 68, 68, 0.86);
    stroke-dasharray: 7 7;
}

#flow-arrow path {
    fill: rgba(16, 185, 129, 0.84);
}

#flow-arrow-invalid path {
    fill: rgba(239, 68, 68, 0.92);
}

.flow-node {
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: var(--radius-md);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.08);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    gap: 9px;
    height: 150px;
    justify-content: flex-start;
    padding: 10px;
    pointer-events: auto;
    position: absolute;
    text-align: left;
    transition: transform 0.3s ease-out, border-color 0.3s ease-out, background-color 0.3s ease-out;
    width: 220px;
    will-change: transform;
}

.flow-node:hover,
.flow-node.active {
    border-color: rgba(255, 93, 143, 0.4);
    transform: translateY(-4px) translateZ(16px);
}

.flow-node.active {
    background: rgba(255, 235, 240, 0.96);
}

.flow-node.has-issues {
    border-color: rgba(245, 158, 11, 0.55);
}

.flow-node.is-disconnected {
    opacity: 0.82;
}

.flow-node-title {
    flex: 1;
    font-size: 0.84rem;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flow-node-head {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 0;
}

.flow-node-order {
    align-items: center;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-weight: 900;
    height: 24px;
    justify-content: center;
    min-width: 32px;
    padding: 0 8px;
}

.flow-node-type {
    border-radius: 999px;
    flex: 0 0 auto;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 3px 7px;
    text-transform: uppercase;
}

.flow-node-type.type-narrator {
    background-color: var(--primary-light);
    color: var(--primary);
}

.flow-node-type.type-ai {
    background-color: var(--warning-light);
    color: var(--warning);
}

.flow-node-preview {
    align-items: center;
    background-color: var(--bg-main);
    background-position: center;
    background-size: cover;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    display: flex;
    flex: 1;
    font-size: 0.78rem;
    font-weight: 800;
    justify-content: center;
    min-height: 92px;
    overflow: hidden;
}

.flow-node-issue {
    align-items: center;
    background: var(--warning);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 800;
    height: 22px;
    justify-content: center;
    position: absolute;
    right: -7px;
    top: -7px;
    width: 22px;
}

.flow-graph-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 28px;
}

.flow-bottom-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.flow-bottom-tabs {
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0;
    min-height: 42px;
}

.flow-bottom-tab {
    align-items: center;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    font-family: var(--font-sans);
    font-size: 0.84rem;
    font-weight: 700;
    gap: 8px;
    min-width: 150px;
    padding: 0 14px;
    transition: background-color 0.3s ease-out, color 0.3s ease-out;
}

.flow-bottom-tab:hover,
.flow-bottom-tab.active {
    background: var(--bg-surface);
    color: var(--primary);
}

.flow-bottom-tab i {
    height: 15px;
    width: 15px;
}

.bottom-empty-state {
    align-items: center;
    color: var(--text-muted);
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: center;
    padding: 22px;
    text-align: center;
}

.flow-bottom-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.flow-selected-state-bar {
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(170px, 0.8fr) minmax(320px, 1.5fr) auto;
    padding: 14px 16px;
}

.flow-state-config {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(140px, 190px) minmax(220px, 1fr);
}

.flow-state-config label {
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    font-size: 0.72rem;
    font-weight: 800;
    gap: 5px;
    text-transform: uppercase;
}

.flow-inline-control {
    display: flex;
    gap: 8px;
}

.flow-tab-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 16px;
}

.flow-tab-panel.active {
    display: block;
}

.flow-dialogue-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.flow-line-card {
    background: rgba(248, 250, 252, 0.78);
    border-color: rgba(226, 232, 240, 0.9);
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.05);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out, border-color 0.3s ease-out;
}

.flow-line-card.is-dragging {
    opacity: 0.56;
    transform: scale(0.99);
}

.flow-line-card.is-drop-target {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.flow-line-card-head {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.flow-drag-handle {
    align-items: center;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: grab;
    display: inline-flex;
    flex: 0 0 auto;
    height: 30px;
    justify-content: center;
    transition: var(--transition-smooth);
    width: 30px;
}

.flow-drag-handle:hover {
    background-color: var(--primary-light);
    border-color: rgba(255, 93, 143, 0.28);
    color: var(--primary);
}

.flow-drag-handle i {
    height: 18px;
    stroke-width: 2.8px;
    width: 18px;
}

.flow-line-title {
    color: var(--primary);
    flex: 1;
    font-size: 0.85rem;
    font-weight: 800;
}

.flow-line-card-body {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 1fr);
}

.flow-line-fields {
    min-width: 0;
}

.flow-line-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.flow-line-image {
    align-items: center;
    aspect-ratio: 16 / 9;
    background-color: var(--bg-surface);
    background-position: center;
    background-size: cover;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    display: flex;
    font-size: 0.86rem;
    font-weight: 700;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.flow-line-no-bg {
    position: relative;
    z-index: 1;
}

.flow-line-image-overlay {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.12), rgba(15, 23, 42, 0.82));
    bottom: 0;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 8px;
    left: 0;
    opacity: 0;
    padding: 12px;
    pointer-events: none;
    position: absolute;
    right: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.flow-line-image:hover .flow-line-image-overlay,
.flow-line-image:focus-within .flow-line-image-overlay {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.flow-line-image-name {
    font-size: 0.78rem;
    font-weight: 800;
    overflow-wrap: anywhere;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.5);
}

.flow-line-image-controls {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.flow-line-image-controls .input-control {
    background-color: rgba(255, 255, 255, 0.92);
}

.transition-card-invalid {
    background-color: var(--danger-light);
    border-color: rgba(239, 68, 68, 0.24) !important;
}

.state-line-card[role="button"] {
    cursor: pointer;
    transition: border-color 0.25s ease-out, box-shadow 0.25s ease-out, transform 0.25s ease-out;
}

.state-line-card[role="button"]:hover {
    border-color: rgba(255, 93, 143, 0.34) !important;
    transform: translateY(-1px);
}

.transition-card-selected {
    border-color: rgba(255, 93, 143, 0.55) !important;
    box-shadow: 0 0 0 3px rgba(255, 93, 143, 0.14);
}

.editor-sidebar {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

.state-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 8px;
}

.state-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    margin-bottom: 2px;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
}

.state-item:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.state-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.editor-main {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.editor-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.editor-state-heading {
    min-width: 0;
}

.editor-state-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.editor-state-summary {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.editor-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin: -4px 0 16px;
    padding-bottom: 12px;
}

.editor-tab {
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    font-family: var(--font-sans);
    font-size: 0.84rem;
    font-weight: 700;
    gap: 7px;
    min-height: 38px;
    padding: 7px 10px;
    transition: var(--transition-smooth);
}

.editor-tab:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.editor-tab.active {
    background-color: var(--primary-light);
    border-color: rgba(255, 93, 143, 0.24);
    color: var(--primary);
}

.editor-tab i {
    width: 15px;
    height: 15px;
}

.editor-tab-count {
    align-items: center;
    background-color: var(--bg-main);
    border-radius: 999px;
    color: var(--text-muted);
    display: inline-flex;
    font-size: 0.72rem;
    justify-content: center;
    min-width: 20px;
    padding: 1px 6px;
}

.editor-tab-count.has-issues {
    background-color: var(--warning-light);
    color: var(--warning);
}

.editor-scroll {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.editor-tab-panel {
    display: none;
}

.editor-tab-panel.active {
    display: block;
}

.editor-section-header {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.editor-section-header h4 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.editor-section-header p {
    color: var(--text-muted);
    font-size: 0.82rem;
    max-width: 620px;
}

.editor-section-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.editor-ai-panel {
    background-color: rgba(255, 93, 143, 0.05);
    border: 1px solid rgba(255, 93, 143, 0.16);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    padding: 16px;
}

.editor-ai-panel h4 {
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.editor-empty-note,
.editor-field-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.editor-field-hint {
    margin-top: 5px;
}

.editor-validation-panel {
    margin-bottom: 14px;
}

.editor-validation-empty {
    align-items: center;
    background-color: var(--success-light);
    border: 1px solid rgba(16, 185, 129, 0.16);
    border-radius: var(--radius-md);
    color: var(--success);
    display: flex;
    font-size: 0.82rem;
    font-weight: 700;
    gap: 8px;
    padding: 10px 12px;
}

.editor-validation-empty i {
    width: 15px;
    height: 15px;
}

.editor-validation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
}

.editor-validation-list li {
    align-items: flex-start;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    font-size: 0.82rem;
    gap: 8px;
    line-height: 1.35;
    padding: 9px 10px;
}

.editor-validation-list li i {
    flex: 0 0 auto;
    height: 15px;
    margin-top: 1px;
    width: 15px;
}

.editor-validation-list .validation-error {
    background-color: var(--danger-light);
    border-color: rgba(239, 68, 68, 0.18);
    color: var(--danger);
}

.editor-validation-list .validation-warning {
    background-color: var(--warning-light);
    border-color: rgba(245, 158, 11, 0.18);
    color: var(--warning);
}

.editor-validation-list .validation-info {
    background-color: var(--bg-main);
    color: var(--text-secondary);
}

.asset-reference-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.asset-reference-item {
    align-items: center;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 10px 12px;
}

.asset-reference-item span {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.asset-reference-item strong {
    color: var(--text-primary);
    font-size: 0.86rem;
    overflow-wrap: anywhere;
    text-align: right;
}

.state-line-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

/* Editor responsive form grids (collapse to a single column on narrow screens) */
.editor-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.editor-line-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 12px;
    margin-bottom: 8px;
}

.editor-transition-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

/* Desktop: collapse the states column to give the editor full width */
.editor-layout.sidebar-collapsed {
    grid-template-columns: 1fr;
}

.editor-layout.sidebar-collapsed .editor-sidebar {
    display: none;
}

@media (max-width: 1200px) {
    .story-editor-toolbar {
        align-items: flex-start;
    }

    .story-editor-actions {
        flex: 1 1 320px;
    }

    .save-status {
        flex-basis: auto;
        min-width: 0;
    }

    .editor-layout {
        grid-template-columns: minmax(230px, 260px) minmax(0, 1fr);
        gap: 16px;
    }

    .editor-main {
        padding: 18px;
    }

    .editor-panel-header {
        flex-wrap: wrap;
    }

    .editor-section-header {
        flex-direction: column;
    }

    .editor-transition-grid {
        grid-template-columns: 1fr 1fr;
    }

    .story-flow-editor {
        grid-template-rows: minmax(280px, 42vh) minmax(360px, 1fr);
    }

    .flow-selected-state-bar {
        grid-template-columns: 1fr;
    }

    .flow-state-config {
        grid-template-columns: 1fr 1fr;
    }
}

/* Off-canvas backdrop is hidden until the drawer opens (mobile only) */
.editor-backdrop {
    display: none;
}

@media (max-width: 900px) {
    .editor-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .editor-main {
        height: calc(100vh - var(--header-height) - 64px);
    }

    /* The states list becomes an off-canvas drawer that slides in from the left */
    .editor-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 1200;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .editor-layout.sidebar-open .editor-sidebar {
        transform: translateX(0);
    }

    /* On mobile the drawer model governs visibility, not the desktop collapse class */
    .editor-layout.sidebar-collapsed .editor-sidebar {
        display: flex;
    }

    .editor-layout.sidebar-open .editor-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 1100;
    }

    .editor-form-grid,
    .editor-line-grid,
    .editor-transition-grid {
        grid-template-columns: 1fr;
    }

    .editor-tab {
        flex: 1 1 140px;
        justify-content: center;
    }

    .asset-reference-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .asset-reference-item strong {
        text-align: left;
    }

    .story-flow-editor {
        grid-template-rows: minmax(260px, 38vh) minmax(420px, 1fr);
    }

    .flow-graph-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .flow-bottom-tabs {
        overflow-x: auto;
    }

    .flow-bottom-tab {
        flex: 0 0 auto;
    }

    .flow-state-config,
    .flow-line-card-body {
        grid-template-columns: 1fr;
    }

    .flow-line-preview-caption {
        text-align: left;
    }
}

@media (prefers-reduced-motion: reduce) {
    .flow-node,
    .flow-line-card,
    .flow-bottom-tab {
        transition: none;
    }

    .flow-node:hover,
    .flow-node.active {
        transform: none;
    }
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-control {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 0.88rem;
    font-family: var(--font-sans);
    transition: var(--transition-smooth);
}

.input-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 93, 143, 0.15);
}

/* Alert Notification */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.88rem;
    border: 1px solid transparent;
}

.alert-danger {
    background-color: var(--danger-light);
    border-color: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.alert-success {
    background-color: var(--success-light);
    border-color: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

/* Login Page Layout */
.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;
}

body.login-page {
    background: #ffffff;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(420px, 42.6%) minmax(0, 1fr);
    min-height: 100vh;
}

.login-panel {
    min-height: 100vh;
}

.login-panel-left {
    background: #ffffff;
    border-right: 1px solid #edf0f4;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(32px, 4vw, 64px);
}

.login-panel-inner {
    width: min(360px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-brand {
    display: inline-flex;
    margin-bottom: 46px;
}

.login-brand img {
    width: 240px;
    height: auto;
    display: block;
}

.login-kicker {
    width: 100%;
    margin-bottom: 12px;
    color: #6b7280;
    font-size: 0.92rem;
    font-weight: 500;
}

.login-google-button {
    width: 100%;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    background:
        linear-gradient(#ffffff, #ffffff) padding-box,
        linear-gradient(90deg, #ff7b54 0%, #ffb24c 24%, #5ec86f 52%, #5fa6ff 78%, #5dc5ff 100%) border-box;
    color: #111827;
    font-family: var(--font-sans);
    font-size: 0.98rem;
    font-weight: 500;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.login-google-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.login-divider {
    width: 100%;
    height: 2px;
    margin: 38px 0 34px;
    background: linear-gradient(90deg, rgba(226, 232, 240, 0) 0%, rgba(226, 232, 240, 0.95) 18%, rgba(226, 232, 240, 0.95) 82%, rgba(226, 232, 240, 0) 100%);
}

.login-auth-card {
    width: 100%;
    position: relative;
}

.login-auth-tab {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 14px 14px 0 0;
    background: #f3f4f6;
    color: #2b3553;
    font-size: 0.92rem;
    font-weight: 500;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.login-auth-body {
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 0 16px 16px 16px;
    background: #f3f4f6;
    overflow: hidden;
}

.login-alert {
    margin: 0 0 12px;
    border-radius: 0;
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.12);
}

.login-form {
    padding-bottom: 0;
}

.login-form .form-group {
    margin-bottom: 0;
}

.login-input {
    background: #edf2f7;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 0;
    padding: 16px 16px;
    font-size: 0.95rem;
    color: #1f2937;
}

.login-input::placeholder {
    color: #6b7280;
}

.login-input:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(255, 93, 143, 0.12);
    border-color: rgba(255, 93, 143, 0.45);
}

.login-submit {
    width: 100%;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0 0 14px 14px;
    background: linear-gradient(180deg, #f17aa6 0%, #ef74a1 100%);
    color: #ffffff;
    font-family: var(--font-sans);
    font-size: 0.98rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.login-submit:hover {
    background: linear-gradient(180deg, #f06c9e 0%, #ec6798 100%);
}

.login-links {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    font-size: 0.84rem;
}

.login-links a {
    color: #1f2937;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.login-links a:hover {
    color: var(--primary);
}

.login-links span {
    color: #94a3b8;
    margin: 0 4px;
}

.login-links-accent {
    color: #f472b6 !important;
}

.login-panel-right {
    background: #b8f7f6;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: clamp(40px, 4vw, 72px);
    overflow: hidden;
    position: relative;
}

.login-bunny {
    width: min(430px, 27vw);
    min-width: 330px;
    height: auto;
    display: block;
    transform: translateY(2%);
    filter: drop-shadow(0 14px 26px rgba(255, 255, 255, 0.2));
    pointer-events: none;
    user-select: none;
}

@media (max-width: 1080px) {
    .login-shell {
        grid-template-columns: minmax(360px, 100%);
    }

    .login-panel-right {
        display: none;
    }

    .login-panel-left {
        border-right: 0;
    }
}

@media (max-width: 520px) {
    .login-panel-left {
        padding: 24px 18px;
    }

    .login-panel-inner {
        width: 100%;
    }

    .login-brand {
        margin-bottom: 28px;
    }

    .login-brand img {
        width: 210px;
    }

    .login-divider {
        margin: 28px 0 24px;
    }

    .login-google-button {
        font-size: 0.94rem;
    }
}

/* Coming soon overlay styling */
.coming-soon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}

.coming-soon-icon {
    font-size: 4rem;
    margin-bottom: 24px;
    color: var(--primary);
}

.coming-soon-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.coming-soon-desc {
    color: var(--text-secondary);
    max-width: 480px;
    margin-bottom: 32px;
}
