:root {
    --nav-bg: #252a30;
    --nav-hover: #323840;
    --brand-blue: #0095d9;
    --brand-blue-dark: #007bb5;
    --link-blue: #0288d1;
    --section-bar-bg: #e8f4f8;
    --section-bar-text: #2c3e50;
    --border-light: #e2e6ea;
    --border-med: #cfd6dd;
    --text-main: #33373d;
    --text-muted: #6c757d;
    --status-red: #d32f2f;
    --status-orange: #f57c00;
    --status-green: #2e7d32;
    --bg-page: #ffffff;
    --book-font-family: 'Georgia', 'Times New Roman', serif;
    --book-font-size: 12pt;
    --book-line-height: 1.65;
    --book-first-indent: 1.5em;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    font-size: 13px;
    color: var(--text-main);
    background-color: var(--bg-page);
    line-height: 1.45;
}

/* --- AUTHENTICATION GATE & COLOUR SWATCHES --- */
.auth-gate-backdrop {
    position: fixed;
    inset: 0;
    background: #1e2329;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: #ffffff;
    width: 410px;
    max-width: 100%;
    border-radius: 6px;
    padding: 28px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

.auth-brand-header {
    text-align: center;
    margin-bottom: 18px;
}

.auth-brand-header h2 {
    font-size: 20px;
    color: #1f2933;
    margin-bottom: 2px;
}

.auth-brand-header p {
    font-size: 12px;
    color: var(--text-muted);
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-med);
    margin-bottom: 16px;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.auth-tab.active {
    color: var(--brand-blue-dark);
    border-bottom-color: var(--brand-blue);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-form label {
    font-size: 12px;
    font-weight: 600;
    color: #3a3f45;
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-med);
    border-radius: 4px;
    font-size: 13px;
}

.auth-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}

.color-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.color-swatches .swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #cfd6dd;
    cursor: pointer;
}

.color-swatches .swatch.active {
    box-shadow: 0 0 0 2px #111;
}

.color-swatches input[type="color"] {
    width: 26px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

/* --- TOP NAVIGATION BAR --- */
.top-navbar {
    background-color: var(--nav-bg);
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}

.brand-logo-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    margin-right: 10px;
    cursor: pointer;
    display: block;
    border-radius: 6px;
    flex-shrink: 0;
}

.auth-brand-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    margin: 0 auto 10px auto;
    display: block;
    border-radius: 10px;
}

.nav-item {
    color: #e4e7eb;
    text-decoration: none;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    white-space: nowrap;
}

.nav-item:hover, .nav-item.active {
    background-color: var(--nav-hover);
    color: #ffffff;
}

.nav-item .caret {
    color: var(--brand-blue);
    font-size: 10px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.plan-badge-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    cursor: pointer;
}

.plan-badge-pill.free {
    background: rgba(255, 255, 255, 0.14);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.plan-badge-pill.pro {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    border: 1px solid #fbbf24;
}

.nav-icon-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none;
    padding: 4px 6px;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    color: #e4e7eb;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.15s, transform 0.1s;
}

.nav-icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    transform: translateY(-1px);
}

.bell-badge {
    position: absolute;
    top: -2px;
    right: -3px;
    background-color: #d32f2f;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.avatar-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #9E5A3C;
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.avatar-circle.small {
    width: 24px;
    height: 24px;
    font-size: 11px;
    border: none;
}

/* --- BREADCRUMBS & PAGE HEADERS --- */
.page-container {
    padding: 12px 24px 40px 24px;
    max-width: 100%;
}

.breadcrumbs {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.breadcrumbs span.link {
    color: var(--link-blue);
    cursor: pointer;
}

.breadcrumbs span.link:hover {
    text-decoration: underline;
}

.page-title-main {
    font-size: 20px;
    font-weight: 600;
    color: #2b3036;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

/* --- LIST VIEW (NOVELS & CHAPTERS) --- */
.search-bar-box {
    border: 1px solid var(--border-light);
    background-color: #fafbfc;
    border-radius: 3px;
    padding: 7px 12px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-icon-circle {
    background-color: #e1e4e8;
    color: #555;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.search-bar-box input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 13px;
    outline: none;
    color: var(--text-main);
}

.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-outline {
    background: #ffffff;
    border: 1px solid var(--border-med);
    color: var(--text-main);
    padding: 5px 12px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-outline:hover {
    background-color: #f4f6f8;
}

.btn-blue-pill {
    background-color: var(--brand-blue);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    padding: 5px 16px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-blue-pill:hover {
    background-color: var(--brand-blue-dark);
}

.btn-blue-pill:disabled,
.btn-disabled-grey {
    background-color: #cbd5e1 !important;
    color: #64748b !important;
    border: 1px solid #cbd5e1 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

.toggle-pill-group {
    display: inline-flex;
    border: 1px solid var(--border-med);
    border-radius: 16px;
    overflow: hidden;
    background: #f8fafc;
}

.toggle-pill-btn {
    background: transparent;
    border: none;
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.toggle-pill-btn.active {
    background-color: var(--brand-blue);
    color: #ffffff;
}

.btn-auto-format {
    background-color: #1e293b !important;
    color: #ffffff !important;
    border: 1px solid #0f172a !important;
    border-radius: 14px !important;
    padding: 4px 13px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-auto-format:hover {
    background-color: #0288d1 !important;
    border-color: #0277bd !important;
    color: #ffffff !important;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.per-page-select {
    border: 1px solid var(--border-med);
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 12.5px;
    background: #fff;
}

/* --- FOLIO DATA TABLE --- */
.folio-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.folio-table th {
    color: var(--link-blue);
    font-weight: 600;
    font-size: 12px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-med);
    white-space: nowrap;
}

.folio-table td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
    font-size: 13px;
    color: #3a3f45;
}

.folio-table tr:hover td {
    background-color: #f8fbfd;
}

.notif-row-clickable {
    cursor: pointer;
}

.notif-row-unread td {
    background-color: #f0f9ff;
    font-weight: 600;
}

/* --- STATUS COLOURS --- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-draft, .status-pill.status-draft {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}
.status-dot.status-draft {
    background-color: var(--status-red);
    border: none;
    padding: 0;
}

.status-first-draft, .status-pill.status-first-draft {
    background-color: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}
.status-dot.status-first-draft {
    background-color: var(--status-orange);
    border: none;
    padding: 0;
}

.status-final-draft, .status-pill.status-final-draft {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}
.status-dot.status-final-draft {
    background-color: var(--status-green);
    border: none;
    padding: 0;
}

.status-blue, .status-pill.status-blue {
    background-color: #e3f2fd;
    color: #0277bd;
    border: 1px solid #bbdefb;
}

.link-cell {
    color: var(--link-blue);
    cursor: pointer;
    text-decoration: none;
}

.link-cell:hover {
    text-decoration: underline;
}

.tag-text {
    color: var(--link-blue);
    font-size: 12.5px;
}

/* --- CHAPTER DETAIL SPLIT WORKSPACE --- */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 370px;
    gap: 28px;
    align-items: start;
}

.sub-tabs {
    display: flex;
    gap: 16px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.sub-tab {
    padding: 8px 4px;
    font-size: 13px;
    color: var(--link-blue);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.sub-tab.active {
    color: #222;
    border-bottom: 2px solid var(--brand-blue);
    font-weight: 600;
}

.section-header-plain {
    font-size: 15px;
    font-weight: 600;
    color: #2b3036;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-bar {
    background-color: var(--section-bar-bg);
    color: var(--section-bar-text);
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 2px;
    margin-top: 18px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px 20px;
    margin-bottom: 14px;
}

.meta-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #3a3f45;
    margin-bottom: 4px;
}

.meta-field input, .meta-field textarea, .meta-field select {
    width: 100%;
    border: 1px solid transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 4px 2px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-main);
    background: transparent;
    transition: border-color 0.15s;
}

.meta-field input:focus, .meta-field textarea:focus, .meta-field select:focus {
    outline: none;
    border-bottom-color: var(--brand-blue);
    background-color: #fafdff;
}

/* --- SCENE-BY-SCENE MANUSCRIPT EVENTS & DYNAMIC BOOK TYPOGRAPHY --- */
.scene-block-card {
    border: 1px solid var(--border-med);
    border-left: 4px solid var(--brand-blue);
    border-radius: 4px;
    margin-bottom: 18px;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.scene-block-header {
    background: #f4f9fc;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scene-block-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.scene-badge-num {
    background: var(--brand-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.scene-heading-input {
    flex: 1;
    font-weight: 700;
    font-size: 13.5px;
    color: #1f2933;
    border: 1px solid transparent;
    border-bottom: 1px dashed var(--border-med);
    background: transparent;
    padding: 2px 4px;
    outline: none;
}

.scene-heading-input:focus {
    border-bottom-color: var(--brand-blue);
    background: #fff;
}

.scene-notes-input {
    width: 100%;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    background: #ffffff;
    padding: 6px 8px;
    font-size: 12px;
    color: #475569;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

.scene-prose-editor {
    min-height: 150px;
    padding: 18px 28px;
    font-family: var(--book-font-family);
    font-size: var(--book-font-size);
    line-height: var(--book-line-height);
    color: #1f2328;
    outline: none;
    background: #ffffff;
    overflow: auto;
}

.scene-prose-editor p,
.scene-prose-editor div {
    margin-top: 0;
    margin-bottom: 0.35em;
    text-indent: var(--book-first-indent);
}

.scene-prose-editor p:first-child {
    text-indent: 0;
}

.scene-prose-editor p.scene-break {
    text-align: center !important;
    text-indent: 0 !important;
    margin: 1.1em 0 !important;
}

/* Inline Manuscript Images (Centre / Wrap Left / Wrap Right / Full) */
.ms-image-block {
    display: block;
    margin: 12px auto;
    max-width: 100%;
    text-align: center;
    text-indent: 0 !important;
}

.ms-image-block img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid var(--border-light);
}

.ms-image-block.align-left {
    float: left;
    margin: 6px 18px 10px 0;
    max-width: 48%;
    text-align: left;
}

.ms-image-block.align-right {
    float: right;
    margin: 6px 0 10px 18px;
    max-width: 48%;
    text-align: right;
}

.ms-image-block.align-full {
    width: 100%;
    margin: 14px 0;
}

.ms-image-caption {
    display: block;
    font-size: 10pt;
    font-style: italic;
    color: #64748b;
    margin-top: 4px;
    text-indent: 0 !important;
}

sup.manuscript-footnote {
    color: var(--brand-blue-dark);
    font-weight: 700;
    font-size: 9pt !important;
    cursor: pointer;
    padding: 0 2px;
    background: #e0f2fe;
    border-radius: 3px;
}

.compiled-chapter-preview {
    border: 1px solid var(--border-med);
    background: #fffdf9;
    padding: 32px 44px;
    border-radius: 4px;
    font-family: var(--book-font-family);
    font-size: var(--book-font-size);
    line-height: var(--book-line-height);
    color: #1f2328;
    max-height: 680px;
    overflow-y: auto;
}

.compiled-chapter-preview p {
    text-indent: var(--book-first-indent);
    margin-bottom: 0.35em;
}

.compiled-chapter-preview p:first-child {
    text-indent: 0;
}

.compiled-chapter-preview p.scene-break {
    text-align: center;
    text-indent: 0;
    margin: 1.2em 0;
}

/* --- STATS & GOALS DASHBOARD --- */
.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stats-kpi-card {
    background: #ffffff;
    border: 1px solid var(--border-med);
    border-top: 3px solid var(--brand-blue);
    border-radius: 6px;
    padding: 12px 14px;
}

.stats-kpi-val {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 2px 0;
}

.stats-kpi-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.progress-track {
    width: 100%;
    height: 12px;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin: 6px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0095d9, #2e7d32);
    transition: width 0.3s ease;
}

.bar-chart-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
}

.bar-chart-label {
    width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.bar-chart-track {
    flex: 1;
    height: 14px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.bar-chart-fill {
    height: 100%;
    background: var(--brand-blue);
    border-radius: 4px;
}

/* --- STANDALONE TIMELINE --- */
.timeline-stream {
    position: relative;
    padding-left: 26px;
    border-left: 3px solid var(--brand-blue);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.timeline-node {
    position: relative;
    background: #ffffff;
    border: 1px solid var(--border-med);
    border-radius: 6px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.timeline-node::before {
    content: '';
    position: absolute;
    left: -34px;
    top: 16px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--brand-blue);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--brand-blue);
}

.timeline-node.chapter-node {
    border-left: 4px solid #7b1fa2;
    background: #faf5ff;
}

/* --- DRAG-AND-DROP PLANNING BOARD --- */
.planning-board-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(230px, 1fr));
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 12px;
}

.planning-column {
    background: #f4f6f9;
    border: 1px solid var(--border-med);
    border-radius: 6px;
    padding: 10px;
    min-height: 420px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.planning-column.drag-over {
    background: #e0f2fe;
    border-color: var(--brand-blue);
}

.planning-col-header {
    font-weight: 700;
    font-size: 13px;
    color: #1e293b;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-med);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.planning-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--brand-blue);
    border-radius: 4px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    cursor: grab;
}

.planning-card.dragging {
    opacity: 0.45;
}

/* --- CHARACTER PROFILE CARDS & NOVEL TABS --- */
.novel-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.profile-sheet-card {
    border: 1px solid var(--border-med);
    border-radius: 6px;
    padding: 16px;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --- AI HELPER CHIPS & RADIO PILLS --- */
.ai-chips-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.ai-prompt-chip {
    background: #e8f4f8;
    border: 1px solid #bae6fd;
    color: #0369a1;
    border-radius: 14px;
    padding: 4px 11px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
}

.ai-prompt-chip:hover {
    background: var(--brand-blue);
    color: #ffffff;
    border-color: var(--brand-blue);
}

.service-radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.service-radio-pill {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px;
    border: 1px solid var(--border-med);
    border-radius: 6px;
    background: #ffffff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.service-radio-pill:has(input:checked) {
    background: #e8f4f8;
    border-color: var(--brand-blue);
    color: var(--brand-blue-dark);
}

.editor-toolbar button {
    background: #fff;
    border: 1px solid var(--border-light);
    padding: 3px 8px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-main);
}

.editor-toolbar button:hover {
    background: #eef4f8;
}

/* --- RIGHT SIDEBAR --- */
.right-sidebar {
    border-left: 1px solid transparent;
}

.sidebar-label {
    font-size: 12px;
    font-weight: 600;
    color: #3a3f45;
    margin-bottom: 6px;
}

.stage-widget {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-med);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 14px;
}

.stage-badge {
    background-color: #f8fafc;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    border-right: 1px solid var(--border-med);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.stage-widget select {
    border: none;
    padding: 7px 10px;
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    outline: none;
    background: #fff;
}

.wordcount-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
}

.stat-box-label {
    font-size: 12px;
    font-weight: 600;
    color: #3a3f45;
}

.stat-box-val {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- COLOUR-CODED RIGHT SIDEBAR STORY BIBLE SECTIONS --- */
.right-accordion {
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: #fff;
}

.right-accordion.cat-Character { border-left: 4px solid #1976d2; background: #f5f9ff; }
.right-accordion.cat-Character .count-pill, .right-accordion.cat-Character .avatar-circle.small { background-color: #1976d2; }

.right-accordion.cat-Location { border-left: 4px solid #7b1fa2; background: #faf5ff; }
.right-accordion.cat-Location .count-pill, .right-accordion.cat-Location .avatar-circle.small { background-color: #7b1fa2; }

.right-accordion.cat-Item { border-left: 4px solid #0097a7; background: #f2fbfc; }
.right-accordion.cat-Item .count-pill, .right-accordion.cat-Item .avatar-circle.small { background-color: #0097a7; }

.right-accordion.cat-Concept { border-left: 4px solid #00838f; background: #f0fdfa; }
.right-accordion.cat-Concept .count-pill, .right-accordion.cat-Concept .avatar-circle.small { background-color: #00838f; }

.right-acc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 700;
    font-size: 13.5px;
    color: #1f2933;
}

.count-pill {
    background-color: var(--brand-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
}

.right-acc-body { margin-top: 10px; }

.note-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.note-speech-box {
    flex: 1;
    border: 1px solid var(--border-med);
    border-radius: 3px;
    padding: 6px 8px;
    background: #fff;
}

.note-speech-box input, .note-speech-box textarea {
    width: 100%;
    border: none;
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
}

.note-speech-box input {
    font-weight: 600;
    margin-bottom: 4px;
    border-bottom: 1px dashed var(--border-light);
    padding-bottom: 3px;
}

.note-card-item {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.note-card-content {
    flex: 1;
    border: 1px solid var(--border-med);
    border-radius: 3px;
    padding: 7px 9px;
    background: #fff;
}

.note-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 4px;
}

.note-card-title { font-weight: 600; font-style: normal; color: #2b3036; }
.note-card-body { font-size: 12.5px; color: #3a3f45; white-space: pre-wrap; }

/* --- MODAL --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}

.modal-box {
    background: #fff;
    width: 500px;
    max-width: 96vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    overflow: hidden;
}

.modal-header {
    background: var(--nav-bg);
    color: #fff;
    padding: 12px 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="number"],
.modal-body input[type="url"],
.modal-body input[type="password"],
.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border-med);
    border-radius: 3px;
    font-family: inherit;
    font-size: 13px;
}

.modal-footer {
    padding: 10px 16px;
    background: #f6f8fa;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border-light);
}

/* --- EDITING NOTES & GEMINI --- */
.editing-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}

.editing-notes-area {
    width: 100%;
    height: 150px;
    border: 1px solid var(--border-med);
    border-radius: 3px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-main);
    background-color: #fafcfd;
    resize: vertical;
    outline: none;
}

.row-dots-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 2px 7px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-muted);
}

.row-dots-btn:hover {
    background: #eef2f6;
    border-color: var(--border-med);
    color: var(--text-main);
}

.row-dropdown-menu {
    display: none;
    background: #ffffff;
    border: 1px solid var(--border-med);
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.14);
    min-width: 165px;
    overflow: hidden;
}

.row-dropdown-menu.open { display: block; }

.row-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 12.5px;
    color: var(--text-main);
    cursor: pointer;
}

.row-dropdown-item:hover { background: #f0f7fb; color: var(--brand-blue-dark); }
.row-dropdown-item.danger { color: #c62828; border-top: 1px solid var(--border-light); }

.gemini-box {
    border: 1px solid var(--border-med);
    border-radius: 3px;
    background: #fafcfd;
    padding: 12px;
}

.gemini-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.gemini-chat-history {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    padding: 4px;
}

.gemini-msg {
    padding: 9px 12px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.gemini-msg.user {
    background: #e3f2fd;
    color: #1a237e;
    align-self: flex-end;
    max-width: 85%;
    border: 1px solid #bbdefb;
}

.gemini-msg.ai {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-light);
    align-self: flex-start;
    max-width: 95%;
}

.gemini-msg-actions {
    margin-top: 6px;
    display: flex;
    gap: 6px;
}

.gemini-mini-btn {
    background: #f1f5f9;
    border: 1px solid var(--border-med);
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    color: #334155;
}

.gemini-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.gemini-input-row textarea {
    flex: 1;
    border: 1px solid var(--border-med);
    border-radius: 3px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    background: #fff;
}

/* --- DISTRACTION-FREE WRITING MODE --- */
body.distraction-free { background-color: #f4f5f7; }

body.distraction-free .top-navbar,
body.distraction-free .breadcrumbs,
body.distraction-free .page-title-main,
body.distraction-free .sub-tabs,
body.distraction-free #ws-group-deets,
body.distraction-free #ws-group-notes,
body.distraction-free #sec-prose,
body.distraction-free .right-sidebar { display: none !important; }

body.distraction-free .page-container { padding: 20px; }
body.distraction-free .workspace-grid { display: block; max-width: 820px; margin: 0 auto; }

body.distraction-free #body-prose {
    display: block !important;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    background: #ffffff;
}

body.distraction-free .df-floating-bar {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: #ffffff;
    border: 1px solid var(--border-med);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

/* --- STORY BIBLE TOOLTIP & MENTIONS --- */
.editor-toolbar button.active-tool {
    background-color: #e8f4f8;
    border-color: var(--brand-blue);
    color: var(--brand-blue-dark);
    font-weight: 500;
}

.lore-mention { border-radius: 2px; padding: 0 2px; cursor: help; }
.lore-mention.lore-Character { border-bottom: 2px solid #1976d2; background-color: rgba(25, 118, 210, 0.12); }
.lore-mention.lore-Location { border-bottom: 2px solid #7b1fa2; background-color: rgba(123, 31, 162, 0.12); }
.lore-mention.lore-Item { border-bottom: 2px solid #0097a7; background-color: rgba(0, 151, 167, 0.14); }
.lore-mention.lore-Concept { border-bottom: 2px solid #00838f; background-color: rgba(0, 131, 143, 0.16); }

.story-bible-tooltip {
    display: none;
    position: fixed;
    z-index: 10000;
    max-width: 310px;
    background: #252a30;
    color: #ffffff;
    padding: 10px 13px;
    border-radius: 5px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    font-size: 12.5px;
    line-height: 1.45;
    pointer-events: none;
}

.story-bible-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.story-bible-tooltip-badge {
    background: var(--brand-blue);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.drag-handle-cell {
    width: 28px;
    text-align: center;
    cursor: grab;
    color: #9aa5b1;
    font-size: 15px;
    user-select: none;
}

tr.chapter-draggable-row.dragging { opacity: 0.45; background-color: #e8f4f8; }
tr.chapter-draggable-row.drag-over-top td { border-top: 2px solid var(--brand-blue); }
tr.chapter-draggable-row.drag-over-bottom td { border-bottom: 2px solid var(--brand-blue); }

.fr-mode-tabs { display: flex; border-bottom: 1px solid var(--border-med); margin-bottom: 2px; }
.fr-mode-tab { background: transparent; border: none; border-bottom: 2px solid transparent; padding: 6px 14px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.fr-mode-tab.active { color: var(--brand-blue-dark); border-bottom-color: var(--brand-blue); }

mark.find-highlight { background-color: #fef08a; color: #111; padding: 0 1px; border-radius: 2px; }
mark.find-highlight.active-match { background-color: #fb923c; color: #fff; outline: 2px solid #ea580c; }
