/* User Mode Styles */
.user-mode-content {
    position: absolute;
    top: 70px; /* Header height */
    left: 0;
    right: 0;
    bottom: 40px; /* Footer height */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--primary-bg);
    z-index: 10;
    overflow: hidden; /* Prevent any scrollbar on the main content */
}

.user-mode-container {
    width: 100%;
    height: 100%;
    display: flex;
    gap: 2%;
    transition: all 0.5s ease;
    overflow: hidden; /* Prevent scrollbar on container */
}

.user-mode-title {
    font-size: 2rem;
    color: #e0e0e0;
    margin-bottom: 2rem;
    font-weight: 300;
    transition: all 0.5s ease;
}

/* Initial centered state */
.user-mode-container:not(.building) {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.user-mode-container:not(.building) .left-container {
    width: 100%;
    max-width: 800px;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-mode-container:not(.building) .right-container {
    display: none;
}

/* Building state - side by side layout */
.user-mode-container.building {
    flex-direction: row;
    align-items: stretch;
}

.user-mode-container.building .user-mode-title {
    display: none;
}

/* Left Container - 49% width, 100% height */
.left-container {
    width: 49%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.5s ease;
    position: relative; /* For absolute positioned children like widget picker */
}

.user-mode-container.building .left-container {
    padding: 0;
}

/* Chat Interface */
.chat-interface {
    display: none;
    flex-direction: column;
    height: 100%;
    gap: 0;
    overflow: hidden; /* Prevent overflow */
}

.user-mode-container.building .chat-interface {
    display: flex;
}

/* Chat History Area */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid #333;
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    max-width: 85%;
}

.user-message {
    background: #007acc;
    color: white;
    margin-left: auto;
    text-align: right;
}

.assistant-message {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    margin-right: auto;
}

.message-content {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Chat Input Area */
.chat-input-area {
    display: flex;
    gap: 0;
    flex-shrink: 0;
    max-height: 200px; /* Limit maximum height to prevent overflow */
    overflow: visible;
    position: relative;
}

/* Element Autocomplete Dropdown */
.element-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    background: #1e1e2e;
    border: 1px solid #3a3a4e;
    border-radius: 8px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    margin-bottom: 8px;
    display: none;
}

.element-autocomplete.show {
    display: block;
}

.element-autocomplete-header {
    padding: 10px 14px;
    border-bottom: 1px solid #3a3a4e;
    font-size: 12px;
    color: #888;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: #1e1e2e;
}

.element-autocomplete-header .hint {
    color: #667eea;
    font-weight: 500;
}

.element-autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.15s;
}

.element-autocomplete-item:last-child {
    border-bottom: none;
}

.element-autocomplete-item:hover,
.element-autocomplete-item.selected {
    background: rgba(102, 126, 234, 0.15);
}

.element-autocomplete-item.selected {
    background: rgba(102, 126, 234, 0.25);
}

.element-autocomplete-item .element-tag {
    padding: 2px 8px;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    min-width: 50px;
    text-align: center;
}

.element-autocomplete-item .element-name {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: #4ade80;
    font-weight: 500;
}

.element-autocomplete-item .element-preview {
    flex: 1;
    font-size: 12px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.element-autocomplete-item .connector-badge {
    font-size: 14px;
    margin-left: 8px;
    opacity: 0.8;
}

.element-autocomplete-item.has-connector {
    border-left: 3px solid #4ade80;
}

.element-autocomplete-item.has-connector .element-name {
    color: #4ade80;
}

.element-autocomplete-empty {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

.element-autocomplete-loading {
    padding: 20px;
    text-align: center;
    color: #667eea;
    font-size: 13px;
}

/* Name Mode Indicator */
.name-mode-indicator {
    position: absolute;
    top: -30px;
    right: 0;
    padding: 4px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    display: none;
}

.name-mode-indicator.show {
    display: block;
}

.chat-input {
    flex: 1;
    padding: 1rem;
    border: 1px solid #333;
    border-radius: 0 0 0 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 54px;
    max-height: 150px;
    line-height: 1.4;
    overflow-y: hidden;
    outline: none;
    border-right: none;
}

.chat-input:focus {
    border-color: #007acc;
}

/* Slim scrollbar for chat input */
.chat-input::-webkit-scrollbar {
    width: 6px;
}

.chat-input::-webkit-scrollbar-track {
    background: transparent;
}

.chat-input::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-input::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Firefox */
.chat-input {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.chat-submit {
    padding: 1rem 1.5rem;
    background: #007acc;
    color: white;
    border: 1px solid #007acc;
    border-radius: 0 0 8px 0;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
}

.chat-submit:hover {
    background: #005a9e;
    border-color: #005a9e;
}

/* Right Container - 49% width, 100% height */
.right-container {
    width: 49%;
    height: 100%;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    transition: all 0.5s ease;
}

/* Device Preview Container */
.device-preview {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
}

.user-mode-container.building .right-container {
    display: flex;
    animation: fadeInRight 0.5s ease 0.3s both;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Left title in building mode */
.left-title {
    display: none;
    font-size: 1.5rem;
    color: #e0e0e0;
    margin-bottom: 1rem;
    font-weight: 300;
    text-align: left;
}

.user-mode-container.building .left-title {
    display: block;
    flex-shrink: 0;
}

/* Input section in building mode */
.user-mode-container.building .left-container .user-input-section {
    display: none;
}

.user-mode-container.building .left-container .user-input-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.user-mode-container.building .left-container .user-input-label {
    font-size: 1rem;
    color: #e0e0e0;
    margin-bottom: 0.5rem;
    display: block;
}

/* Phone device mockup */
.phone-device {
    /* iPhone 14 Pro: 1179/2556 ≈ 0.461 - Accurate Apple aspect ratio */
    height: calc(100% - 80px); /* Use most of available height */
    width: auto;                 /* let aspect-ratio compute width */
    max-width: 100%;
    max-height: 100%;
    background: #1a1a1a;
    border-radius: 25px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    flex-shrink: 0;
    aspect-ratio: 1179 / 2556;   /* iPhone 14 Pro */
    transition: all 0.3s ease; /* Smooth transitions between device types */
}

/* iPhone 14 Pro Max variant */
.phone-device.iphone-pro-max {
    /* iPhone 14 Pro Max: 1290/2796 ≈ 0.461 - Same ratio as Pro, but larger display */
    aspect-ratio: 1290 / 2796;
    height: calc((100% - 80px) * 1.05); /* slightly taller instead of transform */
}

/* 11-inch iPad Pro variant */
.phone-device.ipad-pro {
    /* 11-inch iPad Pro: 1668/2388 ≈ 0.698 - Accurate iPad aspect ratio */
    width: auto;              /* rely on aspect-ratio to compute width */
    max-width: 100%;
    max-height: 100%;
    border-radius: 15px; /* Less rounded for tablet */
    aspect-ratio: 1668 / 2388;
    height: calc((100% - 80px) * 0.95);
    padding: 15px; /* Slightly less padding for iPad */
}

/* Legacy support for old class names - redirect to new accurate ones */
.phone-device.phone-max {
    /* Redirect to accurate iPhone Pro Max */
    aspect-ratio: 1290 / 2796;
    height: calc((100% - 80px) * 1.05);
}

.phone-device.tablet {
    /* Redirect to accurate iPad Pro */
    aspect-ratio: 1668 / 2388;
    height: calc((100% - 80px) * 0.95);
    border-radius: 15px;
    padding: 15px;
}

.phone-device::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: #333;
    border-radius: 2px;
}

.phone-screen {
    width: 100%;
    height: 100%;
    background: var(--primary-bg);
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex shrinking */
}

.phone-header {
    height: 50px; /* Reduced height for better proportions */
    background: var(--secondary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.phone-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem; /* Larger font for bigger device */
}

.phone-content {
    flex: 1;
    padding: 1rem 0.75rem; /* Optimized padding for accurate iPhone ratios */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 0; /* Allow flex shrinking */
}

/* Adjust content padding for iPad */
.phone-device.ipad-pro .phone-content,
.phone-device.tablet .phone-content {
    padding: 1.5rem 1.25rem; /* More padding for larger iPad screen */
}

/* Adjust form mockup sizes for different devices */
.phone-device.ipad-pro .login-form-mockup,
.phone-device.tablet .login-form-mockup {
    max-width: 280px; /* Larger form for iPad */
}

.phone-device.iphone-pro-max .login-form-mockup,
.phone-device.phone-max .login-form-mockup {
    max-width: 220px; /* Slightly larger for Pro Max */
}

.login-form-mockup {
    max-width: 200px; /* Default for iPhone Pro */
}

/* Building status */
.building-status {
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.building-status .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Login form mockup */
.login-form-mockup {
    display: none;
    width: 100%;
    max-width: 200px; /* Larger for the bigger device */
}

.login-form-mockup.visible {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.form-group-mockup {
    margin-bottom: 1rem;
}

.form-group-mockup label {
    display: block;
    font-size: 0.85rem; /* Larger font for bigger device */
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-align: left;
}

.form-group-mockup input {
    width: 100%;
    padding: 0.75rem; /* Larger padding for bigger device */
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--accent-bg);
    color: var(--text-primary);
    font-size: 0.85rem; /* Larger font for bigger device */
    box-sizing: border-box;
}

.form-group-mockup input:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.login-btn-mockup {
    width: 100%;
    padding: 0.75rem; /* Larger padding for bigger device */
    background: var(--accent-purple);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem; /* Larger font for bigger device */
    cursor: pointer;
    margin-top: 1rem;
}

.login-btn-mockup:hover {
    background: #7c3aed;
}

/* Prompt input wrapper — anchors the clear (X) button to the textarea's
   top-right. The X auto-hides when the textarea is empty via the
   :placeholder-shown sibling rule below. */
.prompt-input-wrapper {
    position: relative;
    width: 100%;
}

.clear-prompt-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 50%;
    color: #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
    padding: 0;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.clear-prompt-btn:hover {
    background: rgba(239, 68, 68, 0.85);
    border-color: rgba(239, 68, 68, 0.9);
    color: #fff;
    transform: scale(1.08);
}

.prompt-input-wrapper .user-mode-input:placeholder-shown ~ .clear-prompt-btn {
    display: none;
}

/* Input styling */
.user-mode-input {
    width: 100%;
    min-height: 150px;
    max-height: 50vh;
    padding: 1.5rem;
    border: 2px solid #333;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    font-size: 18px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease, height 0.2s ease;
    overflow-y: auto;
}

.user-mode-container.building .user-mode-input {
    flex: 1;
    min-height: 60px;
    max-height: 60px;
    resize: none;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-mode-input:focus {
    outline: none;
    border-color: #007acc;
}

.user-mode-input::placeholder {
    color: #888;
}

/* Button Group */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    align-self: center;
    margin-top: 1rem;
}

.button-row {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.build-hint {
    color: #888;
    font-size: 0.8rem;
    margin: 1.5rem 0 0 0;
    text-align: center;
}

.build-hint strong {
    color: #aaa;
}

#templatePickerBtn {
    align-self: flex-start;
}

.user-mode-container.building .button-group {
    align-self: flex-start;
}

/* Tone preset chips — row beneath the prompt textarea. Single-select. */
.tone-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 4px;
    align-items: center;
}

.tone-chips::before {
    content: 'Tone';
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #6b7280;
    margin-right: 6px;
}

.tone-chip {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.04);
    color: #c5c8d3;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    line-height: 1.4;
}

.tone-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
    color: #FAFAFA;
}

.tone-chip.active,
.tone-chip[aria-checked="true"] {
    background: rgba(174, 82, 242, 0.18);
    color: #FAFAFA;
    border-color: rgba(174, 82, 242, 0.55);
    box-shadow: 0 0 0 3px rgba(174, 82, 242, 0.1);
}

.tone-chip.active:hover,
.tone-chip[aria-checked="true"]:hover {
    background: rgba(174, 82, 242, 0.25);
    border-color: rgba(174, 82, 242, 0.75);
}

.user-mode-submit {
    padding: 12px 24px;
    background: #007acc;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-width: 120px;
}

.user-mode-submit:hover {
    background: #0098ff;
}

.generate-prompt-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 12px 24px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.generate-prompt-btn:hover {
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

.generate-prompt-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.generate-prompt-btn svg {
    width: 16px;
    height: 16px;
}

.user-mode-container.building .generate-prompt-btn {
    display: none;
}

.search-templates-btn {
    padding: 10px 20px;
    background: transparent;
    color: #00d4ff;
    border: 2px solid #00d4ff;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-templates-btn:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: #00ffff;
    color: #00ffff;
}

.search-templates-btn svg {
    width: 16px;
    height: 16px;
}

.user-mode-container.building .button-group {
    justify-content: flex-start;
}

/* Template Picker Button */
.template-picker-btn {
    padding: 10px 20px;
    background: transparent;
    color: #007acc;
    border: 2px solid #007acc;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: center;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-picker-btn:hover {
    background: rgba(0, 122, 204, 0.1);
    border-color: #0098ff;
    color: #0098ff;
}

.template-picker-btn svg {
    width: 16px;
    height: 16px;
}

.user-mode-container.building .template-picker-btn {
    display: none;
}

.user-mode-container.building .search-templates-btn {
    display: none;
}

/* Template Suggestions */
.template-suggestions {
    margin-top: 1.5rem;
    background: rgba(0, 212, 255, 0.05);
    border: 2px solid rgba(0, 212, 255, 0.2);
    border-radius: 10px;
    padding: 1rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}

.suggestions-header h4 {
    margin: 0;
    color: #00d4ff;
    font-size: 16px;
    font-weight: 600;
}

.close-suggestions {
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.close-suggestions:hover {
    color: #00d4ff;
}

.suggestions-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.suggestion-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggestion-card:hover {
    border-color: #00d4ff;
    background: rgba(0, 212, 255, 0.1);
    transform: translateY(-2px);
}

.suggestion-card h5 {
    margin: 0 0 0.5rem 0;
    color: #e0e0e0;
    font-size: 15px;
    font-weight: 600;
}

.suggestion-card p {
    margin: 0 0 0.75rem 0;
    color: #b0b0b0;
    font-size: 13px;
    line-height: 1.5;
}

.suggestion-card .suggestion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.suggestion-card .suggestion-tags .tag {
    padding: 3px 8px;
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 10px;
    font-size: 11px;
    color: #00d4ff;
    font-weight: 500;
}

.suggestions-loading {
    text-align: center;
    padding: 2rem;
    color: #00d4ff;
}

.suggestions-loading svg {
    animation: spin 1s linear infinite;
}

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

/* Template Modal */
.template-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.template-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-modal-content {
    background: #1e1e1e;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    height: 85vh;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

.template-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.template-modal-header h2 {
    margin: 0;
    color: #e0e0e0;
    font-size: 24px;
}

.template-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    line-height: 1;
}

.template-modal-close:hover {
    color: #e0e0e0;
}

/* Template Search */
.template-search-container {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #333;
    position: relative;
    flex-shrink: 0;
}

.template-search-input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 15px;
    transition: all 0.3s ease;
}

.template-search-input:focus {
    outline: none;
    border-color: #007acc;
    background: rgba(255, 255, 255, 0.08);
}

.template-search-input::placeholder {
    color: #666;
}

.template-search-icon {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    pointer-events: none;
}

.template-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.template-section {
    margin-bottom: 2rem;
}

.template-section:last-child {
    margin-bottom: 0;
}

.template-section h3 {
    margin: 0 0 1rem 0;
    color: #e0e0e0;
    font-size: 18px;
    font-weight: 600;
}

.template-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333;
    border-radius: 10px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    gap: 1rem;
}

.template-card:hover {
    border-color: #007acc;
    background: rgba(0, 122, 204, 0.1);
    transform: translateY(-2px);
}

.template-card.featured {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(0, 122, 204, 0.05) 100%);
}

.template-card.featured:hover {
    border-color: #a78bfa;
}

.template-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #007acc 0%, #0098ff 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.template-card.featured .template-icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
}

.template-info {
    flex: 1;
}

.template-info h4 {
    margin: 0 0 0.5rem 0;
    color: #e0e0e0;
    font-size: 16px;
    font-weight: 600;
}

.template-info p {
    margin: 0 0 0.75rem 0;
    color: #b0b0b0;
    font-size: 14px;
    line-height: 1.5;
}

.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.template-tags .tag {
    padding: 4px 10px;
    background: rgba(0, 122, 204, 0.2);
    border: 1px solid #007acc;
    border-radius: 12px;
    font-size: 12px;
    color: #00d4ff;
    font-weight: 500;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }

    .template-modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* Template Param Form */
.template-param-form {
    padding: 2rem 1.5rem;
}

.template-param-header {
    margin-bottom: 1.5rem;
}

.template-param-header h3 {
    margin: 0 0 0.5rem 0;
    color: #e0e0e0;
    font-size: 20px;
    font-weight: 600;
}

.template-param-header p {
    margin: 0;
    color: #888;
    font-size: 14px;
    line-height: 1.5;
}

.template-param-field {
    margin-bottom: 1.25rem;
}

.template-param-field label {
    display: block;
    margin-bottom: 0.5rem;
    color: #b0b0b0;
    font-size: 14px;
    font-weight: 500;
}

.template-param-field label .required-star {
    color: #ef4444;
    margin-left: 2px;
}

.template-param-field input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 15px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.template-param-field input:focus {
    outline: none;
    border-color: #007acc;
    background: rgba(255, 255, 255, 0.08);
}

.template-param-field input::placeholder {
    color: #666;
}

.template-param-field input.invalid {
    border-color: #ef4444;
}

.template-param-field .field-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.template-param-field.inactive label {
    opacity: 0.7;
}

.template-param-field .param-inactive-note {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    font-style: italic;
    margin-top: 4px;
}

/* Free-tier inline match suggestions and brand prompt (E13–E15) */
.free-suggest-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.free-suggest-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.free-suggest-chip {
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.15);
    border: 1px solid rgba(102, 126, 234, 0.5);
    color: #c5cdfb;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.free-suggest-chip:hover {
    background: rgba(102, 126, 234, 0.3);
}

.free-suggest-browse {
    align-self: flex-start;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    margin-top: 4px;
}

.free-brand-prompt {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.free-brand-row {
    display: flex;
    gap: 8px;
}

.free-brand-row input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 14px;
}

.free-brand-row input:focus {
    outline: none;
    border-color: #667eea;
}

.free-brand-row button {
    padding: 8px 16px;
    border-radius: 6px;
    background: #667eea;
    border: none;
    color: white;
    font-weight: 600;
    cursor: pointer;
}

.template-param-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.template-param-actions .btn-use-template {
    padding: 10px 24px;
    background: linear-gradient(135deg, #007acc 0%, #0098ff 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-param-actions .btn-use-template:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.4);
}

.template-param-skip {
    background: none;
    border: none;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.template-param-skip:hover {
    color: #b0b0b0;
}

.template-param-back {
    background: none;
    border: none;
    color: #007acc;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.template-param-back:hover {
    color: #0098ff;
}

/* Dynamic Preview Styles */
.app-preview-container {
    display: none;
    width: 100%;
    position: relative;
}

/* Applying overlay - shown during style/typography/layout changes */
.applying-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}
.applying-overlay-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(30, 30, 30, 0.95);
    padding: 16px 28px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    font-size: 14px;
    font-weight: 500;
}
.applying-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.app-preview-container.visible {
    display: block;
    animation: fadeIn 0.5s ease;
}

/* Adjust preview sizes for different devices */
.phone-device.ipad-pro .app-preview-container,
.phone-device.tablet .app-preview-container {
    /* Removed max-width for full RHS width */
}

.phone-device.iphone-pro-max .app-preview-container,
.phone-device.phone-max .app-preview-container {
    /* Removed max-width for full RHS width */
}

.preview-placeholder {
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.placeholder-icon {
    font-size: 2rem;
    color: var(--accent-purple);
    opacity: 0.5;
}

.dynamic-preview {
    width: 100%;
}

.todo-preview, .form-preview, .generic-preview {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border);
    font-size: 0.8rem;
}

.todo-preview h3, .form-preview h3, .generic-preview h3 {
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: center;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    padding: 0.3rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.todo-item input[type="checkbox"] {
    margin: 0;
    transform: scale(0.8);
}

.todo-item label {
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
    flex: 1;
}

.add-task {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.75rem;
}

.add-task input {
    flex: 1;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.7rem;
}

.add-task button, .submit-btn {
    padding: 0.3rem 0.6rem;
    background: var(--accent-purple);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 0.7rem;
    cursor: pointer;
}

.add-task button:hover, .submit-btn:hover {
    background: #7c3aed;
}

.form-group-mockup {
    margin-bottom: 0.75rem;
}

.form-group-mockup label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.form-group-mockup input, .form-group-mockup textarea {
    width: 100%;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.7rem;
    box-sizing: border-box;
}

.form-group-mockup textarea {
    height: 40px;
    resize: vertical;
}

.feature-list {
    margin-top: 0.75rem;
}

.feature {
    padding: 0.15rem 0;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.app-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--accent-gradient);
    color: white !important;
    text-decoration: none;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    margin: 0.5rem 0;
}

.app-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-cyan) 100%);
    filter: brightness(1.1);
    text-decoration: none;
}

.app-link:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.user-mode-submit:hover {
    background: #005a9e;
}

.user-mode-submit:active {
    transform: translateY(1px);
}

/* Device Selector */
.device-selector {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    margin-top: auto;
    padding: 1rem;
    flex-wrap: wrap;
}

.device-btn {
    width: 60px;
    height: 50px;
    border: 2px solid #333;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
    position: relative;
    overflow: visible;
}

.device-btn::after {
    content: attr(title);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: #666;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.device-btn:hover::after {
    opacity: 1;
}

.device-btn:hover {
    border-color: #007acc;
    color: #007acc;
    background: rgba(0, 122, 204, 0.1);
}

.device-btn.active {
    border-color: #007acc;
    color: #007acc;
    background: rgba(0, 122, 204, 0.2);
}

.device-btn i {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

/* Device-specific icon styling */
.device-btn[data-device="iphone-pro"] i,
.device-btn[data-device="phone"] i {
    font-size: 1.3rem;
}

.device-btn[data-device="iphone-pro-max"] i,
.device-btn[data-device="phone-max"] i {
    font-size: 1.5rem;
}

.device-btn[data-device="ipad-pro"] i,
.device-btn[data-device="tablet"] i {
    font-size: 1.6rem;
}

/* Expand Controls */
.expand-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 100;
}

.expand-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #333;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    backdrop-filter: blur(10px);
}

.expand-btn:hover {
    border-color: #007acc;
    color: #007acc;
    background: rgba(0, 122, 204, 0.1);
}

/* Expanded State Styles */
.user-mode-container.expanded {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 40px;
    z-index: 1000;
    background: var(--primary-bg);
    flex-direction: row;
    padding: 1rem;
}

.user-mode-container.expanded .left-container {
    display: none;
}

.user-mode-container.expanded .right-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Preview Header Buttons (Refresh, Edit Mode) */
.preview-header-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.preview-header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.preview-header-btn.active {
    background: rgba(102, 126, 234, 0.3);
    border-color: rgba(102, 126, 234, 0.6);
    color: #a5b4fc;
}

.preview-header-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Expand button icon transition */
.preview-header-btn i {
    transition: transform 0.3s ease;
    font-size: 14px;
}

.user-mode-container.expanded .device-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Expanded view: same principle — no fixed width */
.user-mode-container.expanded .phone-device {
    height: calc(100% - 40px);
    width: auto;
    max-width: none;
    max-height: none;
    /* aspect-ratio remains per device */
    transform: none; /* avoid visual distortion/blurriness */
    transition: all 0.5s ease;
}

.user-mode-container.expanded .phone-device.iphone-pro-max,
.user-mode-container.expanded .phone-device.phone-max {
    height: calc(100% - 40px);
}

.user-mode-container.expanded .phone-device.ipad-pro,
.user-mode-container.expanded .phone-device.tablet {
    height: calc(100% - 40px);
}

/* Adjust expand button for expanded state */
.user-mode-container.expanded .expand-btn {
    background: rgba(0, 0, 0, 0.9);
    border-color: #007acc;
    color: #007acc;
}

/* Phone Toggle Styles */
.phone-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
}

.phone-toggle .toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.phone-toggle .toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.phone-toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: 0.3s;
    border-radius: 24px;
}

.phone-toggle .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.phone-toggle input:checked + .slider {
    background-color: var(--accent-purple);
}

.phone-toggle input:checked + .slider:before {
    transform: translateX(26px);
}

.phone-toggle .mode-label {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Maximized Container Styles */
.maximized-container {
    width: 49%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--secondary-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.maximized-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    min-height: 0;
}

/* Maximized Building Status */
.building-status.maximized {
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 3rem;
}

.building-status.maximized .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.building-status.maximized p {
    font-size: 1.2rem;
    margin: 0;
}

/* Maximized Preview Container */
.app-preview-container.maximized {
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.app-preview-container.maximized .preview-placeholder {
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.app-preview-container.maximized .placeholder-icon {
    font-size: 4rem;
    color: var(--accent-purple);
    opacity: 0.5;
}

.app-preview-container.maximized .placeholder-icon p {
    font-size: 1.1rem;
}

/* Maximized Dynamic Preview */
.dynamic-preview.maximized {
    width: 100%;
    max-width: 500px;
    animation: fadeIn 0.5s ease;
}

.dynamic-preview.maximized .todo-preview,
.dynamic-preview.maximized .form-preview,
.dynamic-preview.maximized .generic-preview {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid var(--border);
}

.dynamic-preview.maximized h3 {
    margin: 0 0 1.5rem 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    text-align: center;
}

.dynamic-preview.maximized .todo-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.dynamic-preview.maximized .todo-item label {
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    flex: 1;
}

.dynamic-preview.maximized .add-task {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.dynamic-preview.maximized .add-task input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 1rem;
}

.dynamic-preview.maximized .add-task button,
.dynamic-preview.maximized .submit-btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent-purple);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}

.dynamic-preview.maximized .form-group-mockup {
    margin-bottom: 1.5rem;
}

.dynamic-preview.maximized .form-group-mockup label {
    display: block;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.dynamic-preview.maximized .form-group-mockup input,
.dynamic-preview.maximized .form-group-mockup textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 1rem;
    box-sizing: border-box;
}

.dynamic-preview.maximized .form-group-mockup textarea {
    height: 80px;
    resize: vertical;
}

.dynamic-preview.maximized .feature-list {
    margin-top: 1.5rem;
}

.dynamic-preview.maximized .feature {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Layout adjustments when maximized view is active */
.user-mode-container.maximized-view {
    gap: 2%;
}

.user-mode-container.maximized-view .right-container {
    display: none;
}

.user-mode-container.maximized-view .maximized-container {
    display: flex;
}

/* ============================================
   App Preview Panel (v2 - No Phone Template)
   ============================================ */

.app-preview-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    overflow: hidden;
}

.app-preview-panel .preview-header {
    background: #252936;
    border-bottom: 1px solid #3f4354;
    padding: 0.75rem 1rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
}

.app-preview-panel .preview-header h3 {
    margin: 0;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

#pageTabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

#pageTabs::-webkit-scrollbar {
    height: 6px;
}

#pageTabs::-webkit-scrollbar-track {
    background: transparent;
}

#pageTabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

#pageTabs::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.app-preview-panel .building-status {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    gap: 1.5rem;
    background: #0f0f0f;
    flex: 1;
}

.app-preview-panel .building-status .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.app-preview-panel .building-status p {
    color: #e0e0e0;
    font-size: 1rem;
    margin: 0;
}

.app-preview-panel .app-preview-container {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: #0f0f0f;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.app-preview-panel .preview-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #666;
    z-index: 1;
}

.app-preview-panel .preview-placeholder .placeholder-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.app-preview-panel .preview-placeholder p {
    font-size: 1rem;
    margin: 0;
}

.app-preview-panel #appIframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    border: none;
    display: block;
}

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

/* Prompt History Dots — no box chrome, dots inline & aligned with the
   textarea's content inset (textarea has padding: 1.5rem + 2px border) */
.prompt-history {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
    padding: 0 calc(1.5rem + 2px);
    background: transparent;
    border: none;
    overflow: visible !important;
    position: relative;
    min-height: 14px;
}

.view-history-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    background: rgba(0, 122, 204, 0.2);
    border: 1px solid #007acc;
    border-radius: 6px;
    color: #007acc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.view-history-btn:hover {
    background: rgba(0, 122, 204, 0.3);
    transform: scale(1.1);
}

.history-dot {
    position: relative;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #007acc 0%, #00d4ff 100%);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.history-dot:hover {
    transform: scale(1.3);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.6);
}

/* Tooltip element */
.history-dot-tooltip {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 9999;
    pointer-events: none;
    border: 1px solid #00d4ff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.history-dot:hover .history-dot-tooltip {
    opacity: 1;
    visibility: visible;
}
/* History Modal */
.history-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.history-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-modal-content {
    background: #1e1e1e;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

.history-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.history-modal-header h2 {
    margin: 0;
    color: #e0e0e0;
    font-size: 24px;
}

.history-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    line-height: 1;
}

.history-modal-close:hover {
    color: #e0e0e0;
}

.history-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.history-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    transition: all 0.3s ease;
}

.history-item:hover {
    border-color: #007acc;
    background: rgba(0, 122, 204, 0.1);
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-text {
    color: #e0e0e0;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.history-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.history-use-btn,
.history-delete-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.history-use-btn {
    background: #007acc;
    color: white;
}

.history-use-btn:hover {
    background: #0098ff;
    transform: scale(1.1);
}

.history-delete-btn {
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
}

.history-delete-btn:hover {
    background: #ff4444;
    color: white;
    transform: scale(1.1);
}
/* Quick Actions Bar */
.quick-actions-bar {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.quick-action-btn:active {
    transform: translateY(0);
}

.quick-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.quick-action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Layout Modal */
.layout-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.layout-modal.show {
    display: flex;
}

.layout-modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.layout-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.layout-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.layout-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 50%;
}

.layout-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.layout-modal-body {
    padding: 2rem;
    overflow-y: auto;
    max-height: calc(85vh - 100px);
}

.layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.layout-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.layout-card:hover {
    transform: translateY(-4px);
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
}

.layout-preview {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    height: 120px;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.layout-card h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #e0e0e0;
}

.layout-card p {
    margin: 0;
    font-size: 0.8rem;
    color: #888;
    line-height: 1.4;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .layout-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .layout-modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .layout-modal-body {
        padding: 1rem;
    }

    .quick-actions-bar {
        flex-direction: column;
    }

    .quick-action-btn {
        width: 100%;
    }
}

/* My Apps Modal */
.my-apps-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.my-apps-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.apps-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
}

.app-item {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.25rem;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 0.5rem 1rem;
    transition: all 0.3s ease;
}

.app-item:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.app-item.running {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.05);
}

.app-header {
    grid-column: 1;
    grid-row: 1;
}

.app-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
    display: flex;
    gap: 0.5rem;
}

.app-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: #e0e0e0;
}

.app-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.app-name-row .copy-prompt-btn {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.app-name-row:hover .copy-prompt-btn {
    opacity: 1;
}

.app-description {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    color: #999;
    line-height: 1.4;
}

.app-meta {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 1rem;
    align-items: center;
}


.app-id {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #666;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.app-date {
    font-size: 0.75rem;
    color: #888;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.app-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #999;
}

.app-status.running {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.app-version {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    font-family: 'Courier New', monospace;
    margin-left: auto;
}

.app-version.needs-rebuild {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.app-action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-action-btn svg {
    flex-shrink: 0;
}

.view-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.view-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.start-btn {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(74, 222, 128, 0.4);
}

.delete-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-2px);
}

.rebuild-btn {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.rebuild-btn:hover {
    background: rgba(251, 191, 36, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(251, 191, 36, 0.2);
}

/* Rebuild Progress Modal */
.rebuild-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.rebuild-modal.show {
    opacity: 1;
    visibility: visible;
}

.rebuild-modal-content {
    background: #1e1e2e;
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rebuild-modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.rebuild-modal-header .icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rebuild-modal-header .icon svg {
    width: 24px;
    height: 24px;
    color: #1e1e2e;
}

.rebuild-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #fff;
}

.rebuild-modal-header .app-name {
    font-size: 0.875rem;
    color: #888;
    margin-top: 0.25rem;
}

.rebuild-progress-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.rebuild-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rebuild-step:last-child {
    border-bottom: none;
}

.rebuild-step-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    color: #666;
    font-size: 12px;
}

.rebuild-step.pending .rebuild-step-icon {
    background: rgba(255, 255, 255, 0.1);
    color: #666;
}

.rebuild-step.active .rebuild-step-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    animation: pulse 1.5s ease-in-out infinite;
}

.rebuild-step.complete .rebuild-step-icon {
    background: #22c55e;
    color: white;
}

.rebuild-step.error .rebuild-step-icon {
    background: #ef4444;
    color: white;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.rebuild-step-content {
    flex: 1;
}

.rebuild-step-title {
    font-size: 0.9375rem;
    color: #fff;
    margin: 0 0 0.25rem 0;
}

.rebuild-step.pending .rebuild-step-title {
    color: #666;
}

.rebuild-step-detail {
    font-size: 0.8125rem;
    color: #888;
    margin: 0;
}

.rebuild-step.active .rebuild-step-detail {
    color: #a78bfa;
}

.rebuild-overall-progress {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.rebuild-progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.rebuild-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.rebuild-progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #888;
}

.rebuild-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.rebuild-modal-actions button {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rebuild-cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.rebuild-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.rebuild-cancel-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rebuild-done-btn {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border: none;
    display: none;
}

.rebuild-done-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(34, 197, 94, 0.3);
}

.no-apps, .loading-apps, .error-loading {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
    font-size: 1rem;
}

.error-loading {
    color: #ef4444;
}

/* Confirmation Dialog */
.confirm-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.confirm-dialog.show {
    display: flex;
}

.confirm-dialog-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: confirmSlideIn 0.3s ease-out;
}

@keyframes confirmSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.confirm-dialog-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.confirm-dialog-content h3 {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    color: #e0e0e0;
}

.confirm-dialog-content p {
    margin: 0 0 2rem 0;
    font-size: 1rem;
    color: #999;
    line-height: 1.5;
}

.confirm-dialog-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.confirm-dialog-buttons button {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

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

.confirm-btn:not(.cancel-btn) {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
}

.confirm-btn:not(.cancel-btn):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.confirm-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

/* Refresh dialog OK button */
.ok-btn {
    background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
    color: white;
    border: none;
}

.ok-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Refresh dialog options */
.refresh-dialog-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    text-align: left;
}

.refresh-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-option:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.refresh-option:has(input:checked) {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.4);
}

.refresh-option input[type="radio"] {
    accent-color: #667eea;
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.refresh-option span {
    color: #e0e0e0;
    font-size: 0.9375rem;
}

.refresh-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    cursor: pointer;
}

.refresh-checkbox input[type="checkbox"] {
    accent-color: #667eea;
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.refresh-checkbox span {
    color: #999;
    font-size: 0.875rem;
}

/* Version mismatch dialog styles */
.version-details {
    font-family: monospace;
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    color: #6dd5ed;
    margin-bottom: 1.5rem !important;
}

.confirm-btn.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.ok-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ok-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Hide main content until auth is determined */
.header,
.user-mode-content,
.footer {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.app-container.auth-ready .header,
.app-container.auth-ready .user-mode-content,
.app-container.auth-ready .footer {
    opacity: 1;
}

/* Full Page Login Styles */
.login-page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    z-index: 9999;
    overflow: auto;
}

.login-page.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-page-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    text-align: center;
}

.login-page-header {
    margin-bottom: 2rem;
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.login-logo .beetle-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.login-logo .logo-text h1 {
    font-size: 2rem;
    margin: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo .logo-text .tagline {
    font-size: 0.875rem;
    color: #888;
}

.login-page-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    padding: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.login-page-card h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    color: #e0e0e0;
}

.login-subtitle {
    margin: 0 0 2rem 0;
    color: #888;
    font-size: 0.9375rem;
}

.login-form {
    text-align: left;
}

.login-field {
    margin-bottom: 1.25rem;
}

.login-field label {
    display: block;
    font-size: 0.875rem;
    color: #e0e0e0;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.login-field input {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.3);
    color: #e0e0e0;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.login-field input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.login-field input::placeholder {
    color: #666;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: #e0e0e0;
}

.login-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    display: none;
    text-align: center;
}

.login-error.show {
    display: block;
}

.password-requirements {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 1rem;
    text-align: center;
}

.password-requirements p {
    margin: 0;
}

.login-submit-btn {
    width: 100%;
    padding: 1rem;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.login-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.login-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-submit-btn.loading {
    position: relative;
    color: transparent;
}

.login-submit-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.login-footer-text {
    margin-top: 2rem;
    color: #666;
    font-size: 0.8125rem;
}

.login-version {
    margin-top: 0.5rem;
    color: #888;
    font-size: 0.75rem;
}

/* Registration Page - Full Width Two-Panel Layout */

.reg-page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.reg-page.show {
    display: flex;
}

/* Left Panel - Branding */
.reg-left-panel {
    width: 45%;
    min-height: 100vh;
    background: linear-gradient(160deg, #0f0f1a 0%, #1a1033 40%, #0d1b2a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.reg-left-panel::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.12) 0%, transparent 70%);
    pointer-events: none;
}

.reg-left-panel::after {
    content: '';
    position: absolute;
    bottom: -10%;
    right: -10%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(118, 75, 162, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.reg-left-content {
    position: relative;
    z-index: 1;
    padding: 3rem;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.reg-left-content .login-logo {
    margin-bottom: 3rem;
}

.reg-hero h2 {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
    margin: 0 0 1rem 0;
    background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 50%, #b8bcc8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.reg-hero p {
    font-size: 1.0625rem;
    color: #888;
    line-height: 1.6;
    margin: 0 0 2.5rem 0;
}

.reg-features {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.reg-feature {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #b8bcc8;
    font-size: 0.9375rem;
}

.reg-feature i {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.reg-left-footer {
    margin-top: auto;
    padding-top: 2rem;
    color: #555;
    font-size: 0.8125rem;
}

/* Right Panel - Form */
.reg-right-panel {
    width: 55%;
    min-height: 100vh;
    background: linear-gradient(180deg, #111322 0%, #161929 100%);
    overflow-y: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.reg-right-content {
    width: 100%;
    max-width: 680px;
    padding: 3rem 3rem 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.reg-right-header {
    margin-bottom: 2rem;
}

.reg-right-header h2 {
    font-size: 1.75rem;
    color: #e0e0e0;
    margin: 0 0 1.5rem 0;
    font-weight: 600;
}

/* Step Indicator - Horizontal with lines */
.registration-steps {
    display: flex;
    align-items: center;
    gap: 0;
}

.reg-step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    color: #555;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.reg-step .step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.reg-step-line {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.08);
    min-width: 16px;
    transition: background 0.3s ease;
}

.reg-step.active {
    color: #667eea;
}

.reg-step.active .step-num {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.reg-step.completed {
    color: #10b981;
}

.reg-step.completed .step-num {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.reg-step-line.completed {
    background: #10b981;
}

/* Step content */
.step-content {
    flex: 1;
    animation: regFadeIn 0.3s ease;
}

@keyframes regFadeIn {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

.reg-step-title {
    font-size: 1.25rem;
    color: #e0e0e0;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.reg-step-desc {
    font-size: 0.9375rem;
    color: #666;
    margin: 0 0 1.75rem 0;
    line-height: 1.5;
}

/* Form field rows */
.reg-field-row {
    display: flex;
    gap: 1rem;
}

.reg-field-row .login-field {
    flex: 1;
}

/* Select styling */
.login-field select {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.3);
    color: #e0e0e0;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
    appearance: none;
    -webkit-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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.login-field select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.login-field select option {
    background: #1a1a2e;
    color: #e0e0e0;
}

/* Navigation buttons */
.reg-nav-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.reg-nav-buttons .login-submit-btn {
    flex: 1;
}

.reg-back-btn {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #888 !important;
    flex: 0 0 auto !important;
    width: auto !important;
    padding-left: 2rem !important;
    padding-right: 2rem !important;
}

.reg-back-btn:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #e0e0e0 !important;
    box-shadow: none !important;
}

/* Offer info */
.reg-offer-info {
    margin-bottom: 1rem;
}

.reg-plan-banner {
    margin: 0 0 1.25rem 0;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(174, 82, 242, 0.12), rgba(62, 179, 252, 0.12));
    border: 1px solid rgba(174, 82, 242, 0.32);
    color: #FAFAFA;
    font-size: 0.92rem;
}

.reg-plan-banner i {
    margin-right: 0.5rem;
    color: #41E3CA;
}

.reg-offer-valid {
    padding: 1rem;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    font-size: 0.9rem;
}

.reg-offer-valid i {
    margin-right: 0.25rem;
}

.reg-offer-valid span {
    color: #888;
    font-size: 0.825rem;
}

/* Agreements */
.reg-agreements {
    margin-bottom: 1rem;
}

.reg-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #b8bcc8;
    cursor: pointer;
}

.reg-checkbox input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    flex-shrink: 0;
}

.reg-checkbox a {
    color: #667eea;
    text-decoration: none;
}

.reg-checkbox a:hover {
    text-decoration: underline;
}

/* Password strength */
.password-strength {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.strength-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.strength-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: width 0.3s ease, background 0.3s ease;
}

.strength-text {
    font-size: 0.75rem;
    min-width: 60px;
    text-align: right;
}

/* Success */
.reg-success-icon {
    font-size: 3.5rem;
    color: #10b981;
    margin-bottom: 1rem;
}

/* Footer */
.reg-right-footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
}

.reg-right-footer a {
    color: #667eea;
    text-decoration: none;
    font-size: 0.9rem;
}

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

/* Login page create account link */
.login-create-account {
    margin-top: 1.5rem;
    color: #888;
    font-size: 0.875rem;
}

.login-create-account a {
    color: #667eea;
    text-decoration: none;
}

.login-create-account a:hover {
    text-decoration: underline;
}

/* Mobile responsive for registration */
@media (max-width: 900px) {
    .reg-page.show {
        flex-direction: column;
    }

    .reg-left-panel {
        width: 100%;
        min-height: auto;
        padding: 2rem 1.5rem;
    }

    .reg-left-content {
        padding: 0;
        max-width: 100%;
    }

    .reg-hero h2 {
        font-size: 1.5rem;
    }

    .reg-features {
        display: none;
    }

    .reg-left-footer {
        display: none;
    }

    .reg-right-panel {
        width: 100%;
        min-height: auto;
        flex: 1;
    }

    .reg-right-content {
        padding: 1.5rem;
        min-height: auto;
    }

    .reg-field-row {
        flex-direction: column;
        gap: 0;
    }

    .reg-step .step-label {
        display: none;
    }

    .reg-step-line {
        min-width: 8px;
    }
}

/* Quick Start Guide Styles */
.quick-start-page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    z-index: 9998;
    overflow: auto;
}

.quick-start-page.show {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
}

.quick-start-container {
    width: 100%;
    max-width: 900px;
    padding: 2rem 0;
}

.quick-start-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.quick-start-header h1 {
    font-size: 2rem;
    color: #e0e0e0;
    margin: 0 0 0.5rem 0;
}

.quick-start-subtitle {
    font-size: 1rem;
    color: #888;
    margin: 0;
}

.quick-start-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quick-start-step {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 1.25rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    align-items: start;
}

.step-number {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.step-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #e0e0e0;
}

.step-content p {
    margin: 0;
    font-size: 0.875rem;
    color: #999;
    line-height: 1.5;
}

.step-how {
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.how-label {
    display: block;
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.step-how p {
    margin: 0;
    font-size: 0.875rem;
    color: #888;
    line-height: 1.5;
}

.step-how strong {
    color: #6dd5ed;
}

.quick-start-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    margin-top: 2rem;
}

.dont-show-again {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #888;
    font-size: 0.875rem;
}

.dont-show-again input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    cursor: pointer;
}

.quick-start-btn {
    padding: 0.875rem 3rem;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.quick-start-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.quick-start-btn-secondary {
    padding: 0.875rem 2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #e0e0e0;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-start-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Responsive Quick Start */
@media (max-width: 768px) {
    .quick-start-step {
        grid-template-columns: auto 1fr;
        gap: 1rem;
    }

    .step-how {
        grid-column: 2;
        padding-left: 0;
        padding-top: 0.75rem;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .quick-start-buttons {
        flex-direction: column;
        width: 100%;
    }

    .quick-start-btn,
    .quick-start-btn-secondary {
        width: 100%;
    }
}

/* Help Manual Viewer Styles */
.help-manual-page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    z-index: 10000;
    overflow: hidden;
}

.help-manual-page.show {
    display: flex;
    flex-direction: column;
}

.help-manual-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.help-manual-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.help-manual-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: #e0e0e0;
}

.help-manual-close {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-manual-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.help-manual-content {
    flex: 1;
    overflow: auto;
    padding: 2rem;
}

.help-manual-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem;
    color: #888;
}

.help-manual-loading i {
    font-size: 2rem;
    color: #667eea;
}

/* Markdown Body Styles */
.markdown-body {
    max-width: 900px;
    margin: 0 auto;
    color: #e0e0e0;
    line-height: 1.7;
}

.markdown-body h1 {
    font-size: 2rem;
    color: #e0e0e0;
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
    padding-bottom: 0.5rem;
    margin: 2rem 0 1rem 0;
}

.markdown-body h1:first-child {
    margin-top: 0;
}

.markdown-body h2 {
    font-size: 1.5rem;
    color: #e0e0e0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    margin: 2rem 0 1rem 0;
}

.markdown-body h3 {
    font-size: 1.25rem;
    color: #e0e0e0;
    margin: 1.5rem 0 0.75rem 0;
}

.markdown-body h4 {
    font-size: 1.1rem;
    color: #ccc;
    margin: 1.25rem 0 0.5rem 0;
}

.markdown-body p {
    margin: 0.75rem 0;
    color: #b8bcc8;
}

.markdown-body a {
    color: #6dd5ed;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body strong {
    color: #e0e0e0;
    font-weight: 600;
}

.markdown-body code {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    color: #6dd5ed;
}

.markdown-body pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
    color: #e0e0e0;
}

.markdown-body ul,
.markdown-body ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.markdown-body li {
    margin: 0.5rem 0;
    color: #b8bcc8;
}

.markdown-body blockquote {
    border-left: 4px solid #667eea;
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 0 8px 8px 0;
}

.markdown-body blockquote p {
    color: #999;
    margin: 0.5rem 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.markdown-body th,
.markdown-body td {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.markdown-body th {
    background: rgba(102, 126, 234, 0.2);
    color: #e0e0e0;
    font-weight: 600;
}

.markdown-body td {
    color: #b8bcc8;
}

.markdown-body tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.2);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 2rem 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
}

/* Hide screenshot placeholder images and style their containers */
.markdown-body img[alt="Screenshot Placeholder"] {
    display: none;
}

/* Style screenshot placeholder blockquotes as subtle info boxes */
.markdown-body blockquote:has(strong:first-child) {
    background: rgba(102, 126, 234, 0.05);
    border-left-color: #555;
    padding: 0.5rem 1rem;
    margin: 0.5rem 0;
}

.markdown-body blockquote p:has(img[alt="Screenshot Placeholder"]) {
    display: none;
}

/* ============================================
   EDIT MODE STYLES
   ============================================ */

/* Edit Toolbar */
.edit-toolbar {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 320px;
    background: #1e1e2e;
    border: 1px solid #2a2a3e;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    overflow: hidden;
}

.edit-toolbar-header {
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-toolbar-title {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.edit-toolbar-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.edit-toolbar-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.edit-toolbar-content {
    padding: 20px;
}

.edit-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.edit-label {
    color: #b4b4c8;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.edit-textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    background: #2a2a3e;
    border: 1px solid #3a3a4e;
    border-radius: 6px;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.edit-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.edit-input {
    width: 100%;
    padding: 10px;
    background: #2a2a3e;
    border: 1px solid #3a3a4e;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
}

.edit-input:focus {
    outline: none;
    border-color: #667eea;
}

.edit-select {
    width: 100%;
    padding: 10px;
    background: #2a2a3e;
    border: 1px solid #3a3a4e;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    cursor: pointer;
}

.edit-select:focus {
    outline: none;
    border-color: #667eea;
}

.edit-color-picker {
    width: 100%;
    height: 40px;
    border: 1px solid #3a3a4e;
    border-radius: 6px;
    background: #2a2a3e;
    cursor: pointer;
}

.edit-divider {
    text-align: center;
    color: #6c6c7e;
    font-size: 12px;
    margin: 8px 0;
}

.edit-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.edit-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-btn-cancel {
    background: #3a3a4e;
    color: #b4b4c8;
}

.edit-btn-cancel:hover {
    background: #4a4a5e;
}

.edit-btn-save,
.edit-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.edit-btn-save:hover,
.edit-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.image-preview-container {
    width: 100%;
    height: 150px;
    background: #2a2a3e;
    border: 1px solid #3a3a4e;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-preview {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Image Gallery Modal */
.image-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.image-gallery-content {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    background: #1e1e2e;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.image-gallery-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-gallery-header h2 {
    color: white;
    margin: 0;
    font-size: 20px;
}

.image-gallery-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-gallery-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.image-gallery-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    background: #2a2a3e;
    border-bottom: 1px solid #3a3a4e;
    overflow-x: auto;
}

.gallery-tab {
    padding: 8px 16px;
    background: #1e1e2e;
    border: 1px solid #3a3a4e;
    border-radius: 6px;
    color: #b4b4c8;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.gallery-tab:hover {
    background: #3a3a4e;
}

.gallery-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.image-gallery-grid {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.gallery-image-card {
    aspect-ratio: 1;
    background: #2a2a3e;
    border: 2px solid #3a3a4e;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.gallery-image-card:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.gallery-image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #6c6c7e;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: #1e1e2e;
    border: 1px solid #3a3a4e;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 10002;
    min-width: 200px;
    overflow: hidden;
}

.context-menu-item {
    padding: 12px 16px;
    color: #e0e0e0;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: #2a2a3e;
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.context-menu-divider {
    height: 1px;
    background: #3a3a4e;
    margin: 4px 0;
}

/* Edit Mode Active Indicator */
#editModeBtn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#editModeBtn.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Highlight selected element in edit mode */
.edit-mode-highlight {
    outline: 2px dashed #667eea !important;
    outline-offset: 2px;
    cursor: pointer !important;
}

.edit-mode-active [data-element-id]:hover {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    cursor: pointer;
}

/* Inline Picker Panels (Style & Font) */
.inline-picker-panel {
    position: fixed;
    z-index: 10002;
    background: #1e1e2e;
    border: 1px solid #2a2a3e;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    min-width: 300px;
    max-width: 380px;
    font-family: system-ui, -apple-system, sans-serif;
}

.inline-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.inline-panel-close {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
}

.inline-panel-close:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.inline-panel-content {
    padding: 16px;
    max-height: 500px;
    overflow-y: auto;
}

.inline-panel-loading {
    padding: 24px;
    text-align: center;
    color: #888;
}

.inline-panel-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.inline-panel-actions button {
    flex: 1;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.inline-panel-actions .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.inline-panel-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.inline-panel-actions .btn-secondary {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: #ccc;
}

.inline-panel-actions .btn-secondary:hover {
    background: rgba(255,255,255,0.1);
}

/* Image Change Panel */
.image-change-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.image-change-dropzone {
    position: relative;
    border: 2px dashed #3a3a4e;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-change-dropzone.drag-over {
    border-color: #667eea;
    background: rgba(102,126,234,0.1);
}

.image-change-drop-hint {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(102,126,234,0.15);
    color: #667eea;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
}

.image-change-dropzone.drag-over .image-change-drop-hint {
    display: flex;
}

/* Color Groups */
.color-group {
    margin-bottom: 14px;
}

.color-group:last-child {
    margin-bottom: 0;
}

.color-group-title {
    font-size: 10px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 6px;
}

.color-swatch {
    text-align: center;
}

.swatch-box {
    height: 32px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 2px;
}

.swatch-label {
    font-size: 8px;
    color: #777;
}

/* Font Panel */
.font-preview {
    background: rgba(255,255,255,0.05);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.form-group select {
    width: 100%;
    padding: 8px 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 13px;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ============================================
   Debug Panel Styles
   ============================================ */

.debug-panel {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 40px;
    background: #1a1a2e;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.debug-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #16213e;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.debug-panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
}

.debug-panel-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.debug-btn {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.4);
    color: #667eea;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.debug-btn:hover {
    background: rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

.debug-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

.debug-close:hover {
    color: #e0e0e0;
}

.debug-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.debug-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.debug-tab {
    background: transparent;
    border: 1px solid transparent;
    color: #888;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.debug-tab:hover {
    color: #e0e0e0;
    background: rgba(255,255,255,0.05);
}

.debug-tab.active {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.4);
    color: #667eea;
}

.debug-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.debug-tab-content {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
    padding: 20px 24px;
}

.debug-tab-content.active {
    display: block;
}

.debug-loading, .debug-empty {
    color: #666;
    text-align: center;
    padding: 40px;
    font-size: 14px;
}

.debug-panel-footer {
    padding: 12px 24px;
    background: rgba(0,0,0,0.3);
    border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 12px;
    color: #666;
}

.debug-panel-footer span {
    color: #888;
}

#debugFbId, #debugWsStatus {
    color: #667eea;
    font-family: monospace;
}

/* Debug Section Styles */
.debug-section {
    margin-bottom: 24px;
}

.debug-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.debug-section-title .count {
    background: rgba(102, 126, 234, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: normal;
}

.debug-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.debug-table th {
    text-align: left;
    padding: 10px 12px;
    background: rgba(0,0,0,0.3);
    color: #888;
    font-weight: 500;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.debug-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: #e0e0e0;
    vertical-align: top;
}

.debug-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

.debug-table .id-cell {
    font-family: monospace;
    color: #4ecdc4;
    font-size: 12px;
}

.debug-table .type-cell {
    color: #f39c12;
}

.debug-table .value-cell {
    font-family: monospace;
    font-size: 12px;
    color: #98c379;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.debug-table .path-cell {
    font-family: monospace;
    font-size: 11px;
    color: #666;
}

/* JSON Tree View */
.debug-json {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 16px;
    font-family: monospace;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    color: #98c379;
    max-height: 400px;
    overflow-y: auto;
}

/* Event Log Styles */
.debug-events-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.debug-event {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 12px 16px;
    border-left: 3px solid #667eea;
}

.debug-event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.debug-event-fn {
    font-weight: 600;
    color: #667eea;
    font-family: monospace;
}

.debug-event-time {
    font-size: 11px;
    color: #666;
}

.debug-event-details {
    font-family: monospace;
    font-size: 12px;
    color: #e0e0e0;
}

.debug-event-id {
    color: #4ecdc4;
}

.debug-event-value {
    color: #98c379;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Element Found/Not Found Indicators */
.debug-found {
    color: #4ecdc4;
}

.debug-not-found {
    color: #e74c3c;
}

.debug-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.debug-badge-success {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
}

.debug-badge-warning {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
}

.debug-badge-error {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

/* LLM Calls Debug Styles */
.debug-llm-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-btn-small {
    padding: 6px 12px;
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 4px;
    color: #667eea;
    cursor: pointer;
    font-size: 12px;
}

.debug-btn-small:hover {
    background: rgba(102, 126, 234, 0.3);
}

.debug-llm-count {
    font-size: 12px;
    color: #888;
}

.debug-llm-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.debug-llm-entry {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-llm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(102, 126, 234, 0.15);
    cursor: pointer;
}

.debug-llm-header:hover {
    background: rgba(102, 126, 234, 0.25);
}

.debug-llm-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.debug-llm-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
}

.debug-llm-status.error {
    background: #e74c3c;
}

.debug-llm-prompt-preview {
    font-size: 13px;
    color: #e0e0e0;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.debug-llm-meta {
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: #888;
}

.debug-llm-body {
    display: none;
    padding: 16px;
}

.debug-llm-entry.expanded .debug-llm-body {
    display: block;
}

.debug-llm-section {
    margin-bottom: 16px;
}

.debug-llm-section:last-child {
    margin-bottom: 0;
}

.debug-llm-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.debug-llm-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(102, 126, 234, 0.2);
}

.debug-llm-code {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #e0e0e0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.debug-llm-code.system-prompt {
    max-height: 200px;
    color: #888;
}

.debug-llm-code.user-prompt {
    border-left: 3px solid #4ade80;
}

.debug-llm-code.response {
    border-left: 3px solid #667eea;
}

.debug-llm-code.function-calls {
    border-left: 3px solid #f39c12;
}

.debug-llm-code.error {
    border-left: 3px solid #e74c3c;
    color: #e74c3c;
}

.debug-llm-toggle {
    font-size: 14px;
    transition: transform 0.2s;
}

.debug-llm-entry.expanded .debug-llm-toggle {
    transform: rotate(180deg);
}

/* ========================================
   Widget Picker Styles
   ======================================== */

.widget-picker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.widget-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--secondary-bg, #2a2a2a);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.widget-picker-item:hover {
    background: var(--hover-bg, #333);
    border-color: var(--accent-color, #4a90d9);
}

.widget-picker-item.selected {
    background: var(--accent-color, #4a90d9);
    border-color: var(--accent-color, #4a90d9);
    color: white;
}

/* Dragging state for drag-and-drop widget placement */
.widget-picker-item[draggable="true"] {
    cursor: grab;
}

.widget-picker-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
    transform: scale(0.98);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.widget-picker-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-bg, #1e1e1e);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

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

.widget-picker-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-picker-desc {
    font-size: 12px;
    color: var(--text-muted, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-picker-item.selected .widget-picker-desc {
    color: rgba(255, 255, 255, 0.8);
}

.widget-picker-category-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted, #888);
    padding: 8px 12px 4px;
    text-transform: uppercase;
}

.widget-picker-category-group {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #aaa);
    padding: 6px 12px 2px;
    margin-top: 4px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

.widget-picker-item[data-source="library"] .widget-picker-icon {
    opacity: 0.8;
}

.widget-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted, #888);
}

.widget-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted, #888);
}

.widget-empty a {
    color: var(--accent-color, #4a90d9);
    text-decoration: none;
}

.widget-empty a:hover {
    text-decoration: underline;
}

/* Slot Selector */
.slot-selector {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #333);
}

/* Slot buttons removed - using drag and drop instead */

/* Widget Placement Status */
.widget-place-status {
    margin-top: 12px;
    padding: 12px;
    background: var(--success-bg, rgba(46, 204, 113, 0.1));
    border: 1px solid var(--success-color, #2ecc71);
    border-radius: 6px;
    color: var(--success-color, #2ecc71);
    font-size: 13px;
    text-align: center;
}

.widget-place-status.error {
    background: rgba(231, 76, 60, 0.1);
    border-color: #e74c3c;
    color: #e74c3c;
}

/* =============================================
   Widget Picker Sidebar (replaces left panel)
   ============================================= */
.widget-picker-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--panel-bg, #1a1a2e);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.widget-picker-sidebar-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.back-to-chat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.back-to-chat-btn:hover {
    background: rgba(255,255,255,0.3);
}

.widget-picker-title {
    font-weight: 600;
    font-size: 15px;
}

.widget-picker-sidebar-content {
    flex: 1;
    overflow: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.widget-picker-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--secondary-bg, #2a2a2a);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 8px;
    flex-shrink: 0;
}

.widget-picker-search-bar input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: inherit;
    font-size: 13px;
    font-family: inherit;
}

.widget-picker-search-bar input::placeholder {
    color: var(--text-muted, #666);
}

.widget-picker-section {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 8px;
}

/* Widget list section: shrinks to content, caps at 40vh */
.widget-picker-list-section {
    flex: 0 1 auto;
    max-height: 40vh;
    overflow: hidden;
    min-height: 80px;
}

/* Flexible sections that grow to fill space */
.widget-picker-section.flexible {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.widget-picker-sidebar .widget-picker-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    min-height: 80px;
    padding-right: 8px;
}

.widget-picker-sidebar .widget-picker-item {
    padding: 8px 10px;
    gap: 8px;
    border-radius: 6px;
}

.widget-picker-sidebar .widget-picker-icon {
    font-size: 16px;
}

.widget-picker-sidebar .widget-picker-name {
    font-size: 13px;
}

.widget-picker-sidebar .widget-picker-desc {
    font-size: 11px;
}

.widget-picker-sidebar .widget-picker-list::-webkit-scrollbar {
    width: 6px;
}

.widget-picker-sidebar .widget-picker-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
}

.widget-picker-sidebar .widget-picker-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.widget-preview-area {
    background: #0d0d1a;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    flex: 1;
    min-height: 120px;
    padding: 0;
}

.widget-preview-placeholder {
    color: #666;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.widget-preview-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    transition: all 0.3s ease;
}

/* Full width alignment (default) */
.widget-preview-wrapper.align-full {
    justify-content: stretch;
}

.widget-preview-wrapper.align-full .widget-preview-iframe {
    width: 100%;
}

/* Left alignment */
.widget-preview-wrapper.align-left {
    justify-content: flex-start;
}

.widget-preview-wrapper.align-left .widget-preview-iframe {
    width: 60%;
}

/* Center alignment */
.widget-preview-wrapper.align-center {
    justify-content: center;
}

.widget-preview-wrapper.align-center .widget-preview-iframe {
    width: 60%;
}

/* Right alignment */
.widget-preview-wrapper.align-right {
    justify-content: flex-end;
}

.widget-preview-wrapper.align-right .widget-preview-iframe {
    width: 60%;
}

.widget-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    border-radius: 6px;
    transition: width 0.3s ease;
}

/* Alignment buttons */
.alignment-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.alignment-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    font-size: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s;
}

.alignment-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.alignment-btn.selected {
    background: rgba(102, 126, 234, 0.2);
    border-color: #667eea;
    color: #667eea;
}

.alignment-btn svg {
    flex-shrink: 0;
}

/* Sizing buttons (new Flexbox-based layout system) */
.sizing-buttons-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.sizing-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    font-size: 11px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s;
}

.sizing-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sizing-btn.selected {
    background: rgba(102, 126, 234, 0.2);
    border-color: #667eea;
    color: #667eea;
}

.sizing-btn svg {
    flex-shrink: 0;
}

.fixed-width-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
}

.fixed-width-input label {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}

.fixed-width-input input {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: #fff;
}

.fixed-width-input input:focus {
    outline: none;
    border-color: #667eea;
}

.widget-picker-sidebar-footer {
    padding: 16px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.drag-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(102, 126, 234, 0.1);
    border: 1px dashed rgba(102, 126, 234, 0.4);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.drag-hint svg {
    opacity: 0.7;
}

.place-widget-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.place-widget-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.place-widget-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.place-widget-btn.loading {
    background: linear-gradient(135deg, #555 0%, #666 100%);
}

.place-widget-btn .spinner {
    animation: spin 1s linear infinite;
}

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

/* ============================================
   Publish Modal Styles
   ============================================ */

.publish-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.publish-modal.show {
    opacity: 1;
    visibility: visible;
}

.publish-modal-content {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.publish-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.publish-modal-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.publish-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.publish-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.publish-modal-body {
    padding: 24px;
    text-align: center;
}

.publish-modal-body h2 {
    color: white;
    font-size: 24px;
    margin: 0 0 8px;
}

.publish-app-name {
    color: #9ca3af;
    font-size: 14px;
    margin: 0 0 24px;
}

.publish-qr-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 20px;
}

.publish-qr-code {
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.publish-qr-code canvas,
.publish-qr-code img {
    display: block;
}

.qr-instruction {
    color: #6b7280;
    font-size: 12px;
    margin: 12px 0 0;
}

.qr-safari-note {
    color: #9ca3af;
    font-size: 11px;
    margin: 8px 0 0;
    padding: 6px 10px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 6px;
    border-left: 3px solid #3b82f6;
}

.publish-url-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.publish-url-container label {
    display: block;
    color: #9ca3af;
    font-size: 12px;
    margin-bottom: 8px;
    text-align: left;
}

.publish-url-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.publish-url-link {
    flex: 1;
    color: #60a5fa;
    text-decoration: none;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.publish-url-link:hover {
    text-decoration: underline;
}

.copy-url-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-url-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.copy-url-btn.copied {
    background: #10b981;
    border-color: #10b981;
}

.publish-features {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.publish-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #10b981;
    font-size: 13px;
    text-align: left;
    justify-content: center;
}

.publish-feature svg {
    flex-shrink: 0;
}

.publish-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
}

.publish-done-btn {
    padding: 10px 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.publish-done-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Publish button styles in My Apps */
.app-action-btn.publish-btn {
    color: #a78bfa;
    border-color: #7c3aed;
}

.app-action-btn.publish-btn:hover {
    background: #7c3aed;
    color: white;
    border-color: #7c3aed;
}

/* Published status indicator */
.app-status.published {
    color: #a78bfa;
    background: rgba(124, 58, 237, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.app-status.published.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-status.published.clickable:hover {
    background: rgba(124, 58, 237, 0.3);
    transform: scale(1.05);
}

/* ==========================================
   Data Panel Styles
   ========================================== */

.data-panel {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 40px;
    background: #0f172a;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
}

.data-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #16213e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
}

.data-panel-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.data-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.data-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

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

.data-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

.data-btn-upgrade {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.5);
    color: #c5cdfb;
    font-style: italic;
}

.data-btn-upgrade:hover {
    background: rgba(102, 126, 234, 0.3);
}

/* Unsplash search picker modal */
.unsplash-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.unsplash-modal-content {
    width: min(960px, 92vw);
    height: min(720px, 88vh);
    background: #1c1c2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.unsplash-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.unsplash-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #f0f0f0;
}

.unsplash-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    line-height: 1;
}

.unsplash-modal-close:hover {
    color: #fff;
}

.unsplash-search-bar {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.unsplash-search-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
}

.unsplash-search-input:focus {
    outline: none;
    border-color: #667eea;
}

.unsplash-search-btn {
    padding: 10px 22px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.unsplash-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    align-content: start;
}

.unsplash-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: rgba(255, 255, 255, 0.45);
    padding: 60px 0;
    font-size: 14px;
}

.unsplash-result {
    position: relative;
    padding: 0;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 4/3;
    transition: border-color 0.15s, transform 0.15s;
}

.unsplash-result:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.unsplash-result img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.unsplash-result-photographer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
    color: #fff;
    font-size: 11px;
    text-align: left;
    padding: 14px 8px 6px;
    opacity: 0;
    transition: opacity 0.15s;
}

.unsplash-result:hover .unsplash-result-photographer {
    opacity: 1;
}

.unsplash-attribution {
    padding: 10px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    text-align: center;
}

.unsplash-attribution a {
    color: #c5cdfb;
}

/* ============================================================
   Data Builder — split-view modal
   ============================================================ */

.data-builder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* The page's persistent .footer (z-index 1001, --footer-height: 40px)
       is part of the chrome on every screen, so the builder sits on top of
       the rest of the app and the page footer remains visible below it.
       Cap our height to leave that 40px strip untouched. */
    bottom: var(--footer-height, 40px);
    width: 100vw;
    height: calc(100vh - var(--footer-height, 40px));
    background: #0b0b13;
    z-index: 1500;
    display: none;
    flex-direction: column;
}

.data-builder-frame {
    flex: 1 1 auto;
    margin: 0;
    background: #14141f;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.data-builder-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.data-builder-header h3 {
    margin: 0;
    color: #f0f0f0;
    font-size: 16px;
    font-weight: 600;
}

.data-builder-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    flex-wrap: wrap;
}

.data-builder-tab {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.data-builder-tab:hover { background: rgba(255, 255, 255, 0.08); }

.data-builder-tab.active {
    background: rgba(102, 126, 234, 0.25);
    border-color: rgba(102, 126, 234, 0.6);
    color: #fff;
}

.data-builder-tab-count {
    background: rgba(0, 0, 0, 0.35);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    color: #c5cdfb;
}

.data-builder-body {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(280px, 38%) 1fr;
    overflow: hidden;
}

.data-builder-search {
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.data-builder-search-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 14px 0;
}

.data-builder-source-tab {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    cursor: pointer;
}

.data-builder-source-tab.active {
    color: #fff;
    border-bottom-color: #667eea;
}

.data-builder-source-tab:disabled {
    color: rgba(255, 255, 255, 0.25);
    cursor: not-allowed;
}

.data-builder-search-bar {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
}

.data-builder-search-bar input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
}

.data-builder-search-bar button {
    padding: 8px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}

.data-builder-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px 14px 14px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    align-content: start;
}

.data-builder-search-empty {
    grid-column: 1 / -1;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 32px 0;
    font-size: 12px;
}

.data-builder-search-thumb {
    aspect-ratio: 4/3;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
    cursor: grab;
    position: relative;
}

.data-builder-search-thumb:active { cursor: grabbing; }
.data-builder-search-thumb:hover { border-color: #667eea; }

.data-builder-search-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Uploaded-tab affordances: empty-state card spans the whole grid; the
   add-tile sits as the first cell when the grid already has thumbs.
   Both open the file picker on click; the parent grid accepts drops. */
.data-builder-search-results.upload-active {
    outline: 2px dashed rgba(102, 126, 234, 0.65);
    outline-offset: -10px;
    background: rgba(102, 126, 234, 0.05);
}

.data-builder-upload-card,
.data-builder-upload-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    border: 1.5px dashed rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.data-builder-upload-card {
    grid-column: 1 / -1;
    min-height: 180px;
    border-radius: 8px;
    padding: 24px;
    font-size: 13px;
}

.data-builder-upload-tile {
    aspect-ratio: 4/3;
    border-radius: 6px;
    font-size: 11px;
}

.data-builder-upload-card:hover,
.data-builder-upload-tile:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
    color: #c5cdfb;
}

.data-builder-upload-card .upload-icon,
.data-builder-upload-tile .upload-icon {
    font-size: 24px;
    opacity: 0.7;
}

.data-builder-upload-tile .upload-icon { font-size: 18px; }

/* In-flight upload card. Shape matches a thumb (4/3) so it slots into
   the grid in place; the progress bar sits at the bottom and animates
   width via JS as bytes flow. Local preview (URL.createObjectURL) shows
   above so the user knows which file is which during multi-file uploads. */
.data-builder-progress-card {
    position: relative;
    aspect-ratio: 4/3;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(102, 126, 234, 0.5);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.data-builder-progress-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.55;
}

.data-builder-progress-card .progress-meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 4px;
    padding: 0 8px;
    color: #fff;
    font-size: 10px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.data-builder-progress-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.15s ease-out;
}

.data-builder-progress-card.error {
    border-color: rgba(239, 68, 68, 0.6);
    background: rgba(127, 29, 29, 0.25);
}

.data-builder-progress-card.error .data-builder-progress-bar {
    background: #ef4444;
    width: 100%;
}

.data-builder-progress-card.error .progress-meta {
    color: #fecaca;
}

.data-builder-progress-card .progress-retry {
    position: absolute;
    inset: auto 6px 14px 6px;
    padding: 4px 0;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    pointer-events: auto;
}

.data-builder-progress-card .progress-retry:hover {
    background: rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

.data-builder-records {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.data-builder-records-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.data-builder-records-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.data-builder-empty {
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 60px 0;
    font-size: 13px;
}

.data-builder-record-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.data-builder-record-fields {
    flex: 1;
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
    line-height: 1.5;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px 14px;
    align-content: start;
}

.data-builder-field-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.data-builder-field-row.tall {
    grid-column: span 2;
}

@media (max-width: 1100px) {
    .data-builder-field-row.tall {
        grid-column: span 1;
    }
}

.data-builder-field-row.auto {
    opacity: 0.6;
}

.data-builder-field-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 600;
}

.data-builder-field-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    color: #fff;
    font: inherit;
    padding: 6px 8px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}

.data-builder-field-input:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

.data-builder-field-input:disabled {
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.45);
}

.data-builder-field-input.invalid {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

textarea.data-builder-field-input {
    resize: vertical;
    min-height: 60px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    line-height: 1.4;
}

input.data-builder-field-input[type="checkbox"] {
    width: auto;
    align-self: flex-start;
    accent-color: #667eea;
    margin-top: 4px;
}

.data-builder-field-empty {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    font-size: 12px;
}

/* When ✏️ in the Data panel routes here, briefly pulse the targeted
   record so the user knows where focus landed. */
.data-builder-record-card.focused {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    animation: builder-record-pulse 1.5s ease-out;
}

@keyframes builder-record-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.55); }
    50%  { box-shadow: 0 0 0 8px rgba(102, 126, 234, 0.18); }
    100% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0); }
}

.data-builder-record-slots {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    /* Slots come first in the markup; this keeps them flush to the
       card's left edge regardless of card width. */
    order: -1;
}

.data-builder-record-slot {
    width: 96px;
    height: 72px;
    border-radius: 6px;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.25);
    overflow: hidden;
    position: relative;
    color: rgba(255, 255, 255, 0.4);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.data-builder-record-slot.drop-active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.18);
    color: #c5cdfb;
}

.data-builder-record-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.data-builder-record-slot-label {
    position: absolute;
    bottom: 2px;
    left: 4px;
    right: 4px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.data-builder-csv-hint {
    padding: 10px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    text-align: center;
}

.data-builder-csv-warnings {
    padding: 8px 18px;
    background: rgba(254, 243, 199, 0.08);
    color: #fbbf24;
    font-size: 12px;
    border-top: 1px solid rgba(251, 191, 36, 0.25);
}

.data-builder-records.csv-drag-over {
    background: rgba(102, 126, 234, 0.05);
    outline: 2px dashed rgba(102, 126, 234, 0.5);
    outline-offset: -8px;
}

.data-builder-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.data-builder-dirty-flag {
    color: #fbbf24;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.data-builder-footer-actions {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.data-builder-footer-actions .data-btn {
    padding: 9px 22px;
    font-size: 13px;
}

.data-btn-builder {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.5);
    color: #d8b4fe;
}

.data-btn-builder:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.25);
}

.data-btn-primary:hover:not(:disabled) {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.data-btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: transparent;
}

.data-btn-success:hover:not(:disabled) {
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Export Dropdown */
.data-export-dropdown {
    position: relative;
    display: inline-block;
}

.data-btn-split {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding-right: 8px;
}

.data-btn-split span:first-child {
    padding-right: 10px;
}

.data-btn-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 8px;
}

.data-btn-arrow {
    font-size: 10px;
    opacity: 0.7;
}

.data-export-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    background: #2a2a3a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 160px;
    z-index: 100;
    overflow: hidden;
}

.data-export-menu.show {
    display: block;
}

.data-export-option {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: #e0e0e0;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.data-export-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.data-export-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

.data-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.data-close:hover {
    color: #e0e0e0;
}

.data-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.data-tabs {
    display: flex;
    gap: 0;
    padding: 0 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
}

.data-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #888;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.data-tab:hover {
    color: #e0e0e0;
    background: rgba(255, 255, 255, 0.05);
}

.data-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.data-tab-count {
    display: inline-block;
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.data-tab.active .data-tab-count {
    background: #667eea;
    color: white;
}

.data-content {
    flex: 1;
    padding: 20px 24px;
    overflow: auto;
}

.data-array-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.data-array-selector label {
    color: #888;
    font-size: 13px;
}

.data-array-selector select {
    padding: 8px 12px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 13px;
    min-width: 200px;
}

.data-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: #0f172a;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: #1e293b;
    color: #94a3b8;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table th:last-child {
    border-right: none;
}

.data-table td {
    padding: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    vertical-align: middle;
    background: transparent;
}

.data-table td:last-child {
    border-right: none;
}

.data-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.data-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

.data-table tbody tr:nth-child(even):hover td {
    background: rgba(255, 255, 255, 0.045);
}

.data-row-num {
    width: 40px;
    text-align: center;
    color: #64748b;
    font-size: 12px;
    padding: 8px 12px !important;
}

.data-cell-input {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    color: #e0e0e0;
    font-size: 13px;
    transition: background 0.15s;
    box-sizing: border-box;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.data-cell-input:hover {
    background: rgba(255, 255, 255, 0.03);
}

.data-cell-input:focus {
    outline: none;
    background: rgba(102, 126, 234, 0.1);
    box-shadow: inset 0 0 0 2px rgba(102, 126, 234, 0.4);
    white-space: normal;
    overflow: visible;
}

.data-cell-input.data-cell-saved {
    background: rgba(16, 185, 129, 0.15);
    box-shadow: none;
}

.data-cell-input.data-cell-error {
    background: rgba(239, 68, 68, 0.15);
    box-shadow: none;
}

.data-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

/* ============================================
   Image Drop Zone Styles
   ============================================ */

.image-drop-zone {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-drop-zone:hover {
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(102, 126, 234, 0.05);
}

.image-drop-zone .data-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 9px;
    color: #64748b;
    text-align: center;
    padding: 4px;
}

.image-drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    text-align: center;
    padding: 4px;
}

.image-drop-zone.drag-over {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.image-drop-zone.drag-over .image-drop-overlay {
    display: flex;
}

.image-drop-zone.uploading {
    opacity: 0.6;
    pointer-events: none;
}

.image-drop-zone.uploading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.image-drop-zone.upload-success {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.image-drop-zone.upload-error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.image-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1;
}

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

/* ============================================
   Bulk Image Upload Styles
   ============================================ */

.bulk-image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.bulk-image-form {
    background: #1e1e2e;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.bulk-image-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 16px;
}

.bulk-image-header h3 {
    flex: 1;
    margin: 0;
    font-size: 18px;
    color: #e0e0e0;
}

.bulk-image-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.bulk-image-dropzone {
    border: 2px dashed rgba(102, 126, 234, 0.5);
    border-radius: 12px;
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 200px;
}

.bulk-image-dropzone:hover,
.bulk-image-dropzone.drag-over {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.bulk-dropzone-content {
    text-align: center;
    color: #94a3b8;
}

.bulk-dropzone-content i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 16px;
}

.bulk-dropzone-content p {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #e0e0e0;
}

.bulk-dropzone-content small {
    font-size: 13px;
}

.bulk-image-matches {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bulk-matches-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #94a3b8;
    font-size: 14px;
}

.bulk-matches-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.bulk-match-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.bulk-match-preview {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.bulk-match-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bulk-match-filename {
    font-size: 13px;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bulk-match-confidence {
    font-size: 12px;
}

.bulk-match-confidence.confidence-high {
    color: #10b981;
}

.bulk-match-confidence.confidence-medium {
    color: #f59e0b;
}

.bulk-match-confidence.confidence-low {
    color: #64748b;
}

.bulk-match-select {
    width: 180px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 13px;
    cursor: pointer;
}

.bulk-match-select:focus {
    outline: none;
    border-color: #667eea;
}

.data-btn-images {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.data-btn-images:hover {
    opacity: 0.9;
}

.data-btn-images:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.data-btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

.data-actions {
    width: 50px;
    text-align: center;
    padding: 8px 12px !important;
}

.data-action-btn {
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #64748b;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
}

.data-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
}

.data-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.data-panel-footer {
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 12px;
    align-items: center;
}

.data-empty {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.data-empty p {
    margin-bottom: 16px;
}

.data-json {
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: 8px;
    font-size: 12px;
    overflow-x: auto;
    color: #94a3b8;
    max-height: 300px;
}

.data-error {
    color: #ef4444;
    padding: 20px;
    text-align: center;
}

.data-loading {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

/* Data sections */
.data-section {
    margin-bottom: 24px;
}

.data-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #94a3b8;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Fields grid */
.data-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.data-field-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.data-field-label {
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    text-transform: capitalize;
}

.data-field-input {
    padding: 8px 12px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 13px;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.data-field-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.data-field-json {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    resize: vertical;
}

/* Primitive arrays (tags) */
.data-primitive-array {
    margin-bottom: 16px;
}

.data-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    min-height: 44px;
    align-items: center;
}

.data-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #1e293b;
    border-radius: 4px;
    overflow: hidden;
}

.data-tag-input {
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: #e0e0e0;
    font-size: 13px;
    min-width: 80px;
    width: auto;
}

.data-tag-input:focus {
    outline: none;
    background: rgba(102, 126, 234, 0.1);
}

.data-tag-remove {
    padding: 6px 8px;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.data-tag-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.data-tag-add {
    padding: 6px 12px;
    background: rgba(102, 126, 234, 0.2);
    border: 1px dashed rgba(102, 126, 234, 0.5);
    border-radius: 4px;
    color: #667eea;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.data-tag-add:hover {
    background: rgba(102, 126, 234, 0.3);
    border-style: solid;
}

/* ==========================================
   Data Edit Form Overlay
   ========================================== */

.data-edit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f172a;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.data-edit-form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.data-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #16213e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-edit-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
}

.data-edit-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.data-edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.data-edit-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.data-edit-field.full-width {
    grid-column: 1 / -1;
}

.data-edit-label {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: capitalize;
}

.data-edit-input {
    padding: 12px 16px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 14px;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.data-edit-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.data-edit-input[type="number"] {
    font-family: 'Monaco', 'Menlo', monospace;
}

.data-edit-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.data-edit-textarea.json-field {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    min-height: 150px;
}

.data-edit-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #1e293b;
    border-radius: 8px;
}

.data-edit-checkbox {
    width: 20px;
    height: 20px;
    accent-color: #667eea;
}

.data-edit-checkbox-label {
    color: #e0e0e0;
    font-size: 14px;
}

.data-edit-image-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.data-edit-image-input-wrapper .data-edit-input {
    flex: 1;
}

.data-ai-image-btn {
    padding: 10px 14px;
    background: rgba(102, 126, 234, 0.15);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    color: #667eea;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.data-ai-image-btn:hover:not(:disabled) {
    background: rgba(102, 126, 234, 0.25);
    border-color: rgba(102, 126, 234, 0.5);
    color: #8b9df5;
}

.data-ai-image-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.data-ai-image-btn i {
    font-size: 14px;
}

.data-ai-image-btn.loading i {
    visibility: hidden;
}

.data-ai-image-btn.loading {
    position: relative;
}

.data-ai-image-btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: ai-btn-spin 0.8s linear infinite;
}

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

.data-edit-image-preview-wrapper {
    margin-top: 12px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e293b;
    border-radius: 8px;
    overflow: hidden;
}

.data-edit-image-preview {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
}

.data-edit-image-placeholder {
    color: #64748b;
    font-size: 13px;
    padding: 40px;
}

/* Image Gallery (for image arrays) */
.edit-image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: #1e293b;
    border-radius: 8px;
    min-height: 80px;
    align-items: flex-start;
}

.edit-image-thumb-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: #334155;
}

.edit-image-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.edit-image-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.edit-image-thumb-wrapper:hover .edit-image-remove {
    opacity: 1;
}

.edit-no-images {
    color: #64748b;
    font-size: 13px;
    font-style: italic;
}

.edit-image-add-wrapper {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.edit-image-add-url {
    flex: 1;
    padding: 8px 12px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #f1f5f9;
    font-size: 13px;
}

.edit-image-add-btn {
    padding: 8px 16px;
    background: #334155;
    border: none;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.edit-image-add-btn:hover {
    background: #475569;
    color: #f1f5f9;
}

/* Upload image button (green, matches AI wand button sizing) */
.data-upload-image-btn,
.edit-image-upload-btn {
    padding: 10px 14px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    color: #10b981;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.data-upload-image-btn:hover:not(:disabled),
.edit-image-upload-btn:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.5);
    color: #34d399;
}

.data-upload-image-btn:disabled,
.edit-image-upload-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.data-upload-image-btn.loading,
.edit-image-upload-btn.loading {
    position: relative;
}

.data-upload-image-btn.loading i,
.edit-image-upload-btn.loading i {
    visibility: hidden;
}

.data-upload-image-btn.loading::after,
.edit-image-upload-btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(16, 185, 129, 0.3);
    border-top-color: #10b981;
    border-radius: 50%;
    animation: ai-btn-spin 0.8s linear infinite;
}

/* Array upload button - smaller, inline */
.edit-image-upload-btn {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    min-width: 38px;
}

/* Drop zone overlay (for single image preview and gallery) */
.data-edit-image-dropzone,
.data-edit-gallery-dropzone {
    position: relative;
}

.data-edit-image-dropzone .drop-overlay,
.data-edit-gallery-dropzone .drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(102, 126, 234, 0.15);
    border: 2px dashed rgba(102, 126, 234, 0.6);
    border-radius: 8px;
    z-index: 10;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.data-edit-image-dropzone .drop-overlay i,
.data-edit-gallery-dropzone .drop-overlay i {
    font-size: 24px;
    color: #667eea;
    margin-right: 8px;
}

.data-edit-image-dropzone .drop-overlay span,
.data-edit-gallery-dropzone .drop-overlay span {
    color: #a5b4fc;
    font-size: 14px;
    font-weight: 500;
}

.data-edit-image-dropzone.drag-over .drop-overlay,
.data-edit-gallery-dropzone.drag-over .drop-overlay {
    display: flex;
}

/* Upload states */
.data-edit-image-dropzone.uploading,
.data-edit-gallery-dropzone.uploading {
    opacity: 0.6;
    pointer-events: none;
}

.data-edit-image-dropzone.upload-success {
    animation: upload-success-flash 0.6s ease;
}

.data-edit-gallery-dropzone.upload-success {
    animation: upload-success-flash 0.6s ease;
}

.data-edit-image-dropzone.upload-error {
    animation: upload-error-flash 0.6s ease;
}

.data-edit-gallery-dropzone.upload-error {
    animation: upload-error-flash 0.6s ease;
}

@keyframes upload-success-flash {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: inset 0 0 0 2px #10b981; }
}

@keyframes upload-error-flash {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: inset 0 0 0 2px #ef4444; }
}

/* Tags (for ID arrays) */
.edit-tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    background: #1e293b;
    border-radius: 6px;
    min-height: 40px;
    align-items: center;
}

.edit-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #334155;
    border-radius: 4px;
    font-size: 12px;
    color: #e2e8f0;
}

.edit-tag-remove {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.edit-tag-remove:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.edit-no-tags {
    color: #64748b;
    font-size: 13px;
    font-style: italic;
}

.edit-tag-add-wrapper {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.edit-tag-add-input {
    flex: 1;
    padding: 6px 10px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #f1f5f9;
    font-size: 12px;
}

.edit-tag-add-btn {
    padding: 6px 12px;
    background: #334155;
    border: none;
    border-radius: 4px;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.edit-tag-add-btn:hover {
    background: #475569;
    color: #f1f5f9;
}

/* JSON collapsible */
.edit-json-details {
    background: #1e293b;
    border-radius: 6px;
    overflow: hidden;
}

.edit-json-summary {
    padding: 10px 14px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 13px;
    border-bottom: 1px solid #334155;
    user-select: none;
}

.edit-json-summary:hover {
    background: rgba(255, 255, 255, 0.02);
}

.edit-json-details[open] .edit-json-summary {
    color: #e2e8f0;
}

.edit-json-details .data-edit-textarea {
    border-radius: 0;
    border: none;
    margin: 0;
}

/* Compact textarea for simple arrays */
.data-edit-textarea-small {
    min-height: 60px !important;
    max-height: 80px;
    font-size: 12px;
}

.data-edit-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.data-edit-footer .data-btn {
    padding: 10px 24px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.data-edit-footer .data-btn .spinner {
    animation: spin 1s linear infinite;
}

.data-edit-footer .data-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* ==========================================
   Sticky Column Positioning
   ========================================== */

/* Row number column - sticky left */
.data-table th.data-col-num,
.data-table td.data-col-num {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #1e293b;
    text-align: center;
    width: 50px;
    min-width: 50px;
    color: #64748b;
    font-size: 12px;
}

.data-table tbody td.data-col-num {
    background: #0f172a;
}

.data-table tbody tr:nth-child(even) td.data-col-num {
    background: #0d1321;
}

.data-table tbody tr:hover td.data-col-num {
    background: #151d2e;
}

/* Actions column - sticky right */
.data-table th.data-col-actions,
.data-table td.data-col-actions {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #1e293b;
    text-align: center;
    width: 90px;
    min-width: 90px;
    padding: 4px 8px;
}

.data-table tbody td.data-col-actions {
    background: #0f172a;
}

.data-table tbody tr:nth-child(even) td.data-col-actions {
    background: #0d1321;
}

.data-table tbody tr:hover td.data-col-actions {
    background: #151d2e;
}

/* Edit button styling */
.data-edit-btn {
    color: #667eea;
}

.data-edit-btn:hover {
    background: rgba(102, 126, 234, 0.15);
    color: #8b9df5;
}

/* Data cell display (read-only view) */
.data-cell-display {
    display: block;
    padding: 8px 12px;
    color: #e0e0e0;
    font-size: 13px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 200px;
}

/* ==========================================
   Generate Data Overlay (Full Page)
   ========================================== */

.generate-data-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f172a;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.generate-data-form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.generate-data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, #1e293b 0%, #16213e 100%);
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
    gap: 16px;
}

.generate-data-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
    flex: 1;
    text-align: center;
}

.generate-data-back {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.generate-data-back:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.3);
}

.generate-data-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.generate-data-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: 100%;
}

@media (max-width: 800px) {
    .generate-data-columns {
        grid-template-columns: 1fr;
    }
}

.generate-data-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.generate-data-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.generate-data-section-label {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.generate-data-label-hint {
    font-weight: 400;
    color: #64748b;
    font-size: 12px;
}

.generate-data-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f8fafc;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.generate-data-textarea:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.generate-data-textarea::placeholder {
    color: #64748b;
}

/* Assertions */
.assertions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assertion-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

.assertion-input {
    flex: 1;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #f8fafc;
    font-size: 13px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.assertion-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.assertion-input::placeholder {
    color: #64748b;
}

.assertion-remove {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.assertion-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: #ef4444;
}

.add-assertion-btn {
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-top: 8px;
    transition: all 0.2s;
}

.add-assertion-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.5);
    color: #667eea;
}

.assertions-hint {
    margin-top: 8px;
    margin-bottom: 8px;
}

.assertions-hint small {
    color: #64748b;
    font-size: 12px;
    font-style: italic;
}

/* Entity Row Counts */
.entity-row-counts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.entity-row-counts-loading {
    color: #64748b;
    font-size: 13px;
    padding: 12px;
    text-align: center;
}

.entity-row-count {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.entity-row-count-name {
    flex: 1;
    font-size: 13px;
    color: #e2e8f0;
    font-weight: 500;
}

.entity-row-count-input {
    width: 60px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #f8fafc;
    font-size: 13px;
    text-align: center;
}

.entity-row-count-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
}

.entity-row-count-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Entity Toggle Switch */
.entity-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.entity-toggle-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
}

.entity-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: 0.2s;
    border-radius: 20px;
}

.entity-toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #94a3b8;
    transition: 0.2s;
    border-radius: 50%;
}

.entity-toggle-checkbox:checked + .entity-toggle-slider {
    background-color: rgba(102, 126, 234, 0.3);
    border-color: rgba(102, 126, 234, 0.5);
}

.entity-toggle-checkbox:checked + .entity-toggle-slider:before {
    transform: translateX(16px);
    background-color: #667eea;
}

/* Disabled entity row */
.entity-row-count.entity-disabled {
    opacity: 0.5;
}

.entity-row-count.entity-disabled .entity-row-count-name {
    color: #64748b;
}

.entity-transient-note {
    grid-column: 1 / -1;
    padding: 12px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 8px;
    margin-top: 8px;
}

.entity-transient-note small {
    color: #fbbf24;
    font-size: 12px;
}

/* Radio Groups */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-option:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

.radio-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    cursor: pointer;
}

.radio-option span {
    font-size: 13px;
    color: #e2e8f0;
}

/* CSV Dropzone */
.csv-dropzone {
    padding: 24px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.csv-dropzone:hover {
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(102, 126, 234, 0.05);
}

.csv-dropzone.dragover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.csv-dropzone-text {
    color: #64748b;
    font-size: 13px;
}

/* CSV Preview */
.csv-preview {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.csv-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.csv-preview-header span {
    color: #10b981;
    font-size: 13px;
    font-weight: 500;
}

.csv-remove-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.csv-remove-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.csv-preview-content {
    padding: 12px;
    max-height: 120px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 11px;
    color: #94a3b8;
    white-space: pre-wrap;
}

/* CSV Usage Mode */
.csv-usage-mode {
    margin-top: 12px;
    padding: 12px;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
}

.csv-usage-mode > label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
    margin-bottom: 8px;
}

/* Generate Data Header Button */
.generate-data-header .data-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
}

.generate-data-header .btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Generate Data Button in Footer */
.data-btn-generate {
    background: linear-gradient(135deg, #8b5cf6 0%, #667eea 100%);
    color: white;
    border: none;
}

.data-btn-generate:hover {
    background: linear-gradient(135deg, #9d6ffc 0%, #7b8ff5 100%);
    transform: translateY(-1px);
}

.generate-data-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 12px 14px 0;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.18) 0%, rgba(102, 126, 234, 0.18) 100%);
    border: 1px solid rgba(139, 92, 246, 0.45);
    border-radius: 10px;
    color: #e8e6ff;
    font-size: 13px;
    line-height: 1.4;
}

.generate-data-banner-text {
    flex: 1;
}

.generate-data-banner-text i {
    margin-right: 6px;
    color: #c5b6ff;
}

.generate-data-banner-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #8b5cf6 0%, #667eea 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: transform 0.15s;
}

.generate-data-banner-btn:hover {
    transform: translateY(-1px);
}

.generate-data-banner-close {
    background: transparent;
    border: none;
    color: rgba(232, 230, 255, 0.6);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.generate-data-banner-close:hover {
    color: #fff;
}

.template-choice-modal {
    position: absolute;
    inset: 0;
    background: rgba(8, 10, 24, 0.7);
    backdrop-filter: blur(6px);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.template-choice-card {
    width: 100%;
    max-width: 440px;
    background: linear-gradient(180deg, #1f1b3a 0%, #161430 100%);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 14px;
    padding: 28px 28px 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    color: #e8e6ff;
    text-align: left;
}

.template-choice-title {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.template-choice-body {
    margin: 0 0 22px;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(232, 230, 255, 0.85);
}

.template-choice-body strong {
    color: #c5b6ff;
    font-weight: 600;
}

.template-choice-params {
    margin: -14px 0 22px;
    padding: 10px 12px;
    font-size: 13px;
    color: #c5b6ff;
    background: rgba(139, 92, 246, 0.12);
    border-left: 2px solid rgba(139, 92, 246, 0.55);
    border-radius: 4px;
    line-height: 1.4;
}

.template-choice-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.template-choice-btn {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #e8e6ff;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.template-choice-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}

.template-choice-btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #667eea 100%);
    border-color: transparent;
    color: #fff;
    font-weight: 500;
}

.template-choice-btn-primary:hover {
    background: linear-gradient(135deg, #9d6ffc 0%, #7b8ff5 100%);
    transform: translateY(-1px);
}

.template-choice-cancel {
    display: block;
    margin: 0 auto;
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: rgba(232, 230, 255, 0.55);
    font-size: 13px;
    cursor: pointer;
}

.template-choice-cancel:hover {
    color: rgba(232, 230, 255, 0.9);
}

/* Horizontal Radio Group */
.radio-group-horizontal {
    flex-direction: row;
    gap: 12px;
}

.radio-group-horizontal .radio-option {
    flex: 1;
}

/* ==========================================
   Generating Data Overlay (Blur + Status)
   ========================================== */

.generating-data-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
}

.generating-data-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px 60px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.generating-data-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.generating-data-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
}

.generating-data-status {
    margin: 0;
    font-size: 14px;
    color: #94a3b8;
    text-align: center;
    min-height: 20px;
}

.generating-data-cancel {
    margin-top: 10px;
    padding: 10px 24px;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.generating-data-cancel:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

/* ==========================================
   Review Data Overlay (Full Page)
   ========================================== */

.review-data-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f172a;
    z-index: 11;
    display: flex;
    flex-direction: column;
}

.review-data-form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.review-data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, #065f46 0%, #064e3b 100%);
    border-bottom: 1px solid rgba(16, 185, 129, 0.3);
    gap: 16px;
}

.review-data-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
    flex: 1;
    text-align: center;
}

.review-data-back {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.review-data-back:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.3);
}

.review-data-actions {
    display: flex;
    gap: 12px;
}

.review-data-actions .data-btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.review-data-actions .data-btn-primary:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

.review-data-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.review-data-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.review-data-stat {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.review-data-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #10b981;
}

.review-data-stat-label {
    font-size: 12px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.review-data-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.review-data-entity {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.review-data-entity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.review-data-entity-name {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
}

.review-data-entity-count {
    font-size: 12px;
    color: #10b981;
    background: rgba(16, 185, 129, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
}

.review-data-table-wrapper {
    overflow-x: auto;
    /* No max-height - let tables flow naturally, single main scroll */
}

.review-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.review-data-table th {
    position: sticky;
    top: 0;
    background: #1e293b;
    color: #94a3b8;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.review-data-table td {
    padding: 8px 12px;
    color: #e0e0e0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.review-data-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}

.review-data-table .cell-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.review-data-table .cell-truncate {
    max-width: 150px;
}

/* ============================================
   Data Source Button & Modal
   ============================================ */

.data-source-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 10px 20px;
    background: transparent;
    color: #2dd4a8;
    border: 2px solid #2dd4a8;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.data-source-btn:hover {
    background: rgba(45, 212, 168, 0.1);
    border-color: #5eead4;
    color: #5eead4;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 212, 168, 0.3);
}

.data-source-btn svg {
    width: 16px;
    height: 16px;
}

.user-mode-container.building .data-source-btn {
    display: none;
}

/* Data Source Type Grid */
.ds-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.ds-type-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.ds-type-card:hover {
    border-color: #2dd4a8;
    background: rgba(45, 212, 168, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(45, 212, 168, 0.15);
}

.ds-type-card .ds-card-icon {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}

.ds-type-card .ds-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 0.35rem;
}

.ds-type-card .ds-card-desc {
    font-size: 0.8rem;
    color: #888;
    line-height: 1.4;
}

/* Data Source Config Form */
.ds-config-group {
    margin-bottom: 1.25rem;
}

.ds-config-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #ccc;
    margin-bottom: 0.4rem;
}

.ds-config-group .ds-hint {
    font-size: 0.75rem;
    color: #777;
    margin-top: 0.25rem;
}

.ds-config-group input,
.ds-config-group textarea,
.ds-config-group select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.ds-config-group input:focus,
.ds-config-group textarea:focus,
.ds-config-group select:focus {
    outline: none;
    border-color: #2dd4a8;
}

.ds-config-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Data Source Action Buttons */
.ds-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ds-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

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

.ds-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.ds-btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.ds-btn-primary {
    background: rgba(45, 212, 168, 0.15);
    color: #2dd4a8;
    border: 1px solid #2dd4a8;
}

.ds-btn-primary:hover:not(:disabled) {
    background: rgba(45, 212, 168, 0.25);
}

.ds-btn-success {
    background: linear-gradient(135deg, #2dd4a8 0%, #20b090 100%);
    color: #fff;
}

.ds-btn-success:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(45, 212, 168, 0.4);
    transform: translateY(-1px);
}

/* Data Source Test Status */
.ds-status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ds-status.success {
    background: rgba(45, 212, 168, 0.1);
    border: 1px solid rgba(45, 212, 168, 0.3);
    color: #2dd4a8;
}

.ds-status.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.ds-status.loading {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    color: #667eea;
}

/* Data Source Preview */
.ds-preview-entity {
    margin-bottom: 1.5rem;
}

.ds-preview-entity h4 {
    color: #e0e0e0;
    font-size: 0.95rem;
    margin: 0 0 0.25rem 0;
}

.ds-preview-entity .ds-entity-meta {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.75rem;
}

.ds-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.ds-preview-table th {
    text-align: left;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.05);
    color: #aaa;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.ds-preview-table td {
    padding: 6px 10px;
    color: #ccc;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ds-preview-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.ds-field-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    margin-right: 4px;
}

/* Data Source Indicator (below textarea) */
.ds-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 8px 12px;
    background: rgba(45, 212, 168, 0.08);
    border: 1px solid rgba(45, 212, 168, 0.25);
    border-radius: 8px;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #2dd4a8;
}

.ds-indicator-icon {
    flex-shrink: 0;
}

.ds-indicator-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ds-indicator-clear {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.ds-indicator-clear:hover {
    color: #ef4444;
}

/* Sheet Chips (Google Sheets auto-detected tabs) */
.ds-sheet-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    color: #ccc;
    user-select: none;
}

.ds-sheet-chip:hover {
    border-color: rgba(45, 212, 168, 0.4);
    background: rgba(45, 212, 168, 0.05);
}

.ds-sheet-chip:has(input:checked) {
    border-color: #2dd4a8;
    background: rgba(45, 212, 168, 0.1);
    color: #2dd4a8;
}

.ds-sheet-checkbox {
    width: 14px;
    height: 14px;
    accent-color: #2dd4a8;
    cursor: pointer;
}

.ds-sheet-chip-label {
    cursor: pointer;
}

@media (max-width: 600px) {
    .ds-type-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   My Account — settings layout (sticky nav + cards)
   ============================================ */
.account-page {
    position: fixed;
    inset: 0;
    background: #0a0d1f;
    z-index: 9000;
    display: none;
    color: #FAFAFA;
    flex-direction: column;
}
.account-page.show { display: flex; }

.account-topbar {
    flex: 0 0 auto;
    background: #0F1225;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.account-topbar__inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
}
.account-topbar__brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.account-topbar__brand .beetle-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #AE52F2 0%, #3EB3FC 100%);
    color: #fff;
    font-size: 16px;
}
.account-topbar__title {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.2;
    color: #FAFAFA;
}
.account-topbar__subtitle {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}
.account-close-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    color: #b0b6c8;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.account-close-btn:hover {
    color: #FAFAFA;
    border-color: rgba(255,255,255,0.24);
    background: rgba(255,255,255,0.04);
}

.account-shell {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 40px;
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 32px 80px;
    min-height: 0;
}

.account-nav {
    position: sticky;
    top: 32px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.account-nav__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: #b0b6c8;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}
.account-nav__item i {
    width: 18px;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
}
.account-nav__item:hover {
    background: rgba(255,255,255,0.04);
    color: #FAFAFA;
}
.account-nav__item.active {
    background: rgba(174, 82, 242, 0.12);
    color: #FAFAFA;
}
.account-nav__item.active i {
    color: #AE52F2;
}
.account-nav__item--danger { color: #f87171; }
.account-nav__item--danger i { color: #ef4444; }
.account-nav__item--danger:hover { background: rgba(239, 68, 68, 0.08); color: #ef4444; }
.account-nav__item--danger.active { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.account-content {
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-width: 0;
    max-width: 720px;
    scroll-behavior: smooth;
}

/* Each section is a self-contained card */
.account-section {
    background: #161a36;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 32px;
    scroll-margin-top: 24px;
}
.account-section--danger {
    border-color: rgba(239, 68, 68, 0.28);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.04), #161a36 80%);
}
.account-section__header {
    margin: 0 0 28px;
}
.account-section__title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px;
    color: #FAFAFA;
    letter-spacing: -0.01em;
    line-height: 1.3;
}
.account-section--danger .account-section__title {
    color: #f87171;
}
.account-section__lead {
    color: #8b92a5;
    font-size: 14px;
    line-height: 1.55;
    margin: 0;
    max-width: 56ch;
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Sub-section inside a card — clusters related fields under a small heading */
.account-group {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.account-group:last-of-type {
    padding-bottom: 0;
    border-bottom: none;
}
.account-group__title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #6b7280;
    margin: 0 0 4px;
}
.account-field {
    display: flex;
    flex-direction: column;
}
.account-field label {
    font-size: 13px;
    color: #d4d6e0;
    font-weight: 500;
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}
.account-field input,
.account-field select,
.account-field textarea {
    padding: 11px 14px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    background: #0F1225;
    color: #FAFAFA;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    width: 100%;
    box-sizing: border-box;
}
.account-field textarea {
    height: auto;
    min-height: 96px;
    padding: 12px 14px;
    line-height: 1.5;
}
.account-field input:hover,
.account-field select:hover {
    border-color: rgba(255,255,255,0.16);
}
.account-field input:focus,
.account-field select:focus,
.account-field textarea:focus {
    border-color: #AE52F2;
    background: #14172e;
    box-shadow: 0 0 0 3px rgba(174, 82, 242, 0.12);
}
.account-field input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: #0a0d1f;
    border-color: rgba(255,255,255,0.04);
}
.account-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.account-field-hint {
    font-size: 12px;
    color: #6b7280;
    margin: 6px 0 0;
    line-height: 1.5;
}
.account-readonly-tag {
    background: rgba(255,255,255,0.06);
    color: #6b7280;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.account-meta {
    color: #8b92a5;
    font-size: 13px;
    margin: 8px 0;
}
.account-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
    align-items: center;
}
.account-actions--right {
    justify-content: flex-end;
}
.account-actions .login-submit-btn {
    width: auto;
    padding: 10px 22px;
    height: 40px;
}
.account-actions .reg-back-btn {
    background: transparent !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    color: #b0b6c8 !important;
}
.account-actions .reg-back-btn:hover {
    background: rgba(255,255,255,0.04) !important;
    color: #FAFAFA !important;
}
.account-loading {
    color: #8b92a5;
    font-size: 14px;
    padding: 12px 0;
}
.account-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #10b981;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
}
.account-btn-danger {
    background: linear-gradient(135deg, #b91c1c, #ef4444) !important;
}
.account-btn-danger:hover { filter: brightness(1.1); }
.account-btn-danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: none;
}

.account-sub-card {
    padding: 20px 22px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(174, 82, 242, 0.08), rgba(62, 179, 252, 0.05));
}
.account-sub-card__head {
    font-size: 16px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.account-sub-card__head strong {
    color: #FAFAFA;
    font-weight: 600;
}

.account-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-left: 8px;
    vertical-align: middle;
}
.account-badge--ok { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.account-badge--warn { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.account-badge--err { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.account-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    max-width: 720px;
}
.account-table th {
    text-align: left;
    padding: 10px 12px;
    color: #6b7280;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.account-table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: #FAFAFA;
}
.account-table tr:hover td {
    background: rgba(255,255,255,0.02);
}
.account-table__actions a {
    color: #3EB3FC;
    text-decoration: none;
    font-size: 13px;
}
.account-table__actions a:hover { text-decoration: underline; }

#acctDeleteEmailInput {
    width: 100%;
    max-width: 420px;
    margin-bottom: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: #161a36;
    color: #FAFAFA;
    font-size: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    outline: none;
}
#acctDeleteEmailInput:focus {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.04);
}

@media (max-width: 880px) {
    .account-shell {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 20px 16px 64px;
    }
    .account-nav {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        margin-bottom: 8px;
    }
    .account-nav__item {
        flex: 0 0 auto;
        padding: 8px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
    .account-content {
        max-width: 100%;
    }
    .account-section { padding: 24px; }
    .account-topbar__inner { padding: 12px 16px; }
    .account-topbar__subtitle { display: none; }
    .account-field-row { grid-template-columns: 1fr; }
}

/* ============================================================
 * Choose Your Plan modal — Beetler-themed plan picker.
 * Follows the .template-modal pattern (dark overlay, blur, card surface).
 * ============================================================ */

.choose-plan-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    animation: fadeIn 0.25s ease;
}

.choose-plan-content {
    background: var(--secondary-bg, #252936);
    border: 1px solid var(--border, #3f4354);
    border-radius: 14px;
    padding: 28px 32px 24px;
    max-width: 980px;
    width: 100%;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: slideUp 0.25s ease;
}

.choose-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 4px;
}

.choose-plan-title {
    margin: 0;
    color: var(--text-primary, #ffffff);
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.choose-plan-close {
    background: transparent;
    border: none;
    color: var(--text-muted, #8b92a5);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.choose-plan-close:hover {
    color: var(--text-primary, #ffffff);
}

.choose-plan-current {
    margin: 0 0 22px;
    color: var(--text-secondary, #b8bcc8);
    font-size: 0.9rem;
}

.choose-plan-current strong {
    color: var(--text-primary, #ffffff);
    font-weight: 600;
}

.choose-plan-grid {
    display: flex;
    gap: 14px;
    align-items: stretch;
    flex-wrap: wrap;
}

.choose-plan-card {
    position: relative;
    background: var(--accent-bg, #2d3142);
    color: var(--text-primary, #ffffff);
    border: 1px solid var(--border, #3f4354);
    border-radius: 12px;
    padding: 26px 22px 20px;
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.choose-plan-card:hover {
    border-color: var(--text-muted, #8b92a5);
}

.choose-plan-card--featured {
    background: var(--card-bg, #343750);
    border: 1.5px solid var(--accent-purple, #8b5cf6);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.2), 0 12px 28px rgba(139, 92, 246, 0.15);
}

.choose-plan-card--featured:hover {
    border-color: var(--accent-purple, #8b5cf6);
    transform: translateY(-2px);
}

.choose-plan-ribbon {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gradient, linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%));
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 4px 12px;
    border-radius: 12px;
    white-space: nowrap;
    text-transform: uppercase;
}

.choose-plan-card__name {
    margin: 0 0 8px;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary, #ffffff);
}

.choose-plan-card__price {
    text-align: center;
    margin-bottom: 18px;
    color: var(--text-primary, #ffffff);
}

.choose-plan-card__price-amount {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.choose-plan-card__price-period {
    font-size: 0.88rem;
    color: var(--text-muted, #8b92a5);
    margin-left: 3px;
}

.choose-plan-card__features {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    flex: 1;
}

.choose-plan-card__features li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 9px;
    font-size: 0.85rem;
    color: var(--text-secondary, #b8bcc8);
    line-height: 1.45;
}

.choose-plan-card__features li::before {
    content: "✓";
    color: var(--success, #10b981);
    flex-shrink: 0;
    font-weight: 700;
}

.choose-plan-card__cta {
    padding: 11px 16px;
    border-radius: 8px;
    border: none;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent-purple, #8b5cf6);
    color: #ffffff;
    transition: background 0.2s ease, transform 0.1s ease;
    font-family: inherit;
}

.choose-plan-card__cta:hover:not(:disabled) {
    background: #7c3aed;
}

.choose-plan-card__cta:active:not(:disabled) {
    transform: translateY(1px);
}

.choose-plan-card--featured .choose-plan-card__cta {
    background: var(--accent-gradient, linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%));
}

.choose-plan-card--featured .choose-plan-card__cta:hover:not(:disabled) {
    filter: brightness(1.1);
}

.choose-plan-card__cta:disabled {
    background: rgba(139, 146, 165, 0.2);
    color: var(--text-muted, #8b92a5);
    cursor: default;
    border: 1px solid var(--border, #3f4354);
}

.choose-plan-card--featured .choose-plan-card__cta:disabled {
    background: rgba(139, 146, 165, 0.2);
}

.choose-plan-voucher {
    margin: 24px auto 0;
    max-width: 420px;
    text-align: center;
}
.choose-plan-voucher__label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted, #8b92a5);
    margin-bottom: 8px;
}
.choose-plan-voucher__field {
    display: flex;
    gap: 8px;
    align-items: center;
}
.choose-plan-voucher__field input {
    flex: 1;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: inherit;
    font-size: 0.9rem;
    outline: none;
    letter-spacing: 0.05em;
}
.choose-plan-voucher__field input:focus {
    border-color: rgba(139, 92, 246, 0.6);
}
.choose-plan-voucher__btn {
    padding: 9px 18px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 6px;
    color: var(--primary-accent, #a78bfa);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}
.choose-plan-voucher__btn:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.25);
}
.choose-plan-voucher__btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.choose-plan-voucher__status {
    margin-top: 10px;
    font-size: 0.85rem;
}
.choose-plan-voucher__status[data-kind="success"] {
    color: #10b981;
}
.choose-plan-voucher__status[data-kind="error"] {
    color: #ef4444;
}

.choose-plan-footnote {
    margin: 18px 0 0;
    color: var(--text-muted, #8b92a5);
    font-size: 0.78rem;
    text-align: center;
}

@media (max-width: 720px) {
    .choose-plan-grid { flex-direction: column; }
    .choose-plan-card { min-width: 0; }
    .choose-plan-card--featured { transform: none; }
}

/* ============================================================
 * Upgrade-required modal — small dialog shown when a Free user
 * clicks a paid feature. Pairs with .choose-plan-modal.
 * ============================================================ */

.upgrade-required-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.upgrade-required-content {
    background: var(--secondary-bg, #252936);
    border: 1px solid var(--border, #3f4354);
    border-radius: 12px;
    padding: 22px 24px 20px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.25s ease;
}

.upgrade-required-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.upgrade-required-icon {
    font-size: 1.3rem;
}

.upgrade-required-title {
    margin: 0;
    color: var(--text-primary, #ffffff);
    font-size: 1.05rem;
    font-weight: 600;
}

.upgrade-required-body {
    margin: 0 0 18px;
    color: var(--text-secondary, #b8bcc8);
    font-size: 0.9rem;
    line-height: 1.5;
}

.upgrade-required-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.upgrade-required-btn {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--border, #3f4354);
    background: transparent;
    color: var(--text-secondary, #b8bcc8);
    font-size: 0.88rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s ease, color 0.2s ease;
}

.upgrade-required-btn:hover {
    background: var(--accent-bg, #2d3142);
    color: var(--text-primary, #ffffff);
}

.upgrade-required-btn--primary {
    background: var(--accent-purple, #8b5cf6);
    border-color: var(--accent-purple, #8b5cf6);
    color: #ffffff;
    font-weight: 600;
}

.upgrade-required-btn--primary:hover {
    background: #7c3aed;
    color: #ffffff;
}

/* ============================================================
 * Agreements section (My Account → Agreements) + Legal viewer modal.
 * Clicking a card opens the modal that fetches /api/legal/:slug and
 * renders the markdown using marked. Beetler dark theme.
 * ============================================================ */

.agreements-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.agreements-card {
    background: var(--accent-bg, #2d3142);
    border: 1px solid var(--border, #3f4354);
    border-radius: 12px;
    padding: 20px 22px;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary, #ffffff);
    font-family: inherit;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agreements-card:hover {
    background: var(--card-bg, #343750);
    border-color: var(--accent-purple, #8b5cf6);
    transform: translateY(-1px);
}

.agreements-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agreements-card__head i {
    color: var(--accent-purple, #8b5cf6);
    font-size: 1.1rem;
}

.agreements-card__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
}

.agreements-card__body {
    margin: 0;
    color: var(--text-secondary, #b8bcc8);
    font-size: 0.86rem;
    line-height: 1.5;
}

.agreements-card__cta {
    margin-top: auto;
    color: var(--accent-purple, #8b5cf6);
    font-size: 0.82rem;
    font-weight: 500;
}

.agreements-card__cta i {
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.agreements-card:hover .agreements-card__cta i {
    transform: translateX(3px);
}

/* Legal viewer modal */

.legal-viewer-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.25s ease;
}

.legal-viewer-content {
    background: var(--secondary-bg, #252936);
    border: 1px solid var(--border, #3f4354);
    border-radius: 14px;
    width: 100%;
    max-width: 820px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.25s ease;
}

.legal-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border, #3f4354);
}

.legal-viewer-title {
    margin: 0;
    color: var(--text-primary, #ffffff);
    font-size: 1.05rem;
    font-weight: 600;
}

.legal-viewer-meta {
    color: var(--text-muted, #8b92a5);
    font-size: 0.78rem;
    margin-left: 10px;
}

.legal-viewer-close {
    background: transparent;
    border: none;
    color: var(--text-muted, #8b92a5);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    transition: color 0.2s ease;
}

.legal-viewer-close:hover {
    color: var(--text-primary, #ffffff);
}

.legal-viewer-body {
    padding: 20px 28px 28px;
    overflow-y: auto;
    color: var(--text-secondary, #b8bcc8);
    font-size: 0.92rem;
    line-height: 1.65;
}

.legal-viewer-body h1 {
    color: var(--text-primary, #ffffff);
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0 0 18px;
    letter-spacing: -0.01em;
}

.legal-viewer-body h2 {
    color: var(--text-primary, #ffffff);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 28px 0 10px;
}

.legal-viewer-body h3 {
    color: var(--text-primary, #ffffff);
    font-size: 1rem;
    font-weight: 600;
    margin: 20px 0 8px;
}

.legal-viewer-body h4 {
    color: var(--text-primary, #ffffff);
    font-size: 0.95rem;
    font-weight: 600;
    margin: 16px 0 6px;
}

.legal-viewer-body p {
    margin: 0 0 12px;
}

.legal-viewer-body strong {
    color: var(--text-primary, #ffffff);
    font-weight: 600;
}

.legal-viewer-body em {
    color: var(--text-muted, #8b92a5);
    font-style: italic;
}

.legal-viewer-body ul,
.legal-viewer-body ol {
    padding-left: 1.4rem;
    margin: 0 0 12px;
}

.legal-viewer-body li {
    margin-bottom: 5px;
}

.legal-viewer-body a {
    color: var(--accent-cyan, #06b6d4);
    text-decoration: underline;
}

.legal-viewer-body a:hover {
    text-decoration: none;
}

.legal-viewer-body code {
    background: var(--accent-bg, #2d3142);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.88em;
}

.legal-viewer-body hr {
    border: none;
    border-top: 1px solid var(--border, #3f4354);
    margin: 28px 0;
}

.legal-viewer-loading,
.legal-viewer-error {
    padding: 40px 0;
    text-align: center;
    color: var(--text-muted, #8b92a5);
}

.legal-viewer-error {
    color: #f87171;
}
