:root {
    color-scheme: light;
    /* Colors */
    --color-teal: var(--brand-blue);
    --color-hover-bg: var(--brand-surface-alt);
    --color-border: var(--brand-border);

    /* Surfaces */
    --color-bg-page: var(--brand-bg);
    --color-bg-surface: var(--brand-surface);
    --color-bg-surface-alt: var(--brand-gray-1);
    --color-bg-elevated: var(--brand-gray-2);
    --color-bg-sunken: var(--brand-gray-0);

    /* Borders */
    --color-border-subtle: var(--brand-border-subtle);
    --color-border-medium: var(--brand-border);
    --color-border-strong: var(--brand-border-strong);

    /* Text */
    --color-text-primary: var(--brand-text);
    --color-text-secondary: var(--brand-gray-7);
    --color-text-muted: var(--brand-gray-6);
    --color-text-faint: var(--brand-gray-5);
    --color-text-disabled: var(--brand-gray-4);
    --color-text-placeholder: var(--brand-gray-5);

    /* Inputs */
    --color-input-bg: var(--brand-surface);
    --color-input-border: var(--brand-border);

    /* Scrollbar */
    --color-scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --color-scrollbar-track: transparent;

    /* Component-specific */
    --color-notepad-rule: var(--brand-gray-2);
    --color-welcome-bg-from: var(--brand-bg);
    --color-welcome-bg-to: var(--brand-surface);
    --color-loading-bg: var(--brand-surface);
    --color-loading-text: var(--brand-gray-6);
    --color-loading-spinner-track: var(--brand-border);

    /* Spacing scale */
    --spacing-xs: 4px;
    --spacing-sm: 6px;
    --spacing-md: 8px;
    --spacing-lg: 12px;
    --spacing-xl: 16px;
    --spacing-2xl: 24px;

    /* Shadows */
    --shadow-card: 1px 1px 3px rgba(0, 0, 0, 0.12), 2px 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-dropdown: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-hover: 2px 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-modal: 0 4px 24px rgba(0, 0, 0, 0.15);

    /* Sizing */
    --card-width: 180px;
    --label-width: 80px;
    --border-radius: 6px;
    --border-radius-sm: 4px;
}

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

body {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--color-bg-page);
    height: 100vh;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    position: relative;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto 20px;
    padding: 16px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon {
    color: var(--color-teal);
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.5px;
}


.community-link {
    position: relative;
    display: none;
    align-items: center;
    align-self: center;
    margin-top: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #0b5a8c;
    text-decoration: none;
    padding: 5px 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(22, 155, 222, 0.08), rgba(22, 155, 222, 0.04));
    border: 1.5px solid rgba(22, 155, 222, 0.25);
    transition: all 0.2s ease;
}

body.welcome-visible .community-link {
    display: inline-flex;
}

body.welcome-visible {
    padding: 0;
    background-color: var(--color-welcome-bg-from);
}

body.welcome-visible .board-name {
    display: none;
}

body.welcome-visible .header-actions {
    margin-left: auto;
}

body.welcome-visible .header-actions #searchBtn,
body.welcome-visible .header-actions #undoBtn,
body.welcome-visible .header-actions #redoBtn,
body.welcome-visible .header-actions #buildAiBtn {
    display: none;
}

body.welcome-visible .header {
    padding-left: 24px;
    padding-right: 24px;
}

.community-link:hover {
    color: #084464;
    border-color: rgba(22, 155, 222, 0.45);
    background: linear-gradient(135deg, rgba(22, 155, 222, 0.14), rgba(22, 155, 222, 0.06));
    box-shadow: 0 2px 8px rgba(22, 155, 222, 0.2);
}

.badge-new {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #f59e0b, #dc7a04);
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 5px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.5);
    animation: badge-glow 2s ease-in-out infinite;
}

@keyframes badge-glow {
    0%, 100% { box-shadow: 0 1px 4px rgba(245, 158, 11, 0.5); }
    50% { box-shadow: 0 2px 8px rgba(245, 158, 11, 0.8), 0 0 12px rgba(245, 158, 11, 0.3); }
}

.community-link-muted {
    color: var(--color-text-faint);
    background: rgba(0, 0, 0, 0.02);
    border-color: #e0e0e0;
    cursor: default;
}

.community-link-muted:hover {
    color: var(--color-text-faint);
    border-color: #e0e0e0;
    background: rgba(0, 0, 0, 0.02);
    box-shadow: none;
}

.badge-soon {
    position: absolute;
    top: -6px;
    right: -10px;
    background: linear-gradient(135deg, #909296, #757575);
    color: #fff;
    font-size: 7px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 5px;
    border-radius: 6px;
    letter-spacing: 0.3px;
    line-height: 1;
}

.board-name {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
    text-align: center;
    background: transparent;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.board-name:hover {
    background-color: var(--color-hover-bg);
}

.board-name:focus {
    outline: none;
    border-color: #6fc4e8;
    background-color: var(--color-bg-surface);
}

.board-name::placeholder {
    color: var(--color-text-placeholder);
    font-weight: 400;
}

.board-name.hidden {
    visibility: hidden;
    pointer-events: none;
}

/* Map-level tags (header) */
.map-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    max-width: 340px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 2px 0;
}
.map-tags.hidden { display: none; }
.map-tag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding: 3px 5px 3px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: var(--brand-blue);
    background: color-mix(in srgb, var(--brand-blue) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--brand-blue) 30%, transparent);
    border-radius: 999px;
    white-space: nowrap;
}
.map-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.55;
}
.map-tag-remove:hover { opacity: 1; background: color-mix(in srgb, var(--brand-blue) 22%, transparent); }
.map-tag-input {
    flex-shrink: 0;
    width: 88px;
    min-width: 70px;
    padding: 4px 9px;
    font-family: inherit;
    font-size: 12px;
    color: var(--color-text-primary);
    background: transparent;
    border: 1px dashed var(--color-border);
    border-radius: 999px;
    outline: none;
    transition: border-color 0.15s ease;
}
.map-tag-input:focus { border-style: solid; border-color: var(--brand-blue); }
.map-tag-input::placeholder { color: var(--color-text-muted); }

/* Search Bar */
.search-bar {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-bar.hidden {
    display: none;
}

.search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #6fc4e8;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    color: var(--color-text-primary);
    background: var(--color-bg-surface);
    outline: none;
}

.search-bar input::placeholder {
    color: var(--color-text-placeholder);
}

.search-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.search-close:hover {
    color: var(--color-text-primary);
}

/* Search dimmed state */
.search-dimmed {
    opacity: 0.12 !important;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* Hide add buttons while searching */
.search-active .btn-add-story,
.search-active .btn-add-slice {
    opacity: 0.15;
    pointer-events: none;
}

.header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

/* Share Dropdown */
.share-dropdown {
    position: relative;
}

.share-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: var(--shadow-dropdown);
    min-width: 170px;
    padding: 4px 0;
    z-index: 200;
}

.share-menu.visible {
    display: block;
}

.share-menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13px;
    font-family: inherit;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.share-menu-item:hover:not(:disabled) {
    background-color: var(--color-hover-bg);
}

.share-menu-item:disabled {
    color: var(--color-text-disabled);
    cursor: default;
}

.viewer-count {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.viewer-count.visible {
    display: flex;
}

.viewer-name {
    cursor: pointer;
    border-radius: 4px;
    padding: 1px 2px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-name:hover {
    background: rgba(3, 105, 161, 0.1);
}

.viewer-live {
    display: none;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #0369a1;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: default;
    position: relative;
}

.viewer-live.visible {
    display: flex;
}

.viewer-live::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Tooltip listing connected users */
.viewer-live::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #272727;
    color: #f1f5f9;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: pre;
    line-height: 1.6;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.viewer-live:hover::after {
    opacity: 1;
}

.active-mappers {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.active-mappers.visible {
    display: flex;
}

.active-mappers::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    min-width: 220px;
    padding: 6px;
    z-index: 100;
    display: none;
    white-space: nowrap;
}

.dropdown-menu.visible {
    display: block;
    animation: menu-glass-in 0.18s ease-out;
}
@keyframes menu-glass-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 7px 12px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13px;
    color: var(--color-text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.12s ease;
}

.dropdown-item:hover:not(:disabled):not(.disabled) {
    background-color: rgba(22, 155, 222, 0.08);
}

.dropdown-item:disabled,
.dropdown-item.disabled {
    color: #9ca3af;
    cursor: not-allowed;
    pointer-events: none;
}
body.welcome-visible #mainMenu > .dropdown-item:disabled,
body.welcome-visible #mainMenu > .dropdown-submenu:has(> .dropdown-submenu-trigger:disabled) {
    display: none;
}

.dropdown-divider {
    height: 0;
    border: none;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
    margin: 4px 8px;
    background: none;
}

.dropdown-submenu-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.dropdown-submenu-trigger::after {
    content: '›';
    margin-left: 8px;
    transition: transform 0.15s ease;
}

.dropdown-submenu-trigger.expanded::after {
    transform: rotate(90deg);
}

.dropdown-submenu-content {
    display: none;
    padding-left: 8px;
    margin: 2px 0;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
}

.dropdown-submenu-content.visible {
    display: block;
}

.dropdown-submenu-content .dropdown-item {
    font-size: 13px;
}

.submenu-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(0, 0, 0, 0.4);
    padding: 6px 12px 2px;
}

.integration-icons {
    display: flex;
    gap: 6px;
    padding: 4px 8px;
}

.file-icons .integration-icon {
    flex: 0;
}

.integration-icon {
    background: none;
    border: 1.5px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 8px 4px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    flex: 1;
}

.integration-icon span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(0, 0, 0, 0.5);
    line-height: 1;
}

.integration-icon:hover {
    background: rgba(22, 155, 222, 0.08);
    border-color: rgba(22, 155, 222, 0.2);
}

.integration-icon.active {
    background: rgba(22, 155, 222, 0.12);
    border-color: rgba(22, 155, 222, 0.5);
}

.integration-options {
    display: none;
    padding-left: 12px;
}

.integration-options.visible {
    display: block;
}

.integration-options .dropdown-item {
    font-size: 13px;
}

.menu-badge {
    display: inline-block;
    background: #f59e0b;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn {
    background: linear-gradient(135deg, #169bde, #0b5a8c);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(22, 155, 222, 0.25);
}

.btn:hover {
    background: linear-gradient(135deg, #0b5a8c, #084464);
    box-shadow: 0 2px 8px rgba(22, 155, 222, 0.35);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 1px 2px rgba(22, 155, 222, 0.2);
}

.btn-secondary {
    background: var(--color-bg-surface);
    color: #084464;
    border: 1px solid #6fc4e8;
    box-shadow: none;
}

.btn-secondary:hover {
    background: #f0fdfa;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    padding: 8px 10px;
    font-size: 16px;
    line-height: 1;
}

#shareBtn, #buildAiBtn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 14px;
    font-size: 13px;
    height: 34px;
}


.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Zoom Controls */
.story-map-wrapper {
    display: none;
    overflow: auto;
    flex: 1;
    min-height: 0;
    position: relative;
    width: 100%; /* Fix Safari alignment */

    /* Hide scrollbar but keep scroll functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Hide scrollbar for Webkit (Chrome, Safari, Edge) */
.story-map-wrapper::-webkit-scrollbar {
    display: none;
}

.story-map-wrapper.visible {
    display: block;
}

.story-map-wrapper.panning {
    cursor: grabbing;
    user-select: none;
}

/* Right-side controls stack */
.controls-right {
    position: fixed;
    bottom: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
}

.controls-right.hidden {
    display: none;
}

/* Unified Controls Panel */
.panel-body {
    display: none;
    background: var(--color-bg-surface);
    overflow: clip;
    max-width: min(540px, calc(100vw - 48px));
}

.controls-right.panel-open .panel-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
    animation: panel-reveal 0.15s ease;
}

.panel-section {
    display: none;
}

.panel-section.open {
    display: block;
}

.panel-section[data-section="notepad"].open {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

@keyframes panel-reveal {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tab bar — single unified strip */
.panel-tabs {
    display: flex;
    background: var(--color-bg-surface);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    border: 1px solid var(--color-border-medium);
    min-width: 218px;
}

/* When panel is open, merge tabs into the panel card */
.controls-right.panel-open {
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
}

.controls-right.panel-open .panel-body {
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--color-border-medium);
    border-bottom: none;
}

.controls-right.panel-open .panel-tabs {
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border-medium);
    border-top: 1px solid var(--color-border-subtle);
    align-self: stretch;
}

.panel-tab {
    flex: 1;
    height: 36px;
    background: transparent;
    border: none;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
}

/* Vertical dividers between tabs */
.panel-tab + .panel-tab {
    border-left: 1px solid var(--color-border-subtle);
}

.panel-tab:hover:not(:disabled):not(.active) {
    color: #555;
    background: #f8f9fa;
}

.panel-tab:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

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

/* Active indicator line */
.panel-tab.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 6px;
    right: 6px;
    height: 2px;
    background: var(--color-teal);
    border-radius: 0 0 2px 2px;
}

/* Partials tab icon */
#partialsToggle::before {
    content: '';
    display: inline-block;
    flex-shrink: 0;
    width: 13px;
    height: 13px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Crect x='3' y='3' width='7' height='7' rx='1' fill='%23fef08a' stroke='%23d4aa00'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1' fill='%23fecdd3' stroke='%23e88a9a'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1' fill='%23a5f3fc' stroke='%2367c5d6'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1' fill='%2314b8a6' stroke='%230d9488'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Legend body */
.legend-body {
    padding: 8px;
    min-width: 218px;
}

.legend-entries {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-entry {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-swatch {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.legend-swatch:hover {
    transform: scale(1.1);
}

.legend-label {
    flex: 1;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    font-family: inherit;
    background: transparent;
    color: var(--color-text-primary);
    min-width: 0;
}

.legend-label:focus {
    outline: none;
    border-color: #45b2e1;
    background: var(--color-bg-surface);
}

.legend-remove {
    background: none;
    border: none;
    color: var(--color-text-faint);
    cursor: pointer;
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
}

.legend-remove:hover {
    color: #e11d48;
}

.legend-add-btn {
    width: 100%;
    background: none;
    border: 1px dashed var(--color-border);
    border-radius: 4px;
    padding: 4px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-text-faint);
    cursor: pointer;
    transition: all 0.15s ease;
}

.legend-add-btn:hover {
    border-color: #45b2e1;
    color: var(--color-text-primary);
}

.legend-color-picker {
    padding: 8px;
    border-top: 1px solid var(--color-border-subtle);
    margin-top: 4px;
}

/* Notes body */
.notes-body {
    width: min(540px, calc(100vw - 48px));
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.notes-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-bg-sunken);
}

.notes-title {
    display: none;
}

.notes-close {
    background: none;
    border: none;
    color: var(--color-text-disabled);
    cursor: pointer;
    font-size: 15px;
    padding: 2px 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.notes-close:hover {
    color: var(--color-text-secondary);
    background: var(--color-border-subtle);
}

.notes-editor {
    width: 100%;
    flex: 1 1 auto;
    height: min(620px, calc(100vh - 200px));
    height: min(620px, calc(100dvh - 200px));
    min-height: 200px;
    overflow: hidden;
    border: none;
    border-left: 2px solid transparent;
    box-sizing: border-box;
    background: var(--color-bg-surface);
    background-image: repeating-linear-gradient(
        transparent,
        transparent calc(25px - 1px),
        var(--color-notepad-rule) calc(25px - 1px),
        var(--color-notepad-rule) 25px
    );
    background-size: 100% 25px;
    background-position: 0 10px;
    transition: border-color 0.15s ease;
}

.notes-editor:focus-within {
    border-left-color: var(--color-teal);
}

.notes-editor .cm-editor {
    height: 100%;
    background: transparent;
}

.notes-editor .cm-scroller {
    overflow: auto;
}

.notes-editor .cm-content {
    min-height: min(600px, calc(100vh - 220px));
    min-height: min(600px, calc(100dvh - 220px));
}

/* Legend: tablet */
@media (max-width: 900px) {
}

/* Legend & Notes: mobile */
@media (max-width: 600px) {
    .controls-right {
        right: 12px;
        bottom: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        max-height: calc(100vh - 32px);
        max-height: calc(100dvh - 32px);
    }

    .panel-body {
        max-width: calc(100vw - 32px);
    }

    .notes-body {
        width: calc(100vw - 32px);
    }

    .panel-tab {
        height: 32px;
        font-size: 11px;
        padding: 0 8px;
    }

    #partialsToggle::before {
        width: 11px;
        height: 11px;
    }

    .legend-body {
        width: auto;
        padding: 6px;
    }

    .legend-swatch {
        width: 20px;
        height: 20px;
        min-width: 20px;
    }

    .legend-label {
        font-size: 12px;
    }

    .notes-editor {
        height: min(400px, calc(100vh - 180px));
        height: min(400px, calc(100dvh - 180px));
        min-height: 160px;
    }

    .notes-editor .cm-content {
        min-height: min(380px, calc(100dvh - 200px));
    }

    .notes-header {
        padding: 6px 10px;
    }

    .partials-body {
        width: auto;
    }

    .partials-entry-btn {
        min-height: 32px;
        padding: 4px 10px;
        font-size: 12px;
    }

    .partial-delete-popover {
        left: 12px;
        right: 12px;
        top: auto !important;
        bottom: 80px;
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }

    .controls-right.panel-open .panel-body {
        max-height: calc(100vh - 100px);
        max-height: calc(100dvh - 100px);
    }
}

.bottom-controls {
    display: flex;
    gap: 6px;
    align-self: flex-end;
    margin-top: 6px;
}

.zoom-controls {
    display: flex;
    gap: 2px;
    background: var(--color-bg-surface);
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--color-border-medium);
}

.zoom-controls.hidden {
    display: none;
}

.zoom-btn {
    width: 30px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: background-color 0.15s ease, color 0.15s ease;
}

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

.zoom-btn.zoom-level {
    width: auto;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.view-controls {
    display: flex;
    gap: 2px;
    background: var(--color-bg-surface);
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--color-border-medium);
}

.view-btn {
    width: 30px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: background-color 0.15s ease, color 0.15s ease;
}

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

.view-btn.active {
    color: var(--color-teal);
    background-color: rgba(22, 155, 222, 0.1);
}


/* Story Map Container */
.story-map {
    position: relative; /* Required for cursor positioning */
    display: inline-flex;
    flex-direction: column;
    margin: 100vh 150vw; /* Infinite canvas: scrollable space on all sides */
    min-width: calc(100vw / var(--zoom, 1)); /* Fill visible area so separators extend */
    padding-top: 4px; /* Space for highlight glow on top cards */
    transform-origin: top left;
}

/* Steps Row (Backbone) */
.steps-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.steps-row-spacer {
    width: var(--label-width);
    flex-shrink: 0;
    padding-right: 12px;
    display: flex;
    align-items: center;
}

/* Step Card (Backbone) */
.step {
    background-color: var(--card-bg, #77bf81);
    padding: 12px 14px;
    border-radius: 2px;
    min-height: 100px;
    width: var(--card-width);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-card);
    position: relative;
}

.step-drag-handle {
    position: absolute;
    top: 4px;
    left: 4px;
    cursor: grab;
    color: #16a34a;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 2px;
    transition: color 0.15s ease, background-color 0.15s ease;
    user-select: none;
    opacity: 0.6;
}

.step-drag-handle:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

/* Column being dragged - elevate and follow step */
.step.column-being-dragged,
.story-card.column-being-dragged {
    z-index: 100;
    position: relative;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8), var(--shadow-card);
    pointer-events: none;
}

.step::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.06) 50%);
    border-radius: 0 0 2px 0;
}

.step-text {
    color: #0f3d3a;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    overflow: hidden;
    font-family: inherit;
    cursor: text;
    caret-color: #134e4a;
}

.step-text::placeholder {
    color: rgba(19, 78, 74, 0.5);
}

/* Step Placeholder (hidden header) - click to show */
.step-placeholder {
    width: var(--card-width);
    min-height: 100px;
    flex-shrink: 0;
    border: 1px dashed transparent;
    border-radius: 2px;
    background-color: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.step-placeholder:hover {
    border-color: var(--color-border-strong);
    background-color: rgba(0, 0, 0, 0.03);
}

/* Phantom step placeholder (auto-expanding columns) */
.phantom-step {
    width: var(--card-width);
    min-height: 100px;
    flex-shrink: 0;
    background-color: rgba(0, 0, 0, 0.01);
    border: 1px dashed var(--color-border);
    border-radius: 2px;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.phantom-step:hover {
    opacity: 0.6;
    border-color: var(--color-border-strong);
    background-color: rgba(0, 0, 0, 0.03);
}

/* Partial Map Reference Block (collapsed view in steps row) */
.partial-map-ref {
    position: relative;
    width: var(--card-width);
    min-height: 100px;
    flex-shrink: 0;
    border: 1px solid #99e2d3;
    border-left: 4px solid #169bde;
    border-radius: 2px;
    background: linear-gradient(135deg, #f0fdfa 0%, #f7fffe 40%, #effcf8 100%);
    box-shadow:
        /* Layer 1: gap */
        2px 2px 0 0px #f5f5f5,
        /* Layer 1: card */
        3px 3px 0 0px #86d9ca,
        4px 4px 0 0px #e0f7f2,
        /* Layer 2: gap */
        6px 6px 0 0px #f5f5f5,
        /* Layer 2: card */
        7px 7px 0 0px #a3e4d7,
        8px 8px 0 0px #eefbf7;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 8px;
    user-select: none;
    margin-bottom: 8px;
}

.partial-map-ref-icon {
    display: flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    background: #6fc4e8;
    border-radius: 5px;
    padding: 1px;
}

.partial-map-ref-name {
    font-size: 12px;
    font-weight: 700;
    color: #0f4f47;
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
}

.partial-map-ref-meta {
    font-size: 10px;
    color: #0b5a8c;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.partial-map-ref-range {
    font-size: 9px;
    color: #45b2e1;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.partial-map-ref-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #169bde, #0b5a8c);
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(22, 155, 222, 0.5);
    z-index: 1;
}


/* Partial Map Reference Cell (collapsed view in slice rows) */
.partial-map-ref-cell {
    width: var(--card-width);
    min-height: 40px;
    flex-shrink: 0;
}

/* Partial Map Edit Mode — dim non-partial content */
.partial-editing .step:not(.partial-map-editing),
.partial-editing .step-placeholder:not(.partial-map-editing),
.partial-editing .story-column:not(.partial-map-editing-col),
.partial-editing .slice-label-container,
.partial-editing .row-label-container {
    opacity: 0.3;
    pointer-events: none;
}

.partial-editing .partial-map-ref:not(.partial-map-ref-editing) {
    opacity: 0.3;
}

.partial-editing .partial-map-ref-cell:not(.partial-map-ref-cell-editing) {
    opacity: 0.15;
}

/* Partial Map Preview — expanded inline, read-only */
.partial-map-preview-col {
    pointer-events: none;
    position: relative;
}

.step.partial-map-preview-col {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8);
}

.partial-map-preview-col .story-card {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8);
}

.partial-map-preview-col .story-card.has-body .btn-expand {
    opacity: 0.5;
    pointer-events: auto;
    cursor: pointer;
}

.partial-map-preview-col .story-card.has-body .btn-expand:hover {
    opacity: 1;
}

.story-text-preview {
    width: 100%;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #1a1a1a;
    text-align: center;
    line-height: 1.4;
    word-break: break-word;
    display: block;
}

/* Partials body */
.partials-body {
    padding: 8px;
    width: 300px;
    max-width: calc(100vw - 48px);
}

.partials-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.partials-expand-btn {
    align-self: stretch;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    color: #0369a1;
    cursor: pointer;
    transition: all 0.1s;
    text-align: center;
}

.partials-expand-btn:hover:not(:disabled) {
    background: #e0f2fe;
    border-color: #7dd3fc;
}

.partials-expand-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.partials-empty {
    font-size: 12px;
    color: #909296;
    padding: 8px 4px;
    text-align: center;
}

.partials-entry {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    border-radius: 5px;
    background: var(--color-bg-page);
    border: 1px solid #c1c2c5;
}

.partials-entry-info {
    flex: 1;
    min-width: 0;
}

.partials-entry-name {
    font-size: 12px;
    font-weight: 500;
    color: #373a40;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

input.partials-entry-name-input {
    background: var(--color-bg-surface);
    border: 1px solid #c1c2c5;
    border-radius: 3px;
    padding: 1px 4px;
    width: 100%;
    box-sizing: border-box;
}

input.partials-entry-name-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.partials-entry-meta {
    font-size: 10px;
    color: #909296;
}

.partials-entry-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.partials-entry-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: #757575;
    cursor: pointer;
    transition: all 0.1s;
}

.partials-entry-btn:hover {
    background: #c1c2c5;
    color: #373a40;
}

.partials-entry-btn.expanded {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #bae6fd;
}

.partials-entry-btn.editing {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.partials-entry-btn.delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

.partial-delete-popover {
    position: fixed;
    background: var(--color-bg-surface);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--color-border-medium);
    min-width: 180px;
    z-index: 10000;
    padding: 4px;
    animation: panel-reveal 0.12s ease;
}

.partial-delete-popover-btn {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    width: 100%;
    background: none;
    border: none;
    border-radius: 5px;
    color: #373a40;
    padding: 7px 8px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.partial-delete-popover-btn > svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.partial-delete-popover-btn > span {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.partial-delete-popover-desc {
    font-size: 11px;
    font-weight: 400;
    color: #909296;
}

.partial-delete-popover-btn:hover {
    background: var(--color-hover-bg);
}

.partial-delete-popover-btn.danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.partial-delete-popover-btn.restore:hover {
    background: #f0fdfa;
    color: #0b5a8c;
}

/* Log */
.log-body {
    padding: 8px;
    width: 300px;
    max-width: calc(100vw - 48px);
}
.log-caption {
    font-size: 10px;
    color: var(--color-text-disabled);
    padding: 0 4px 4px;
}

.log-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.log-empty {
    font-size: 12px;
    color: #909296;
    padding: 8px 4px;
    text-align: center;
}

.log-entry {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 4px;
    font-size: 12px;
    border-radius: 4px;
}

.log-entry:hover {
    background: var(--color-bg-sunken);
}

.log-dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    position: relative;
    top: -1px;
}

.log-time {
    flex-shrink: 0;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 11px;
    color: var(--color-text-secondary);
    min-width: 40px;
}

.log-src-icon {
    flex-shrink: 0;
    color: var(--color-text-secondary);
    opacity: 0.7;
    font-size: 11px;
    line-height: 1;
}

.log-text {
    color: var(--color-text-secondary);
}

/* Slice Container */
.slice-container {
    display: flex;
    flex-direction: row;
    gap: 10px;
    border-top: 2px solid var(--color-border-strong);
    margin-top: 12px;
    padding-top: 12px;
    width: fit-content;
    min-width: 100%;
}

.slice-container:first-of-type {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* Backbone rows (Users, Activities) */
.users-row,
.contexts-row,
.activities-row,
.backbone-row {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-bottom: 8px;
}

/* Bottom-align user cards so they sit adjacent to Activities below */
.users-row .story-column {
    justify-content: flex-end;
}

/* Empty backbone rows (placeholder state) */
.empty-backbone-row .row-type-label {
    color: var(--color-text-disabled);
}

.empty-backbone-row:hover .row-type-label {
    color: var(--color-text-faint);
}

.empty-backbone-row .story-column {
    min-height: 40px;
    border: 1px dashed transparent;
    border-radius: 2px;
    transition: all 0.15s ease;
}

.empty-backbone-row .story-column:hover {
    border-color: var(--color-border-strong);
    background-color: rgba(0, 0, 0, 0.03);
}

/* Slice Label on Left */
.slice-label-container {
    width: var(--label-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-top: 8px;
    padding-right: 16px;
    border-right: 1px solid var(--color-border);
    position: relative;
    cursor: default;
}

.slice-label {
    background: transparent;
    border: none;
    outline: none;
    overflow: hidden;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 4px 0;
    border-radius: 3px;
    width: 100%;
    text-align: left;
    resize: none;
    overflow-wrap: break-word;
    word-wrap: break-word;
    line-height: 1.4;
    cursor: text;
    caret-color: var(--color-text-muted);
    min-height: 100px;
}

.slice-label:focus {
    background-color: var(--color-bg-surface);
    padding: 4px;
    margin: -4px;
    margin-bottom: 0;
    width: calc(100% + 8px);
    box-shadow: 0 0 0 2px rgba(22, 155, 222, 0.3);
}

.slice-label::placeholder {
    color: var(--color-text-disabled);
    text-transform: none;
    letter-spacing: 0;
}

/* Slice Progress Bar */
.slice-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: auto 0;
}

.slice-progress-track {
    flex: 1;
    height: 4px;
    background: var(--color-border-medium);
    border-radius: 2px;
    overflow: hidden;
}

.slice-progress-bar {
    height: 100%;
    background: #22c55e;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.slice-metrics {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    margin-top: auto;
}

.slice-progress-text {
    font-size: 10px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.slice-points-text {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #0e7490;
    background: #ecfeff;
    border: 1px solid rgba(14, 116, 144, 0.15);
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
    letter-spacing: 0.01em;
    align-self: flex-start;
}

/* Undo/Redo highlight animation */
@keyframes undo-highlight {
    0% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8); }
    100% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0); }
}

.undo-highlight {
    animation: undo-highlight 1.5s ease-out forwards;
}

.log-highlight {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.7) !important;
    border-radius: 6px;
    transition: box-shadow 0.15s ease;
}

.log-locatable:hover {
    background: rgba(59, 130, 246, 0.08);
    cursor: pointer;
}
/* Slice Stories Area */
.slice-stories-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Row label container (for backbone rows) */
.row-label-container {
    width: var(--label-width);
    flex-shrink: 0;
    padding-right: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    position: relative;
}

.row-label-container .btn-delete {
    position: absolute;
    bottom: 0;
    left: 0;
    opacity: 0;
    width: 20px;
    height: 20px;
    font-size: 12px;
}

.users-row:hover .row-label-container .btn-delete,
.contexts-row:hover .row-label-container .btn-delete,
.activities-row:hover .row-label-container .btn-delete,
.backbone-row:hover .row-label-container .btn-delete {
    opacity: 1;
}

/* Row type label */
.row-type-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stories Row */
.stories-row {
    display: flex;
    gap: 10px;
}

/* Story Column */
.story-column {
    width: var(--card-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 60px;
}

/* Story Card (Tasks) */
.story-card {
    background-color: var(--card-bg, #fad875);
    padding: 10px 12px;
    border-radius: 2px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-card);
    position: relative;
}

/* Disable hover effects when main menu is open (prevents print artifacts) */
body.main-menu-open .story-card:hover,
body.main-menu-open .step:hover {
    transform: none;
    box-shadow: var(--shadow-card);
}

/* Sortable drag styles */
.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.2);
}

.sortable-drag {
    opacity: 1;
}

/* Prevent hover effects from firing on items being dragged */
.story-card.sortable-chosen:hover,
.step.sortable-chosen:hover {
    transform: none;
    transition: none;
}

/* SortableJS fallback clone (used on Safari) */
.sortable-fallback {
    opacity: 1 !important;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.2);
}

.story-card.sortable-ghost {
    background-color: rgba(22, 155, 222, 0.2);
}

.slice-container.sortable-ghost {
    background-color: rgba(22, 155, 222, 0.1);
    border: 2px dashed var(--color-teal);
    border-radius: 4px;
}

.story-card::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.05) 50%);
    border-radius: 0 0 2px 0;
}

.story-text {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    overflow: hidden;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #1a1a1a;
    text-align: center;
    line-height: 1.4;
    cursor: text;
    caret-color: #1a1a1a;
}

.story-text::placeholder {
    color: rgba(51, 51, 51, 0.5);
}

.story-text.limit-hit,
.step-text.limit-hit {
    animation: shake 0.3s ease;
    box-shadow: 0 0 0 1.5px rgba(239, 68, 68, 0.5);
    border-radius: 2px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-2px); }
    40% { transform: translateX(2px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(1px); }
}

/* Add Story Button */
.btn-add-story {
    background-color: rgba(254, 240, 138, 0.3);
    border: 2px dashed rgba(250, 204, 21, 0.5);
    color: rgba(161, 98, 7, 0.6);
    padding: 8px;
    border-radius: 2px;
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 40px;
}

.btn-add-story:hover {
    background-color: rgba(254, 240, 138, 0.5);
    border-color: rgba(250, 204, 21, 0.8);
    color: #a16207;
}

/* Slim add buttons for backbone rows */
.users-row .btn-add-story,
.contexts-row .btn-add-story,
.activities-row .btn-add-story,
.backbone-row .btn-add-story {
    min-height: 15px;
    padding: 2px 8px;
    font-size: 11px;
    border-width: 1px;
    border-style: solid;
}

.users-row .btn-add-story {
    background-color: rgba(253, 164, 175, 0.3);
    border-color: rgba(253, 164, 175, 0.6);
    color: #9f1239;
    text-decoration: none;
    outline: none;
    box-shadow: none;
}

.users-row .btn-add-story:hover {
    background-color: rgba(253, 164, 175, 0.5);
    border-color: #fda4af;
}

.contexts-row .btn-add-story {
    background-color: rgba(159, 125, 208, 0.25);
    border-color: rgba(159, 125, 208, 0.55);
    color: #5d3f95;
}

.contexts-row .btn-add-story:hover {
    background-color: rgba(159, 125, 208, 0.45);
    border-color: #9f7dd0;
}

.activities-row .btn-add-story {
    background-color: rgba(147, 197, 253, 0.3);
    border-color: rgba(147, 197, 253, 0.6);
    color: #1e40af;
}

.activities-row .btn-add-story:hover {
    background-color: rgba(147, 197, 253, 0.5);
    border-color: #45b2e1;
}

/* Empty columns in backbone rows - clickable to add card */
.empty-backbone-column {
    min-height: 40px;
    border: 1px dashed transparent;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.empty-backbone-column:hover {
    border-color: var(--color-border-strong);
    background-color: rgba(0, 0, 0, 0.02);
}

/* Phantom story column (auto-expanding columns) */
.phantom-column {
    min-height: 40px;
    border: 1px dashed var(--color-border);
    border-radius: 2px;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

/* In slices, phantom columns sit at the top instead of stretching to full slice height */
.slice-container .phantom-column {
    align-self: flex-start;
}

.phantom-column:hover {
    opacity: 0.6;
    border-color: var(--color-border-strong);
    background-color: rgba(0, 0, 0, 0.02);
}

.btn-add-slice {
    background: transparent;
    border: 1px dashed var(--color-border-strong);
    color: var(--color-text-faint);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    margin-top: 8px;
}

.btn-add-slice:hover {
    border-color: var(--color-teal);
    color: #0b5a8c;
    background-color: rgba(22, 155, 222, 0.1);
}

/* Delete Button */
.btn-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.btn-delete:hover {
    background-color: #fee2e2;
    border-color: #e84d6d;
}

.step:hover .btn-delete,
.story-card:hover .btn-delete,
.slice-label-container:hover .btn-delete,
.step.card-hovered .btn-delete,
.story-card.card-hovered .btn-delete {
    opacity: 1;
}

/* Slice delete button - static positioning */
.slice-label-container .btn-delete {
    position: static;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    font-size: 12px;
}

/* Slice controls row (drag handle + delete) */
.slice-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: auto;
    padding-top: 8px;
    cursor: default;
}

/* Slice drag handle */
.slice-drag-handle {
    cursor: grab;
    color: var(--color-text-disabled);
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 2px;
    transition: color 0.15s ease, background-color 0.15s ease;
    user-select: none;
}

.slice-drag-handle:hover {
    color: var(--color-text-muted);
    background-color: rgba(0, 0, 0, 0.05);
}

/* Slice Menu */
.slice-menu {
    position: relative;
}

.btn-slice-menu {
    width: 24px;
    height: 24px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.btn-slice-menu:hover {
    background: var(--color-border-medium);
}

.slice-menu-dropdown {
    display: none;
    position: absolute;
    top: 0;
    left: 100%;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    z-index: 100;
    padding: 4px 0;
    margin-left: 4px;
}

.slice-menu-dropdown.visible {
    display: block;
}

.slice-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.slice-menu-item:hover {
    background-color: #f5f5f5;
}

.slice-menu-item-danger:hover {
    background-color: #fef2f2;
    color: #dc2626;
}

.slice-menu-icon {
    font-size: 14px;
}

/* Collapsed Slice */
.slice-collapsed {
    min-height: auto;
}

.slice-collapsed .slice-label-container {
    min-height: 36px;
}

.slice-completed-row {
    position: relative;
    min-height: 36px;
}

.collapsed-column-placeholder {
    min-height: 36px;
    visibility: hidden;
}

.slice-completed-banner {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid #6ee7b7;
    border-radius: 4px;
    padding: 6px 16px;
    z-index: 1;
}

.slice-completed-text {
    font-size: 11px;
    font-weight: 500;
    color: #065f46;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.slice-closed-banner {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #45b2e1;
}
.slice-closed-banner .slice-completed-text {
    color: #1e40af;
}

/* Card Options Menu */
.card-options {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 10;
    display: flex;
    gap: 2px;
}

.btn-options {
    width: 24px;
    height: 24px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

.btn-options:hover {
    background-color: #f0f0f0;
}

.btn-expand {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    z-index: 10;
}

.btn-expand:hover {
    background-color: #f0f0f0;
}

.story-card.has-body .btn-expand {
    opacity: 0.5;
}

.step:hover .btn-expand,
.story-card:hover .btn-expand,
.step:hover .btn-options,
.story-card:hover .btn-options,
.step.card-hovered .btn-expand,
.story-card.card-hovered .btn-expand,
.step.card-hovered .btn-options,
.story-card.card-hovered .btn-options {
    opacity: 1;
}

.story-card:has(.card-tag-overflow:hover) .btn-options,
.story-card:has(.card-tag-overflow:hover) .btn-expand {
    opacity: 0 !important;
}


.step.menu-open,
.story-card.menu-open {
    z-index: 50;
}

.options-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    padding: 6px 0;
    display: none;
    z-index: 100;
}

.options-menu.visible {
    display: block;
}

.options-menu.flip-left {
    right: auto;
    left: 0;
}

.options-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.options-item:hover {
    background-color: #f5f5f5;
}

.options-color {
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: default;
}

.options-color:hover {
    background-color: transparent;
}

.options-color span {
    font-size: 13px;
    color: var(--color-text-primary);
}

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 182px;
}

.color-swatch {
    width: 22px;
    height: 22px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border-color: var(--color-text-primary);
}

/* Status swatches in options menu */
.options-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
}

.status-swatches {
    display: flex;
    gap: 4px;
}

.status-swatch {
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.status-swatch:hover {
    transform: scale(1.15);
}

.status-swatch.selected {
    border-color: var(--color-text-primary);
}

.status-swatch.status-none {
    background-color: var(--color-border-medium);
    color: var(--color-text-faint);
    font-size: 12px;
    line-height: 14px;
    text-align: center;
}

/* Status indicator on cards */
.status-indicator {
    position: absolute;
    bottom: 6px;
    left: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    z-index: 5;
}

/* Points badge on cards */
.points-badge {
    position: absolute;
    bottom: 4px;
    left: 20px;
    font-size: 10px;
    font-weight: 600;
    color: #444;
    background: rgba(255, 255, 255, 0.75);
    padding: 1px 5px;
    border-radius: 8px;
    line-height: 1.4;
    z-index: 5;
}

/* Points input in options menu */
.options-points {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
}

.points-input {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    text-align: center;
}

.points-input:focus {
    outline: none;
    border-color: var(--color-teal);
}

.options-delete {
    color: #dc2626;
    border-top: 1px solid var(--color-border-subtle);
    margin-top: 4px;
    padding-top: 10px;
}

.options-delete:hover {
    background-color: #fef2f2;
}

.options-delete-column {
    color: #dc2626;
    font-weight: 500;
}

.options-delete-column:hover {
    background-color: #fef2f2;
}

/* URL Indicator */
.url-indicator {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 14px;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 5;
}

.url-indicator:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Welcome Screen */
.welcome-screen {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--color-welcome-bg-from) 0%, var(--color-welcome-bg-to) 100%);
    position: relative;
}

@keyframes welcomeFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-screen.visible .welcome-content {
    animation: welcomeFadeIn 0.45s ease both;
}

.welcome-screen.visible {
    display: flex;
}

/* Split layout — text left, visual right */
.welcome-split {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 48px 40px;
    gap: 80px;
    width: 100%;
}

.welcome-content {
    text-align: center;
    flex: 1;
    min-width: 0;
}


mark.highlight {
    color: #333;
    background: linear-gradient(
        120deg,
        rgba(254,240,138,0.5) 0%,
        rgba(254,205,211,0.5) 30%,
        rgba(165,243,252,0.5) 65%,
        rgba(22,155,222,0.35) 100%
    );
    border-radius: 4px;
    padding: 2px 6px;
    margin: 0 1px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

html.dark-mode mark.highlight {
    color: #c1c2c5;
    background: linear-gradient(
        120deg,
        rgba(254,240,138,0.25) 0%,
        rgba(254,205,211,0.2) 30%,
        rgba(165,243,252,0.2) 65%,
        rgba(22,155,222,0.2) 100%
    );
}

.welcome-content h1 {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: #111;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
    line-height: 1.1;
    white-space: nowrap;
}

.welcome-subtitle {
    font-size: 15px;
    line-height: 1.6;
    color: #555;
    margin-bottom: 12px;
}

.welcome-integrations-text {
    font-size: 13px;
    color: #888;
    margin-bottom: 10px;
    text-align: center;
}

.welcome-integrations {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 32px;
}

.welcome-integration {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    background: var(--color-bg-surface);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 7px 14px 7px 10px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.welcome-integration:hover {
    border-color: var(--color-teal);
    box-shadow: 0 2px 8px rgba(22, 155, 222, 0.15);
    transform: translateY(-1px);
}

.welcome-integration svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nowrap {
    white-space: nowrap;
}

/* Visual panel — elevated product screenshot */
.welcome-visual {
    flex: 1.5;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-hero-img {
    width: 100%;
    max-width: 1532px;
    height: auto;
    border-radius: 12px;
    box-shadow:
        0 20px 40px rgba(0,0,0,0.12),
        0 8px 16px rgba(0,0,0,0.08);
    border: 1px solid #c1c2c5;
}

@keyframes heroImgIn {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-screen.visible .welcome-hero-img {
    animation: heroImgIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.welcome-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.welcome-counter {
    display: none;
    font-size: 13px;
    color: #555;
}

.welcome-counter.visible {
    display: block;
}

.welcome-counter .count {
    font-weight: 600;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.welcome-cta-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.btn-large {
    padding: 14px 36px;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(22, 155, 222, 0.3);
}

.btn-large:hover {
    box-shadow: 0 4px 16px rgba(22, 155, 222, 0.35);
    transform: translateY(-1px);
}

.btn-large.btn-secondary {
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-large.btn-secondary:hover {
    transform: none;
}


.welcome-samples {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.welcome-samples-label {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 0;
}

.welcome-samples-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.btn-sample {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--color-text-primary);
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.btn-sample:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-sample-yellow { background: var(--color-bg-surface); border-color: #e5e7eb; }
.btn-sample-yellow::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: #fad875; margin-right: 8px; flex-shrink: 0; }

.btn-sample-pink { background: var(--color-bg-surface); border-color: #e5e7eb; }
.btn-sample-pink::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: #ea6582; margin-right: 8px; flex-shrink: 0; }

.btn-sample-cyan { background: var(--color-bg-surface); border-color: #e5e7eb; }
.btn-sample-cyan::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: #30d3ef; margin-right: 8px; flex-shrink: 0; }

.btn-sample-teal { background: var(--color-bg-surface); border-color: #e5e7eb; }
.btn-sample-teal::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: #169bde; margin-right: 8px; flex-shrink: 0; }

.btn-sample-purple { background: var(--color-bg-surface); border-color: #e5e7eb; }
.btn-sample-purple::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: #9f7dd0; margin-right: 8px; flex-shrink: 0; }

.btn-sample-green { background: var(--color-bg-surface); border-color: #e5e7eb; }
.btn-sample-green::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: #77bf81; margin-right: 8px; flex-shrink: 0; }


/* Bottom section — learn more */
.welcome-bottom {
    border-top: 1px solid #e8ecf0;
    padding: 24px 48px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.welcome-learn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.welcome-learn-groups {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.welcome-learn-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.welcome-learn-group-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.welcome-learn-group-cards {
    display: flex;
    gap: 8px;
}

.welcome-learn-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--color-bg-surface);
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    color: #444;
    font-size: 12px;
    font-weight: 500;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    min-width: 90px;
    height: 90px;
}

.welcome-learn-card:hover {
    border-color: var(--color-teal);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.welcome-learn-icon {
    width: 36px;
    height: 36px;
}

.welcome-learn-book {
    height: 36px;
    width: auto;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.welcome-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--color-text-secondary);
    padding: 16px 48px;
    border-top: 1px solid #e8ecf0;
}

.welcome-footer .footer-main {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.welcome-footer .footer-text {
    text-align: center;
}

.welcome-footer .footer-support {
    display: flex;
    align-items: center;
}

.welcome-footer .footer-legal {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-faint);
}

.welcome-footer .footer-dot {
    color: var(--color-text-disabled);
}

.welcome-footer .bmc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #FFDD00;
    border-radius: 8px;
    padding: 6px 10px;
    text-decoration: none;
}

.welcome-footer .bmc-btn:hover {
    opacity: 0.85;
}

.welcome-footer .bmc-btn svg {
    height: 32px;
    width: auto;
}

.welcome-footer a {
    color: var(--color-teal);
    text-decoration: none;
}

.welcome-footer a:hover {
    text-decoration: underline;
}

.welcome-footer .footer-legal a {
    color: var(--color-text-faint);
}

.welcome-footer .footer-legal a:hover {
    color: var(--color-teal);
}

.mobile-only {
    display: none;
}

.desktop-only {
    display: inline;
}

/* Responsive - Tablet welcome layout (stack instead of side-by-side) */
@media (max-width: 1100px) {
    .welcome-split {
        flex-direction: column;
        align-items: center;
        gap: 32px;
    }

    .welcome-content {
        flex: none;
        max-width: 600px;
    }

    .welcome-content h1 {
        white-space: normal;
    }

    .welcome-visual {
        flex: none;
        max-width: 640px;
        width: 100%;
    }
}

/* Responsive - Tablet */
@media (max-width: 900px) {
    body.welcome-visible .community-link {
        display: none;
    }


    body.welcome-visible {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .steps-row-spacer,
    .slice-label-container {
        width: 60px;
        padding-right: 12px;
    }

    .slice-label {
        font-size: 10px;
    }

    .logo-text {
        font-size: 18px;
    }

    .step,
    .step-placeholder {
        width: 140px;
        min-height: 80px;
    }

    .step {
        padding: 10px 10px;
    }

    .step-text {
        font-size: 12px;
    }

    .story-column {
        width: 140px;
    }

    .story-card {
        min-height: 75px;
        padding: 8px 8px;
    }

    .story-text {
        font-size: 12px;
    }

    .btn-expand,
    .btn-options {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }

    .status-indicator {
        width: 8px;
        height: 8px;
    }

    .points-badge {
        font-size: 9px;
        left: 17px;
        padding: 0 4px;
    }

    .url-indicator {
        font-size: 12px;
    }

    .card-tag-badge {
        font-size: 8px;
        max-width: 44px;
        padding: 0 4px;
    }

    .card-tag-overflow {
        font-size: 8px;
    }

    .row-label-container {
        width: 60px;
        padding-right: 8px;
    }

    .row-type-label {
        font-size: 9px;
    }

    .story-map-wrapper {
        padding-bottom: 60px;
    }

    .welcome-split {
        padding: 24px 24px;
        gap: 24px;
    }

    .welcome-content h1 {
        font-size: 32px;
        margin-bottom: 8px;
    }

    .welcome-subtitle {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .welcome-integrations {
        margin-bottom: 20px;
    }

    .welcome-actions {
        gap: 10px;
    }

    .welcome-samples-list {
        gap: 6px;
    }

    .btn-sample {
        font-size: 11px;
        padding: 6px 10px;
    }

    .btn-large {
        padding: 10px 24px;
        font-size: 14px;
    }

    .welcome-samples-label {
        font-size: 12px;
    }

    .welcome-bottom {
        padding: 16px 24px;
    }

    .welcome-learn-groups {
        gap: 16px;
    }

    .welcome-learn-group-cards {
        gap: 6px;
    }

    .welcome-learn-group-label {
        font-size: 10px;
    }

    .welcome-learn-card {
        padding: 10px 12px;
        font-size: 11px;
        min-width: 80px;
        height: 80px;
    }

    .welcome-learn-icon {
        width: 28px;
        height: 28px;
    }

    .welcome-learn-book {
        height: 32px;
    }

    .welcome-footer {
        margin-top: 24px;
        padding-top: 10px;
        padding-left: 24px;
        padding-right: 24px;
        font-size: 11px;
    }

    .welcome-footer .footer-main {
        flex-direction: column;
        gap: 10px;
    }

    .welcome-footer .footer-legal {
        font-size: 11px;
    }

}

/* Responsive - Mobile */
@media (max-width: 600px) {
    .mobile-only {
        display: inline;
    }

    .desktop-only {
        display: none;
    }

    body {
        padding: 12px;
    }

    .header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 0;
        margin-bottom: 16px;
    }

    .logo {
        order: 1;
    }

    .header-actions {
        order: 2;
        margin-left: auto;
        gap: 4px;
    }

    .header-actions .btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .header-actions .btn-icon {
        padding: 6px 8px;
        font-size: 14px;
    }

    .header-actions .btn-icon svg {
        width: 12px;
        height: 12px;
    }

    .header-actions #shareBtn,
    .header-actions #buildAiBtn {
        height: 28px;
        padding: 0 8px;
    }

    .header-actions .btn-label {
        display: none;
    }

    .search-bar {
        order: 4;
        flex: 0 0 100%;
        max-width: none;
        margin: 0;
    }

    .board-name {
        order: 3;
        flex: 0 0 100%; /* Reset flex and force full width */
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 6px 10px;
        font-size: 14px;
    }

    .board-name.hidden {
        display: none;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .story-map-wrapper {
        margin: 0 -12px;
        padding: 0 12px 60px;
        width: calc(100% + 24px);
    }

    .story-map {
        display: flex;
        width: 100%;
        margin: 0;
        min-width: 0; /* Override infinite-canvas min-width on mobile */
    }

    .welcome-split {
        flex-direction: column;
        padding: 20px 16px;
        gap: 24px;
        align-items: stretch;
    }

    .welcome-content {
        flex: none;
        max-width: 100%;
        text-align: center;
    }

    .welcome-content h1 {
        font-size: 28px;
        white-space: normal;
    }

    .welcome-actions {
        align-items: center;
    }

    .welcome-samples {
        align-items: center;
    }

    .welcome-samples-list {
        justify-content: center;
    }

    .welcome-visual {
        display: none;
    }

    .welcome-bottom {
        padding: 16px;
    }

    .welcome-learn-groups {
        flex-wrap: wrap;
        gap: 12px;
    }

    .welcome-learn-group-cards {
        gap: 4px;
    }

    .welcome-learn-group-label {
        font-size: 9px;
    }

    .welcome-learn-card {
        padding: 8px 10px;
        font-size: 10px;
        min-width: 70px;
        height: 68px;
    }

    .welcome-learn-icon {
        width: 24px;
        height: 24px;
    }

    .welcome-learn-book {
        height: 26px;
    }

    .steps-row-spacer,
    .slice-label-container,
    .row-label-container {
        width: 50px;
        padding-right: 8px;
    }

    .slice-label,
    .row-type-label {
        font-size: 9px;
    }

    .step,
    .step-placeholder {
        width: 120px;
        min-height: 70px;
    }

    .step {
        padding: 8px 8px;
    }

    .step-text {
        font-size: 11px;
    }

    .story-column {
        width: 120px;
    }

    .story-card {
        min-height: 65px;
        padding: 6px 6px;
    }

    .story-text {
        font-size: 11px;
    }

    .btn-expand,
    .btn-options {
        width: 18px;
        height: 18px;
        font-size: 11px;
    }

    .status-indicator {
        width: 7px;
        height: 7px;
        bottom: 5px;
        left: 5px;
    }

    .points-badge {
        font-size: 8px;
        left: 14px;
        bottom: 3px;
        padding: 0 3px;
    }

    .url-indicator {
        font-size: 11px;
        bottom: 3px;
        right: 3px;
    }

    .card-tag-badge {
        font-size: 7px;
        max-width: 36px;
        padding: 0 3px;
    }

    .card-tag-overflow {
        font-size: 7px;
    }

    .card-tags-row {
        display: none;
    }

    .points-badge {
        display: none;
    }

    .zoom-controls {
        padding: 3px;
    }

    .zoom-btn {
        width: 28px;
        height: 26px;
        font-size: 14px;
    }

    .zoom-btn.zoom-level {
        padding: 0 8px;
        font-size: 11px;
    }

    .view-controls {
        padding: 3px;
    }

    .view-btn {
        width: 28px;
        height: 26px;
    }

    .nav-arrow {
        display: none !important;
    }

    .viewer-count,
    .active-mappers {
        display: none !important;
    }


    .welcome-screen {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .welcome-screen {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    .welcome-screen::-webkit-scrollbar {
        display: none;
    }

    .welcome-footer {
        margin-top: 16px;
        padding-left: 16px;
        padding-right: 16px;
    }

    .welcome-footer .footer-main {
        flex-direction: column;
        gap: 10px;
    }

    .welcome-footer .footer-legal {
        font-size: 10px;
    }

    .loading-indicator {
        padding: 20px 24px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
        max-width: 90vw;
    }

    .loading-indicator span {
        white-space: nowrap !important;
    }

    /* Touch-friendly drag handles - always visible since no hover on touch */
    .step-drag-handle {
        opacity: 1;
        padding: 4px 6px;
    }

    .slice-drag-handle {
        color: var(--color-text-faint);
        padding: 4px 6px;
    }

    /* Show delete buttons on mobile (no hover) */
    .step .btn-delete,
    .story-card .btn-delete,
    .slice-label-container .btn-delete {
        opacity: 1;
    }

    /* Larger touch target for slice controls */
    .slice-controls-row {
        padding-top: 12px;
    }

    /* Adjust slice gutter width for narrower screens */
    .slice-label-container {
        min-width: 50px;
    }

    .btn-add-slice {
        font-size: 11px;
        padding: 3px 6px;
    }

    .filter-panel {
        width: calc(100vw - 24px);
        left: 0;
        right: 0;
        transform: none;
        margin-left: auto;
        margin-right: auto;
    }

}

@media (max-width: 400px) {
    .logo-text {
        display: none;
    }
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xl);
    padding: 32px 48px;
    background: var(--color-bg-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-modal);
    z-index: 3000;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.loading-indicator.visible {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-loading-spinner-track);
    border-top-color: var(--color-teal);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Import Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: var(--color-bg-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-modal);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border-medium);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

/* Custom dialog modals (replace native alert/confirm/prompt) */
.dialog-overlay { z-index: 2100; }
.dialog-modal {
    max-width: 440px;
    width: 90vw;
    padding: 24px;
    border-radius: 12px;
}
.dialog-message {
    font-size: 15px;
    color: var(--color-text-primary);
    margin-bottom: 16px;
    white-space: pre-line;
    line-height: 1.5;
}
.dialog-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-bottom: 16px;
    outline: none;
}
.dialog-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15); }
.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.dialog-btn {
    padding: 8px 18px;
    font-size: 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
}
.dialog-btn-cancel {
    background: #f3f4f6;
    color: #374151;
}
.dialog-btn-cancel:hover { background: #e5e7eb; }
.dialog-btn-ok {
    background: #3b82f6;
    color: #fff;
}
.dialog-btn-ok:hover { background: #2563eb; }

.import-modal-body {
    display: flex;
    gap: 24px;
    min-height: 400px;
}

.import-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.import-column h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 4px 0;
}

.import-column p {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 0 0 16px 0;
}

.import-column-json {
    flex: 1.2;
}

.import-textarea {
    flex: 1;
    min-height: 280px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: none;
    margin-bottom: 12px;
    background: var(--color-bg-surface-alt);
    color: var(--color-text-primary);
}

.import-textarea:focus {
    outline: none;
    border-color: var(--color-teal);
    background: var(--color-bg-surface);
}

.import-textarea::placeholder {
    color: var(--color-text-faint);
}

.import-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}

.import-divider span {
    color: var(--color-text-faint);
    font-size: 13px;
    background: var(--color-bg-surface);
    padding: 8px 0;
}

.import-column-file {
    flex: 0.8;
}

.import-file-dropzone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    border: 2px dashed var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-surface-alt);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    padding: 24px;
    text-align: center;
}

.import-file-dropzone:hover,
.import-file-dropzone.dragover {
    border-color: var(--color-teal);
    background: rgba(22, 155, 222, 0.05);
}

.import-file-icon {
    color: var(--color-text-faint);
    transition: color 0.15s ease;
}

.import-file-dropzone:hover .import-file-icon,
.import-file-dropzone.dragover .import-file-icon {
    color: var(--color-teal);
}

.import-file-dropzone span {
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* Export Modal */
.export-modal-body {
    display: flex;
    gap: 24px;
    min-height: 400px;
}

.export-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.export-column h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.export-column p {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 0 0 16px 0;
}

.export-column-json {
    flex: 1.2;
}

.export-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.import-validation-error {
    color: #dc2626;
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.import-validation-error.hidden {
    display: none;
}

.export-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-secondary);
    cursor: pointer;
}

.export-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-teal);
}

.export-textarea {
    flex: 1;
    min-height: 280px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: none;
    margin-bottom: 12px;
    background: var(--color-bg-surface-alt);
    color: var(--color-text-primary);
}

.export-textarea:focus {
    outline: none;
    border-color: var(--color-teal);
}

.export-actions {
    display: flex;
    gap: 8px;
}

.export-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}

.export-divider span {
    color: var(--color-text-faint);
    font-size: 13px;
    background: var(--color-bg-surface);
    padding: 8px 0;
}

.export-column-file {
    flex: 0.8;
    justify-content: flex-start;
}

.export-file-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.export-filename-row {
    display: flex;
    align-items: center;
}

.export-filename {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px 0 0 6px;
    font-family: inherit;
    font-size: 14px;
    color: var(--color-text-primary);
    background: var(--color-bg-surface);
}

.export-filename:focus {
    outline: none;
    border-color: var(--color-teal);
}

.export-filename::placeholder {
    color: var(--color-text-faint);
}

.export-filename-ext {
    padding: 10px 12px;
    background: #f0f0f0;
    border: 1px solid var(--color-border);
    border-left: none;
    border-radius: 0 6px 6px 0;
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* Responsive - Modal */
@media (max-width: 700px) {
    .import-modal-body,
    .export-modal-body {
        flex-direction: column;
        min-height: auto;
    }

    .import-column-json,
    .import-column-file,
    .export-column-json,
    .export-column-file {
        flex: none;
    }

    .import-textarea,
    .export-textarea {
        min-height: 200px;
    }

    .import-divider,
    .export-divider {
        padding: 8px 0;
    }

    .import-file-dropzone {
        min-height: 150px;
    }

    .export-fields-row {
        flex-direction: column;
        gap: 12px;
    }

    .export-fields-row .export-field[style] {
        flex: none !important;
    }

    .export-step-content {
        padding-left: 0 !important;
        gap: 12px;
    }

    .export-verify-row {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .api-export-modal-body {
        gap: 12px;
    }

    .export-field-input {
        width: auto;
        max-width: 100%;
        box-sizing: border-box;
    }

    .export-step-content,
    .export-fields-row,
    .export-field {
        min-width: 0;
        max-width: 100%;
    }

    .modal-overlay {
        padding: 10px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-body {
        padding: 12px;
    }

    .api-export-modal .export-actions,
    .export-modal .export-actions {
        margin: 0 -12px -12px;
        padding: 12px;
        bottom: -12px;
    }

    .export-instructions {
        gap: 16px;
    }
}

/* Jira Export Modal */
.jira-export-modal {
    max-width: 900px;
}

.jira-export-help-link {
    font-size: 13px;
    font-weight: 400;
    color: #0052CC;
    text-decoration: none;
}

.jira-export-help-link:hover {
    text-decoration: underline;
}

.jira-export-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.jira-csv-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.jira-csv-warning a {
    color: #991b1b;
    font-weight: 600;
    text-decoration: underline;
}

.jira-csv-warning a:hover {
    color: #7f1d1d;
}

.jira-export-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jira-project-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jira-project-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.jira-project-input {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
}

.jira-project-input:focus {
    outline: none;
    border-color: var(--color-teal);
}

.jira-space-name {
    width: 180px;
}

.jira-space-key {
    width: 100px;
    text-transform: uppercase;
}

.jira-project-type {
    width: 110px;
    cursor: pointer;
    background: var(--color-bg-surface);
}

.jira-project-input:focus {
    outline: none;
    border-color: var(--color-teal);
}

.jira-export-filters {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.jira-export-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jira-export-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.jira-export-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.jira-export-count {
    font-weight: 400;
    color: var(--color-text-secondary);
    font-size: 13px;
}

.jira-export-section-desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 0;
}

/* Slice checkboxes */
.jira-export-slices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.jira-slice-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.jira-slice-checkbox:hover {
    background: #e5e7eb;
}

.jira-slice-checkbox.checked {
    background: #dbeafe;
    border-color: #3b82f6;
}

.jira-slice-checkbox input {
    margin: 0;
    cursor: pointer;
    accent-color: #3b82f6;
}

.jira-slice-name {
    font-size: 13px;
    color: var(--color-text-primary);
    font-weight: 500;
}

.jira-slice-count {
    color: var(--color-text-secondary);
    font-size: 12px;
    margin-left: 2px;
}

/* Status mapping */
.jira-export-status-mapping {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.jira-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jira-status-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    min-width: 50px;
}

.jira-status-input {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    width: 120px;
    color: var(--color-text-primary);
}

.jira-status-input:focus {
    outline: none;
    border-color: var(--color-teal);
}

/* Epics list */
.jira-export-epics {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jira-export-epic {
    background: var(--color-bg-surface-alt);
    border: 1px solid var(--color-border-medium);
    border-radius: 8px;
    padding: 16px;
    transition: opacity 0.15s ease;
}

.jira-export-epic.excluded {
    opacity: 0.5;
}

.jira-export-epic-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.jira-export-epic-checkbox {
    margin: 0;
    cursor: pointer;
    accent-color: #3b82f6;
    width: 18px;
    height: 18px;
}

.jira-export-epic-name {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
    background: var(--color-bg-surface);
}

.jira-export-epic-name:focus {
    outline: none;
    border-color: var(--color-teal);
}

.jira-export-epic-type {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--color-text-primary);
    background: var(--color-bg-surface);
    cursor: pointer;
}

.jira-export-epic-type:focus {
    outline: none;
    border-color: var(--color-teal);
}

.jira-export-epic-description {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: var(--color-text-primary);
    background: var(--color-bg-surface);
    resize: vertical;
    min-height: 60px;
    margin-bottom: 12px;
}

.jira-export-epic-description:focus {
    outline: none;
    border-color: var(--color-teal);
}

.jira-export-epic-description::placeholder {
    color: var(--color-text-faint);
}

.jira-export-tasks {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 12px;
    border-left: 2px solid var(--color-border-medium);
    margin-left: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.jira-export-task {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 4px 0;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.jira-export-task:hover .jira-export-task-name {
    color: #000;
}

.jira-export-task.excluded {
    opacity: 0.5;
}

.jira-export-task-checkbox {
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
    accent-color: #3b82f6;
}

.jira-export-task-name {
    flex: 1;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jira-export-task-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
}

.jira-export-task-status.done {
    background: #dcfce7;
    color: #166534;
}

.jira-export-task-status.in-progress {
    background: #fef3c7;
    color: #92400e;
}

.jira-export-task-status.planned {
    background: #e5e7eb;
    color: #4b5563;
}

.jira-export-task-status.none {
    background: #f3f4f6;
    color: #6b7280;
}

.jira-export-task-count {
    font-size: 12px;
    color: var(--color-text-faint);
    font-style: italic;
    padding: 2px 0;
}

.jira-export-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-medium);
    position: sticky;
    bottom: -24px;
    background: var(--color-bg-surface);
    margin: 0 -24px -24px;
    padding: 16px 24px;
}

/* API Export Modals (Phabricator, Jira API, Asana API, Asana CSV) */
.api-export-modal {
    max-width: 900px;
}

.api-export-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.export-stage.hidden {
    display: none;
}

.export-filters {
    display: flex;
    column-gap: 32px;
    row-gap: 12px;
    flex-wrap: wrap;
}

.export-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.export-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.export-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 12px 0 0 0;
}

.export-section:first-child .export-section-title {
    margin-top: 0;
}

.export-count {
    font-weight: 400;
    color: var(--color-text-secondary);
    font-size: 13px;
}

.export-slices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.export-slice-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.export-slice-checkbox:hover {
    background: #e5e7eb;
}

.export-slice-checkbox.checked {
    background: #dbeafe;
    border-color: #3b82f6;
}

.export-slice-checkbox input {
    margin: 0;
    cursor: pointer;
    accent-color: #3b82f6;
}

.export-slice-name {
    font-size: 13px;
    color: var(--color-text-primary);
    font-weight: 500;
}

.export-slice-count {
    color: var(--color-text-secondary);
    font-size: 12px;
    margin-left: 2px;
}

.export-epics {
    max-height: 300px;
    overflow-y: auto;
}

.export-epic {
    background: var(--color-bg-surface-alt);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.export-epic.excluded {
    opacity: 0.5;
}

.export-epic-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.export-epic-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.export-epic-name {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

.export-epic-name:focus {
    outline: none;
    border-color: var(--color-teal);
}

.export-epic-type {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 13px;
    background: var(--color-bg-surface);
    cursor: pointer;
}

.export-epic-type:focus {
    outline: none;
    border-color: var(--color-teal);
}

.export-epic-description {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 13px;
    resize: vertical;
    min-height: 40px;
    font-family: inherit;
    margin-bottom: 8px;
}

.export-epic-description:focus {
    outline: none;
    border-color: var(--color-teal);
}

.export-epic-description::placeholder {
    color: var(--color-text-faint);
}

.export-tasks {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 30px;
}

.export-task {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.export-task:hover .export-task-name {
    color: #000;
}

.export-task.excluded {
    opacity: 0.5;
}

.export-task-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.export-task-name {
    flex: 1;
    font-size: 13px;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.export-task-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.export-task-status.done {
    background: #dcfce7;
    color: #166534;
}

.export-task-status.in-progress {
    background: #dbeafe;
    color: #1e40af;
}

.export-task-status.planned {
    background: #e5e7eb;
    color: #4b5563;
}

.export-task-status.none {
    background: #f3f4f6;
    color: #6b7280;
}

.export-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-medium);
    position: sticky;
    bottom: -24px;
    background: var(--color-bg-surface);
    margin: 0 -24px -24px;
    padding: 16px 24px;
}

/* Phabricator Instructions Stage */
.export-instructions {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.export-step {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-step-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.export-step-number {
    width: 28px;
    height: 28px;
    background: var(--color-teal);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.export-step-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.export-step-content {
    padding-left: 40px;
    padding-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.export-step-desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 0;
    padding-left: 40px;
}

.export-fields-row {
    display: flex;
    gap: 20px;
}

.export-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.export-field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.export-token-help {
    font-weight: 400;
    color: #909296;
}

.export-token-help a {
    color: #3b82f6;
    text-decoration: none;
}

.export-token-help a:hover {
    text-decoration: underline;
}

.export-field-tags {
    max-width: 100%;
}

.export-field-tags .export-field-input {
    width: 100%;
    max-width: 400px;
}

.export-field-recommended {
    font-weight: 600;
    color: #059669;
}

.export-field-hint {
    font-size: 11px;
    color: #757575;
    margin-top: 4px;
}

.export-info-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #065f46;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 6px 10px;
    border-radius: 5px;
    max-width: fit-content;
}

.export-info-banner.export-info-warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}
.export-info-banner.export-info-warning .export-info-icon {
    color: #f59e0b;
}

.export-info-icon {
    width: 14px;
    height: 14px;
    color: #10b981;
    flex-shrink: 0;
}

.export-field-input {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    width: 340px;
}

.export-field-input:focus {
    outline: none;
    border-color: var(--color-teal);
}


.export-code-block {
    position: relative;
    margin-left: 40px;
    margin-top: 8px;
    margin-bottom: 16px;
}

.export-code-block pre {
    background: #272727;
    color: #c1c2c5;
    padding: 16px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.export-copy-btn {
    position: absolute;
    top: 16px;
    right: 24px;
    padding: 4px 12px;
    font-size: 12px;
}

/* Remote Cursor Presence */
.cursor-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: visible;
}

.remote-cursor {
    position: absolute;
    pointer-events: none;
    transform: translate(-2px, -2px);
    transition: left 0.05s linear, top 0.05s linear;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.remote-cursor svg {
    display: block;
}

.cursor-label {
    position: absolute;
    top: 22px;
    left: 4px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 4px;
    color: #fff;
    pointer-events: none;
}

.remote-drag-ghost {
    position: absolute;
    pointer-events: none;
    width: var(--card-width);
    min-height: 90px;
    padding: 10px 12px;
    border-radius: 2px;
    border: none;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.2);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    color: #1a1a1a;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 0.85;
    z-index: 999;
    transition: left 0.08s linear, top 0.08s linear;
    animation: ghost-appear 0.15s ease-out;
}

/* Dog-ear corner matching .story-card::before */
.remote-drag-ghost::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.05) 50%);
    border-radius: 0 0 2px 0;
}

/* Colored stripe to identify the dragger */
.remote-drag-ghost::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 2px 0 0 2px;
    background-color: var(--ghost-accent, var(--color-text-muted));
}

/* Column ghost — full column stack (step header + story cards) */
.remote-drag-ghost-column {
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    min-height: auto;
    width: calc(var(--card-width) + 10px);
    padding: 0;
    padding-left: 6px;
    overflow: visible;
    background: transparent !important;
    box-shadow: none;
    border-left: 4px solid var(--ghost-accent, var(--color-text-muted));
    border-radius: 0;
}

.remote-drag-ghost-column::before,
.remote-drag-ghost-column::after {
    display: none;
}

.ghost-column-step {
    background-color: #77bf81;
    color: #0f3d3a;
    font-weight: 600;
    padding: 12px 14px;
    border-radius: 2px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8), 2px 2px 6px rgba(0, 0, 0, 0.15);
}

.ghost-column-card {
    padding: 10px 12px;
    border-radius: 2px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    color: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8), 2px 2px 6px rgba(0, 0, 0, 0.15);
}

@keyframes ghost-appear {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 0.85; transform: scale(1); }
}

.remote-drag-ghost.ghost-drop {
    animation: ghost-drop 0.2s ease-in forwards;
}

@keyframes ghost-drop {
    from { opacity: 0.85; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.5); }
}

/* Tutorial Toast */
.app-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    padding: 10px 20px;
    background: rgba(30, 41, 59, 0.92);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 2001;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.app-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tutorial-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(30, 41, 59, 0.9);
    color: #fff;
    font-size: 13px;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1500;
}

.tutorial-toast.visible {
    display: flex;
}

.tutorial-toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s ease;
}

.tutorial-toast-close:hover {
    color: #fff;
}

@media (max-width: 600px) {
    .tutorial-toast,
    .tutorial-toast.visible {
        display: none;
    }
}

/* Print Styles */
@media print {
    body {
        padding: 0;
        background: white;
        display: block; /* Reset flex for Safari print */
        height: auto;
        overflow: visible;
    }

    .welcome-screen {
        display: none !important;
    }

    .header {
        padding: 12px 0;
        margin-bottom: 16px;
    }

    .header-actions,
    .btn-add-story,
    .btn-add-slice,
    .phantom-step,
    .phantom-column,
    .btn-delete,
    .btn-options,
    .btn-expand,
    .step-drag-handle,
    .slice-drag-handle,
    .slice-controls-row,
    .slice-menu,
    .options-menu,
    .empty-backbone-row,
    .zoom-controls,
    .controls-right,
    .loading-indicator,
    .cursor-overlay,
    .filter-panel,
    .selection-toolbar,
    footer {
        display: none !important;
    }

    .story-map-wrapper {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
    }

    .story-map {
        display: flex;
        margin: 0;
        transform: none !important;
    }

    .story-column {
        break-inside: avoid;
    }

    .slice-container {
        break-inside: avoid;
    }

    .step,
    .story-card {
        box-shadow: none;
        border: 1px solid #ccc;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .step::before,
    .story-card::before {
        display: none;
    }

    .status-indicator {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* =============================================================================
   Lock Feature Styles
   ============================================================================= */

/* Lock Menu Item */
#lockMapBtn,
#relockBtn,
#updatePasswordBtn,
#removeLockBtn {
    display: none;
}

#lockMapBtn.visible,
#relockBtn.visible,
#updatePasswordBtn.visible,
#removeLockBtn.visible {
    display: block;
}

#lockDivider {
    display: none;
}

#lockDivider.visible {
    display: block;
}

.menu-icon,
.lock-menu-icon {
    display: inline-flex;
    width: 22px;
    text-align: center;
    justify-content: center;
    margin-right: 8px;
    font-size: 15px;
}

/* Read-Only Banner */
.read-only-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    padding: 6px 12px;
    text-align: center;
    z-index: 1500;
    font-size: 12px;
    font-weight: 500;
    color: #92400e;
}

.read-only-banner.visible {
    display: block;
}

.read-only-banner-text {
    display: inline-block;
}

/* Adjust body when banner is visible */
body.read-only-mode {
    padding-top: calc(24px + 32px);
}

/* Lock Modal */
.lock-modal {
    max-width: 400px;
}

.lock-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lock-modal-body p {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.5;
}

.lock-password-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lock-password-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.lock-password-field input {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    color: var(--color-text-primary);
    background: var(--color-bg-surface);
}

.lock-password-field input:focus {
    outline: none;
    border-color: var(--color-teal);
}

.lock-modal-note {
    font-size: 12px;
    color: var(--color-text-muted);
    background: var(--color-bg-sunken);
    padding: 10px 12px;
    border-radius: 4px;
    line-height: 1.5;
}

.lock-modal-note strong {
    color: var(--color-text-secondary);
}

.lock-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
}

/* Backups Modal */
.backups-modal {
    max-width: 480px;
}

.backups-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 24px 24px;
}

.backups-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.backups-desc {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0;
}

.backups-create-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 13px;
}

.backups-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.backups-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #b0b0b0;
    font-size: 14px;
    padding: 36px 20px;
}

.backups-empty-icon {
    width: 36px;
    height: 36px;
    opacity: 0.4;
}

.backup-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--color-border-subtle);
    border-bottom-color: #f0f0f0;
    transition: background 0.12s;
}

.backup-row:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.backup-row:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-bottom-color: var(--color-border-subtle);
}

.backup-row + .backup-row {
    border-top: none;
}

.backup-row:hover {
    background: #fafafa;
}

.backup-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f0fdfa;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-teal);
}

.backup-icon.backup-icon-auto {
    background: #f5f5f5;
    color: var(--color-text-placeholder);
}

.backup-icon.backup-icon-imported {
    background: #eff6ff;
    color: #6b8ec2;
}

.backup-icon svg {
    width: 16px;
    height: 16px;
}

.backup-info {
    flex: 1;
    min-width: 0;
}

.backup-time {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.backup-meta {
    font-size: 11px;
    color: var(--color-text-placeholder);
    margin-top: 1px;
}

.backup-imported-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #6b8ec2;
    background: #eff6ff;
    padding: 1px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 4px;
    letter-spacing: 0.02em;
}

.backup-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.backup-actions button {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    background: var(--color-bg-surface);
    cursor: pointer;
    color: #555;
    font-family: inherit;
    transition: all 0.15s;
}

.backup-actions button:hover {
    background: #f5f5f5;
    border-color: var(--color-border-strong);
}

.backup-actions .backup-restore-btn {
    color: var(--color-teal);
    border-color: #b2f0e6;
    background: #f0fdfa;
}

.backup-actions .backup-restore-btn:hover {
    background: #e0faf5;
    border-color: var(--color-teal);
}

.backup-actions .backup-delete-btn {
    color: var(--color-text-disabled);
    border-color: transparent;
    background: transparent;
    padding: 5px 8px;
}

.backup-actions .backup-delete-btn:hover {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fecaca;
}

/* Backup count badge in menu */
.backup-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.07);
    color: var(--color-text-secondary);
    margin-left: 6px;
    line-height: 1;
    vertical-align: middle;
}

.backup-count-badge.hidden {
    display: none;
}

@media (max-width: 480px) {
    .backups-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .backups-create-btn {
        justify-content: center;
    }

    .backup-row {
        gap: 10px;
        padding: 12px;
    }

    .backup-icon {
        display: none;
    }

    .backup-meta {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .backup-actions {
        flex-direction: column;
        gap: 4px;
    }
}

/* Card Expand Modal */
.card-expand-modal {
    max-width: 360px;
    width: min(360px, 90vw);
    border-radius: 2px;
    background-color: #fad875;
    overflow: hidden;
    position: relative;
    box-shadow:
        1px 1px 3px rgba(0, 0, 0, 0.12),
        3px 4px 10px rgba(0, 0, 0, 0.1);
}

.card-expand-modal .modal-header {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 1;
    padding: 0;
    border: none;
    background: none;
}

.card-expand-modal .modal-header h2 {
    display: none;
}

.card-expand-modal .modal-close {
    font-size: 15px;
    padding: 6px 8px;
    line-height: 1;
    border-radius: 4px;
    color: rgba(0, 0, 0, 0.35);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.card-expand-modal .modal-close:hover {
    color: rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.08);
}

.card-expand-modal .modal-body {
    padding: 20px 20px 12px;
}

.card-expand-name,
.card-expand-body {
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    font-family: inherit;
    color: #1a1a1a;
    text-align: left;
    resize: none;
    outline: none;
    box-sizing: border-box;
    caret-color: #1a1a1a;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-scrollbar-thumb) var(--color-scrollbar-track);
}

.card-expand-name {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    max-height: 30vh;
    margin-bottom: 8px;
    overflow: hidden;
}

.card-expand-body {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.55;
    min-height: 180px;
    max-height: 50vh;
}

.card-expand-body::placeholder {
    color: rgba(0, 0, 0, 0.3);
}

.card-expand-name::-webkit-scrollbar,
.card-expand-body::-webkit-scrollbar {
    width: 4px;
}

.card-expand-name::-webkit-scrollbar-track,
.card-expand-body::-webkit-scrollbar-track {
    background: transparent;
}

.card-expand-name::-webkit-scrollbar-thumb,
.card-expand-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

/* Read-Only State - Disable editing UI */
body.read-only-mode .story-card:hover {
    transform: none;
    box-shadow: var(--shadow-card);
}

body.read-only-mode .card-options,
body.read-only-mode .btn-delete,
body.read-only-mode .btn-add-story,
body.read-only-mode .btn-add-slice,
body.read-only-mode .phantom-step,
body.read-only-mode .phantom-column,
body.read-only-mode .step-drag-handle,
body.read-only-mode .slice-drag-handle,
body.read-only-mode .slice-controls-row,
body.read-only-mode .slice-menu {
    display: none !important;
}

body.read-only-mode .story-text,
body.read-only-mode .step-text,
body.read-only-mode .slice-label,
body.read-only-mode .board-name {
    pointer-events: none;
    cursor: default;
}

body.read-only-mode .step-placeholder,
body.read-only-mode .empty-backbone-column {
    pointer-events: none;
    cursor: default;
}


/* Mobile adjustments for lock */
@media (max-width: 600px) {
    .read-only-banner {
        font-size: 11px;
        padding: 5px 10px;
    }

    body.read-only-mode {
        padding-top: calc(12px + 28px);
    }

    .dialog-modal { width: 94vw; padding: 18px; }
    .dialog-btn { padding: 10px 18px; }
}

/* Print: hide lock UI */
@media print {
    #lockMapBtn,
    #lockDivider,
    .read-only-banner,
    .lock-modal,
    .selection-toolbar,
    .canvas-context-menu,
    .dialog-overlay {
        display: none !important;
    }

}

/* =============================================================================
   Column Selection
   ============================================================================= */

.step.column-selected {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.7);
}

.step-placeholder.column-selected {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.7);
    background-color: rgba(59, 130, 246, 0.05);
}

.story-column.column-selected {
    background-color: rgba(59, 130, 246, 0.05);
    border-radius: 4px;
}

.story-card.card-selected {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.7);
}

/* Selection Toolbar, context menu & tag overflow — hidden on touch devices */
@media (hover: none) {
    .selection-toolbar,
    .canvas-context-menu,
    .card-tag-overflow { display: none !important; }
}

@media (any-hover: none) {
    .viewer-count { display: none !important; }

    .story-card.has-body .btn-expand { opacity: 0.5; }
}

/* On touch devices, stretch tabs to full width so they stay aligned
   when the Partials tab is hidden (touch users can't create partials). */
@media (pointer: coarse) {
    .panel-tabs { align-self: stretch; }
}

.selection-toolbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(30, 41, 59, 0.95);
    color: #fff;
    font-size: 13px;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 1500;
    animation: toolbar-appear 0.2s ease-out;
    white-space: nowrap;
}

.selection-toolbar-label {
    font-weight: 500;
    white-space: nowrap;
}

.selection-toolbar-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.selection-toolbar-split {
    position: relative;
    display: flex;
}

.selection-toolbar-duplicate,
.selection-toolbar-delete,
.selection-toolbar-partial {
    color: white;
    border: none;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 6px 0 0 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.selection-toolbar-duplicate { background-color: #3b82f6; }
.selection-toolbar-duplicate:hover { background-color: #2563eb; }

.selection-toolbar-delete { background-color: #ef4444; }
.selection-toolbar-delete:hover { background-color: #dc2626; }

.selection-toolbar-partial { background-color: #0891b2; display: flex; align-items: center; gap: 5px; }
.selection-toolbar-partial:hover { background-color: #0e7490; }
.selection-toolbar-partial svg { width: 14px; height: 14px; flex-shrink: 0; }

.selection-toolbar-split-arrow {
    color: white;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 8px;
    font-size: 10px;
    font-family: inherit;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
}

.selection-toolbar-duplicate-arrow,
.selection-toolbar-split-arrow:not(.selection-toolbar-delete-arrow):not(.selection-toolbar-partial-arrow) {
    background-color: #3b82f6;
}
.selection-toolbar-duplicate-arrow:hover,
.selection-toolbar-split-arrow:not(.selection-toolbar-delete-arrow):not(.selection-toolbar-partial-arrow):hover {
    background-color: #2563eb;
}

.selection-toolbar-delete-arrow {
    background-color: #ef4444;
}
.selection-toolbar-delete-arrow:hover {
    background-color: #dc2626;
}

.selection-toolbar-partial-arrow {
    background-color: #0891b2;
}
.selection-toolbar-partial-arrow:hover {
    background-color: #0e7490;
}

.selection-toolbar-split-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: rgba(30, 41, 59, 0.97);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    min-width: 160px;
    z-index: 1;
}

.selection-toolbar-split-menu.visible {
    display: flex;
    flex-direction: column;
}

.selection-toolbar-split-option {
    background: none;
    border: none;
    color: white;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.1s ease;
}

.selection-toolbar-split-option:hover {
    background: rgba(255, 255, 255, 0.12);
}

.selection-toolbar-split-option.active {
    color: #45b2e1;
}

.selection-toolbar-clear {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s ease;
}

.selection-toolbar-clear:hover {
    color: #fff;
}

@keyframes toolbar-appear {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Don't show selection in read-only mode */
body.read-only-mode .step.column-selected {
    box-shadow: none;
}

body.read-only-mode .story-column.column-selected {
    background-color: transparent;
}

body.read-only-mode .story-card.card-selected {
    box-shadow: none;
}

/* Marquee (rectangle) selection */

.marquee-rect {
    position: fixed;
    border: 2px solid rgba(59, 130, 246, 0.7);
    background-color: rgba(59, 130, 246, 0.1);
    z-index: 1400;
    pointer-events: none;
}

.step.marquee-preview,
.story-card.marquee-preview {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}

.story-map-wrapper.marquee-active {
    user-select: none;
    cursor: crosshair;
}

/* Canvas context menu */

.canvas-context-menu {
    position: fixed;
    z-index: 1500;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 4px;
    min-width: 190px;
    box-shadow: var(--shadow-dropdown), 0 8px 24px rgba(0, 0, 0, 0.08);
    animation: ctx-menu-in 0.12s ease-out;
}

@keyframes ctx-menu-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.canvas-context-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 13px;
    text-align: left;
    white-space: nowrap;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.canvas-context-menu button svg {
    flex-shrink: 0;
    opacity: 0.55;
}

.canvas-context-menu button:hover {
    background: var(--color-hover-bg);
}

.canvas-context-menu button.destructive {
    color: #dc3545;
}

.canvas-context-menu button.destructive svg {
    opacity: 0.7;
}

.canvas-context-menu button.destructive:hover {
    background: #fdf0f1;
}

.context-menu-sep {
    height: 1px;
    background: var(--color-border);
    margin: 4px 0;
}

.ctx-submenu-wrapper { position: relative; }

.ctx-submenu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 13px;
    text-align: left;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.ctx-submenu-trigger:hover { background: var(--color-hover-bg); }

.ctx-submenu-trigger svg { flex-shrink: 0; opacity: 0.55; }

.ctx-submenu-arrow {
    margin-left: auto;
    font-size: 15px;
    opacity: 0.4;
}

.ctx-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 240px;
    margin-left: 2px;
}

.ctx-submenu.visible { display: block; }

/* =============================================================================
   Tags — options menu
   ============================================================================= */

.options-tags {
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: default;
    padding: 8px 12px;
}

.options-tags:hover {
    background-color: transparent;
}

.options-tags > span {
    font-size: 13px;
    color: var(--color-text-primary);
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 10px;
    max-width: 120px;
}

.tag-pill > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-remove {
    background: none;
    border: none;
    color: #0369a1;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 0 1px;
    opacity: 0.6;
}

.tag-remove:hover {
    opacity: 1;
}

.tag-input-wrapper {
    position: relative;
}

.tag-input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
}

.tag-input:focus {
    border-color: #6fc4e8;
}

.tag-autocomplete {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 200;
    max-height: 140px;
    overflow-y: auto;
}

.tag-autocomplete.visible {
    display: block;
}

.tag-suggestion {
    display: block;
    width: 100%;
    padding: 6px 8px;
    background: none;
    border: none;
    text-align: left;
    font-size: 12px;
    font-family: inherit;
    color: var(--color-text-primary);
    cursor: pointer;
}

.tag-suggestion:hover {
    background-color: var(--color-hover-bg);
}

/* Tags — on-card display (bottom-right, next to points) */

.card-tags-row {
    position: absolute;
    bottom: 4px;
    right: 6px;
    display: flex;
    align-items: center;
    gap: 3px;
    z-index: 5;
    max-width: 60%;
}

.url-indicator ~ .card-tags-row {
    right: 24px;
}

.card-tag-badge {
    font-size: 9px;
    font-weight: 500;
    color: #0369a1;
    background: rgba(224, 242, 254, 0.8);
    padding: 1px 5px;
    border-radius: 8px;
    max-width: 54px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.5;
}

.card-tag-overflow {
    position: relative;
    font-size: 9px;
    font-weight: 600;
    color: #0369a1;
    background: rgba(186, 220, 248, 0.6);
    padding: 1px 4px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.5;
    white-space: nowrap;
}

.card-tags-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: -4px;
    background: var(--color-bg-surface);
    border: 1px solid rgba(14, 116, 144, 0.12);
    border-radius: 6px;
    padding: 5px 6px;
    gap: 4px;
    flex-wrap: wrap;
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(14, 116, 144, 0.05);
    min-width: 60px;
    max-width: 200px;
    animation: popover-in 0.12s ease-out;
}

.card-tags-popover::after {
    content: '';
    position: absolute;
    bottom: -4px;
    right: 8px;
    width: 7px;
    height: 7px;
    background: var(--color-bg-surface);
    border-right: 1px solid rgba(14, 116, 144, 0.12);
    border-bottom: 1px solid rgba(14, 116, 144, 0.12);
    transform: rotate(45deg);
}

@keyframes popover-in {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card-tag-overflow:hover .card-tags-popover {
    display: flex;
}

.card-tags-popover-pill {
    font-size: 9px;
    font-weight: 500;
    color: #0e7490;
    background: #ecfeff;
    border: 1px solid rgba(14, 116, 144, 0.1);
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
    line-height: 1.5;
}



/* =============================================================================
   Filter panel
   ============================================================================= */

.search-filter-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all 0.15s ease;
}

.search-filter-btn:hover {
    border-color: #6fc4e8;
    color: var(--color-text-primary);
}

.search-filter-btn.active,
.search-filter-btn.has-filters {
    border-color: #169bde;
    color: #169bde;
    background: rgba(22, 155, 222, 0.05);
}

.filter-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
}

.filter-count.hidden {
    display: none;
}

.filter-panel {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 12px 16px;
    z-index: 200;
    width: 396px;
    max-height: 400px;
    overflow-y: auto;
}

.filter-panel.hidden {
    display: none;
}

.filter-section {
    margin-bottom: 12px;
}

.filter-section:last-of-type {
    margin-bottom: 0;
}

.filter-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 13px;
    color: var(--color-text-primary);
    cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.filter-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.filter-color-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
}

.filter-color-swatch {
    width: 22px;
    height: 22px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.filter-color-swatch:hover {
    transform: scale(1.1);
}

.filter-color-swatch.selected {
    border-color: var(--color-text-primary);
}

.filter-tags-list {
    max-height: 100px;
    overflow-y: auto;
}

.filter-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.filter-color-swatch.filter-disabled {
    opacity: 1;
    position: relative;
}

.filter-color-swatch.filter-disabled::after {
    content: '×';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.4);
    line-height: 1;
}

.filter-empty {
    font-size: 12px;
    color: var(--color-text-placeholder);
    font-style: italic;
}

.filter-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border-subtle);
}

.filter-clear-btn {
    flex: 1;
    padding: 6px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-clear-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.filter-done-btn {
    flex: 1;
    padding: 6px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-done-btn:hover {
    border-color: #169bde;
    color: #169bde;
}

/* =============================================================================
   Bulk ops — selection toolbar dropdowns
   ============================================================================= */

.selection-toolbar-dropdown-group {
    position: relative;
}

.selection-toolbar-action {
    color: white;
    border: none;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.selection-toolbar-color {
    background-color: #8b5cf6;
}

.selection-toolbar-color:hover {
    background-color: #7c3aed;
}

.selection-toolbar-status {
    background-color: #22c55e;
}

.selection-toolbar-status:hover {
    background-color: #16a34a;
}

.selection-toolbar-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-bg-surface);
    border: 1px solid #d4d4d4;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.06);
    padding: 8px;
    z-index: 1;
    width: 280px;
}

.selection-toolbar-dropdown.visible {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}

.selection-toolbar-color-swatch {
    width: 28px;
    height: 28px;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.selection-toolbar-color-swatch:hover {
    transform: scale(1.12);
    border-color: rgba(0, 0, 0, 0.15);
}

.selection-toolbar-color-swatch.swatch-active {
    border-color: var(--color-text-primary);
    box-shadow: 0 0 0 1px var(--color-text-primary);
}

.selection-toolbar-status-swatch {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.selection-toolbar-status-swatch:hover {
    transform: scale(1.15);
}

.selection-toolbar-status-swatch.swatch-active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.selection-toolbar-swatch-none {
    background-color: var(--color-border-subtle);
    color: var(--color-text-faint);
    font-size: 16px;
    line-height: 24px;
    text-align: center;
}

.selection-toolbar-status-dropdown {
    width: 150px;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    gap: 2px !important;
    padding: 4px !important;
}

.selection-toolbar-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #555;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.selection-toolbar-status-row:hover {
    background: #f5f5f5;
    color: #111;
}

.selection-toolbar-status-row.active {
    background: #f0f0f0;
    color: #111;
    font-weight: 600;
}

.selection-toolbar-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.selection-toolbar-tags {
    background-color: #0ea5e9;
}

.selection-toolbar-tags:hover {
    background-color: #0284c7;
}

.selection-toolbar-tags-dropdown {
    width: 240px;
    overflow: hidden !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    padding: 8px !important;
}

.selection-toolbar-tags-scroll {
    max-height: 300px;
    overflow-y: auto;
    flex-shrink: 1;
    min-height: 0;
}

.selection-toolbar-tags-section {
    display: flex;
    flex-direction: column;
}

.selection-toolbar-tags-divider {
    height: 1px;
    background: var(--color-border-medium);
    margin: 6px 0;
    flex-shrink: 0;
}

.selection-toolbar-tag-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    border-radius: 6px;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    margin-bottom: 4px;
}

.selection-toolbar-tag-label {
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 500;
}

.selection-toolbar-tag-remove {
    background: none;
    border: none;
    color: #909296;
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.1s ease;
}

.selection-toolbar-tag-remove:hover {
    color: #ef4444;
}

.selection-toolbar-tag-option {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #555;
    font-size: 12px;
    font-family: inherit;
    padding: 6px 10px;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.1s ease;
}

.selection-toolbar-tag-option:hover {
    background: #f5f5f5;
    color: #111;
}

.selection-toolbar-tag-input-row {
    padding-top: 6px;
    margin-top: 2px;
    border-top: 1px solid var(--color-border-medium);
    flex-shrink: 0;
}

.selection-toolbar-tag-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: #fafafa;
    color: var(--color-text-primary);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.selection-toolbar-tag-input::placeholder {
    color: var(--color-text-disabled);
}

.selection-toolbar-tag-input:focus {
    border-color: #45b2e1;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Focus Mode — hides card metadata for a cleaner view */
body.focus-mode .status-indicator,
body.focus-mode .points-badge,
body.focus-mode .url-indicator,
body.focus-mode .card-tags-row,
body.focus-mode .slice-progress,
body.focus-mode .slice-points-text {
    display: none !important;
}

body.focus-mode .btn-expand {
    opacity: 0 !important;
}

body.focus-mode .story-card:hover .btn-expand,
body.focus-mode .step:hover .btn-expand,
body.focus-mode .story-card.card-hovered .btn-expand,
body.focus-mode .step.card-hovered .btn-expand {
    opacity: 1 !important;
}

/* Build with AI Modal */
@keyframes bai-glow-sweep {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes bai-enter {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.build-ai-modal {
    position: relative;
    max-width: 660px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-surface);
    border-radius: 14px;
    border: 1px solid var(--color-border-medium);
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    animation: bai-enter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.build-ai-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--color-teal) 25%, #67e8f9 50%, var(--color-teal) 75%, transparent 100%);
    background-size: 200% 100%;
    animation: bai-glow-sweep 3s ease-in-out infinite;
}

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

.build-ai-subtitle {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--color-text-faint);
    margin-left: 6px;
}

.build-ai-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.02em;
}

.build-ai-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--color-text-disabled);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.build-ai-close:hover {
    color: var(--color-text-primary);
    background: var(--color-hover-bg);
}

.build-ai-body {
    padding: 16px 20px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.build-ai-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-top: 6px;
}

.build-ai-label:first-child {
    margin-top: 0;
}

.build-ai-targets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 6px;
}

.build-ai-target {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 4px 7px;
    border-radius: 10px;
    border: 1.5px solid var(--color-border);
    background: var(--color-bg-surface);
    color: var(--color-text-muted);
    font-size: 10.5px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    position: relative;
}

.build-ai-target:hover {
    border-color: var(--color-border-strong);
    color: var(--color-text-primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.build-ai-target.selected {
    background: rgba(22, 155, 222, 0.06);
    border-color: var(--color-teal);
    color: var(--color-text-primary);
    box-shadow:
        0 0 0 1px rgba(22, 155, 222, 0.15),
        0 2px 8px rgba(22, 155, 222, 0.1);
    transform: translateY(-1px);
}

.build-ai-logo {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    opacity: 0.65;
    transition: all 0.18s ease;
}

.build-ai-target:hover .build-ai-logo {
    opacity: 0.85;
}

.build-ai-target.selected .build-ai-logo {
    opacity: 1;
    transform: scale(1.08);
}

.build-ai-slice {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--color-border);
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.build-ai-slice:focus {
    outline: none;
    border-color: var(--color-teal);
    box-shadow: 0 0 0 3px rgba(22, 155, 222, 0.1);
}

.build-ai-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
}

.build-ai-toggle-row input[type="checkbox"] {
    display: none;
}

.build-ai-toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--color-border);
    border-radius: 10px;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.build-ai-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.build-ai-toggle-row input:checked + .build-ai-toggle-switch {
    background: var(--color-teal);
}

.build-ai-toggle-row input:checked + .build-ai-toggle-switch::after {
    transform: translateX(16px);
}

.build-ai-toggle-text {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-secondary);
    letter-spacing: 0.01em;
}

.build-ai-toggle-row.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.build-ai-selects-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.build-ai-selects-grid .build-ai-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--color-text-secondary);
}
.build-ai-selects-grid .build-ai-slice {
    width: 100%;
    font-weight: 600;
    padding: 10px 12px;
}

.build-ai-instructions-input {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--color-border);
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.build-ai-instructions-input:focus {
    outline: none;
    border-color: var(--color-teal);
    box-shadow: 0 0 0 3px rgba(22, 155, 222, 0.1);
}

.build-ai-instructions-input::placeholder {
    color: var(--color-text-disabled);
    font-style: italic;
}

.build-ai-prompt-wrap {
    position: relative;
    border-radius: 8px;
    background: #272727;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.build-ai-prompt-wrap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(22, 155, 222, 0.3), transparent);
}

.build-ai-prompt {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Menlo', monospace;
    font-size: 12px;
    line-height: 1.65;
    padding: 12px 14px;
    border: none;
    background: transparent;
    color: #94e2d5;
    resize: none;
    width: 100%;
    box-sizing: border-box;
}

.build-ai-prompt:focus {
    outline: none;
}

.build-ai-prompt::selection {
    background: rgba(22, 155, 222, 0.3);
}

.build-ai-instructions {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.4;
    font-style: italic;
}

.build-ai-instructions a {
    color: var(--color-teal);
    text-decoration: none;
}

.build-ai-instructions a:hover {
    text-decoration: underline;
}

.build-ai-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.build-ai-copy {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #169bde, #0b5a8c);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(22, 155, 222, 0.25);
    position: relative;
    overflow: hidden;
}

.build-ai-copy::before {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.build-ai-copy:hover {
    box-shadow: 0 4px 16px rgba(22, 155, 222, 0.35);
    transform: translateY(-1px);
}

.build-ai-copy:hover::before {
    opacity: 1;
}

.build-ai-copy:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(22, 155, 222, 0.2);
}

@media (max-width: 600px) {
    .build-ai-targets {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }
    .build-ai-modal {
        max-width: 100%;
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .modal-overlay#buildAiModal {
        padding: 0;
    }

    .build-ai-modal {
        max-height: 100vh;
        max-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
    }

    .build-ai-body {
        padding: 12px 16px 16px;
        gap: 6px;
    }

    .build-ai-targets {
        grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
        gap: 5px;
    }

    .build-ai-target {
        padding: 6px 2px 4px;
        gap: 3px;
    }

    .build-ai-logo {
        width: 18px;
        height: 18px;
    }

    .build-ai-target span {
        font-size: 9px;
    }

    #buildAiAgentsLabel,
    #buildAiTargets3 {
        display: none;
    }

    .build-ai-subtitle {
        display: none;
    }

    .build-ai-instructions-input {
        min-height: 4.5em;
    }

    .build-ai-selects-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

html.dark-mode {
    color-scheme: dark;

    /* Surfaces (brand dark palette) */
    --color-bg-page: var(--brand-bg);
    --color-bg-surface: var(--brand-surface);
    --color-bg-surface-alt: var(--brand-surface-alt);
    --color-bg-elevated: var(--brand-dark-4);
    --color-bg-sunken: var(--brand-surface-sunken);

    /* Borders */
    --color-border: var(--brand-border);
    --color-border-subtle: var(--brand-border-subtle);
    --color-border-medium: var(--brand-border);
    --color-border-strong: var(--brand-border-strong);

    /* Text */
    --color-text-primary: var(--brand-text);
    --color-text-secondary: var(--brand-text-secondary);
    --color-text-muted: var(--brand-dark-3);
    --color-text-faint: var(--brand-dark-4);
    --color-text-disabled: var(--brand-dark-4);
    --color-text-placeholder: var(--brand-dark-3);

    /* Inputs */
    --color-input-bg: var(--brand-surface-alt);
    --color-input-border: var(--brand-border);

    /* Scrollbar */
    --color-scrollbar-thumb: rgba(255, 255, 255, 0.12);
    --color-scrollbar-track: transparent;

    /* Accent */
    --color-teal: var(--brand-blue);
    --color-hover-bg: var(--brand-surface-alt);

    /* Shadows */
    --shadow-card: 0 0 8px 2px rgba(22, 155, 222, 0.3);
    --shadow-dropdown: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-hover: 2px 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-modal: 0 4px 24px rgba(0, 0, 0, 0.4);

    /* Component-specific */
    --color-notepad-rule: var(--brand-border-subtle);
    --color-welcome-bg-from: var(--brand-bg);
    --color-welcome-bg-to: var(--brand-surface);
    --color-loading-bg: var(--brand-surface);
    --color-loading-text: var(--brand-dark-3);
    --color-loading-spinner-track: var(--brand-border);
}

/* Card darken for dark mode — semi-transparent overlay via ::after
   (avoids filter compositing fringe at fractional zoom). */
html.dark-mode .story-card,
html.dark-mode .step {
    border: none;
}
html.dark-mode .story-card::after,
html.dark-mode .step::after {
    display: none;
}
html.dark-mode .tag-input,
html.dark-mode .selection-toolbar-tag-input {
    background: var(--color-input-bg);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}
html.dark-mode .tag-autocomplete {
    background: #272727;
    border-color: #373a40;
}
html.dark-mode .tag-suggestion {
    color: #c1c2c5;
}
html.dark-mode .tag-suggestion:hover {
    background-color: #373a40;
}
html.dark-mode .selection-toolbar-tag-option {
    color: #c1c2c5;
}
html.dark-mode .selection-toolbar-tag-option:hover {
    background: #373a40;
    color: #fafafa;
}
html.dark-mode .selection-toolbar-tag-label {
    color: #45b2e1;
}
html.dark-mode .selection-toolbar-status-row {
    color: #c1c2c5;
}
html.dark-mode .selection-toolbar-status-row:hover {
    background: #373a40;
    color: #fafafa;
}
html.dark-mode .selection-toolbar-status-row.active {
    background: #373a40;
    color: #fafafa;
}
html.dark-mode .card-expand-modal {
    filter: brightness(0.85) saturate(1.15);
}

html.dark-mode .build-ai-modal {
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.4),
        0 0 1px rgba(255, 255, 255, 0.05);
}
html.dark-mode .build-ai-logo {
    opacity: 0.85;
    filter: brightness(1.2) drop-shadow(0 0 3px rgba(255,255,255,0.15));
}
html.dark-mode .build-ai-target:hover .build-ai-logo {
    opacity: 1;
    filter: brightness(1.3) drop-shadow(0 0 6px rgba(255,255,255,0.25));
}
html.dark-mode .build-ai-target.selected .build-ai-logo {
    opacity: 1;
    filter: brightness(1.3) drop-shadow(0 0 8px rgba(22,155,222,0.4));
}
html.dark-mode .build-ai-instructions-input::placeholder {
    color: var(--color-text-muted);
}
html.dark-mode .build-ai-target span {
    color: var(--color-text-secondary);
}
html.dark-mode .build-ai-toggle-text {
    color: var(--color-text-secondary);
}
html.dark-mode .build-ai-prompt-wrap {
    background: #212121;
}
html.dark-mode .build-ai-prompt {
    color: #6fc4e8;
}

/* Dark mode: darken card colours to ~shade 600/700 and switch to white text */
html.dark-mode .story-card {
    background-color: color-mix(in srgb, var(--card-bg, #fad875), #000 50%);
}
html.dark-mode .step {
    background-color: color-mix(in srgb, var(--card-bg, #77bf81), #000 50%);
}
html.dark-mode .story-text,
html.dark-mode .step-text,
html.dark-mode .story-text-preview,
html.dark-mode .story-card .card-title {
    color: #fff;
    caret-color: #fff;
}
html.dark-mode .story-text::placeholder,
html.dark-mode .step-text::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

/* Card action buttons: crisp white bg with high contrast */
html.dark-mode .step .btn-delete,
html.dark-mode .step .btn-expand,
html.dark-mode .step .btn-options,
html.dark-mode .story-card .btn-delete,
html.dark-mode .story-card .btn-expand,
html.dark-mode .story-card .btn-options {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.15);
    color: #373a40;
}
html.dark-mode .btn-delete:hover {
    background-color: #fee2e2 !important;
    border-color: #e84d6d !important;
}

/* Step drag handle */
html.dark-mode .step-drag-handle {
    color: #0d7a3a;
}

/* Row type labels — bright and legible on dark surface */
html.dark-mode .row-type-label {
    color: #909296;
    text-shadow: 0 0 8px rgba(148, 163, 184, 0.3);
}
html.dark-mode .empty-backbone-row .row-type-label {
    color: #757575;
    text-shadow: none;
}
html.dark-mode .empty-backbone-row:hover .row-type-label {
    color: #909296;
    text-shadow: 0 0 8px rgba(148, 163, 184, 0.3);
}

/* Add story buttons — vivid dashed outlines on dark bg */
html.dark-mode .btn-add-story {
    background-color: rgba(254, 240, 138, 0.1);
    border-color: rgba(250, 204, 21, 0.4);
    color: #fad875;
}
html.dark-mode .btn-add-story:hover {
    background-color: rgba(254, 240, 138, 0.2);
    border-color: rgba(250, 204, 21, 0.7);
    color: #fde047;
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.15);
}
html.dark-mode .users-row .btn-add-story {
    background-color: rgba(253, 164, 175, 0.08);
    border-color: rgba(253, 164, 175, 0.4);
    color: #fda4af;
}
html.dark-mode .users-row .btn-add-story:hover {
    background-color: rgba(253, 164, 175, 0.18);
    border-color: rgba(253, 164, 175, 0.7);
    box-shadow: 0 0 10px rgba(253, 164, 175, 0.15);
}
html.dark-mode .contexts-row .btn-add-story {
    background-color: rgba(159, 125, 208, 0.1);
    border-color: rgba(159, 125, 208, 0.4);
    color: #b89dda;
}
html.dark-mode .contexts-row .btn-add-story:hover {
    background-color: rgba(159, 125, 208, 0.2);
    border-color: rgba(159, 125, 208, 0.7);
    box-shadow: 0 0 10px rgba(159, 125, 208, 0.15);
}
html.dark-mode .activities-row .btn-add-story {
    background-color: rgba(147, 197, 253, 0.08);
    border-color: rgba(147, 197, 253, 0.4);
    color: #45b2e1;
}
html.dark-mode .activities-row .btn-add-story:hover {
    background-color: rgba(147, 197, 253, 0.18);
    border-color: rgba(147, 197, 253, 0.7);
    box-shadow: 0 0 10px rgba(147, 197, 253, 0.15);
}

/* Viewer count badge */
html.dark-mode .viewer-count,
html.dark-mode .active-mappers {
    background: #1a3a4f;
    color: #7dd3fc;
}

html.dark-mode .viewer-name:hover {
    background: rgba(125, 211, 252, 0.12);
}

html.dark-mode .viewer-live {
    color: #7dd3fc;
}

html.dark-mode .viewer-live::after {
    background: #212121;
    color: #c1c2c5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Notepad ruled lines (gradient can't inherit variable cleanly) */
html.dark-mode .notes-editor {
    background-image: repeating-linear-gradient(
        transparent, transparent calc(25px - 1px), #272727 calc(25px - 1px), #272727 25px);
}

/* Scrollbar dark overrides */
html.dark-mode * {
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
html.dark-mode .card-expand-name::-webkit-scrollbar-thumb,
html.dark-mode .card-expand-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

/* Panel tab hover */
html.dark-mode .panel-tab:hover:not(:disabled):not(.active) {
    color: #c1c2c5;
    background: rgba(255, 255, 255, 0.06);
}

/* Card expand placeholder — modal has pastel bg, needs opaque dark text */
html.dark-mode .card-expand-body::placeholder {
    color: rgba(0, 0, 0, 0.45);
}

/* Phantom steps/columns */
html.dark-mode .phantom-step,
html.dark-mode .phantom-column {
    background-color: transparent;
    border-color: rgba(255, 255, 255, 0.06);
}
html.dark-mode .phantom-step:hover,
html.dark-mode .phantom-column:hover {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.12);
}

/* btn-secondary teal accent */
html.dark-mode .btn-secondary {
    background-color: var(--color-bg-surface);
    color: #45b2e1;
    border-color: #45b2e140;
}
html.dark-mode .btn-secondary:hover {
    background-color: #333333;
}

/* Dropdown glass — dark mode */
html.dark-mode .dropdown-menu {
    background: rgba(15, 23, 42, 0.78);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
html.dark-mode .share-menu-item:hover,
html.dark-mode .dropdown-item:hover:not(:disabled):not(.disabled) {
    background-color: rgba(45, 212, 191, 0.1);
}
html.dark-mode .dropdown-divider {
    border-top-color: rgba(255, 255, 255, 0.06);
}
html.dark-mode .dropdown-submenu-content {
    background: rgba(255, 255, 255, 0.03);
}
html.dark-mode .submenu-group-label {
    color: rgba(255, 255, 255, 0.35);
}
html.dark-mode .integration-icon span {
    color: rgba(255, 255, 255, 0.5);
}
html.dark-mode .integration-icon:hover {
    background: rgba(22, 155, 222, 0.12);
    border-color: rgba(22, 155, 222, 0.3);
}
html.dark-mode .integration-icon.active {
    background: rgba(22, 155, 222, 0.18);
    border-color: rgba(22, 155, 222, 0.6);
}
html.dark-mode .backup-count-badge {
    background: rgba(255, 255, 255, 0.1);
}

/* Header border */
html.dark-mode .header {
    border-bottom-color: var(--color-border);
}

/* Welcome page — full dark treatment */
html.dark-mode .welcome-content h1 {
    color: #f1f5f9;
}
html.dark-mode .welcome-subtitle {
    color: #909296;
}
html.dark-mode .welcome-integrations-text {
    color: #757575;
}
html.dark-mode .welcome-integration {
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}
html.dark-mode .welcome-integration:hover {
    border-color: var(--color-teal);
    box-shadow: 0 2px 8px rgba(45, 212, 191, 0.15);
}
html.dark-mode .welcome-counter {
    color: #757575;
}
html.dark-mode .welcome-counter .count {
    color: #c1c2c5;
}
html.dark-mode .welcome-hero-img {
    border-color: #373a40;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.3),
        0 8px 16px rgba(0, 0, 0, 0.2);
}
html.dark-mode .welcome-bottom {
    border-top-color: #272727;
}
html.dark-mode .welcome-samples-label {
    color: #909296;
}

/* Welcome sample buttons */
html.dark-mode .btn-sample {
    background: var(--color-bg-surface) !important;
    color: var(--color-text-primary) !important;
    border-color: var(--color-border);
}
html.dark-mode .btn-sample:hover {
    border-color: var(--color-teal);
    box-shadow: 0 0 10px rgba(45, 212, 191, 0.15);
}

/* Filter/search panel */
html.dark-mode .filter-panel {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
}

/* Partials — teal-accent dark overrides */
html.dark-mode .partials-expand-btn {
    background: var(--color-bg-surface-alt);
    border-color: var(--color-border);
    color: #45b2e1;
}
html.dark-mode .partials-expand-btn:hover:not(:disabled) {
    background: var(--color-bg-surface);
    border-color: #45b2e1;
    color: #6fc4e8;
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.15);
}
html.dark-mode .partials-entry-btn:hover {
    background: rgba(45, 212, 191, 0.1);
    color: #45b2e1;
}
html.dark-mode .partials-entry-btn.delete:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #e84d6d;
}
html.dark-mode .partials-entry-btn.editing {
    background: rgba(45, 212, 191, 0.15);
    color: #6fc4e8;
    border-color: #45b2e1;
}
html.dark-mode input.partials-entry-name-input {
    background: var(--color-bg-surface-alt);
    border-color: var(--color-border);
    color: #c1c2c5;
    caret-color: #45b2e1;
}
html.dark-mode input.partials-entry-name-input:focus {
    border-color: #45b2e1;
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.25);
}

/* Slice divider — stronger contrast line */
html.dark-mode .slice-container {
    border-top-color: #5c5f66;
}

/* Options & expand button hover (on dark card surface) */
html.dark-mode .btn-options:hover,
html.dark-mode .btn-expand:hover {
    background-color: rgba(255, 255, 255, 0.12) !important;
}

/* Slice drag handle */
html.dark-mode .slice-drag-handle {
    color: #757575;
}

/* Slice collapsed label */
html.dark-mode .slice-collapsed .slice-label-container {
    background: var(--color-bg-surface);
}

/* Empty backbone row hover */
html.dark-mode .empty-backbone-row .story-column:hover {
    border-color: #5c5f66;
}

/* Slice progress */
html.dark-mode .slice-progress-track {
    background: #373a40;
}
html.dark-mode .slice-progress-text {
    color: #909296;
}
html.dark-mode .slice-points-text {
    color: #909296;
}

/* Canvas context menu */
html.dark-mode .canvas-context-menu {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
}
html.dark-mode .canvas-context-menu button.destructive {
    color: #e84d6d;
}
html.dark-mode .canvas-context-menu button.destructive:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #e84d6d;
}

/* Selection toolbar: lift above dark page bg */
html.dark-mode .selection-toolbar {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

/* Column/card selection highlight must combine with dark-mode card shadow */
html.dark-mode .step.column-selected,
html.dark-mode .story-card.card-selected {
    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.8),
        var(--shadow-card);
}
html.dark-mode .step-placeholder.column-selected {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8);
    background-color: rgba(59, 130, 246, 0.1);
}
html.dark-mode .story-column.column-selected {
    background-color: rgba(59, 130, 246, 0.1);
}

/* Read-only banner */
html.dark-mode .read-only-banner {
    background: var(--color-bg-surface);
    border-bottom-color: var(--color-border);
    color: var(--color-text-secondary);
}

/* Status swatch "none" */
html.dark-mode .status-swatch.status-none {
    background-color: #373a40;
}

/* Import/export textarea */
html.dark-mode .import-textarea,
html.dark-mode .export-textarea {
    background: var(--color-bg-surface-alt);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}
html.dark-mode .import-textarea:focus,
html.dark-mode .export-textarea:focus {
    background: var(--color-bg-surface);
}
html.dark-mode .import-validation-error {
    color: #e84d6d;
    background: rgba(239, 68, 68, 0.1);
}

/* Import divider span, export divider span */
html.dark-mode .import-divider span,
html.dark-mode .export-divider span {
    background: var(--color-bg-surface);
    color: var(--color-text-muted);
}

/* Export filename input */
html.dark-mode .export-filename,
html.dark-mode .jira-export-epic-name,
html.dark-mode .jira-export-epic-type,
html.dark-mode .jira-export-epic-description,
html.dark-mode .export-epic-name,
html.dark-mode .export-epic-type,
html.dark-mode .export-epic-description {
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

/* Jira export epic rows */
html.dark-mode .jira-export-epic,
html.dark-mode .export-epic {
    background: var(--color-bg-surface-alt);
    border-color: var(--color-border);
}

/* Jira project type select */
html.dark-mode .jira-project-type {
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
}

/* Export/import actions bar */
html.dark-mode .jira-export-actions,
html.dark-mode .export-actions {
    background: var(--color-bg-surface);
    border-top-color: var(--color-border);
}

/* Export modal inputs, selects, checkboxes */
html.dark-mode .jira-project-input,
html.dark-mode .jira-status-input {
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}
html.dark-mode .jira-slice-checkbox,
html.dark-mode .export-slice-checkbox {
    background: #272727;
    border-color: var(--color-border);
}
html.dark-mode .jira-slice-checkbox:hover,
html.dark-mode .export-slice-checkbox:hover {
    background: #373a40;
}
html.dark-mode .jira-slice-checkbox.checked,
html.dark-mode .export-slice-checkbox.checked {
    background: #1e3a5f;
    border-color: #3b82f6;
}
html.dark-mode .jira-export-task:hover .jira-export-task-name,
html.dark-mode .export-task:hover .export-task-name {
    color: #f1f5f9;
}
html.dark-mode .jira-csv-warning {
    background: var(--color-bg-surface-alt);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}
html.dark-mode .jira-csv-warning a {
    color: var(--color-text-secondary);
}
html.dark-mode .jira-export-help-link {
    color: #45b2e1;
}

/* Backup entries */
html.dark-mode .backup-actions button {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
}

/* Board name input */
html.dark-mode .board-name {
    color: var(--color-text-primary);
}
html.dark-mode .board-name:focus {
    background-color: var(--color-bg-surface);
    border-color: var(--color-border);
}

/* Search bar */
html.dark-mode .search-bar input {
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
}

/* Zoom controls */
html.dark-mode .zoom-controls {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
}

html.dark-mode .view-controls {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
}

html.dark-mode .view-btn.active {
    background-color: rgba(45, 212, 191, 0.15);
}

/* Btn-add-slice — visible dashed border with teal hint */
html.dark-mode .btn-add-slice {
    color: #909296;
    border-color: #5c5f66;
}
html.dark-mode .btn-add-slice:hover {
    border-color: var(--color-teal);
    color: #45b2e1;
    background-color: rgba(45, 212, 191, 0.08);
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.15);
}

/* Legend panel */
html.dark-mode .legend-label:focus {
    background: var(--color-bg-surface);
}

/* Notes editor — text and UI elements */
html.dark-mode .notes-editor {
    color: var(--color-text-primary);
}
html.dark-mode .notes-editor .cm-editor {
    color: var(--color-text-primary);
}
html.dark-mode .notes-editor .cm-content {
    caret-color: var(--color-text-primary);
}
html.dark-mode .notes-editor .cm-cursor {
    border-left-color: var(--color-text-primary);
}
html.dark-mode .notes-editor .cm-activeLine {
    background: rgba(255, 255, 255, 0.04);
}
html.dark-mode .notes-editor .cm-selectionBackground,
html.dark-mode .notes-editor .cm-content ::selection {
    background: rgba(45, 212, 191, 0.25) !important;
}
html.dark-mode .notes-editor:focus {
    background: var(--color-bg-surface);
}
html.dark-mode .notes-close {
    color: #757575;
}
html.dark-mode .notes-close:hover {
    color: #909296;
    background: #333333;
}

/* Slice label — readable on dark bg */
html.dark-mode .slice-label {
    color: #909296;
    caret-color: #909296;
}
html.dark-mode .slice-label::placeholder {
    color: #757575;
}
html.dark-mode .slice-label:focus {
    background-color: var(--color-bg-surface);
    color: var(--color-text-primary);
    caret-color: var(--color-text-primary);
}

/* Slice menu dropdown */
html.dark-mode .slice-menu-dropdown {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
}
html.dark-mode .slice-menu-item:hover {
    background-color: var(--color-hover-bg);
}
html.dark-mode .slice-menu-item-danger:hover {
    background-color: rgba(239, 68, 68, 0.12);
    color: #e84d6d;
}

/* Options menu */
html.dark-mode .options-menu {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
}
html.dark-mode .options-item:hover {
    background-color: var(--color-hover-bg);
}
html.dark-mode .options-delete,
html.dark-mode .options-delete-column {
    color: #e84d6d;
}
html.dark-mode .options-delete:hover,
html.dark-mode .options-delete-column:hover {
    background-color: rgba(239, 68, 68, 0.12);
    color: #e84d6d;
}

/* Card expand modal overlay */
html.dark-mode .card-expand-overlay {
    background: rgba(0, 0, 0, 0.6);
}

/* Learn more cards on welcome */
/* Learn cards */
html.dark-mode .welcome-learn-group-label {
    color: #909296;
}
html.dark-mode .welcome-learn-card {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
    color: #909296;
}
html.dark-mode .welcome-learn-card:hover {
    border-color: var(--color-teal);
    box-shadow: 0 2px 12px rgba(45, 212, 191, 0.15);
    color: #c1c2c5;
}

/* Welcome footer */
html.dark-mode .welcome-footer {
    border-top-color: #272727;
    color: #909296;
}
html.dark-mode .welcome-footer .footer-text {
    color: #909296;
}
html.dark-mode .welcome-footer a {
    color: #45b2e1;
}
html.dark-mode .welcome-footer .footer-legal {
    color: #757575;
}
html.dark-mode .welcome-footer .footer-legal a {
    color: #757575;
}
html.dark-mode .welcome-footer .footer-legal a:hover {
    color: #45b2e1;
}
html.dark-mode .welcome-footer .footer-dot {
    color: #373a40;
}

/* Partials entries (partial map list) */
html.dark-mode .partials-entry {
    background: var(--color-bg-surface-alt);
    border-color: var(--color-border);
}
html.dark-mode .partials-entry-name {
    color: #c1c2c5;
}
html.dark-mode .partials-entry-meta {
    color: #909296;
}
html.dark-mode .partials-entry-btn {
    color: #909296;
}
html.dark-mode .partials-entry-btn.expanded {
    background: rgba(45, 212, 191, 0.12);
    color: #45b2e1;
    border-color: #45b2e1;
}
html.dark-mode .partials-empty {
    color: var(--color-text-muted);
}

/* Partial map reference card on board */
html.dark-mode .partial-map-ref {
    background: linear-gradient(135deg, #0c1a2a 0%, #122236 40%, #0e1e30 100%);
    border-color: #1e3a5f;
    border-left: 4px solid #45b2e1;
    box-shadow:
        0 0 12px rgba(45, 212, 191, 0.1),
        2px 2px 0 0px #0a1420,
        3px 3px 0 0px #153050,
        4px 4px 0 0px #0e1e30,
        6px 6px 0 0px #0a1420,
        7px 7px 0 0px #1a3855,
        8px 8px 0 0px #112840;
}
html.dark-mode .partial-map-ref-icon {
    background: #084464;
}
html.dark-mode .partial-map-ref-name {
    color: #c1c2c5;
}
html.dark-mode .partial-map-ref-meta {
    color: #45b2e1;
}
html.dark-mode .partial-map-ref-range {
    color: #909296;
}
html.dark-mode .partial-map-ref-badge {
    background: linear-gradient(135deg, #169bde, #084464);
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Partial delete popover */
html.dark-mode .partial-delete-popover {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
html.dark-mode .partial-delete-popover-btn {
    color: #c1c2c5;
}
html.dark-mode .partial-delete-popover-desc {
    color: var(--color-text-muted);
}
html.dark-mode .partial-delete-popover-btn:hover {
    background: rgba(45, 212, 191, 0.1);
}
html.dark-mode .partial-delete-popover-btn.danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #e84d6d;
}
html.dark-mode .partial-delete-popover-btn.restore:hover {
    background: rgba(45, 212, 191, 0.1);
    color: #45b2e1;
}

/* Partial preview columns — teal outline */
html.dark-mode .step.partial-map-preview-col {
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.6), 0 0 12px rgba(45, 212, 191, 0.15);
}
html.dark-mode .partial-map-preview-col .story-card {
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.6), 0 0 12px rgba(45, 212, 191, 0.15);
}

/* Selection toolbar partial button */
html.dark-mode .selection-toolbar-partial {
    background-color: #084464;
}
html.dark-mode .selection-toolbar-partial:hover {
    background-color: #169bde;
}

/* Partials tab — teal active accent */
html.dark-mode #partialsToggle.active {
    color: #45b2e1;
}

/* Tag suggestions dropdown */
html.dark-mode .tag-suggestion-list {
    background: var(--color-bg-surface);
    border-color: var(--color-border);
}

/* Hover backgrounds that were #f0f0f0 */
html.dark-mode .slice-label-container .btn-delete {
    background: var(--color-bg-surface);
    border-color: #5c5f66;
    color: #909296;
}
html.dark-mode .btn-slice-menu {
    background: var(--color-bg-surface);
    border-color: #5c5f66;
    color: #909296;
}
html.dark-mode .btn-slice-menu:hover {
    background: var(--color-hover-bg);
    color: var(--color-text-primary);
}

/* Card body / expand modal details */
html.dark-mode .card-expand-modal .card-detail-section {
    border-color: var(--color-border);
}

/* Backup list entry border */
html.dark-mode .backup-entry {
    border-color: var(--color-border);
}

/* Dialog modal */
html.dark-mode .dialog-input {
    background: var(--color-input-bg);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}
html.dark-mode .dialog-btn-cancel {
    background: #333333;
    color: var(--color-text-secondary);
}
html.dark-mode .dialog-btn-cancel:hover {
    background: #373a40;
}

/* Import dropzone */
html.dark-mode .import-file-dropzone {
    background: var(--color-bg-surface-alt);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

/* Export: hidden utility for export elements */
.export-progress.hidden,
.export-info-banner.hidden { display: none; }

/* Export summary strip */
.export-summary {
    font-size: 13px;
    color: #5c5f66;
    padding: 10px 14px;
    background: #f0fdfa;
    border: 1px solid #e7f5fb;
    border-radius: 8px;
    margin-bottom: 20px;
}
.export-summary strong {
    font-weight: 700;
    color: #0b5a8c;
    font-size: 14px;
}

/* Verify row */
.export-verify-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #fafafa;
    border: 1px solid #c1c2c5;
    border-radius: 8px;
    margin-bottom: 16px;
}
.btn-verify {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 6px;
    border: 1px solid #169bde;
    background: #fff;
    color: #084464;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-verify:hover { background: #f0fdfa; }
.btn-verify:disabled { opacity: 0.5; cursor: default; }
.btn-verify svg { flex-shrink: 0; }
.export-verify-status {
    font-size: 12px;
    color: #909296;
}
.export-verify-status.success {
    color: #059669;
    display: flex;
    align-items: center;
    gap: 5px;
}
.export-verify-status.success::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    flex-shrink: 0;
}
.export-verify-status.error { color: #dc2626; }
.export-verify-status.loading {
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 6px;
}
.spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid #d1d5db;
    border-top-color: #169bde;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Progress header */
.export-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.export-progress-label {
    font-size: 12px;
    font-weight: 600;
    color: #5c5f66;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.export-progress-count {
    font-size: 12px;
    color: #909296;
    font-variant-numeric: tabular-nums;
}

/* Progress bar */
.export-progress-bar-container {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}
.export-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #169bde, #10b981);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.export-progress-bar.indeterminate {
    width: 40% !important;
    animation: indeterminate-slide 1.4s ease-in-out infinite;
}
@keyframes indeterminate-slide {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(150%); }
    100% { transform: translateX(-100%); }
}

/* Item-level progress */
.export-progress-items {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}
.export-progress-item {
    display: flex;
    align-items: center;
    font-size: 13px;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 5px;
    transition: background 0.15s;
}
.export-progress-item.parent {
    font-weight: 600;
    margin-top: 4px;
}
.export-progress-item.child {
    padding-left: 30px;
    font-weight: 400;
}
.export-progress-item .status-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.export-progress-item .item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.export-progress-item .item-result {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    margin-left: auto;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
}

/* Item states */
.export-progress-item.pending { color: #c1c2c5; }
.export-progress-item.pending .status-icon { color: #c1c2c5; }
.export-progress-item.creating { color: #084464; background: #f0fdfa; }
.export-progress-item.creating .status-icon { color: #169bde; animation: spin 0.8s linear infinite; }
.export-progress-item.done { color: var(--color-text-primary); }
.export-progress-item.done .status-icon { color: #10b981; }
.export-progress-item.done .item-result { color: #6b7280; }
.export-progress-item.done .item-result a { color: #0b5a8c; text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
.export-progress-item.done .item-result a:hover { text-decoration: underline; }
.export-progress-item.done .item-result a svg { opacity: 0.5; }
.export-progress-item.done .item-result a:hover svg { opacity: 1; }
.export-progress-item.failed { color: #dc2626; background: #fef2f2; }
.export-progress-item.failed .status-icon { color: #dc2626; }
.export-progress-item.failed .item-result { color: #dc2626; font-family: inherit; }
.export-progress-item.skipped { color: #909296; }
.export-progress-item.skipped .status-icon { color: #c1c2c5; }
.export-progress-item.skipped .item-result { color: #909296; font-style: italic; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Done summary card */
.export-done-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    margin-top: 12px;
}
.export-done-summary .done-icon {
    width: 28px;
    height: 28px;
    background: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.export-done-summary .done-text {
    font-size: 14px;
    font-weight: 600;
    color: #065f46;
}
.export-done-summary .done-detail {
    font-size: 12px;
    color: #047857;
    font-weight: 400;
}
.export-done-summary.has-failures {
    background: #fffbeb;
    border-color: #fde68a;
}
.export-done-summary.has-failures .done-icon {
    background: #f59e0b;
}
.export-done-summary.has-failures .done-text { color: #92400e; }
.export-done-summary.has-failures .done-detail { color: #a16207; }

.export-progress-summary { margin-top: 8px; font-weight: 600; font-size: 13px; }

/* Dark mode: export summary */
html.dark-mode .export-summary {
    background: rgba(22,155,222,0.08);
    border-color: rgba(22,155,222,0.2);
    color: #909296;
}
html.dark-mode .export-summary strong { color: #45b2e1; }

/* Dark mode: verify row */
html.dark-mode .export-verify-row {
    background: #212121;
    border-color: #373a40;
}
html.dark-mode .btn-verify {
    background: #272727;
    border-color: #169bde;
    color: #6fc4e8;
}
html.dark-mode .btn-verify:hover { background: rgba(22,155,222,0.1); }
html.dark-mode .export-verify-status.success { color: #77bf81; }
html.dark-mode .export-verify-status.success::before { background: #77bf81; }
html.dark-mode .export-verify-status.error { color: #e84d6d; }
html.dark-mode .export-verify-status.loading { color: #9ca3af; }
html.dark-mode .spinner-sm { border-color: #4b5563; border-top-color: #45b2e1; }

/* Dark mode: progress */
html.dark-mode .export-progress-label { color: #909296; }
html.dark-mode .export-progress-count { color: #757575; }
html.dark-mode .export-progress-bar-container { background: #373a40; }

/* Dark mode: item progress */
html.dark-mode .export-progress-item.pending { color: #5c5f66; }
html.dark-mode .export-progress-item.pending .status-icon { color: #373a40; }
html.dark-mode .export-progress-item.creating { color: #6fc4e8; background: rgba(22,155,222,0.06); }
html.dark-mode .export-progress-item.creating .status-icon { color: #45b2e1; }
html.dark-mode .export-progress-item.done { color: var(--color-text-primary); }
html.dark-mode .export-progress-item.done .status-icon { color: #77bf81; }
html.dark-mode .export-progress-item.done .item-result { color: #757575; }
html.dark-mode .export-progress-item.done .item-result a { color: #45b2e1; }
html.dark-mode .export-progress-item.failed { color: #e84d6d; background: rgba(220,38,38,0.06); }
html.dark-mode .export-progress-item.failed .status-icon { color: #e84d6d; }
html.dark-mode .export-progress-item.skipped { color: #5c5f66; }
html.dark-mode .export-progress-item.skipped .status-icon { color: #373a40; }

/* Dark mode: done summary */
html.dark-mode .export-done-summary {
    background: rgba(16,185,129,0.08);
    border-color: rgba(16,185,129,0.2);
}
html.dark-mode .export-done-summary .done-text { color: #6ee7b7; }
html.dark-mode .export-done-summary .done-detail { color: #34d399; }
html.dark-mode .export-done-summary.has-failures {
    background: rgba(245,158,11,0.08);
    border-color: rgba(245,158,11,0.2);
}
html.dark-mode .export-done-summary.has-failures .done-text { color: #f9cd4c; }
html.dark-mode .export-done-summary.has-failures .done-detail { color: #f59e0b; }

/* ==================== Import Styles ==================== */

.import-progress-items {
    max-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: var(--color-text-secondary);
    padding: 8px 0;
}

.import-progress-line {
    padding: 2px 0;
}

.import-progress-line.success {
    color: #059669;
}

.import-progress-line.error {
    color: #dc2626;
}

.import-mapping-mode {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--color-border-medium);
    font-size: 13px;
}
.import-mapping-label {
    font-weight: 600;
    color: var(--color-text-secondary);
    white-space: nowrap;
}
.import-mapping-option {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--color-text-primary);
}
.import-mapping-option input[type="radio"] {
    margin: 0;
}

.import-mapping-mode.hidden {
    display: none;
}

/* Import mode toggle (replace vs append) - segmented pill style */
.import-mapping-mode:has([name$="ImportMode"]) {
    border-bottom: none;
    margin-bottom: 12px;
    padding: 0;
    gap: 0;
}
.import-mapping-mode:has([name$="ImportMode"]) .import-mapping-label {
    display: none;
}
.import-mapping-mode:has([name$="ImportMode"]) .import-mapping-option {
    flex: 1;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    margin: 0;
    border: 1.5px solid var(--color-border-medium);
    background: var(--color-bg-surface);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all 0.15s ease;
}
.import-mapping-mode:has([name$="ImportMode"]) .import-mapping-option:first-of-type {
    border-radius: 8px 0 0 8px;
    border-right: none;
}
.import-mapping-mode:has([name$="ImportMode"]) .import-mapping-option:last-of-type {
    border-radius: 0 8px 8px 0;
}
.import-mapping-mode:has([name$="ImportMode"]) .import-mapping-option:has(input:checked) {
    background: linear-gradient(135deg, #169bde, #0b5a8c);
    border-color: #0b5a8c;
    color: #fff;
    font-weight: 600;
}
.import-mapping-mode:has([name$="ImportMode"]) .import-mapping-option input[type="radio"] {
    display: none;
}

.import-status-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.import-status-filters h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}
.import-status-filters .import-status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.import-preview-header {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #166534;
}
.import-toggle-all {
    color: inherit;
    opacity: 0.7;
    font-size: 13px;
    margin-left: 8px;
    text-decoration: underline;
    cursor: pointer;
}
.import-toggle-all:hover { opacity: 1; }

html.dark-mode .import-preview-header {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.import-preview {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--color-border-medium);
    border-radius: var(--border-radius);
    padding: 8px;
}

.import-epic {
    margin-bottom: 4px;
}

.import-epic-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    user-select: none;
}

.import-epic-header:hover {
    background: var(--color-hover-bg);
}

.import-epic-header input[type="checkbox"] {
    flex-shrink: 0;
}

.import-epic.excluded .import-epic-header {
    opacity: 0.5;
}

.import-epic-toggle {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    font-size: 10px;
    color: var(--color-text-muted);
    transition: transform 0.15s;
}

.import-epic.expanded .import-epic-toggle {
    transform: rotate(90deg);
}

.import-issue-key {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 11px;
    background: var(--color-bg-elevated);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

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

.import-story-count {
    font-size: 11px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.import-stories {
    display: none;
    padding-left: 24px;
}

.import-epic.expanded .import-stories {
    display: block;
}

.import-story {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    font-size: 13px;
    border-radius: var(--border-radius-sm);
}

.import-story:hover {
    background: var(--color-hover-bg);
}

.import-story.excluded {
    opacity: 0.5;
}

.import-story-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-primary);
}

.import-status-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.import-status-badge.planned {
    background: #dbeafe;
    color: #1e40af;
}

.import-status-badge.in-progress {
    background: #fef3c7;
    color: #92400e;
}

.import-status-badge.done {
    background: #d1fae5;
    color: #065f46;
}

html.dark-mode .import-status-badge.planned {
    background: rgba(59, 130, 246, 0.2);
    color: #45b2e1;
}

html.dark-mode .import-status-badge.in-progress {
    background: rgba(245, 158, 11, 0.2);
    color: #f9cd4c;
}

html.dark-mode .import-status-badge.done {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.import-points-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--color-bg-elevated);
    color: var(--color-text-secondary);
    font-weight: 600;
    flex-shrink: 0;
}

.import-count {
    font-size: 13px;
    color: var(--color-text-secondary);
    flex: 1;
    text-align: center;
}

/* Print: force light mode */
/* Dark mode is stripped via JS beforeprint/afterprint so light styles apply naturally */

/* ==========================================================================
   Guided Tour
   ========================================================================== */

/* Backdrop — click-catcher behind spotlight */
.tour-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    cursor: pointer;
}

.tour-backdrop.visible {
    display: block;
    background: rgba(10, 15, 20, 0.6);
}

/* Only apply backdrop-filter when no clip-path cutouts (no-target steps) */
.tour-backdrop-dim {
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
}

/* Spotlight — glow border around target element(s) */
.tour-spotlight {
    display: none;
    position: fixed;
    z-index: 10001;
    pointer-events: none;
    box-shadow:
        0 0 0 2px rgba(22, 155, 222, 0.35),
        0 0 20px 4px rgba(22, 155, 222, 0.12);
    border-radius: 8px;
    transition: none;
}

.tour-spotlight-extra {
    transition: none;
}

.tour-spotlight.visible {
    display: block;
}

/* Tooltip card */
.tour-tooltip {
    display: none;
    position: fixed;
    z-index: 10002;
    background: #fff;
    border-radius: 14px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 12px 40px rgba(0, 0, 0, 0.14);
    max-width: 380px;
    width: max-content;
    min-width: 280px;
    padding: 0;
    overflow: hidden;
    animation: tourCardIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.tour-tooltip.visible {
    display: block;
}

/* Wider tooltip for centered (no-target) steps */
.tour-backdrop-dim + .tour-spotlight + .tour-tooltip {
    max-width: 560px;
}

@keyframes tourCardIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Teal accent bar across top of tooltip */
.tour-tooltip::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #169bde, #0ea5e9);
    border-radius: 14px 14px 0 0;
}

/* Arrow — rotated square for a softer look */
.tour-tooltip::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 2px;
    box-shadow: -1px -1px 2px rgba(0, 0, 0, 0.04);
    z-index: -1;
}

.tour-tooltip[data-arrow="top"]::before {
    top: -7px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
}

.tour-tooltip[data-arrow="bottom"]::before {
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.04);
}

.tour-tooltip[data-arrow="left"]::before {
    left: -7px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.tour-tooltip[data-arrow="right"]::before {
    right: -7px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    box-shadow: 1px -1px 2px rgba(0, 0, 0, 0.04);
}

/* Tooltip content area */
.tour-tooltip-content {
    padding: 22px 24px 0;
}

/* Step content enter animation */
.tour-step-enter {
    animation: tourStepFade 0.25s ease;
}

@keyframes tourStepFade {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}

.tour-tooltip-icon {
    display: block;
    font-size: 26px;
    line-height: 1;
    margin-bottom: 8px;
}

.tour-tooltip-title {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.tour-tooltip-body {
    font-size: 14px;
    line-height: 1.6;
    color: #4b5563;
    margin-bottom: 0;
}

.tour-tooltip-body strong {
    color: #111827;
    font-weight: 600;
}

/* Progress dots */
.tour-tooltip-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 24px 0;
}

.tour-progress-dot {
    width: 6px;
    height: 6px;
    border-radius: 6px;
    background: #e5e7eb;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tour-progress-dot.visited {
    background: #b3e0f2;
}

.tour-progress-dot.active {
    width: 20px;
    background: linear-gradient(90deg, #169bde, #0ea5e9);
}

/* Footer */
.tour-tooltip-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 14px;
    gap: 8px;
}

.tour-tooltip-nav {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.tour-btn-skip {
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    padding: 7px 12px;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}

.tour-btn-skip:hover {
    color: #6b7280;
    background: #f3f4f6;
}

.tour-btn-skip:active {
    background: #e5e7eb;
}

.tour-btn-back {
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #4b5563;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    padding: 7px 14px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.tour-btn-back:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.tour-btn-back:active {
    background: #d1d5db;
    transform: scale(0.97);
}

.tour-btn-next {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #169bde, #0b5a8c);
    border: none;
    cursor: pointer;
    padding: 7px 18px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(22, 155, 222, 0.25);
}

.tour-btn-next:hover {
    background: linear-gradient(135deg, #0b5a8c, #084464);
    box-shadow: 0 2px 8px rgba(22, 155, 222, 0.35);
    transform: translateY(-1px);
}

.tour-btn-next:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 1px 2px rgba(22, 155, 222, 0.2);
}

.tour-btn-next-arrow {
    transition: transform 0.2s ease;
}

.tour-btn-next:hover .tour-btn-next-arrow {
    transform: translateX(2px);
}

/* Welcome screen tour button */
/* Suppress tutorial toast during tour */
body.tour-active .tutorial-toast {
    display: none !important;
}

/* Hide card chrome during "V1 Done" tour step so drag-drop DOM rebuilds don't restore them */
body.tour-v1-done .slice-container .btn-expand,
body.tour-v1-done .slice-container .btn-options,
body.tour-v1-done .slice-container .btn-add-story {
    display: none !important;
}

/* Raise sidebar z-index during tour so panel tabs are spotlightable, but disable interaction */
body.tour-active .controls-right {
    z-index: 10003;
    pointer-events: none;
}

@media print {
    .tour-backdrop,
    .tour-spotlight,
    .tour-tooltip {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .tour-tooltip {
        max-width: calc(100vw - 24px);
        min-width: 0;
    }

    .tour-tooltip-content {
        padding: 18px 18px 0;
    }

    .tour-tooltip-icon {
        font-size: 22px;
    }

    .tour-tooltip-title {
        font-size: 15px;
    }

    .tour-tooltip-body {
        font-size: 13px;
    }
}

/* Hide tour options on touch devices (tour requires desktop) */
@media (pointer: coarse) {
    [data-sample="story-mapping-101"],
    #tourMenuBtn,
    #welcomeTourBtn {
        display: none !important;
    }

    #welcomeNewBtn {
        width: 100%;
        padding: 16px 32px;
        font-size: 18px;
        background: linear-gradient(135deg, #169bde, #0b5a8c);
        color: #fff;
        border: none;
        box-shadow: 0 2px 8px rgba(22, 155, 222, 0.3);
    }

    body.welcome-visible #mainMenu > .dropdown-item:disabled,
    body.welcome-visible #mainMenu > .dropdown-submenu:has(> .dropdown-submenu-trigger:disabled) {
        display: none !important;
    }
}

.notransition,
.notransition * {
    transition: none !important;
}
