/* === UI-LAYOUT.CSS === */
/* =========================================
   2. LAYOUT GRID & STRUCTURE
   ========================================= */

* {
    box-sizing: border-box !important;
}

/* Header (Top Navigation) */
header {
    position: fixed;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    border-bottom: 1px solid var(--main-color);
    background: var(--header-bg);
    z-index: 2000;
    box-shadow: none;
    transition: background 0.3s;
    user-select: none;
    overflow: visible;
}

.header-left {
    white-space: nowrap;
    overflow: visible;
}

.header-nav {
    display: flex;
    gap: 8px;
    padding-right: 15px;
    height: 100%;
    align-items: center;
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--main-color);
    color: var(--main-color);
    font-family: var(--font-family);
    font-size: var(--ui-font-size);
    letter-spacing: 1px;
    padding: 6px 14px;
    height: 32px;
    box-sizing: border-box;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

#fullscreen-btn {
    min-width: 44px;
    padding: 6px 10px;
    font-size: var(--ui-font-size);
    text-align: center;
}

.nav-btn:hover {
    box-shadow: 0 0 8px var(--main-color), inset 0 0 10px rgba(0, 0, 0, 0.2);
    text-shadow: 0 0 5px var(--main-color);
}

.nav-btn.active {
    background: var(--main-color);
    color: var(--header-bg);
    box-shadow: 0 0 15px var(--main-color);
    text-shadow: none;
}

/* Sidebar Removed (Legacy clean up) */
#sidebar {
    display: none !important;
}

/* Main Content & Screen Wrapper Viewport Bounds */
#main-content {
    margin: 0 !important;
    width: 100% !important;
    height: 100vh;
    padding-top: 48px;
    display: flex;
    justify-content: center;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0 !important;
    right: 0 !important;
    box-sizing: border-box;
    background: var(--bg-color);
}

#screen-wrapper {
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    background: var(--bg-color);
}

/* Settings Panels (Slide from Right by Default) */
#settings-container {
    position: fixed;
    top: 48px !important;
    right: 0 !important;
    left: auto !important;
    bottom: 0 !important;
    width: 340px;
    background: var(--panel-bg);
    border-left: 1px solid var(--main-color);
    border-right: none;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
    height: calc(100vh - 48px);
    overflow-y: auto;
}

#settings-container.open {
    transform: translateX(0);
}

/* Left Dock Variant */
#settings-container.dock-left {
    right: auto !important;
    left: 0 !important;
    border-left: none !important;
    border-right: 1px solid var(--main-color) !important;
    transform: translateX(-100%);
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.5);
}

#settings-container.dock-left.open {
    transform: translateX(0);
}

/* Fullscreen behavior: Keep fixed to top */
body.is-fullscreen header {
    top: 0 !important;
}

body.is-fullscreen #editor {
    padding-top: 30px !important;
}

body.is-fullscreen #screen-wrapper {
    padding-top: 0;
}

/* Panels inside container */
.panel {
    display: none;
    padding: 20px;
    padding-bottom: 80px;
    width: 100%;
}

.panel.active {
    display: block;
}

.panel-header-title {
    text-align: center;
    margin-bottom: 20px;
    opacity: 0.7;
    font-family: 'Press Start 2P';
    font-size: var(--ui-font-size);
}

/* Accordion Styles */
.accordion {
    width: 100%;
    margin-bottom: 8px;
    border: 2px solid var(--main-color);
    background: var(--panel-bg);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
}

.accordion-header {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    color: var(--main-color);
    padding: 11px 12px;
    text-align: left;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    font-size: calc(var(--ui-font-size) - 2px);
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    border: none;
}

.accordion-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.accordion-header::after {
    content: '+';
    font-weight: bold;
    margin-left: 10px;
}

.accordion-header.active {
    background: var(--main-color);
    color: var(--bg-color);
}

.accordion-header.active::after {
    content: '-';
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: var(--panel-bg);
}

.accordion-content.open {
    max-height: 2000px;
    padding: 15px;
    border-top: 1px solid var(--main-color);
}

/* Control Groups inside Accordions */
.control-group {
    margin-bottom: 15px;
    border-bottom: 1px dashed var(--main-color);
    padding-bottom: 15px;
}

.control-group:last-child {
    border-bottom: none;
}

.control-group h4 {
    margin: 0 0 10px 0;
    font-size: var(--ui-font-size);
    text-transform: uppercase;
    font-family: var(--cjk-stack);
    opacity: 0.8;
}

/* Helper classes */
label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--ui-font-size);
    margin-bottom: 8px;
    opacity: 0.9;
}

.accordion-content input[type=range] {
    width: 120px;
}

.ctl-row label {
    margin-bottom: 0;
}

/* Status Overlay */
#status-overlay {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--main-color);
    color: var(--bg-color);
    padding: 10px 20px;
    font-family: var(--font-family);
    font-weight: bold;
    text-transform: uppercase;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 0 15px var(--main-color);
    border: 2px solid var(--bg-color);
}

/* Init Overlay */
#init-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100000;
    backdrop-filter: blur(5px);
}

.init-content-wrapper {
    width: 800px;
    max-width: 90%;
    text-align: center;
    border: 2px solid var(--main-color);
    padding: 40px;
    background: #050505;
    box-shadow: 0 0 50px rgba(0, 255, 0, 0.1);
    max-height: 90vh;
    overflow-y: auto;
}

.init-warning {
    color: var(--warning-color);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Config IO */
.config-io-area {
    width: 100%;
    height: 100px;
    background: #000 !important;
    border: 1px solid var(--main-color);
    color: var(--main-color);
    font-family: 'Courier New', monospace;
    font-size: 10px;
    padding: 8px;
    margin-bottom: 10px;
    resize: none;
    display: block;
    overflow-y: auto;
}

.config-button-row {
    display: flex;
    gap: 8px;
}

.config-button-row .sys-btn {
    flex: 1;
    font-size: 11px;
    padding: 6px 0;
}

/* Responsive Mobile View */
@media (max-width: 700px) {
    header {
        height: 80px;
        flex-direction: column;
        padding: 5px;
        justify-content: center;
        gap: 5px;
    }

    .header-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    #screen-wrapper {
        padding-top: 80px;
    }

    #settings-container {
        top: 80px !important;
        width: 100%;
        transform: translateY(100%);
        height: calc(100vh - 80px);
    }

    #settings-container.open {
        transform: translateY(0);
    }
}

/* =========================================
   WORLD BUILDER STYLES
   ========================================= */
#world-builder-root {
    display: flex;
    flex-direction: column;
    height: 400px;
    border: 1px solid var(--main-color);
    padding: 5px;
    background: rgba(0, 0, 0, 0.2);
}

.acc-wrapper {
    margin-top: 5px;
}

.acc-header {
    display: flex;
    align-items: center;
}

.acc-btn {
    background: rgba(0, 0, 0, 0.3);
    color: var(--main-color);
    border: 1px solid var(--main-color);
    flex-grow: 1;
    text-align: left;
    padding: 6px 8px;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    text-transform: uppercase;
    transition: all 0.2s;
}

.acc-btn:hover,
.acc-btn.active {
    background: var(--main-color);
    color: var(--bg-color);
}

.acc-panel {
    max-height: 0;
    overflow-y: auto;
    transition: max-height 0.3s ease-out;
    border-left: 1px dashed var(--main-color);
    border-right: 1px dashed var(--main-color);
    margin-bottom: 5px;
    background: rgba(0, 0, 0, 0.2);
}

.acc-panel.open {
    border-bottom: 1px solid var(--main-color);
}

.note-row {
    display: flex;
    border-bottom: 1px dashed #333;
}

.note-item {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--main-color);
    padding: 4px 8px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    opacity: 0.8;
}

.note-item:hover {
    opacity: 1;
    text-decoration: underline;
    background: rgba(51, 255, 0, 0.1);
}

.note-add-btn {
    width: 100%;
    background: transparent;
    border: none;
    border-top: 1px dashed var(--main-color);
    color: var(--main-color);
    padding: 6px;
    cursor: pointer;
    opacity: 0.6;
    font-size: 12px;
}

.note-add-btn:hover {
    opacity: 1;
    font-weight: bold;
}

/* FIXES */
#btn-add-category {
    flex-grow: 0 !important;
    width: 40px !important;
    padding: 0 !important;
    font-size: 18px !important;
    line-height: normal;
}

@media (max-width: 700px) {
    #underdeck {
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        transform: none !important;
        bottom: 0 !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    #underdeck-toggle {
        right: 10px !important;
    }
}

.app-brand-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topbar-favicon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    background-color: var(--main-color);
    -webkit-mask: url('../favicon.svg') no-repeat center / contain;
    mask: url('../favicon.svg') no-repeat center / contain;
    filter: drop-shadow(0 0 calc(var(--glow-strength, 0) * 4px) var(--main-color));
    transition: background-color 0.25s ease;
}

.app-title {
    font-size: calc(var(--ui-font-size, 14px) * 1.3) !important;
}

.stats-bar {
    font-size: var(--ui-font-size, 12px) !important;
}

/* =========================================
   MANUSCRIPT INSIGHTS DASHBOARD
   ========================================= */
.insight-placeholder {
    font-size: 10px;
    opacity: 0.6;
    font-style: italic;
    padding: 4px 0;
}

/* Chapter Outlier Visualizer */
.chapter-bar-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
}

.chapter-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapter-title {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.9;
}

.chapter-wc {
    opacity: 0.8;
    font-family: 'Courier New', monospace;
    font-size: 9px;
}

.chapter-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
}

.chapter-bar-fill {
    height: 100%;
    background: var(--main-color);
    transition: width 0.3s ease;
}

.chapter-bar-fill.outlier-short {
    background: var(--warning-color, #ffaa00);
}

.chapter-bar-fill.outlier-long {
    background: var(--warning-color, #ff5555);
}

.outlier-pill {
    font-size: 8px;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 2px;
    margin-left: 3px;
}

.outlier-pill.short {
    color: var(--warning-color, #ffaa00);
}

.outlier-pill.long {
    color: var(--warning-color, #ff5555);
}

/* Character Alerts */
.insight-alert-pill {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--main-color);
    color: var(--main-color);
    border-radius: 2px;
    font-family: inherit;
    gap: 6px;
    transition: background 0.2s, opacity 0.2s;
    margin-bottom: 2px;
}

.insight-alert-pill:hover {
    background: rgba(255, 255, 255, 0.08);
}

.alert-text {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alert-diff-tag {
    font-size: 8px;
    font-weight: bold;
    border: 1px solid var(--main-color);
    padding: 0 3px;
    border-radius: 2px;
    opacity: 0.8;
}

.alert-count {
    opacity: 0.7;
    font-size: 9px;
    font-family: 'Courier New', monospace;
}

.ignore-alert-btn {
    background: transparent;
    border: 1px solid var(--main-color);
    color: var(--main-color);
    cursor: pointer;
    font-size: 10px;
    padding: 1px 5px;
    line-height: 1;
    opacity: 0.6;
    border-radius: 2px;
    flex-shrink: 0;
    transition: opacity 0.2s, background 0.2s;
}

.ignore-alert-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* Overused Tag Cloud */
.overused-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.overused-tag {
    font-size: 9px;
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--main-color);
    color: var(--main-color);
    border-radius: 2px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    user-select: none;
}

.overused-tag:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.overused-tag.active-phrase-tag,
.insight-alert-pill.active-phrase-tag {
    background: var(--main-color) !important;
    color: var(--bg-color) !important;
    font-weight: bold;
    box-shadow: 0 0 8px var(--main-color);
}

.overused-tag.single-word {
    opacity: 0.85;
    border-style: dashed;
}

/* Dialogue Breakdown */
.dialogue-breakdown {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    font-family: 'Courier New', monospace;
}

.dia-stat {
    padding: 3px 5px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--main-color);
}

.cockpit-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 2px;
}

.card-title {
    font-size: 10px;
    font-weight: bold;
    color: var(--main-color);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

/* Single-Column Classic Rules List */
.rules-list-single {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

.rules-list-single label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 6px;
    font-size: 10px;
    cursor: pointer;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    transition: background 0.2s;
    user-select: none;
    margin-bottom: 0;
}

.rules-list-single label:hover {
    background: rgba(255, 255, 255, 0.05);
}

.rules-list-single label span:first-child {
    flex-grow: 1;
}

.rules-list-single label input[type="checkbox"] {
    margin-left: 8px;
    cursor: pointer;
    accent-color: var(--main-color);
}

.chip-count {
    font-size: 8px;
    font-family: 'Courier New', monospace;
    opacity: 0.7;
    border: 1px solid var(--main-color);
    padding: 0 3px;
    border-radius: 2px;
    min-width: 14px;
    text-align: center;
    margin-left: 6px;
    margin-right: 2px;
}

/* Metric Scores Tiles */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.metric-tile {
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--main-color);
    border-radius: 2px;
    text-align: center;
}

.metric-value {
    font-size: 16px;
    font-weight: bold;
    color: var(--main-color);
    font-family: 'Courier New', monospace;
    margin-bottom: 2px;
}

.metric-label {
    font-size: 8px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Interactive Rhythm Graph */
.interactive-rhythm-graph {
    height: 70px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    opacity: 1;
    overflow-x: auto;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--main-color);
}

.interactive-rhythm-graph .rhythm-bar {
    background: var(--main-color);
    width: 6px;
    min-height: 4px;
    flex-shrink: 0;
    cursor: pointer;
    transition: height 0.2s ease, background 0.2s ease;
}

.interactive-rhythm-graph .rhythm-bar:hover {
    background: var(--warning-color, #ffaa00);
    box-shadow: 0 0 5px var(--warning-color, #ffaa00);
}

.interactive-rhythm-graph .rhythm-bar.active-rhythm-bar {
    background: #ffffff !important;
    box-shadow: 0 0 8px #ffffff;
}

/* =========================================
   WORLD NOTES CORKBOARD & STATUS CHIPS
   ========================================= */
.status-badge {
    font-size: 8px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 2px;
    text-transform: uppercase;
    border: 1px solid var(--main-color);
    color: var(--main-color);
    background: transparent;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.status-badge.status-idea {
    opacity: 0.5;
    border-style: dotted;
}

.status-badge.status-planned {
    opacity: 0.7;
    border-style: dashed;
}

.status-badge.status-draft {
    opacity: 0.9;
    border-style: solid;
}

.status-badge.status-revise {
    opacity: 1;
    border-style: double;
    border-width: 2px;
    padding: 0 3px;
}

.status-badge.status-done {
    background: var(--main-color);
    color: var(--bg-color);
    opacity: 1;
    font-weight: bold;
}

/* Corkboard Grid View */
.corkboard-cat-section {
    margin-bottom: 12px;
    border: 1px solid var(--main-color);
    background: var(--panel-bg, rgba(0, 0, 0, 0.4));
    padding: 8px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

.corkboard-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding-bottom: 5px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--main-color);
    color: var(--main-color);
    white-space: nowrap;
    gap: 8px;
}

.corkboard-cat-header span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.corkboard-cat-header .sys-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 1px 6px;
    font-size: 9px;
    line-height: normal;
}

.corkboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}

.corkboard-card {
    background: var(--bg-color);
    border: 1px solid var(--main-color);
    padding: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 85px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    user-select: none;
    position: relative;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.corkboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 10px var(--main-color);
    border-color: var(--main-color);
    background: rgba(255, 255, 255, 0.05);
}

.corkboard-card-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    font-weight: bold;
    color: var(--main-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
}

.corkboard-card-snippet {
    font-family: var(--font-family), monospace;
    font-size: 13px;
    color: var(--main-color);
    opacity: 0.85;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    word-break: break-word;
}

.corkboard-card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 4px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

/* Drag and Drop Visual Feedback */
.draggable-item {
    cursor: grab;
}

.draggable-item:active {
    cursor: grabbing;
}

.dragging {
    opacity: 0.4 !important;
    border: 1px dashed var(--main-color) !important;
}

.drag-over-top {
    border-top: 2px solid #ffffff !important;
}

.drag-over-bottom {
    border-bottom: 2px solid #ffffff !important;
}

.drag-over-zone {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px dashed var(--main-color) !important;
}

/* Scratchpad Tab Button */
.underdeck-tab-btn {
    position: fixed !important;
    bottom: 0 !important;
    right: 20px !important;
    left: auto !important;
    width: auto !important;
    white-space: nowrap !important;
    background: var(--bg-color) !important;
    border: 2px solid var(--main-color) !important;
    border-bottom: none !important;
    color: var(--main-color) !important;
    padding: 6px 16px !important;
    cursor: pointer !important;
    z-index: 25001 !important;
    font-family: var(--font-family) !important;
    font-weight: bold !important;
    user-select: none !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.7) !important;
    transition: background 0.15s, color 0.15s, left 0.25s ease, right 0.25s ease !important;
}

/* When Game Deck is on the RIGHT side, move Scratchpad to the LEFT side */
.underdeck-tab-btn.shift-left,
body:has(#workspace-flex.pos-right #game-deck-panel.panel-open) #underdeck-toggle {
    left: 20px !important;
    right: auto !important;
}

#underdeck.dock-left,
body:has(#workspace-flex.pos-right #game-deck-panel.panel-open) #underdeck {
    left: 20px !important;
    right: auto !important;
    transform: none !important;
    max-width: calc(100vw - 390px) !important;
    width: 500px !important;
}

/* When Game Deck is on the LEFT side, move Scratchpad to the RIGHT side */
.underdeck-tab-btn.shift-right,
body:has(#workspace-flex.pos-left #game-deck-panel.panel-open) #underdeck-toggle {
    right: 20px !important;
    left: auto !important;
}

#underdeck.dock-right,
body:has(#workspace-flex.pos-left #game-deck-panel.panel-open) #underdeck {
    right: 20px !important;
    left: auto !important;
    transform: none !important;
    max-width: calc(100vw - 390px) !important;
    width: 500px !important;
}

.underdeck-tab-btn:hover {
    background: var(--main-color) !important;
    color: var(--bg-color) !important;
    box-shadow: 0 0 15px var(--main-color) !important;
}

/* POV & Tense Pills */
.insight-pov-pill {
    transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
    user-select: none;
}

.insight-pov-pill:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

.insight-pov-pill.active-pov {
    border-color: var(--main-color);
    box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.2);
}

.insight-pov-pill.active-phrase-tag {
    background: var(--main-color) !important;
    color: var(--bg-color) !important;
    font-weight: bold;
    box-shadow: 0 0 8px var(--main-color);
}

/* Top 2px Progress Bars */
.top-progress-container {
    position: fixed;
    top: 48px;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 2001;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.subtle-progress-bar {
    height: 2px;
    width: 0%;
    background: var(--main-color);
    transition: width 0.3s ease, background 0.3s ease;
    opacity: 0.85;
}

.subtle-progress-bar.sprint-bar {
    background: var(--warning-color, #ffaa00);
    opacity: 0.9;
}

@media (max-width: 768px) {
    .top-progress-container {
        display: none !important;
    }
}

/* Form & Select Dropdown Theme Fix */
select,
select option {
    background-color: var(--bg-color) !important;
    color: var(--main-color) !important;
}

/* Tooltip Cheat Sheets */
.has-tooltip {
    position: relative;
    cursor: help;
}

.has-tooltip[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    width: 250px;
    padding: 8px 10px;
    background: var(--panel-bg);
    border: 1px solid var(--main-color);
    color: var(--main-color);
    font-family: 'Courier New', monospace;
    font-size: 10px;
    line-height: 1.4;
    white-space: pre-wrap;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.95);
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    border-radius: 2px;
}

.has-tooltip:hover::after {
    opacity: 1;
    transform: translateY(0);
}

.underdeck-tab-btn.has-tooltip[data-tooltip]::after {
    left: auto;
    right: 0;
    width: 220px;
}



/* Floating Synonym & Rhythm Popover */
.synonym-popover {
    position: absolute;
    width: 440px;
    max-width: 95vw;
    background: var(--bg-color);
    border: 2px solid var(--main-color);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.85);
    z-index: 25000;
    padding: 10px;
    font-family: var(--font-family);
    color: var(--main-color);
    border-radius: 3px;
}

.synonym-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--main-color);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.syn-word-title {
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.syn-close-btn {
    background: transparent;
    border: none;
    color: var(--main-color);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 6px;
}

.syn-close-btn:hover {
    background: var(--main-color);
    color: var(--bg-color);
}

.synonym-columns-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.syn-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.syn-col-header {
    font-size: 9px;
    font-weight: bold;
    opacity: 0.8;
    border-bottom: 1px dashed var(--main-color);
    padding-bottom: 3px;
    margin-bottom: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.syn-key-badge {
    font-size: 8px;
    padding: 1px 3px;
    border: 1px solid var(--main-color);
    border-radius: 2px;
}

.syn-col-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    min-height: 40px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 3px;
}

.syn-col-list::-webkit-scrollbar {
    width: 4px;
}

.syn-col-list::-webkit-scrollbar-thumb {
    background: var(--main-color);
    border-radius: 2px;
}

.syn-col-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.syn-item-btn {
    flex-shrink: 0;
    min-height: 24px;
    line-height: 1.2;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--main-color);
    font-family: inherit;
    font-size: 11px;
    padding: 4px 6px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.syn-item-btn:hover,
.syn-item-btn:focus {
    background: var(--main-color);
    color: var(--bg-color);
    border-color: var(--main-color);
    outline: none;
}

/* Header EXP Meters */
.exp-meter-box {
    position: relative;
    width: 52px;
    height: 22px;
    box-sizing: border-box;
    background: var(--panel-bg, rgba(0, 0, 0, 0.3));
    border: 1px solid var(--main-color);
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    vertical-align: middle;
    border-radius: 2px;
    margin: 0;
}

.exp-meter-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--main-color);
    opacity: 0.85;
    border-right: 2px solid var(--main-color);
    transition: width 0.25s ease, background 0.25s ease;
    box-shadow: 0 0 6px var(--main-color);
}

.exp-meter-fill.exp-completed {
    background: var(--success-color, #00ff00) !important;
    border-right: 2px solid var(--success-color, #00ff00) !important;
    box-shadow: 0 0 8px var(--success-color, #00ff00);
    opacity: 0.95 !important;
}

.exp-meter-pct {
    position: relative;
    z-index: 5;
    font-size: 11px;
    font-family: inherit;
    font-weight: bold;
    color: var(--main-color);
    text-shadow: none;
    pointer-events: none;
    letter-spacing: 0.5px;
    line-height: 20px;
    transition: color 0.15s ease, text-shadow 0.15s ease;
}

.exp-meter-box.meter-covered .exp-meter-pct {
    color: var(--bg-color);
    font-weight: 900;
    text-shadow:
        1px 1px 0 var(--main-color),
        -1px -1px 0 var(--main-color),
        1px -1px 0 var(--main-color),
        -1px 1px 0 var(--main-color);
}

.exp-meter-box.meter-covered .exp-meter-fill.exp-completed+.exp-meter-pct {
    color: var(--bg-color);
    text-shadow:
        1px 1px 0 var(--success-color),
        -1px -1px 0 var(--success-color),
        1px -1px 0 var(--success-color),
        -1px 1px 0 var(--success-color);
}

/* Ambient Soundscapes Sub-accordions & Controls */
.ambient-category-group {
    margin-top: 8px;
    border: 1px solid var(--main-color);
    background: var(--panel-bg);
    border-radius: 2px;
}

.ambient-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 9px;
    cursor: pointer;
    font-size: calc(var(--ui-font-size) - 3px);
    font-family: 'Press Start 2P', monospace;
    color: var(--main-color);
    background: rgba(255, 255, 255, 0.03);
    user-select: none;
    transition: all 0.2s ease;
    border: none;
}

.ambient-cat-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ambient-cat-content {
    padding: 8px 9px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--panel-bg);
    border-top: 1px solid var(--main-color);
}

.ambient-cat-content.collapsed {
    display: none;
}

.ambient-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    margin-bottom: 2px;
}

.ambient-row span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 6px;
}

.ambient-row input[type="range"] {
    width: 90px;
    margin: 0;
}

/* Binaural Beats Generator Controls */
.binaural-generator-group {
    border-color: var(--main-color);
    background: rgba(0, 0, 0, 0.15);
}

.binaural-preset-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.binaural-preset-btn {
    font-size: 9px;
    padding: 5px 2px;
    line-height: 1.25;
    text-align: center;
    border: 1px solid var(--main-color);
    background: transparent;
    color: var(--panel-text, var(--main-color));
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.15s ease, color 0.15s ease;
}

.binaural-preset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.binaural-preset-btn.active {
    background: var(--main-color);
    color: var(--bg-color, #000000);
    font-weight: bold;
}

/* Floating Emotion Adjuster Popover */
.emotion-popover {
    position: absolute;
    width: 440px;
    max-width: 95vw;
    background: var(--bg-color);
    border: 2px solid var(--main-color);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.85);
    z-index: 25000;
    padding: 10px;
    font-family: var(--font-family);
    color: var(--main-color);
    border-radius: 3px;
}

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

.emotion-title {
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.emotion-columns-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.emotion-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.emotion-col-header {
    font-size: 10px;
    font-weight: bold;
    opacity: 0.85;
    border-bottom: 1px dashed var(--main-color);
    padding-bottom: 3px;
    margin-bottom: 4px;
}

.emotion-col-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    min-height: 50px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 3px;
}

.emotion-col-list::-webkit-scrollbar {
    width: 4px;
}

.emotion-col-list::-webkit-scrollbar-thumb {
    background: var(--main-color);
    border-radius: 2px;
}

.emotion-col-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.emotion-item-btn {
    flex-shrink: 0;
    min-height: 24px;
    line-height: 1.2;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--main-color);
    font-family: inherit;
    font-size: 11px;
    padding: 4px 6px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.emotion-item-btn:hover,
.emotion-item-btn:focus {
    background: var(--main-color);
    color: var(--bg-color);
    border-color: var(--main-color);
    outline: none;
}

.emotion-btn-escalate:hover {
    box-shadow: 0 0 8px var(--main-color);
}

.emotion-btn-deescalate:hover {
    box-shadow: 0 0 8px var(--main-color);
}

/* Floating Sensory Lookup Popover */
.sensory-popover {
    position: absolute;
    width: 480px;
    max-width: 95vw;
    background: var(--bg-color);
    border: 2px solid var(--main-color);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.85);
    z-index: 25000;
    padding: 10px;
    font-family: var(--font-family);
    color: var(--main-color);
    border-radius: 3px;
}

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

.sensory-title {
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sensory-search-box {
    padding: 4px 0;
    margin-bottom: 6px;
}

.sensory-search-box input {
    width: 100%;
    background: transparent;
    border: 1px solid var(--main-color);
    color: var(--main-color);
    font-family: inherit;
    font-size: 11px;
    padding: 4px 8px;
    outline: none;
    box-sizing: border-box;
}

.sensory-search-box input:focus {
    box-shadow: 0 0 6px var(--main-color);
}

.sensory-tabs-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--main-color);
    padding-bottom: 6px;
    overflow-x: auto;
}

.sensory-tab-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--main-color);
    font-family: inherit;
    font-size: 10px;
    font-weight: bold;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sensory-tab-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--main-color);
}

.sensory-tab-btn.active-sensory-tab {
    background: var(--main-color);
    color: var(--bg-color);
    border-color: var(--main-color);
    box-shadow: 0 0 6px var(--main-color);
}

.sensory-words-container {
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.sensory-words-container::-webkit-scrollbar {
    width: 4px;
}

.sensory-words-container::-webkit-scrollbar-thumb {
    background: var(--main-color);
    border-radius: 2px;
}

.sensory-words-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.sensory-words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 5px;
}

.sensory-word-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--main-color);
    font-family: inherit;
    font-size: 11px;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 2px;
    text-align: left;
    transition: all 0.12s ease;
    overflow: hidden;
}

.sensory-word-btn:hover,
.sensory-word-btn:focus {
    background: var(--main-color);
    color: var(--bg-color);
    border-color: var(--main-color);
    outline: none;
    box-shadow: 0 0 6px var(--main-color);
}

.sensory-word-btn:hover .sensory-sense-pill {
    background: var(--bg-color);
    color: var(--main-color);
    border-color: var(--bg-color);
}

.sensory-word-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 4px;
}

.sensory-sense-pill {
    font-size: 8px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    padding: 1px 3px;
    border: 1px solid var(--main-color);
    border-radius: 2px;
    opacity: 0.8;
    flex-shrink: 0;
}

.sensory-no-results {
    font-size: 11px;
    opacity: 0.7;
    text-align: center;
    padding: 20px 10px;
    font-style: italic;
}

/* =========================================
   SYNC & CLOUD CONFLICT STYLES
   ========================================= */
.sync-conflict-banner {
    position: fixed;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 650px;
    background: var(--panel-bg);
    border: 2px solid var(--warning-color, #ffaa00);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 10px var(--warning-color, #ffaa00);
    z-index: 15000;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-family: var(--font-family);
    font-size: 11px;
    color: var(--panel-text);
}

.sync-conflict-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.user-status-pill {
    font-family: var(--font-family), inherit;
    font-size: inherit;
    letter-spacing: 1px;
    padding: 0 8px;
    height: 22px;
    line-height: 20px;
    box-sizing: border-box;
    border: 1px solid var(--main-color);
    background: var(--panel-bg, rgba(0, 0, 0, 0.3));
    color: var(--main-color);
    border-radius: 2px;
    cursor: pointer;
    white-space: nowrap;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    user-select: none;
}

.user-status-pill:hover {
    box-shadow: 0 0 8px var(--main-color), inset 0 0 6px rgba(0, 0, 0, 0.3);
    text-shadow: 0 0 5px var(--main-color);
}

.sync-status-indicator {
    font-family: var(--font-family), inherit;
    font-size: inherit;
    letter-spacing: 1px;
    padding: 0 4px;
    height: 22px;
    line-height: 22px;
    opacity: 0.85;
    color: var(--main-color);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    cursor: default;
    text-transform: uppercase;
    user-select: none;
}

/* ==========================================================================
   STUDIO WORKSPACE EXPANDABLE DROPDOWN (PHASE 1)
   ========================================================================== */
.workspace-dropdown-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 22px;
    user-select: none;
    flex-shrink: 0;
}

.ws-dropdown-btn {
    box-sizing: border-box;
    height: 22px;
    line-height: 20px;
    padding: 0 8px;
    margin: 0;
    background: var(--panel-bg, rgba(0, 0, 0, 0.4));
    border: 1px solid var(--main-color);
    border-radius: 2px;
    color: var(--main-color);
    cursor: pointer;
    font-family: var(--font-family), inherit;
    font-size: var(--ui-font-size, 11px);
    letter-spacing: 1px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    vertical-align: middle;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    white-space: nowrap;
    opacity: 0.92;
    font-weight: bold;
}

.ws-dropdown-btn:hover,
.ws-dropdown-btn[aria-expanded="true"] {
    opacity: 1;
    box-shadow: 0 0 8px var(--main-color), inset 0 0 6px rgba(0, 0, 0, 0.3);
    text-shadow: 0 0 5px var(--main-color);
}

.ws-dropdown-arrow {
    font-size: 8px;
    transition: transform 0.2s ease;
    opacity: 0.8;
}

.ws-dropdown-btn[aria-expanded="true"] .ws-dropdown-arrow {
    transform: rotate(180deg);
}

.ws-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 145px;
    background: var(--panel-bg, #0d0d0d);
    border: 1px solid var(--main-color);
    border-radius: 2px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.8), 0 0 10px rgba(0, 0, 0, 0.6);
    z-index: 9500;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ws-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 6px 8px;
    box-sizing: border-box;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 2px;
    color: var(--panel-text, #fff);
    font-family: var(--font-family), inherit;
    font-size: 11px;
    letter-spacing: 0.5px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
    text-transform: uppercase;
}

.ws-menu-item:hover,
.ws-menu-item:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--main-color);
    outline: none;
}

.ws-menu-item.active {
    background: var(--main-color);
    color: var(--header-bg, #000) !important;
    font-weight: bold;
    border-color: var(--main-color);
    text-shadow: none;
}

.ws-menu-item.active .ws-menu-hint {
    color: var(--header-bg, #000);
    opacity: 0.85;
}

.ws-menu-name {
    flex-grow: 1;
}

.ws-menu-hint {
    font-size: 9px;
    letter-spacing: 0.5px;
    opacity: 0.5;
    margin-left: 10px;
    font-family: monospace;
}

.workspace-tabs-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    user-select: none;
    flex-shrink: 0;
}

.ws-tab {
    box-sizing: border-box;
    height: 22px;
    line-height: 20px;
    padding: 0 8px;
    margin: 0;
    background: var(--panel-bg, rgba(0, 0, 0, 0.3));
    border: 1px solid var(--main-color);
    border-radius: 2px;
    color: var(--main-color);
    cursor: pointer;
    font-family: var(--font-family), inherit;
    font-size: var(--ui-font-size, 11px);
    letter-spacing: 1px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    white-space: nowrap;
    opacity: 0.85;
    font-weight: normal;
}

.ws-tab:hover {
    opacity: 1;
    box-shadow: 0 0 8px var(--main-color), inset 0 0 6px rgba(0, 0, 0, 0.3);
    text-shadow: 0 0 5px var(--main-color);
}

.ws-tab.active {
    opacity: 1;
    background: var(--main-color);
    color: var(--header-bg, #000);
    box-shadow: 0 0 8px var(--main-color);
    text-shadow: none;
    font-weight: bold;
}

.ws-meta-badge {
    box-sizing: border-box;
    height: 22px;
    line-height: 20px;
    padding: 0 6px;
    margin: 0;
    background: var(--panel-bg, rgba(0, 0, 0, 0.3));
    border: 1px solid var(--main-color);
    border-radius: 2px;
    color: var(--main-color);
    font-family: var(--font-family), inherit;
    font-size: var(--ui-font-size, 11px);
    letter-spacing: 1px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    opacity: 0.85;
    cursor: help;
    flex-shrink: 0;
}

.ws-meta-badge.persisted {
    border-color: #00ff66;
    color: #00ff66;
    box-shadow: 0 0 6px rgba(0, 255, 102, 0.4), inset 0 0 4px rgba(0, 0, 0, 0.4);
}

/* Workspace Panels */
.workspace-panel {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-color);
    color: var(--panel-text);
    box-sizing: border-box;
}

/* Hide rich text toolbar outside Pantser */
body:not([data-active-workspace="pantser"]) #rt-toolbar {
    display: none !important;
}

/* Planner Studio Shell & Presets */
.planner-shell-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px 60px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.planner-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 16px;
}

.planner-title-group .planner-title {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--main-color);
    display: block;
    text-shadow: 0 0 calc(var(--glow-strength, 0) * 8px) var(--main-color);
}

.planner-title-group .planner-subtitle {
    font-size: 11px;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

.planner-pacing-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pacing-metric {
    display: flex;
    flex-direction: column;
    padding: 6px 12px;
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    min-width: 90px;
}

.pacing-metric .metric-label {
    font-size: 8.5px;
    opacity: 0.7;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.pacing-metric .metric-val {
    font-size: 13px;
    font-weight: bold;
    color: var(--main-color);
    font-family: monospace;
}

.planner-setup-card {
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.setup-section-title {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--main-color);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.setup-description {
    font-size: 12px;
    opacity: 0.8;
    line-height: 1.5;
    margin: 0 0 16px 0;
}

/* Archetype Cards */
.archetype-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.archetype-card {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.archetype-card:hover {
    border-color: var(--main-color);
    background: rgba(255, 255, 255, 0.03);
}

.archetype-card.active {
    border-color: var(--main-color);
    background: rgba(255, 102, 0, 0.07);
    box-shadow: 0 0 12px rgba(255, 102, 0, 0.15);
}

.archetype-card .archetype-icon {
    font-size: 24px;
    margin-bottom: 6px;
}

.archetype-card .archetype-name {
    font-size: 13px;
    font-weight: bold;
    color: var(--main-color);
    margin-bottom: 4px;
}

.archetype-card .archetype-desc {
    font-size: 11px;
    opacity: 0.75;
    line-height: 1.4;
}

/* System Presets Grid */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
}

.sys-preset-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: var(--panel-text);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    font-family: inherit;
}

.sys-preset-btn:hover {
    border-color: var(--main-color);
    background: rgba(255, 255, 255, 0.04);
}

.sys-preset-btn.active {
    border-color: var(--main-color);
    background: rgba(255, 102, 0, 0.1);
    box-shadow: 0 0 10px rgba(255, 102, 0, 0.2);
}

.preset-badge {
    font-size: 20px;
    flex-shrink: 0;
}

.preset-info .preset-name {
    font-size: 12px;
    font-weight: bold;
    color: var(--main-color);
}

.preset-info .preset-sub {
    font-size: 10px;
    opacity: 0.75;
    line-height: 1.3;
}

/* Pacing Table Wrapper */
.pacing-chapter-table-wrapper {
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.2);
    max-height: 250px;
    overflow-y: auto;
}

.pacing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: 11px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pacing-row:last-child {
    border-bottom: none;
}

.pacing-row-title {
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pacing-tag {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 2px;
    text-transform: uppercase;
}

.pacing-tag.target { background: rgba(0, 255, 100, 0.15); color: #00ff66; }
.pacing-tag.short { background: rgba(255, 200, 0, 0.15); color: #ffcc00; }
.pacing-tag.long { background: rgba(255, 50, 50, 0.15); color: #ff5555; }

/* Responsive Rules for Studio Workspaces */
@media (max-width: 600px) {
    .workspace-dropdown-container,
    .workspace-tabs-group {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .planner-shell-container {
        padding: 14px 10px 40px 10px;
    }
    .planner-pacing-summary {
        width: 100%;
        justify-content: space-between;
    }
    .pacing-metric {
        min-width: 70px;
        padding: 4px 8px;
    }
}