/* Modern CSS for Script Creation System */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #E8651A 0%, #D4550F 100%);
    --primary-color: #E8651A;
    --primary-dark: #C85415;
    --secondary-color: #F0813E;
    --bg-light: #FFF8F4;
    --bg-white: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-white);
}

/* Top Header */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-primary);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    z-index: 100;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: visible;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-left {
    gap: 16px;
    flex: 1 1 auto;
}

.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.hamburger-btn:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.2s;
}

.logo-link:hover {
    opacity: 0.8;
}

.app-logo {
    height: 32px;
    width: auto;
    display: block;
}

.app-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    min-width: 0;
}

.breadcrumb-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.breadcrumb-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-muted);
    user-select: none;
}

.breadcrumb-current {
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.world-name-display {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 12px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    gap: 12px;
    flex: 0 1 auto;
}

/* Header Navigation Tabs (Script / Canvas / Editor) */
.header-nav {
    display: flex;
    justify-content: center;
    gap: 2px;
    padding: 3px;
    background: var(--bg-light, #f1f5f9);
    border-radius: 8px;
    flex-shrink: 0;
}

.header-nav-btn {
    padding: 8px 20px;
    color: var(--text-muted, #94a3b8);
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.header-nav-btn:hover:not(.active) {
    color: var(--text-primary, #1f2937);
    background: rgba(255, 255, 255, 0.5);
}

.header-nav-btn.active {
    color: var(--text-primary, #1f2937);
    background: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* User Avatar + Dropdown */
.sw-avatar-wrap {
    position: relative;
}

.sw-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-color, #E8651A);
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
    text-transform: uppercase;
    flex-shrink: 0;
}

.sw-avatar:hover,
.sw-avatar-wrap--open .sw-avatar {
    border-color: var(--primary-color, #E8651A);
    box-shadow: 0 0 0 2px rgba(232, 101, 26, 0.2);
}

.sw-user-dropdown {
    position: fixed;
    width: 260px;
    background: white;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
    padding: 0;
    overflow: hidden;
    z-index: 9999;
}

.sw-user-dropdown__identity {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.sw-user-dropdown__email {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    word-break: break-all;
}

.sw-user-dropdown__badge {
    display: inline-block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(232, 101, 26, 0.12);
    color: var(--primary-color, #E8651A);
}

.sw-user-dropdown__section {
    padding: 6px 6px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.sw-user-dropdown__section:last-child {
    border-bottom: none;
}

.sw-user-dropdown__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 10px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-primary, #1f2937);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 6px;
    text-align: left;
    text-decoration: none;
    transition: background 0.12s;
}

.sw-user-dropdown__item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.sw-user-dropdown__item--logout {
    color: #e53935;
}

.sw-user-dropdown__power-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 10px;
    font-size: 13px;
}

.sw-user-dropdown__power-val {
    font-weight: 700;
    color: var(--primary-color, #E8651A);
}

.sw-user-dropdown__lang-val {
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
    font-weight: 500;
}

/* Model Selector Card - card-style model selector */
.model-selector-card {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: #f8fafb;
    border-radius: 10px;
    border: 1px solid rgba(226, 232, 240, 0.7);
    gap: 0;
    min-width: 0;
    flex: 0 1 auto;
}

.model-selector-card.compact-open {
    position: fixed;
    display: flex;
    flex-direction: column;
    top: 72px;
    right: 12px;
    width: 380px;
    z-index: 1399;
    padding: 16px;
    gap: 12px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
    background: white;
}

.model-selector-card.compact-open .model-divider {
    display: none;
}

.model-selector-card.compact-open .model-selector-item,
.model-selector-card.compact-open .intervention-level-wrapper {
    margin-left: 0;
    width: 100%;
}

.model-selector-card.compact-open .model-select-wrapper {
    display: block;
    width: 100%;
    min-width: 0;
}

.model-selector-card.compact-open .thinking-mode-wrapper {
    display: flex !important;
    margin-left: 0;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    width: 100%;
}


.model-settings-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.model-settings-toggle-btn:hover {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

.model-settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.2);
    z-index: 1398;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.model-settings-overlay.active {
    opacity: 1;
    visibility: visible;
}

.model-selector-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
}

.text-model-icon {
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
    color: white;
}

.image-model-icon {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
}

.intervention-icon {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
}

.intervention-level-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.model-divider {
    width: 1px;
    height: 32px;
    background: var(--border-color);
    margin: 0 16px;
}

.model-select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 140px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.model-select:hover {
    border-color: var(--primary-color);
}

.model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(232, 101, 26, 0.1);
}

.model-select option {
    background: white;
    color: var(--text-primary);
}

.model-select optgroup {
    color: var(--text-primary);
}

/* Model select overlay for collapsed/expanded dual text */
.model-select-wrapper {
    position: relative;
    display: inline-block;
    width: 160px;
}

.model-select-wrapper .model-select {
    background: transparent;
    color: transparent;
    background-image: none;
    padding-right: 32px;
    width: 100%;
    min-width: auto;
}

.model-select-wrapper .model-select:hover {
    border-color: var(--primary-color);
}

.model-select-wrapper .model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(232, 101, 26, 0.1);
}

.model-select-display {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    padding: 8px 32px 8px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    pointer-events: auto;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.model-select-wrapper:hover .model-select-display {
    border-color: var(--primary-color);
}

.model-select-wrapper:focus-within .model-select-display,
.model-select-wrapper.custom-select-open .model-select-display {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(232, 101, 26, 0.1);
}

.custom-model-select-menu {
    position: fixed;
    z-index: 1600;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}

.custom-model-select-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
}

.custom-model-select-footer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-light, #f8fafc);
}

.set-default-model-btn {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--primary-dark, #9C4A1A);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.set-default-model-btn:hover:not(:disabled) {
    border-color: var(--primary-color, #E8651A);
    background: rgba(232, 101, 26, 0.08);
}

.set-default-model-btn:disabled {
    opacity: 0.65;
    cursor: default;
    color: var(--text-secondary);
}

.set-default-model-hint {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
    text-align: center;
}

.custom-model-select-option.is-world-default:not(.selected) {
    font-weight: 600;
}

.custom-model-select-group {
    padding: 6px 8px 5px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
}

.custom-model-select-option {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
    cursor: pointer;
    white-space: normal;
    word-break: break-word;
}

.custom-model-select-option:hover,
.custom-model-select-option:focus {
    outline: none;
    background: var(--bg-light);
    color: var(--primary-dark);
}

.custom-model-select-option.selected {
    background: var(--primary-color);
    color: white;
}

.custom-model-select-option:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    background: transparent;
}

/* Legacy styles for backward compatibility */
.model-selector-group {
    display: none;
}

/* Docs Link */
.top-bar-docs-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: color 0.15s, background 0.15s;
}
.top-bar-docs-link:hover {
    color: var(--primary-color);
    background: var(--bg-light);
}

/* Credits Display */
.computing-power-display {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fafbfc;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: default;
}

.computing-power-display .power-icon {
    display: flex;
    align-items: center;
    line-height: 1;
}

.computing-power-display .power-value {
    color: var(--text-primary);
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

/* Credits Color States */
.computing-power-display.low-power {
    border-color: var(--error-color);
    background: #fef2f2;
}

.computing-power-display.low-power .power-icon {
    color: var(--error-color);
}

.computing-power-display.low-power .power-value {
    color: var(--error-color);
}

.computing-power-display.medium-power {
    border-color: var(--warning-color);
    background: #fffbeb;
}

.computing-power-display.medium-power .power-icon {
    color: var(--warning-color);
}

.computing-power-display.medium-power .power-value {
    color: var(--warning-color);
}

.computing-power-display.high-power {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.computing-power-display.high-power .power-icon {
    color: var(--success-color);
}

.computing-power-display.high-power .power-value {
    color: var(--success-color);
}

.header-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: white;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.header-action-btn:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
}

.header-action-btn.primary {
    position: relative;
    overflow: visible;
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.header-action-btn.primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 10px -2px rgba(232, 101, 26, 0.35);
}

/*
 * Submit button loading: a bright point travels along the button's own border path
 * Only the starting angle of the conic-gradient rotates; the button shape stays fixed (not the whole ring spinning)
 */
@property --submit-border-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

.header-action-btn.primary .submit-btn-ring {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    box-sizing: border-box;
    /* Exposes only about a 2px border path = the button's border track */
    padding: 2px;
    /* Base color is a dim outline, with a short highlighted "bright point" segment */
    background: conic-gradient(
        from var(--submit-border-angle),
        rgba(255, 255, 255, 0.2) 0deg,
        rgba(255, 255, 255, 0.2) 300deg,
        rgba(255, 255, 255, 0.55) 330deg,
        #ffffff 348deg,
        rgba(255, 255, 255, 0.75) 355deg,
        rgba(255, 255, 255, 0.2) 360deg
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
}

.header-action-btn.primary.is-submitting {
    cursor: wait;
    opacity: 0.85;
    pointer-events: none;
    border-color: transparent;
}

.header-action-btn.primary.is-submitting:hover {
    opacity: 0.85;
    box-shadow: none;
}

.header-action-btn.primary.is-submitting .submit-btn-ring {
    opacity: 1;
    animation: submit-border-highlight-spin 1.2s linear infinite;
}

/* Success: the entire border briefly turns green */
.header-action-btn.primary.submit-success .submit-btn-ring {
    opacity: 1;
    animation: none;
    background: var(--success-color);
}

.header-action-btn.primary:disabled {
    cursor: wait;
}

@keyframes submit-border-highlight-spin {
    to { --submit-border-angle: 360deg; }
}

.header-action-btn.feedback-btn {
    background: rgba(212, 85, 15, 0.08);
    border-color: rgba(212, 85, 15, 0.2);
    color: var(--primary-dark);
}

.header-action-btn.feedback-btn:hover {
    background: rgba(212, 85, 15, 0.15);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 3px 10px -2px rgba(212, 85, 15, 0.35);
}

/* Auto Submit Container */
.auto-submit-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.auto-submit-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    position: relative;
}

.auto-submit-toggle input {
    display: none;
}

.toggle-slider {
    width: 36px;
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    position: relative;
    transition: all 0.3s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.auto-submit-toggle input:checked + .toggle-slider {
    background: var(--success-color);
}

.auto-submit-toggle input:checked + .toggle-slider::after {
    left: 18px;
}

.toggle-label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.auto-submit-countdown {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-light);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.btn-icon {
    font-size: 16px;
}

.btn-text {
    font-size: 14px;
}

/* Main Layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: var(--bg-light);
    margin-left: 60px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background: white;
    border-right: 1px solid rgba(226, 232, 240, 0.6);
    position: relative;
    overflow-x: hidden;
}

.chat-messages {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px;
    background: linear-gradient(180deg, #fefcfa 0%, #fdf8f4 50%, #faf8f6 100%);
}

.scroll-to-bottom-btn {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.scroll-to-bottom-btn:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.scroll-to-bottom-btn svg {
    flex-shrink: 0;
}

/* Welcome Card */
.welcome-card {
    max-width: 560px;
    margin: 48px auto 40px;
    padding: 44px 36px 32px;
    text-align: center;
    position: relative;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.8) 0%, rgba(254, 232, 214, 0.12) 100%);
    border: 1px solid rgba(232, 101, 26, 0.08);
    border-radius: 20px;
}

.welcome-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, rgba(232, 101, 26, 0.12) 0%, rgba(232, 101, 26, 0.06) 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    box-shadow: 0 4px 12px -4px rgba(232, 101, 26, 0.15);
}

.welcome-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.welcome-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.7;
    max-width: 38ch;
    margin-left: auto;
    margin-right: auto;
}

.welcome-hint {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 12px 20px;
    border-radius: 12px;
    background: rgba(232, 101, 26, 0.04);
    border: 1px solid rgba(232, 101, 26, 0.06);
    margin-top: 12px;
    line-height: 1.6;
}

.requirement-selector {
    margin: 0 0 16px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}

.requirement-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.requirement-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.requirement-btn:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px -2px rgba(232, 101, 26, 0.15);
    transform: translateY(-1px);
}

.requirement-btn:active {
    transform: translateY(0);
}

.req-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.requirement-btn:hover .req-icon {
    transform: scale(1.08);
}

.req-icon-import {
    background: #DBEAFE;
    color: #2563EB;
}

.req-icon-continue {
    background: #D1FAE5;
    color: #059669;
}

.req-icon-create {
    background: rgba(232, 101, 26, 0.1);
    color: var(--primary-color);
}

.req-icon-other {
    background: #f3e8ff;
    color: #7c3aed;
}

.req-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    letter-spacing: -0.01em;
}


/* Story type selector */
.story-type-selector {
    margin-top: 16px;
    animation: fadeInUp 0.3s ease-out;
}

.story-type-prompt {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: center;
}

.story-type-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.story-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 24px;
    background: #fff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;
    text-align: center;
}

.story-type-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 14px -2px rgba(232, 101, 26, 0.15);
    transform: translateY(-2px);
}

.story-type-card:active {
    transform: translateY(0);
}

.story-type-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(232, 101, 26, 0.08);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.story-type-card:hover .story-type-icon {
    transform: scale(1.08);
}

.story-type-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.story-type-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

@media (prefers-color-scheme: dark) {
    .story-type-card {
        background: var(--bg-secondary, #1e1e1e);
        border-color: var(--border-color, #333);
    }
    .story-type-icon {
        background: rgba(232, 101, 26, 0.15);
    }
}

@media (max-width: 480px) {
    .story-type-cards {
        flex-direction: column;
    }
    .story-type-card {
        min-width: 0;
    }
}

/* Messages */
.message {
    margin-bottom: 16px;
    min-width: 0;
    max-width: 100%;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    display: flex;
    justify-content: flex-end;
}

.assistant-message {
    display: flex;
    justify-content: flex-start;
}

.message-content {
    max-width: min(75%, 100%);
    min-width: 0;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.user-message .message-content {
    background: #FFF0E8;
    color: #3D2E1F;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
    .user-message .message-content {
        background: #3A2A1E;
        color: #F0DDD0;
    }
}

.assistant-message .message-content {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    max-width: 200px;
    box-shadow: var(--shadow-sm);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

.typing-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Tool Call Indicator - shows tool call status in real time */
.tool-call-indicator {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border: 1px solid #e0e7ff;
    border-radius: var(--radius-lg, 12px);
    border-bottom-left-radius: 4px;
    max-width: 360px;
    box-shadow: 0 1px 3px rgba(212, 85, 15, 0.08);
    animation: toolCallSlideIn 0.3s ease-out;
    margin-top: 4px;
}

@keyframes toolCallSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-call-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #C85415;
    line-height: 1.4;
}

.tool-call-item .tool-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #FDDCBE;
    border-top-color: #D4550F;
    border-radius: 50%;
    animation: toolSpinner 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes toolSpinner {
    to { transform: rotate(360deg); }
}

.tool-call-item .tool-name {
    font-weight: 500;
    color: #C85415;
}

.tool-call-item .tool-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.tool-call-item.tool-completed .tool-spinner {
    display: none;
}

.tool-call-item.tool-completed::before {
    content: '✓';
    color: #16a34a;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.tool-call-item.tool-completed .tool-name {
    color: #16a34a;
}

.tool-call-indicator.fade-out {
    animation: toolCallFadeOut 0.5s ease-out forwards;
}

@keyframes toolCallFadeOut {
    to {
        opacity: 0;
        transform: translateY(-4px);
        max-height: 0;
        padding: 0 16px;
        margin: 0;
        overflow: hidden;
    }
}

/* Input Section */
.input-section {
    padding: 20px 24px;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    flex-shrink: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 5;
}

.input-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/*
 * The send button is always absolutely positioned inside the input box, on the right.
 * - Single line: vertically centered (top:50% + translateY)
 * - Multi-line: anchored to the bottom-right when .input-container.is-expanded
 * Prevents the send button from being pushed out of the viewport and clipped after history messages stretch the flex layout (appearing as the "button disappearing").
 */
.input-container {
    position: relative;
    display: block;
    margin-bottom: 12px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

.message-input {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 14px 56px 14px 18px;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    max-height: 120px;
    background: #fafbfc;
}

.message-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(232, 101, 26, 0.08);
    background: white;
}

.message-input:disabled {
    background: var(--bg-light);
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: var(--border-color);
    box-shadow: none;
}

.send-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: var(--primary-gradient);
    color: white;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 2px 8px -2px rgba(232, 101, 26, 0.35);
}

.send-btn:hover:not(:disabled) {
    transform: translateY(calc(-50% - 1px));
    box-shadow: 0 4px 12px -2px rgba(232, 101, 26, 0.5);
}

/* After growing taller for multiple lines, anchor to bottom-right so it doesn't block the middle-row text */
.input-container.is-expanded .send-btn {
    top: auto;
    bottom: 8px;
    transform: none;
}

.input-container.is-expanded .send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn.sending {
    opacity: 0.7;
    cursor: not-allowed;
    animation: pulse-sending 1.5s ease-in-out infinite;
}

.chat-compress-btn {
    position: absolute;
    top: 4px;
    right: 50px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chat-compress-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 12px -2px rgba(232, 101, 26, 0.4);
}

.chat-compress-btn:active {
    transform: scale(0.95);
}

.chat-refresh-btn {
    position: absolute;
    top: 4px;
    right: 8px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chat-refresh-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: rotate(180deg);
    box-shadow: 0 4px 12px -2px rgba(232, 101, 26, 0.4);
}

.chat-refresh-btn:active {
    transform: rotate(180deg) scale(0.95);
}

/* System message styles */
.system-message {
    margin: 12px 24px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.system-message.info {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-color: #bae6fd;
}

.system-message.warning {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fcd34d;
}

.system-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.system-message-icon {
    font-size: 16px;
}

.system-message-title {
    font-size: 14px;
}

.system-message-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    padding-left: 24px;
}

.feedback-fab-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1100;
}

.feedback-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(212, 85, 15, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feedback-fab:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(212, 85, 15, 0.4);
}

.feedback-fab:active {
    transform: translateY(0) scale(0.95);
}

.feedback-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
    pointer-events: none;
}

.feedback-fab-container:hover .feedback-close-btn {
    opacity: 1;
    pointer-events: auto;
}

.feedback-close-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.feedback-close-btn:active {
    transform: scale(0.9);
}

.send-btn.sending svg {
    animation: rotate-sending 2s linear infinite;
}

@keyframes pulse-sending {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 0.9;
    }
}

@keyframes rotate-sending {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.status-info {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* World Sidebar - overlay mode, independent of the nav bar */
.world-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: white;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
}

.world-sidebar.open {
    transform: translateX(0);
}

/* Mask layer shown when the world sidebar is open */
.world-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.world-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}


.world-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    background: white;
}

.world-sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.world-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.world-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.world-add-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.world-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.world-close-btn:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.world-search-box {
    position: relative;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: white;
}

.world-search-input {
    width: 100%;
    padding: 10px 32px 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-light);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.world-search-input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(232, 101, 26, 0.1);
}

.world-search-clear {
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--text-muted);
    color: white;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}

.world-search-clear:hover {
    background: var(--text-secondary);
}

.world-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.world-sidebar-footer {
    flex-shrink: 0;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: white;
}

.world-deleted-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.world-deleted-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(232, 101, 26, 0.06);
}

.world-deleted-toggle.active-mode {
    border-style: solid;
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(232, 101, 26, 0.08);
}

.world-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    margin-bottom: 8px;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.world-item:hover {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px -2px rgba(232, 101, 26, 0.2);
    transform: translateY(-1px);
}

.world-item.active {
    background: linear-gradient(135deg, rgba(232, 101, 26, 0.1) 0%, rgba(212, 85, 15, 0.1) 100%);
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px -2px rgba(232, 101, 26, 0.3);
}

.world-item.deleted {
    opacity: 0.85;
}

.world-item.deleted .world-name {
    color: var(--text-secondary);
    text-decoration: line-through;
    text-decoration-color: rgba(148, 163, 184, 0.7);
}

.world-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.world-item.deleted .world-info {
    cursor: default;
}

.world-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.world-item:hover .world-actions {
    opacity: 1;
}

.world-edit-btn,
.world-hide-btn,
.world-restore-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.world-edit-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.world-hide-btn:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.1);
}

.world-restore-btn:hover {
    background: #10b981;
    color: white;
    transform: scale(1.1);
}

.world-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.world-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.world-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Collaboration role badge */
.world-role-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}
.world-role-viewer { background: #dbeafe; color: #1d4ed8; }
.world-role-editor { background: #fef3c7; color: #92400e; }
.world-role-creator { background: #d1fae5; color: #065f46; }

.world-collab-btn,
.world-leave-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.world-collab-btn:hover { background: #6366f1; color: white; transform: scale(1.1); }
.world-leave-btn:hover { background: #ef4444; color: white; transform: scale(1.1); }

/* Collaboration modal */
.collab-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
.collab-modal-overlay.active { display: flex; }
.collab-modal {
    background: var(--bg-white, #fff);
    border-radius: 12px;
    width: 520px;
    max-width: 95vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    padding: 20px;
}
.collab-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.collab-modal-header h3 { margin: 0; font-size: 16px; }
.collab-modal-close {
    border: none;
    background: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}
.collab-invite-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.collab-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 13px;
}
.collab-select {
    padding: 6px 8px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 13px;
}
.collab-btn-primary {
    padding: 6px 14px;
    background: var(--primary-color, #6366f1);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}
.collab-btn-primary:hover { opacity: 0.9; }
.collab-btn-danger {
    padding: 4px 10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.collab-btn-danger:hover { background: #dc2626; }
.collab-btn-secondary {
    padding: 4px 10px;
    background: var(--bg-light, #f3f4f6);
    color: var(--text-primary, #333);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.collab-list { display: flex; flex-direction: column; gap: 8px; }
.collab-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-light, #f9fafb);
    border-radius: 6px;
}
.collab-email { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collab-status { font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 3px; }
.collab-status-pending { background: #fef3c7; color: #92400e; }
.collab-status-accepted { background: #d1fae5; color: #065f46; }
.collab-status-declined { background: #fee2e2; color: #991b1b; }
.collab-role-select { font-size: 12px; padding: 3px 6px; }
.collab-loading, .collab-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Pending invitations in world sidebar */
.collab-invitations { margin-bottom: 12px; }
.collab-inv-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-color, #6366f1);
    padding: 4px 0 8px;
}
.collab-inv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(99,102,241,0.06);
    border-radius: 6px;
    margin-bottom: 6px;
}
.collab-inv-info { flex: 1; min-width: 0; }
.collab-inv-info strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collab-inv-info span { font-size: 11px; color: var(--text-secondary); }
.collab-inv-actions { display: flex; gap: 4px; flex-shrink: 0; }
.collab-btn-sm { padding: 3px 8px; font-size: 11px; }

/* World Selection Prompt Styles */
.world-selection-prompt {
    background: linear-gradient(135deg, rgba(232, 101, 26, 0.05) 0%, rgba(212, 85, 15, 0.05) 100%);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-lg);
}

.world-selection-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 24px 0;
    padding: 20px;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.selection-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.selection-step:hover {
    background: white;
    box-shadow: var(--shadow-sm);
}

.step-icon {
    font-size: 18px;
    color: var(--primary-color);
    font-weight: bold;
}

.step-text {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

.selection-divider {
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
    position: relative;
}

.selection-divider::before,
.selection-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-color);
}

.selection-divider::before {
    left: 0;
}

.selection-divider::after {
    right: 0;
}

.selection-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    margin-top: 16px;
}

.note-icon {
    font-size: 16px;
    color: var(--success-color);
}

.selection-note span:last-child {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
}

/* File Sidebar */
.file-sidebar {
    width: 340px;
    display: flex;
    flex-direction: column;
    background: #fafcfe;
    border-left: 1px solid rgba(226, 232, 240, 0.8);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: white;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-overflow-menu {
    position: relative;
}

.overflow-trigger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.overflow-trigger-btn:hover {
    background: rgba(232, 101, 26, 0.08);
    color: var(--primary-color);
}

.overflow-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    padding: 4px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    z-index: 200;
}

.overflow-dropdown.open {
    display: block;
}

.overflow-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s;
    text-align: left;
}

.overflow-item:hover {
    background: rgba(232, 101, 26, 0.06);
}

.overflow-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.overflow-item-danger {
    color: #dc2626;
}

.overflow-item-danger svg {
    color: #dc2626;
}

.overflow-item-danger:hover {
    background: rgba(220, 38, 38, 0.06);
}

.overflow-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 8px;
}

.add-file-btn-fab {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(200, 84, 21, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
}

.add-file-btn-fab:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #D4550F 100%);
    box-shadow: 0 6px 20px rgba(200, 84, 21, 0.4);
    transform: scale(1.1);
}

.add-file-btn-fab:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(200, 84, 21, 0.2);
}

.add-file-btn-fab svg {
    width: 20px;
    height: 20px;
}

.export-icon-btn,
.import-icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.export-icon-btn:hover {
    background: var(--bg-light);
    color: var(--success-color, #27ae60);
}

.import-icon-btn:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.import-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    padding: 4px 6px;
    margin: -4px -2px;
    border: 2px dashed transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.import-drop-zone:hover {
    background: var(--bg-light);
}

.import-drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(232, 101, 26, 0.08);
    color: var(--primary-color);
}

.import-drop-zone.drag-over .import-icon-btn {
    color: var(--primary-color);
}

.import-drop-hint {
    font-size: 10px;
    line-height: 1.2;
    color: var(--text-muted);
    margin-top: 2px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

/* ===== World import progress bar (frontend direct upload to Qiniu + backend rate-limited download) ===== */
.world-import-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 0 8px 4px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.world-import-progress[hidden] {
    display: none !important;
}

.world-import-progress-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.world-import-progress-stage {
    font-size: 11px;
    line-height: 1.3;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.world-import-progress-pct {
    font-size: 10px;
    line-height: 1.2;
    color: var(--text-muted);
}

.world-import-progress-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    width: 100%;
}

.world-import-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.25s ease;
}

.world-import-progress.error .world-import-progress-bar-fill {
    background: var(--danger-color, #e74c3c);
}

.world-import-progress.done .world-import-progress-bar-fill {
    background: var(--success-color, #27ae60);
}

.world-import-progress-cancel {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    flex-shrink: 0;
}

.world-import-progress-cancel:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.06));
    color: var(--danger-color, #e74c3c);
}

.refresh-icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-icon-btn:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.refresh-icon-btn:hover svg {
    transform: rotate(180deg);
}

.refresh-icon-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.delete-icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-icon-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.delete-icon-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.delete-icon-btn:hover svg {
    transform: scale(1.1);
}

.file-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 12px;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 10px;
    position: relative;
}

.tab-btn:hover {
    background: white;
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.tab-btn.active {
    background: rgba(232, 101, 26, 0.08);
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
    box-shadow: 0 1px 4px rgba(232, 101, 26, 0.1);
}

.tab-btn.active .tab-icon svg {
    stroke: var(--primary-color);
}

.tab-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-icon svg {
    transition: stroke 0.2s;
}

.sidebar-scroll-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.file-list-container {
    flex: 1 1 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.file-list-header {
    flex-shrink: 0;
    height: 60px;
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    position: relative;
}

#file-items-container {
    flex: 1 1 auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    cursor: pointer;
}

.file-item:hover {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px -2px rgba(232, 101, 26, 0.2);
    transform: translateY(-1px);
}

.file-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-actions {
    display: flex;
    gap: 6px;
}

.file-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.view-btn {
    color: #3182ce;
}

.view-btn:hover {
    background: #ebf8ff;
}

.edit-btn {
    color: #d69e2e;
}

.edit-btn:hover {
    background: #fefcbf;
}

.delete-btn {
    color: #e53e3e;
}

.delete-btn:hover {
    background: #fff5f5;
}

.storyboard-btn {
    color: #0f766e;
}

.storyboard-btn:hover {
    background: #ccfbf1;
}

.file-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Confirm dialog */
.confirm-dialog {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.confirm-dialog.show {
    display: flex;
}

.confirm-dialog-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
}

.confirm-dialog-card {
    position: relative;
    width: 90%;
    max-width: 420px;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px -12px rgba(0, 0, 0, 0.25);
    padding: 28px 28px 20px;
    animation: modalSlideIn 0.25s ease-out;
}

.confirm-dialog-title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.confirm-dialog-message {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.confirm-dialog-bullets {
    margin: 0 0 20px;
    padding-left: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.confirm-dialog-bullets li::marker {
    color: var(--primary-color);
}

.confirm-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.confirm-dialog-btn {
    padding: 8px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all 0.15s ease;
}

.confirm-dialog-cancel {
    background: white;
    color: var(--text-primary);
}

.confirm-dialog-cancel:hover {
    background: var(--bg-secondary);
}

.confirm-dialog-ok {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.confirm-dialog-ok:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.confirm-dialog-ok.danger {
    background: #dc2626;
    border-color: #dc2626;
}

.confirm-dialog-ok.danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

.modal-dialog.large {
    max-width: 900px;
}


.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.modal-close-btn:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.feedback-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.feedback-desc {
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
}

.qr-wrapper {
    width: 220px;
    height: 220px;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-light);
    border: 1px dashed rgba(212, 85, 15, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 20px rgba(212, 85, 15, 0.08);
}

.qr-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.file-content {
    background: var(--bg-light);
    padding: 20px;
    border-radius: var(--radius-md);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input,
.form-textarea {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(232, 101, 26, 0.1);
}

.form-input[readonly] {
    background: var(--bg-light);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Toast Messages */
.error-toast,
.success-toast,
.info-toast,
.warning-toast {
    padding: 14px 18px;
    margin: 12px 0;
    border-radius: var(--radius-md);
    font-size: 14px;
    animation: fadeInUp 0.3s ease-out;
}

.error-toast {
    background: #fed7d7;
    color: #c53030;
    border-left: 4px solid var(--error-color);
}

.success-toast {
    background: #c6f6d5;
    color: #22543d;
    border-left: 4px solid var(--success-color);
}

.info-toast {
    background: #bee3f8;
    color: #2c5282;
    border-left: 4px solid #3182ce;
}

.warning-toast {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

/* Markdown Styles */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 {
    font-size: 1.8em;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.message-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.message-content h3 {
    font-size: 1.3em;
}

.message-content p {
    margin: 8px 0;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 4px 0;
}

.message-content blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 4px solid var(--primary-color);
    background: rgba(232, 101, 26, 0.05);
    font-style: italic;
}

.message-content code {
    background: var(--bg-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: #d73a49;
}

.message-content pre {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
    max-width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-content table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
    max-width: 100%;
    display: block;
    overflow-x: auto;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background: var(--bg-light);
    font-weight: 600;
}

.message-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s;
}

.message-content a:hover {
    border-bottom-color: var(--primary-color);
}

.message-content strong {
    font-weight: 600;
}

.message-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

/* Tool Call Icon */
.tool-call-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 8px;
    font-size: 0.9em;
    color: #0369a1;
    font-weight: 500;
    cursor: help;
    transition: all 0.2s ease;
}

.tool-call-icon:hover {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    border-color: #7dd3fc;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px -2px rgba(3, 105, 161, 0.2);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* View Form Styles */
.view-form {
    width: 100%;
}

.view-field {
    padding: 12px 16px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 44px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.view-field:empty::before {
    content: 'Not set';
    color: var(--text-muted);
    font-style: italic;
}

.view-image-container {
    min-height: 44px;
}

.preview-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    display: block;
    margin-top: 8px;
    transition: transform 0.2s;
}

.preview-image:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
}

.view-image-container .view-field {
    background: var(--bg-light);
    border: 1px dashed var(--border-color);
    text-align: center;
    color: var(--text-muted);
}

.view-image-container .view-field small {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    word-break: break-all;
}

.view-field.script-content {
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.8;
}

/* Script fullscreen view button */
.script-fullscreen-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    vertical-align: middle;
    margin-left: 8px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    font-size: 12px;
}

.script-fullscreen-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: var(--bg-light);
}

/* Script fullscreen view dialog */
.script-fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    animation: modalFadeIn 0.2s ease-out;
}

.script-fullscreen-overlay.show {
    display: flex;
    flex-direction: column;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.script-fullscreen-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.script-fullscreen-toolbar .toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.script-fullscreen-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.font-size-btn {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-secondary);
    transition: all 0.2s;
    line-height: 1;
}

.font-size-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.font-size-label {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
}

.fullscreen-close-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.fullscreen-close-btn:hover {
    color: var(--error-color);
    border-color: var(--error-color);
}

.script-fullscreen-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px;
    background: var(--bg-white);
}

.script-fullscreen-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 900px;
    margin: 0 auto;
}

.script-fullscreen-textarea {
    width: 100%;
    min-height: calc(100vh - 120px);
    padding: 0;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.8;
    color: var(--text-primary);
    background: transparent;
    font-size: inherit;
}

/* ==================== Narrow screen responsive optimization ==================== */

/* Staging area mask layer */
.file-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1499;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.file-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Narrow screen staging area floating button */
.file-sidebar-toggle-btn {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    cursor: pointer;
    z-index: 1501;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(212, 85, 15, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.file-sidebar-toggle-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(212, 85, 15, 0.4);
}

/*
 * Model selector compact mode (width < 1440px)
 * At medium widths, the model select box automatically shrinks to an icon button, and only expands
 * to full width with the model name shown on hover / focus / when the dropdown opens, saving horizontal header space.
 * Only takes effect at ≥ 901px, avoiding the overlay mode used at ≤ 900px.
 * Uses the .model-selector-card prefix to raise specificity, ensuring it overrides the old width rules
 * for .model-select-wrapper at the breakpoints below.
 */
@media (max-width: 1440px) and (min-width: 901px) {
    .model-selector-card:not(.compact-open) .model-selector-item,
    .model-selector-card:not(.compact-open) .intervention-level-wrapper {
        position: relative;
    }

    .model-selector-card:not(.compact-open) .model-select-wrapper {
        position: relative;
        width: 30px;
        min-width: 30px;
        overflow: visible;
        z-index: 1;
    }

    .model-selector-card:not(.compact-open) .model-select-display {
        position: absolute;
        top: 0;
        left: 0;
        right: auto;
        width: 30px;
        color: transparent;
        background-color: transparent;
        transition: width 0.18s ease, color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
        white-space: nowrap;
        z-index: 1;
    }

    .model-selector-card:not(.compact-open) .model-select-wrapper:hover,
    .model-selector-card:not(.compact-open) .model-select-wrapper:focus-within,
    .model-selector-card:not(.compact-open) .model-select-wrapper.custom-select-open {
        z-index: 25;
    }

    .model-selector-card:not(.compact-open) .model-select-wrapper:hover .model-select-display,
    .model-selector-card:not(.compact-open) .model-select-wrapper:focus-within .model-select-display,
    .model-selector-card:not(.compact-open) .model-select-wrapper.custom-select-open .model-select-display {
        width: 170px;
        color: var(--text-primary);
        background-color: white;
        border-color: var(--primary-color);
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
        z-index: 25;
    }

    .model-selector-card:not(.compact-open) .intervention-level-wrapper .model-select-wrapper:hover .model-select-display,
    .model-selector-card:not(.compact-open) .intervention-level-wrapper .model-select-wrapper:focus-within .model-select-display,
    .model-selector-card:not(.compact-open) .intervention-level-wrapper .model-select-wrapper.custom-select-open .model-select-display {
        width: 150px;
    }

    .model-selector-card:not(.compact-open) .model-divider {
        margin: 0 10px;
    }

    .model-selector-card:not(.compact-open) .intervention-level-wrapper {
        margin-left: 6px;
    }
}

/* Responsive */
@media (max-width: 1400px) {
    .file-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: min(360px, 100vw);
        height: 100vh;
        z-index: 1500;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        border-left: none;
        box-shadow: -12px 0 30px rgba(15, 23, 42, 0.12);
    }

    .file-sidebar.open {
        transform: translateX(0);
    }

    .file-sidebar-toggle-btn {
        display: flex;
        right: 28px;
        bottom: 156px;
    }

    .feedback-fab-container {
        display: none;
    }

    .top-header {
        padding: 10px 16px;
        align-items: flex-start;
        flex-wrap: nowrap;
        row-gap: 8px;
        overflow-y: visible;
    }

    .breadcrumb-nav,
    .world-name-display {
        display: none;
    }

    .header-left {
        flex: 0 0 auto;
        gap: 10px;
    }

    .header-right {
        flex: 1 1 auto;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .model-selector-card {
        padding: 8px 10px;
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .model-select-wrapper {
        width: clamp(112px, 12vw, 150px);
    }

    .intervention-level-wrapper .model-select-wrapper {
        width: clamp(96px, 10vw, 132px);
    }

    .model-divider {
        margin: 0 10px;
    }

    .header-nav-btn {
        padding: 6px 14px;
        font-size: 13px;
    }

    .header-action-btn.primary .btn-text,
    .auto-submit-container .toggle-label {
        display: none;
    }

    .i18n-switcher-container {
        margin-left: 4px !important;
    }
}

@media (max-width: 1024px) {
    .file-sidebar {
        width: 280px;
    }

    .welcome-features {
        grid-template-columns: 1fr;
    }

    .top-header {
        padding: 10px 16px;
    }

    .model-selector-card {
        padding: 8px 12px;
    }

    .model-divider {
        margin: 0 10px;
    }

    .welcome-card {
        padding: 36px 24px 28px;
    }
}

@media (max-width: 768px) {
    /* Staging area changed to a fixed fullscreen slide-in */
    .file-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100vh;
        z-index: 1500;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        border-left: none;
    }

    .file-sidebar.open {
        transform: translateX(0);
    }

    .file-sidebar-toggle-btn {
        display: flex;
    }

    .main-layout {
        margin-left: 0;
    }

    /* Simplified header */
    .top-header {
        padding: 8px 12px;
    }

    .header-left {
        gap: 10px;
        flex: 0 0 auto;
    }

    .header-right {
        gap: 6px;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .breadcrumb-nav {
        display: none;
    }

    .world-name-display {
        display: none;
    }

    .header-nav-btn {
        padding: 5px 12px;
        font-size: 12px;
    }

    .model-selector-card {
        padding: 6px 10px;
        gap: 0;
    }

    .model-divider {
        margin: 0 8px;
    }

    .model-select-wrapper {
        width: 130px;
    }

    .intervention-level-wrapper {
        margin-left: 4px;
        gap: 4px;
    }

    .intervention-level-wrapper .model-select-wrapper {
        width: 110px;
    }

    .computing-power-display {
        padding: 6px 10px;
    }

    .computing-power-display .power-value {
        display: none;
    }

    .header-action-btn.primary .btn-text {
        display: none;
    }

    .auto-submit-container .toggle-label {
        display: none;
    }

    .i18n-switcher-container {
        margin-left: 4px !important;
    }

    .welcome-card {
        padding: 24px 16px 20px;
        margin: 24px auto;
    }

    .welcome-title {
        font-size: 19px;
    }

    .requirement-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .message-content {
        max-width: 85%;
    }

    .input-section {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }

    .input-container {
        margin-bottom: 10px;
    }

    .message-input {
        padding: 12px 56px 12px 16px;
    }

    .send-btn {
        width: 40px;
        height: 40px;
        /* Still vertically centered on narrow screens; anchored to the bottom by the general rule when is-expanded */
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
    }

    .input-container.is-expanded .send-btn {
        top: auto;
        bottom: 8px;
        transform: none;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 480px) {
    .model-selector-card {
        padding: 4px 6px;
    }

    .model-icon {
        width: 28px;
        height: 28px;
    }

    .model-select-wrapper {
        width: 110px;
    }

    .intervention-level-wrapper .model-select-wrapper {
        width: 90px;
    }

    .intervention-level-wrapper {
        display: none;
    }

    .thinking-mode-wrapper {
        margin-left: 4px;
        gap: 4px;
    }

    .thinking-label {
        font-size: 11px;
    }

    .model-divider {
        margin: 0 6px;
    }

    .header-action-btn {
        padding: 6px 10px;
    }

    .auto-submit-toggle .toggle-slider {
        width: 32px;
        height: 18px;
    }

    .auto-submit-toggle .toggle-slider::after {
        width: 14px;
        height: 14px;
    }

    .auto-submit-toggle input:checked + .toggle-slider::after {
        left: 16px;
    }

    .chat-messages {
        padding: 12px;
    }

    .message-content {
        padding: 10px 14px;
        font-size: 13px;
    }

    .message-input {
        padding-right: 52px;
    }

    .send-btn {
        width: 36px;
        height: 36px;
        right: 6px;
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
    }

    .send-btn:hover:not(:disabled) {
        transform: translateY(calc(-50% - 1px));
    }

    .input-container.is-expanded .send-btn {
        top: auto;
        bottom: 6px;
        transform: none;
    }

    .input-container.is-expanded .send-btn:hover:not(:disabled) {
        transform: translateY(-1px);
    }
}

@media (max-width: 900px) {
    .model-settings-toggle-btn {
        display: flex;
    }

    .model-selector-card {
        display: none;
    }

    .model-selector-card.compact-open {
        left: 12px;
        right: 12px;
        width: auto;
    }
}

/* Credits Logs Styles */
.computing-logs-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.computing-logs-tab {
    padding: 10px 20px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.computing-logs-tab:hover {
    background: rgba(232, 101, 26, 0.1);
    border-color: var(--primary-color);
}

.computing-logs-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.computing-logs-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

.computing-logs-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    color: var(--error-color);
    text-align: center;
}

.computing-logs-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.computing-logs-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.computing-logs-empty-text {
    font-size: 16px;
}

.computing-logs-container {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.computing-log-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.computing-log-item:last-child {
    border-bottom: none;
}

.computing-log-item:hover {
    background: var(--bg-light);
}

.computing-log-info {
    flex: 1;
}

.computing-log-behavior {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.computing-log-behavior.increase {
    color: var(--success-color);
}

.computing-log-behavior.deduct {
    color: var(--error-color);
}

.computing-log-description {
    font-size: 13px;
    color: var(--text-secondary);
}

.computing-log-change {
    font-size: 13px;
    color: var(--primary-color);
    margin-top: 6px;
    font-family: monospace;
    font-weight: 600;
    background: rgba(212, 85, 15, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    border-left: 3px solid var(--primary-color);
}

.computing-log-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.computing-log-amount {
    font-size: 18px;
    font-weight: 700;
}

.computing-log-amount.increase {
    color: var(--success-color);
}

.computing-log-amount.deduct {
    color: var(--error-color);
}

.computing-log-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.computing-logs-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding: 20px 0;
}

.computing-logs-pagination button {
    padding: 8px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.computing-logs-pagination button:hover:not(:disabled) {
    background: rgba(232, 101, 26, 0.1);
    border-color: var(--primary-color);
}

.computing-logs-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.computing-logs-page-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== Left navigation bar styles - floating mode ========== */
.step-nav {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: auto;
    width: 56px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-left: none;
    border-radius: 0 14px 14px 0;
    z-index: 1000;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 16px -4px rgba(0, 0, 0, 0.06);
}

.step-nav:hover {
    width: 210px;
    box-shadow: 4px 0 24px -4px rgba(0, 0, 0, 0.12);
}


.step-nav-content {
    padding: 12px 4px;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.step-nav:hover .step-nav-content {
    padding: 16px 12px;
}

.step-nav-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
    padding-left: 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.step-nav:hover .step-nav-title {
    opacity: 1;
}

.step-nav-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    transition: all 0.2s ease;
    position: relative;
    min-height: 40px;
    box-sizing: border-box;
}

.step-nav:hover .step-nav-item {
    justify-content: flex-start;
    padding: 12px 14px;
}

.step-nav-item.active {
    background: linear-gradient(135deg, rgba(232, 101, 26, 0.12) 0%, rgba(212, 85, 15, 0.08) 100%);
    border-color: rgba(232, 101, 26, 0.3);
    color: var(--primary-color);
}

.step-nav-item.clickable {
    cursor: pointer;
}

.step-nav-item.clickable:hover {
    background: rgba(232, 101, 26, 0.06);
    border-color: rgba(232, 101, 26, 0.25);
    transform: translateX(2px);
}

.step-nav-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(232, 101, 26, 0.08);
    color: var(--primary-color);
    transition: background 0.2s, color 0.2s;
}

.step-nav-item.active .step-nav-icon {
    background: var(--primary-color);
    color: white;
}

.step-nav-item.clickable:hover .step-nav-icon {
    background: rgba(232, 101, 26, 0.14);
}

.step-nav-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    display: none;
}

.step-nav:hover .step-nav-text {
    display: block;
}

.step-nav-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
    display: none;
}

.step-nav-badge.current {
    background: var(--primary-color);
    color: white;
}

.step-nav:hover .step-nav-badge {
    display: inline-block;
}

.step-nav-arrow {
    font-size: 16px;
    color: var(--primary-color);
    margin-left: auto;
    display: none;
}

.step-nav:hover .step-nav-arrow {
    display: block;
}

.step-nav-item.clickable:hover .step-nav-arrow {
    transform: translateX(4px);
}

.step-nav-connector {
    width: 2px;
    height: 16px;
    background: linear-gradient(to bottom, rgba(232, 101, 26, 0.2), rgba(232, 101, 26, 0.05));
    margin: 2px auto;
    border-radius: 1px;
    transition: margin 0.25s ease;
}

.step-nav:hover .step-nav-connector {
    margin: 2px 0 2px 30px;
}

.step-nav-home {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    padding: 10px 4px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 0 0 var(--radius-md) 0;
}

.step-nav-home:hover {
    color: var(--primary-color);
}

.step-nav-home-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.step-nav-home-text {
    display: none;
    white-space: nowrap;
}

.step-nav:hover .step-nav-home {
    justify-content: flex-start;
    padding: 10px 14px;
}

.step-nav:hover .step-nav-home-text {
    display: inline;
}

/* Adjust the main content area to fit the floating nav bar */
.app-container {
    margin-left: 0;
}

/* top-header and input-section are unaffected by the nav bar, no space reserved on the left */
.top-header,
.input-section {
    margin-left: 0;
}

@media (max-width: 1024px) {
    .step-nav {
        position: fixed;
        left: 12px;
        top: auto;
        bottom: 90px;
        transform: none;
        width: auto;
        height: auto;
        background: none;
        border: none;
        border-radius: 0;
        z-index: 1000;
    }
    .step-nav:hover {
        width: auto;
        box-shadow: none;
    }
    .step-nav-content {
        padding: 0;
    }
    .step-nav:hover .step-nav-content {
        padding: 0;
    }
    .step-nav-title,
    .step-nav-connector,
    .step-nav-text,
    .step-nav-badge,
    .step-nav-arrow {
        display: none !important;
    }
    .step-nav-list {
        gap: 0;
    }
    .step-nav-item.active {
        display: none !important;
    }
    .step-nav-item.clickable {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--primary-gradient);
        box-shadow: 0 4px 12px rgba(212, 85, 15, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        gap: 0;
    }
    .step-nav-item.clickable:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(212, 85, 15, 0.4);
        background: var(--primary-gradient);
    }
    .step-nav:hover .step-nav-item {
        padding: 0;
    }
    .step-nav-icon {
        font-size: 20px;
        margin: 0;
        width: auto;
        height: auto;
        background: none;
        color: white;
    }
    .step-nav-icon svg {
        stroke: white;
    }
    .step-nav-home {
        display: none;
    }

    .main-layout {
        margin-left: 0;
    }
}

/* ==================== Image preview and upload feature styles ==================== */

/* Image preview icon */
.image-preview-btn {
    color: #666;
    transition: all 0.2s ease;
}

.image-preview-btn.has-image {
    color: #10b981;
}

.image-preview-btn.has-image:hover {
    color: #059669;
    transform: scale(1.1);
}

.image-preview-btn.no-image {
    color: #ef4444;
    opacity: 0.6;
}

.image-preview-btn.no-image:hover {
    opacity: 1;
}

/* Publish to Asset Library button */
.publish-btn {
    color: #666;
    transition: all 0.2s ease;
}
.publish-btn:hover {
    color: var(--primary, #E8651A);
    transform: scale(1.1);
}

/* Voice preview playback button */
.voice-play-btn {
    color: #666;
    transition: all 0.2s ease;
}

.voice-play-btn.has-voice {
    color: #10b981;
}

.voice-play-btn.has-voice:hover {
    color: #059669;
    transform: scale(1.1);
}

.voice-play-btn.no-voice {
    color: #9ca3af;
    opacity: 0.4;
    cursor: not-allowed;
}

.voice-play-btn[disabled] {
    cursor: not-allowed;
    opacity: 0.4;
}

/* Image preview dialog */
.image-preview-dialog {
    max-width: 90vw;
    max-height: 90vh;
}

.image-preview-dialog .modal-body {
    max-height: 80vh;
    overflow-y: auto;
}

.full-preview-image {
    max-width: 100%;
    max-height: 55vh;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

/* Thumbnail grid */
#image-preview-thumbnails {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.thumbnail-item {
    width: 80px;
    text-align: center;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}

.thumbnail-item:hover {
    opacity: 1;
    transform: scale(1.05);
}

.thumbnail-item.active {
    opacity: 1;
}

.thumbnail-item img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
}

.thumbnail-item.active img {
    border-color: #007bff;
}

.thumbnail-label {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    white-space: nowrap;
}

/* Thumbnail generate button */
.thumbnail-item {
    position: relative;
}

.thumbnail-generate-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #E8651A;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.thumbnail-item:hover .thumbnail-generate-btn {
    opacity: 1;
}

.thumbnail-generate-btn:hover {
    background: #C85415;
}

.thumbnail-generate-btn:disabled {
    background: #F0974E;
    cursor: not-allowed;
}

/* Image upload container */
.image-upload-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.image-upload-container .form-input {
    flex: 1;
    background-color: #f9fafb;
}

.image-upload-actions {
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary.btn-sm {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary.btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary.btn-sm {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.btn-secondary.btn-sm:hover {
    background: #e5e7eb;
}

/* Image preview box */
.image-preview-box {
    margin-top: 12px;
    position: relative;
    display: inline-block;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px;
    background: white;
}

.preview-thumbnail {
    max-width: 200px;
    max-height: 200px;
    display: block;
    border-radius: 4px;
}

.preview-remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.preview-remove-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* ========== Import script dialog ========== */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-light);
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(232, 101, 26, 0.04);
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(232, 101, 26, 0.08);
    transform: scale(1.01);
}

.drop-zone.has-file {
    border-color: #22c55e;
    border-style: solid;
    background: rgba(34, 197, 94, 0.04);
}

.drop-zone-text {
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.drop-zone-link {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: underline;
}

.import-divider {
    text-align: center;
    margin: 16px 0;
    position: relative;
    color: var(--text-muted);
    font-size: 13px;
}

.import-divider::before,
.import-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 60px);
    height: 1px;
    background: var(--border-color);
}

.import-divider::before { left: 0; }
.import-divider::after { right: 0; }

/* Verification Question Styles */
.verification-question {
    background: #FFF8F4;
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color, #E8651A);
    color: #3D2E1F;
    margin: 12px 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.verification-title {
    display: block;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--primary-dark, #C85415);
}

.verification-description {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    color: #5C4033;
}

.verification-click-hint {
    font-size: 12px;
    line-height: 1.4;
    margin: 0 0 12px;
    color: #8B7355;
}

.verification-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.option-btn {
    padding: 8px 16px;
    background: #fff;
    border: 1px solid rgba(232, 101, 26, 0.3);
    border-radius: 8px;
    color: #9C4A1A;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.option-btn:hover:not(:disabled) {
    background: var(--primary-color, #E8651A);
    color: #fff;
    border-color: var(--primary-color, #E8651A);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(232, 101, 26, 0.2);
}

.option-btn:active:not(:disabled) {
    transform: translateY(0);
    background: var(--primary-dark, #C85415);
    color: #fff;
    border-color: var(--primary-dark, #C85415);
}

.option-btn:focus-visible {
    outline: 2px solid var(--primary-color, #E8651A);
    outline-offset: 2px;
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none;
    transform: none;
}

/* "Other" button: outlined secondary action */
.option-other-btn {
    background: transparent;
    border: 1px dashed #C4A882;
    color: #8B7355;
    font-weight: 500;
    box-shadow: none;
}

.option-other-btn:hover:not(:disabled) {
    background: rgba(232, 101, 26, 0.08);
    border-color: var(--primary-color, #E8651A);
    color: var(--primary-color, #E8651A);
    box-shadow: none;
}

.verification-expired-badge {
    margin: 12px 0 0;
    font-size: 12px;
    font-weight: 600;
    color: #8B7355;
}

.verification-question.is-expired {
    filter: grayscale(0.35);
    opacity: 0.78;
}

.verification-question.is-expired .option-btn,
.verification-question.is-answered .option-btn {
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.55;
    box-shadow: none;
}

@media (prefers-color-scheme: dark) {
    .verification-question {
        background: #2A2017;
        color: #E8D5C4;
        border-left-color: var(--primary-color, #E8651A);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    }
    .verification-title {
        color: #F0A870;
    }
    .verification-description {
        color: #C8B8A8;
    }
    .verification-click-hint {
        color: #9A8A7A;
    }
    .option-btn {
        background: #3A3028;
        border-color: rgba(232, 101, 26, 0.3);
        color: #F0A870;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
    .option-btn:hover:not(:disabled) {
        background: var(--primary-color, #E8651A);
        color: #fff;
        border-color: var(--primary-color, #E8651A);
        box-shadow: 0 4px 10px rgba(232, 101, 26, 0.3);
    }
    .option-btn:active:not(:disabled) {
        background: var(--primary-dark, #C85415);
        color: #fff;
        border-color: var(--primary-dark, #C85415);
    }
    .option-other-btn {
        border-color: #5A4A3A;
        color: #9A8A7A;
    }
    .option-other-btn:hover:not(:disabled) {
        background: rgba(232, 101, 26, 0.12);
        border-color: var(--primary-color, #E8651A);
        color: #F0A870;
    }
    .verification-expired-badge {
        color: #9A8A7A;
    }
}

/* ── Workflow Complete Card ── */
.workflow-complete-card {
    background: #ffffff;
    border: 2px solid #E8651A;
    border-radius: 16px;
    padding: 24px;
    margin: 12px 0;
    box-shadow: 0 4px 20px rgba(232, 101, 26, 0.12);
}

.wc-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.wc-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #E8651A 0%, #C85415 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.wc-icon svg {
    width: 26px;
    height: 26px;
    stroke: #fff;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wc-title {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.wc-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: 2px 0 0;
}

.wc-script-title {
    font-size: 14px;
    font-weight: 600;
    color: #E8651A;
    margin: 0 0 16px;
}

.wc-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.wc-stat {
    background: #FFF8F4;
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
}

.wc-stat-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: #E8651A;
    line-height: 1.2;
}

.wc-stat-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.wc-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wc-action-primary {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #E8651A 0%, #C85415 100%);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(232, 101, 26, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.wc-action-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(232, 101, 26, 0.4);
}

.wc-action-primary:active {
    transform: translateY(0);
}

.wc-action-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.wc-action-secondary-row {
    display: flex;
    gap: 10px;
}

.wc-action-secondary {
    flex: 1;
    padding: 10px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.wc-action-secondary:hover {
    background: #FFF8F4;
    border-color: #E8651A;
    color: #E8651A;
}

.wc-action-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.workflow-complete-card.is-expired .wc-action-primary,
.workflow-complete-card.is-expired .wc-action-secondary,
.workflow-complete-card.is-answered .wc-action-primary,
.workflow-complete-card.is-answered .wc-action-secondary {
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.55;
}

.workflow-complete-card.history-mode .wc-action-primary,
.workflow-complete-card.history-mode .wc-action-secondary {
    cursor: default;
    pointer-events: none;
}

@media (max-width: 480px) {
    .wc-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .wc-action-secondary-row {
        flex-direction: column;
    }
}

/* ── Compliance Review Card ── */
.compliance-review-card {
    background: #ffffff;
    border: 2px solid #d97706;
    border-radius: 16px;
    padding: 24px;
    margin: 12px 0;
    box-shadow: 0 4px 20px rgba(217, 119, 6, 0.12);
}

.cr-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.cr-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cr-icon svg {
    width: 26px;
    height: 26px;
    stroke: #fff;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cr-title {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.cr-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: 2px 0 0;
}

.cr-summary {
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 18px;
    white-space: pre-line;
}

.cr-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cr-action-primary {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cr-action-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.4);
}

.cr-action-primary:active {
    transform: translateY(0);
}

.cr-action-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.cr-action-secondary-row {
    display: flex;
    gap: 10px;
}

.cr-action-secondary {
    flex: 1;
    padding: 10px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.cr-action-secondary:hover {
    background: #fffbeb;
    border-color: #d97706;
    color: #d97706;
}

.cr-action-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.compliance-review-card.is-expired .cr-action-primary,
.compliance-review-card.is-expired .cr-action-secondary,
.compliance-review-card.is-answered .cr-action-primary,
.compliance-review-card.is-answered .cr-action-secondary {
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.55;
}

.compliance-review-card.history-mode .cr-action-primary,
.compliance-review-card.history-mode .cr-action-secondary {
    cursor: default;
    pointer-events: none;
}

@media (max-width: 480px) {
    .cr-action-secondary-row {
        flex-direction: column;
    }
}

/* Verification questions in history (reuses dialogue styles, interaction disabled only) */
.verification-question.history-mode .option-btn {
    cursor: default;
    pointer-events: none;
}

/* Verification questions in history */
.history-verification {
    background: #FFF8F4;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid rgba(232, 101, 26, 0.15);
    border-left: 3px solid var(--primary-color, #E8651A);
    margin: 8px 0;
    opacity: 0.85;
}

.history-verification .verification-title {
    font-size: 14px;
}

.history-verification .verification-description {
    font-size: 13px;
    margin-bottom: 10px;
}

.history-verification-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.history-option-tag {
    padding: 4px 10px;
    background: rgba(232, 101, 26, 0.06);
    border: 1px solid rgba(232, 101, 26, 0.2);
    border-radius: 5px;
    color: #8B7355;
    font-size: 12px;
    cursor: default;
}

/* ===== Art style recognition block (bottom of the "World" tab in the staging area) ===== */
.style-recognize-section {
    flex-shrink: 0;
    padding: 12px 12px 14px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    background:
        linear-gradient(180deg, rgba(232, 101, 26, 0.04) 0%, transparent 48%),
        var(--bg-secondary, #f9fafb);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.style-recognize-section[hidden] {
    display: none !important;
}

.style-recognize-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.style-recognize-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.style-recognize-title-group {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
}

.style-recognize-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
    letter-spacing: 0.01em;
    min-width: 0;
}

/* Open-source/community edition "free for a limited time" badge; hidden via JS in the commercial edition */
.style-recognize-free-badge {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 1px 7px;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    color: #d97706;
    background: #fff7ed;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.style-recognize-free-badge[hidden] {
    display: none !important;
}

.style-recognize-more-link {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-color, #E8651A);
    text-decoration: none;
    line-height: 1.3;
    white-space: nowrap;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.style-recognize-more-link:hover {
    color: #C85415;
    border-bottom-color: currentColor;
}

.style-recognize-more-link:focus-visible {
    outline: 2px solid rgba(232, 101, 26, 0.45);
    outline-offset: 2px;
    border-radius: 2px;
}

.style-recognize-subtitle {
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted, #9ca3af);
}

/* Drop zone */
.style-drop-zone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 112px;
    padding: 12px;
    border: 1.5px dashed rgba(232, 101, 26, 0.35);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    outline: none;
    overflow: hidden;
}

.style-drop-zone:hover,
.style-drop-zone:focus-visible {
    border-color: var(--primary-color, #E8651A);
    background: rgba(232, 101, 26, 0.06);
    box-shadow: 0 0 0 3px rgba(232, 101, 26, 0.08);
}

.style-drop-zone.drag-over {
    border-color: var(--primary-color, #E8651A);
    border-style: solid;
    background: rgba(232, 101, 26, 0.12);
    box-shadow: 0 0 0 4px rgba(232, 101, 26, 0.12);
    transform: scale(1.01);
}

.style-drop-zone.has-image {
    min-height: 0;
    padding: 8px;
    border-style: solid;
    border-color: rgba(232, 101, 26, 0.22);
    background: #fff;
    cursor: default;
}

.style-drop-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    pointer-events: none;
    user-select: none;
}

.style-drop-zone.has-image .style-drop-empty {
    display: none;
}

.style-drop-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color, #E8651A);
    background: rgba(232, 101, 26, 0.1);
}

.style-drop-hint {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #374151);
    line-height: 1.35;
}

.style-drop-formats {
    font-size: 10px;
    color: var(--text-muted, #9ca3af);
    line-height: 1.3;
}

.style-drop-preview {
    position: relative;
    width: 100%;
    display: none;
}

.style-drop-zone.has-image .style-drop-preview {
    display: block !important;
}

.style-drop-preview .preview-thumbnail {
    display: block;
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    border-radius: 8px;
    background: #f3f4f6;
}

.style-drop-preview .preview-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.72);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 2;
}

.style-drop-preview .preview-remove-btn:hover {
    background: rgba(220, 38, 38, 0.9);
}

/* Model row */
.style-model-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.style-model-field {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.style-model-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
}

.style-model-select {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: #fff;
    color: var(--text-primary, #1f2937);
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.style-model-select:hover {
    border-color: rgba(232, 101, 26, 0.45);
}

.style-model-select:focus {
    border-color: var(--primary-color, #E8651A);
    box-shadow: 0 0 0 3px rgba(232, 101, 26, 0.12);
}

.style-recognize-btn {
    flex-shrink: 0;
    height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

#recognizeStyleBtn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

#style-confirm-modal .modal-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    line-height: 1.5;
}

#style-confirm-modal .form-group {
    margin-bottom: 12px;
}

#style-confirm-modal .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary, #1f2937);
}

#style-confirm-modal textarea.form-input {
    width: 100%;
    resize: vertical;
    font-family: inherit;
}



/* ==================== Art style recognition collapse (collapse/expand) ==================== */

.style-recognize-collapse-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, transform 0.2s ease;
}

.style-recognize-collapse-btn:hover {
    color: var(--primary-color, #E8651A);
    background: rgba(232, 101, 26, 0.08);
}

.style-recognize-collapse-btn:focus-visible {
    outline: 2px solid rgba(232, 101, 26, 0.45);
    outline-offset: 1px;
}

.style-recognize-collapse-btn svg {
    transition: transform 0.2s ease;
}

/* Collapsed state: body and subtitle hidden, arrow points up */
.style-recognize-section.is-collapsed .style-recognize-body,
.style-recognize-section.is-collapsed .style-recognize-subtitle {
    display: none;
}

.style-recognize-section.is-collapsed .style-recognize-collapse-btn svg {
    transform: rotate(180deg);
}

.style-recognize-section.is-collapsed {
    padding-bottom: 10px;
}

/* ==================== Queued message stack area (messages pushed while AI is streaming, shown above the input box) ==================== */

.pending-queue-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    max-height: 132px;
    overflow-y: auto;
    flex-shrink: 0;
}

.pending-queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px dashed rgba(232, 101, 26, 0.45);
    background: rgba(232, 101, 26, 0.06);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary, #1f2937);
    line-height: 1.4;
}

.pending-queue-item::before {
    content: "⏳";
    flex-shrink: 0;
    font-size: 12px;
}

.pending-queue-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pending-queue-remove {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted, #9ca3af);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.pending-queue-remove:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* ==================== Staging area: image-generating indicator ==================== */

/* Generating: the image preview button icon is replaced with a loading spinner (no text, to avoid crowding the filename width) */
.image-preview-btn.is-generating {
    color: #3b82f6;
    cursor: default;
}

.image-preview-btn .image-generating-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: image-generating-spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes image-generating-spin {
    to { transform: rotate(360deg); }
}

/* Outline button variant */
.btn-outline {
    background: transparent;
    color: var(--primary, #E8651A);
    border: 1px solid var(--primary, #E8651A);
}
.btn-outline:hover {
    background: var(--primary, #E8651A);
    color: #fff;
}

/* Edit/create modals that can open sub-pickers — lower so pickers sit on top */
#edit-modal,
#new-character-modal,
#new-location-modal,
#new-prop-modal {
    z-index: 1900;
}

/* Picker modals opened from within edit modals — must sit above them */
#voice-picker-modal {
    z-index: 2100;
}
.voice-picker-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.voice-picker-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
}
.voice-picker-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted, #94a3b8);
    font-size: 14px;
}
.voice-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.voice-picker-item:hover {
    background: var(--bg-light, #FFF8F4);
}
.voice-picker-item-info {
    flex: 1;
    min-width: 0;
}
.voice-picker-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1e293b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.voice-picker-item-desc {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}
.voice-picker-item-tags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}
.voice-picker-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-light, #f1f5f9);
    color: var(--text-secondary, #64748b);
}
.voice-picker-item audio {
    flex-shrink: 0;
    height: 32px;
    width: 160px;
}
.voice-picker-item .btn-sm {
    flex-shrink: 0;
}

/* Asset Image Picker (shared by character and props browse) - above edit modal */
#asset-image-picker-modal {
    z-index: 2100;
}
.asset-image-picker-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.asset-image-picker-list {
    max-height: 480px;
    overflow-y: auto;
    padding: 8px 0;
}
.asset-image-picker-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted, #94a3b8);
    font-size: 14px;
}
.asset-image-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.asset-image-picker-item:hover {
    background: var(--bg-light, #FFF8F4);
}
.asset-image-picker-item-thumb {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-light, #f1f5f9);
}
.asset-image-picker-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.asset-image-picker-item-info {
    flex: 1;
    min-width: 0;
}
.asset-image-picker-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1e293b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.asset-image-picker-item-desc {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}
.asset-image-picker-item-tags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}
.asset-image-picker-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-light, #f1f5f9);
    color: var(--text-secondary, #64748b);
}
.asset-image-picker-use-btn {
    flex-shrink: 0;
}

/* ===== Vue floating toast notification ===== */
.sw-toast-notification {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    max-width: 420px;
    word-break: break-word;
}
.sw-toast--info {
    background: rgba(59, 130, 246, 0.92);
    color: #fff;
}
.sw-toast--success {
    background: rgba(16, 185, 129, 0.92);
    color: #fff;
}
.sw-toast--error {
    background: rgba(239, 68, 68, 0.92);
    color: #fff;
}
.sw-toast--warning {
    background: rgba(245, 158, 11, 0.92);
    color: #fff;
}
.sw-toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.sw-toast-message {
    flex: 1;
    min-width: 0;
}
.sw-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 0 0 0 4px;
    line-height: 1;
}
.sw-toast-close:hover {
    color: #fff;
}
.sw-toast-enter-active {
    transition: all 0.3s ease-out;
}
.sw-toast-leave-active {
    transition: all 0.2s ease-in;
}
.sw-toast-enter-from {
    opacity: 0;
    transform: translateX(40px);
}
.sw-toast-leave-to {
    opacity: 0;
    transform: translateX(40px);
}
@media (max-width: 480px) {
    .sw-toast-notification {
        right: 12px;
        left: 12px;
        max-width: none;
    }
}
