/* ==========================================================================
   App CSS - Application-Specific Styles
   ========================================================================== */

:root {
    --sidebar-width: 360px;
    --header-height: 84px;
}

/* ==========================================================================
   App Layout
   ========================================================================== */

.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
}

.app.authenticated {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.sidebar-header {
    padding: 10px var(--space-5) 10px var(--space-8);
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xl);
    font-weight: 800;
    letter-spacing: -0.3px;
}

/* Mode Dropdown — sits next to logo, replaces sidebar mode tabs */
.mode-dropdown {
    position: relative;
}

.mode-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 10px var(--space-3);
    height: 44px;
    box-sizing: border-box;
    border: none;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent);
    font-family: var(--font);
    font-size: var(--text-xl);
    font-weight: 800;
    letter-spacing: -0.3px;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
}

.mode-dropdown-trigger:hover,
.mode-dropdown.open .mode-dropdown-trigger {
    background: rgba(var(--accent-rgb), 0.14);
}

.mode-dropdown-chevron {
    width: 12px;
    height: 12px;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.mode-dropdown.open .mode-dropdown-chevron {
    transform: rotate(180deg);
}

.mode-dropdown-menu {
    position: fixed;
    /* top/left set by JS on open so the popover escapes .sidebar { overflow: hidden } */
    width: 240px;
    box-sizing: border-box;
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(var(--shadow-color), 0.10), 0 2px 6px rgba(var(--shadow-color), 0.05);
    z-index: 1000;
}

.mode-dropdown.open .mode-dropdown-menu {
    display: flex;
}

.mode-dropdown-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    padding: var(--space-2) 10px 10px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-family: var(--font);
    gap: 2px;
    transition: background 0.12s ease;
}

.mode-dropdown-item:hover:not(.active) {
    background: var(--bg);
}

.mode-dropdown-item.active {
    background: var(--accent-soft);
}

.mode-dropdown-item-title {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
    letter-spacing: -0.2px;
}

.mode-dropdown-item-desc {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.4;
}

.mode-dropdown-item.active .mode-dropdown-item-title,
.mode-dropdown-item.active .mode-dropdown-item-desc {
    color: var(--accent);
}

/* ============================================
   Custom select (.cs-*) — progressive enhancement over native <select>.
   Trigger mirrors the native select; menu reuses .mode-dropdown look.
   ============================================ */

/* Hide the native arrow on wraps we've enhanced (the trigger draws its own). */
.select-wrap.cs-enhanced::after {
    display: none;
}

.cs-native-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    margin: 0;
}

.cs-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    width: 100%;
    height: 44px;
    padding: 0 14px;
    box-sizing: border-box;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--text-md);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.cs-trigger:hover,
.cs-trigger.cs-open {
    background: var(--surface-hover);
}

.cs-trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.cs-trigger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cs-trigger-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cs-trigger-chevron {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-tertiary);
    transition: transform 0.2s ease;
}

.cs-trigger.cs-open .cs-trigger-chevron {
    transform: rotate(180deg);
}

.cs-menu {
    position: fixed;
    box-sizing: border-box;
    display: none;
    flex-direction: column;
    gap: var(--space-1);
    max-height: 320px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(var(--shadow-color), 0.18);
    z-index: 1000;
}

.cs-menu.cs-open {
    display: flex;
}

/* Subtle custom scrollbar. */
.cs-menu {
    scrollbar-width: thin;
    scrollbar-color: var(--surface-hover) transparent;
}

.cs-menu::-webkit-scrollbar {
    width: 6px;
}

.cs-menu::-webkit-scrollbar-track {
    background: transparent;
}

.cs-menu::-webkit-scrollbar-thumb {
    background: var(--surface-hover);
    border-radius: var(--radius-2xs);
}

.cs-menu::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.cs-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cs-section + .cs-section {
    margin-top: 6px;
}

.cs-caption {
    padding: 10px 10px var(--space-1);
    color: var(--text-tertiary);
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.cs-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: var(--text-md);
    font-weight: 600;
    line-height: 20px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s ease;
}

.cs-item:hover:not(.cs-selected),
.cs-item.cs-active:not(.cs-selected) {
    background: var(--bg);
}

.cs-item.cs-selected {
    background: var(--accent-soft);
    color: var(--accent);
}

/* Two-line item (title + description), e.g. the model picker. */
.cs-item--rich {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: var(--space-2) 10px;
    line-height: 1.3;
}

.cs-item-title {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cs-item-desc {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: normal;
}

.cs-item.cs-selected .cs-item-desc {
    color: var(--accent);
}

/* Item with a leading glyph (e.g. aspect-ratio visualization). */
.cs-item--icon {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cs-item--icon .cs-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Fixed square box keeps every ratio rect centered on the same baseline. */
.cs-ratio-icon {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.cs-item.cs-selected .cs-ratio-icon {
    color: var(--accent);
}

.cs-ratio-rect {
    box-sizing: border-box;
    border: 1.5px solid currentColor;
    border-radius: var(--radius-2xs);
}

.cs-item[aria-disabled="true"] {
    opacity: 0.4;
    pointer-events: none;
}

/* Scroll affordance: gradient fade + chevron at the menu's scrollable edges. */
.cs-scrim {
    position: fixed;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 1001;
}

.cs-scrim::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}

.cs-scrim--bottom {
    align-items: flex-end;
    padding-bottom: 6px;
    background: linear-gradient(to top, var(--surface), transparent);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.cs-scrim--bottom::after {
    border-top: 6px solid var(--text-tertiary);
}

.cs-scrim--top {
    align-items: flex-start;
    padding-top: 6px;
    background: linear-gradient(to bottom, var(--surface), transparent);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.cs-scrim--top::after {
    border-bottom: 6px solid var(--text-tertiary);
}

.cs-scrim.cs-scrim--hidden {
    display: none;
}

/* Backdrop only used in bottom-sheet (mobile) mode. */
.cs-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(var(--shadow-color), 0.35);
    z-index: 999;
    display: none;
}

.cs-backdrop.cs-open {
    display: block;
}

/* Bottom-sheet presentation on narrow viewports. */
@media (max-width: 640px) {
    .cs-menu {
        left: 0 !important;
        right: 0 !important;
        bottom: 0;
        top: auto !important;
        width: 100% !important;
        max-width: 100%;
        max-height: 70vh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -8px 30px rgba(var(--shadow-color), 0.18);
        transform: translateY(100%);
        transition: transform 0.22s ease;
    }

    .cs-menu.cs-open {
        transform: translateY(0);
    }

    .cs-item {
        padding: 14px var(--space-3);
    }

    /* The scrim is anchored to a fixed-height popover; not used for the sheet. */
    .cs-scrim {
        display: none;
    }
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-4) var(--space-25) var(--space-8);
}

.sidebar-content::-webkit-scrollbar {
    width: 0;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-8) var(--space-4) var(--space-8) var(--space-8);
    background: linear-gradient(to top, var(--surface) 80%, transparent);
}

/* ==========================================================================
   Upload Zone
   ========================================================================== */

.upload-zone {
    border: none;
    border-radius: var(--radius);
    padding: var(--space-8) var(--space-5);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: var(--space-4);
    background: var(--bg);
}

.upload-zone:hover {
    background: var(--surface-hover);
}

.upload-zone.active {
    background: rgba(var(--accent-rgb), 0.06);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}

.upload-zone.has-image {
    padding: var(--space-3);
}

.upload-icon {
    width: 32px;
    height: 32px;
    margin: 0 auto var(--space-3);
    color: var(--text);
}

.upload-text {
    color: var(--text);
    font-size: var(--text-md);
}

.upload-preview {
    display: none;
}

.upload-zone.has-image .upload-placeholder {
    display: none;
}

.upload-zone.has-image .upload-preview {
    display: block;
}

/* Single image preview - full size */
.single-preview {
    display: none;
}

.upload-zone.has-single-image .single-preview {
    display: flex;
    justify-content: center;
}

.upload-zone.has-single-image .single-preview img {
    max-width: 100%;
    max-height: 230px;
    border-radius: var(--radius);
}

.upload-zone.has-single-image .upload-grid {
    display: none;
}

/* Multi-image upload grid */
.upload-grid {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-1);
}

.upload-zone.has-multiple-images .upload-grid {
    display: grid;
}

.upload-zone.has-multiple-images .single-preview {
    display: none;
}

.upload-grid .upload-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
}

.upload-grid .upload-thumb img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
}

.upload-grid .upload-thumb .remove-thumb {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(var(--shadow-color), 0.6);
    color: var(--white);
    border: none;
    border-radius: var(--radius-round);
    font-size: var(--text-2xs);
    line-height: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.upload-grid .upload-thumb:hover .remove-thumb {
    opacity: 1;
}

.upload-preview .remove-btn {
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
}

.upload-preview .remove-btn:hover {
    color: var(--error);
}

#file-input {
    display: none;
}

/* ==========================================================================
   Section & Form Controls
   ========================================================================== */

/* Decorative group header — visually separates form sections. No interaction. */
.section-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-6) 0 var(--space-4) 0;
    margin: 0;
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.section-group-header:first-child {
    margin-top: 0;
}

.section-group-icon {
    display: none;
}

.section {
    margin-bottom: var(--space-4);
}

/* Inline layout: label left, dropdown right */
.section-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.section-inline .section-label {
    margin-bottom: 0;
    flex-shrink: 0;
    min-width: 90px;
}

.section-inline .select-wrap {
    flex: 1;
    max-width: 188px;
}

.section-label {
    font-size: var(--text-md);
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    margin-bottom: 10px;
}

/* Select */
.select-wrap {
    position: relative;
}

.select-wrap::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-tertiary);
    pointer-events: none;
}

select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    appearance: none;
    cursor: pointer;
    transition: background 0.2s;
    box-sizing: border-box;
}

select:hover {
    background: var(--surface-hover);
}

select:focus {
    outline: none;
    background: var(--surface-hover);
}

/* Toggle */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0;
}

.toggle-label {
    font-size: var(--text-md);
    color: var(--text);
}

.toggle {
    position: relative;
    width: 44px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--text-tertiary);
    border-radius: var(--radius);
    transition: 0.3s;
}

.toggle-track::before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 2px;
    bottom: 2px;
    background: var(--white);
    border-radius: var(--radius-round);
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(var(--shadow-color), 0.25);
}

.toggle input:checked + .toggle-track {
    background: var(--success);
}

.toggle input:checked + .toggle-track::before {
    transform: translateX(18px);
}

/* Slider */
.slider-row {
    margin-bottom: var(--space-4);
}

.slider-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.slider-label {
    font-size: var(--text-md);
}

.slider-value {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--accent);
}

input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: var(--radius-2xs);
    background: var(--text-tertiary);
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-round);
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(var(--shadow-color), 0.3), 0 0 0 1px rgba(var(--shadow-color), 0.08);
    cursor: pointer;
}

/* Manual Prompt */
.manual-section {
    display: none;
}

.manual-section.visible {
    display: block;
}

textarea {
    width: 100%;
    padding: 10px var(--space-3);
    font-size: var(--text-md);
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    resize: none;
    min-height: 200px;
    transition: background 0.2s;
}

textarea:focus {
    outline: none;
    background: var(--surface-alt);
}

textarea::placeholder {
    color: var(--text-tertiary);
}

#manual-prompt {
    min-height: 250px;
    font-weight: 600;
}

/* Custom mode: vibes picker is gone, so the prompt grows into the freed space */
#manual-prompt.manual-prompt-extended {
    min-height: 360px;
}

/* Art mode: compact subject field at the top of the sidebar */
.art-subject-input {
    min-height: 72px;
    font-weight: 600;
}

/* Generate Button */
.generate-btn {
    width: 100%;
    padding: 14px;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    color: var(--white);
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.credit-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: var(--space-1) var(--space-2) var(--space-1) var(--space-2);
    border-radius: var(--radius);
    background: rgba(var(--white-rgb), 0.3);
    font-size: var(--text-xs);
    font-weight: 800;
    line-height: 1;
}

.credit-pill-icon {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.credit-pill-count {
    font-size: var(--text-xs);
    font-weight: 800;
}

.generate-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.01);
}

.generate-btn:active {
    transform: scale(0.99);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Divider */
.divider {
    display: none;
}

/* API Key */
.api-input {
    width: 100%;
    padding: 10px var(--space-3);
    font-size: var(--text-md);
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s;
}

.api-input:focus {
    outline: none;
    background: var(--surface-alt);
}

/* Custom Input */
.custom-input-wrap {
    margin-top: var(--space-2);
    display: none;
}

.custom-input-wrap.visible {
    display: block;
}

/* For inline sections, custom input spans full width below */
.section-inline + .custom-input-wrap,
.section-inline .custom-input-wrap {
    flex-basis: 100%;
    margin-top: var(--space-3);
    margin-bottom: var(--space-3);
}

.custom-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg);
    box-sizing: border-box;
    color: var(--text);
    transition: background 0.2s;
}

.custom-input:focus {
    outline: none;
    background: var(--surface-hover);
}

.custom-input::placeholder {
    color: var(--text-tertiary);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    position: relative;
}

.main-header {
    padding: var(--space-5) var(--space-8) var(--space-5) var(--space-5);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    box-sizing: border-box;
    flex-shrink: 0;
}

.main-title {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.status-dot {
    display: none;
    /* glyph text is injected from JS (cycling spinner) — fixed box so
       varying glyph widths never shift the status text beside it */
    flex: 0 0 auto;
    width: 1em;
    height: 1em;
    overflow: hidden;
    text-align: center;
    white-space: nowrap;
    color: var(--accent);
    font-weight: 700;
    line-height: 1;
}

/* Terminal status states: green check on success, red cross on failure */
.status-dot.success { color: var(--success); }
.status-dot.error { color: var(--error); }

/* ==========================================================================
   Profile Dropdown
   ========================================================================== */

.profile-dropdown-wrapper {
    display: none;
    position: relative;
}

.profile-dropdown-wrapper.visible {
    display: block;
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 14px;
    background: var(--bg);
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s ease;
}

.profile-btn:hover,
.profile-dropdown-wrapper:hover .profile-btn {
    background: var(--on-surface-soft);
}

.profile-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.profile-label {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-secondary);
}

.profile-chevron {
    width: 10px;
    height: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
    margin-left: 2px;
}

.profile-dropdown-wrapper:hover .profile-chevron {
    transform: rotate(180deg);
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 240px;
    padding-top: var(--space-2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 100;
}

.profile-dropdown-wrapper:hover .profile-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(var(--shadow-color), 0.18);
    overflow: hidden;
}

/* Section 1: Email (centered) */
.dropdown-header {
    padding: 6px;
}

.dropdown-email {
    font-family: var(--font);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text);
    padding: var(--space-3) 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Section 2: Credits + CTA */
.dropdown-credits-section {
    padding: 10px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.credits-display {
    text-align: center;
}

.credits-amount-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.credits-amount-icon {
    width: 24px;
    height: 24px;
    color: var(--accent);
    flex-shrink: 0;
}

.credits-amount {
    font-family: var(--font);
    font-size: var(--text-4xl);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.25;
}

.credits-label {
    display: block;
    font-family: var(--font);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 2px;
}

.dropdown-topup-btn {
    width: 100%;
    height: 44px;
    padding: 0 var(--space-4);
    background: var(--accent);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    transition: all 0.2s;
}

.dropdown-topup-btn:hover {
    background: var(--accent-hover);
}

.dropdown-topup-btn:active {
    transform: scale(0.98);
}

/* Section 3: Settings rows (Language, Theme) */
.dropdown-settings {
    padding: 6px;
}

.dropdown-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    height: 44px;
    padding: 0 var(--space-1) 0 10px;
}

.dropdown-setting-label {
    flex: 1;
    font-family: var(--font);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* Chip-style dropdown trigger + menu */
.dropdown-chip {
    position: relative;
    flex-shrink: 0;
}

.dropdown-chip-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 36px;
    padding: 0 var(--space-3);
    background: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s ease;
}

.dropdown-chip-btn:hover,
.dropdown-chip.open .dropdown-chip-btn {
    background: var(--surface-hover);
}

.dropdown-chip-arrow {
    width: 10px;
    height: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.dropdown-chip.open .dropdown-chip-arrow {
    transform: rotate(180deg);
}

.dropdown-chip-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 140px;
    padding: var(--space-1);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(var(--shadow-color), 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 110;
}

.dropdown-chip.open .dropdown-chip-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-chip-option {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: none;
    border: none;
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s ease, color 0.1s ease;
}

.dropdown-chip-option:hover {
    background: var(--bg);
}

.dropdown-chip-option.active {
    color: var(--accent);
}

/* Section 4 & 5: Links + Sign Out */
.dropdown-links {
    padding: 6px;
    border-top: 1px solid var(--border);
}

.dropdown-links a.dropdown-action {
    text-decoration: none;
}

.dropdown-actions {
    padding: 6px;
    border-top: 1px solid var(--border);
}

.dropdown-action {
    width: 100%;
    padding: 0 10px;
    height: 44px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    color: var(--text);
    text-align: left;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-action:hover {
    background: var(--bg);
}

.dropdown-action svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.dropdown-action:hover svg {
    color: var(--text);
}

.dropdown-action.danger {
    color: var(--error);
}

.dropdown-action.danger svg {
    color: var(--error);
}

.dropdown-action.danger:hover {
    background: rgba(var(--error-rgb), 0.10);
}

/* Language Switcher */
.dropdown-language {
    padding: var(--space-2) 10px;
    border-top: 1px solid var(--border);
}

.language-switcher {
    display: flex;
    gap: var(--space-1);
    justify-content: center;
}

.lang-btn {
    padding: 6px var(--space-3);
    font-size: var(--text-xs);
    font-weight: 600;
    font-family: var(--font);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.lang-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.lang-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
}

/* Language Dropdown (top bar) - matches profile button style */
.lang-dropdown {
    position: relative;
}

.lang-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 14px;
    background: var(--bg);
    border: none;
    border-radius: var(--radius);
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease;
}

.lang-dropdown-btn:hover,
.lang-dropdown.open .lang-dropdown-btn {
    background: var(--on-surface-soft);
}

.lang-dropdown-btn svg {
    width: 10px;
    height: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
}

.lang-dropdown.open .lang-dropdown-btn svg {
    transform: rotate(180deg);
}

.lang-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 120px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: all 0.15s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(var(--shadow-color), 0.25);
}

.lang-dropdown.open .lang-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: none;
    border: none;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    border-radius: var(--radius);
    transition: all 0.1s;
    white-space: nowrap;
}

.lang-option:hover {
    background: var(--bg);
    color: var(--text);
}

.lang-option.active {
    color: var(--accent);
}

.clear-btn {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px var(--space-3);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.clear-btn:hover {
    background: var(--bg);
    color: var(--error);
}

/* View Switcher */
.view-switcher {
    display: flex;
    position: relative;
    background: var(--bg);
    padding: 3px;
    gap: var(--space-1);
    border-radius: var(--radius);
    height: 44px;
    box-sizing: border-box;
}

.view-switcher-indicator {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 5px);
    height: calc(100% - 6px);
    background: var(--surface);
    border-radius: var(--radius);
    /* Soft symmetric glow per Figma spec (369:861) — matches .mode-tabs-indicator */
    box-shadow: 0 0 5px rgba(var(--shadow-color), 0.06);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.view-switcher.list-active .view-switcher-indicator {
    transform: translateX(calc(100% + 4px));
}

.view-btn {
    padding: 0 14px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.view-btn.active {
    color: var(--text);
}

.view-btn:hover:not(.active) {
    color: var(--text);
    background: var(--surface-hover);
}

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

/* Mode Tabs (Presets/Manual) */
.mode-tabs-section {
    margin: 0 0 var(--space-4) 0;
}

.mode-tabs {
    display: flex;
    position: relative;
    background: var(--bg);
    padding: 3px;
    gap: var(--space-1);
    border-radius: var(--radius);
    height: 44px;
    box-sizing: border-box;
}

.mode-tabs-indicator {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(33.333% - 4.667px);
    height: calc(100% - 6px);
    background: var(--surface);
    border-radius: var(--radius);
    /* Soft symmetric glow per Figma spec (369:861): 0/0 offset, 5px blur, 6% black */
    box-shadow: 0 0 5px rgba(var(--shadow-color), 0.06);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

/* Tab order: presets (left) · views (middle) · manual (right) */
.mode-tabs.views-active .mode-tabs-indicator {
    transform: translateX(calc(100% + 4px));
}

.mode-tabs.manual-active .mode-tabs-indicator {
    transform: translateX(calc(200% + 8px));
}

.mode-tab {
    flex: 1;
    padding: 0 14px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    transition: color 0.2s ease, background 0.2s ease;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-tab.active {
    color: var(--text);
}

.mode-tab:hover:not(.active) {
    color: var(--text);
    background: var(--surface-hover);
}

/* ==========================================================================
   Feed & Image Grid
   ========================================================================== */

.feed {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-8) var(--space-14) var(--space-4);
}

.feed::-webkit-scrollbar {
    width: 8px;
}

.feed::-webkit-scrollbar-track {
    background: transparent;
}

.feed::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius);
}

/* Expiration Banner - minimalistic, centered text-only at bottom of main */
.expiration-banner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    justify-content: center;
    align-items: center;
    height: 32px;
    padding: 0 var(--space-5);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    text-align: center;
    z-index: 10;
}

.expiration-banner svg {
    display: none;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-tertiary);
}

.empty-icon {
    width: 256px;
    height: 256px;
}

@media (max-width: 768px) {
    .empty-icon {
        width: 128px;
        height: 128px;
    }
}

.empty-text {
    font-size: var(--text-md);
}

/* Image Grid - Masonry Layout */
.image-grid {
    position: relative;
    width: 100%;
    transition: height 0.3s ease;
}

.image-grid .image-card {
    position: absolute;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.4s ease;
    opacity: 0;
    transform: translateY(20px);
}

.image-grid .image-card.placed {
    opacity: 1;
    transform: translateY(0);
}

/* List View - Single Column */
.image-grid.view-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    height: auto !important;
}

.image-grid.view-list .image-card {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    border-radius: var(--radius);
    background: var(--surface-alt);
    opacity: 1 !important;
    transform: none !important;
}

.image-grid.view-list .image-card.placed {
    transform: none !important;
}

.image-grid.view-list .image-card img {
    width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

/* ==========================================================================
   Vibes Upload
   ========================================================================== */

.vibes-zone {
    border: none;
    border-radius: var(--radius-sm);
    padding: 0 var(--space-3);
    height: 44px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
}

.vibes-zone:hover {
    background: var(--surface-hover);
}

.vibes-zone.has-image {
    height: auto;
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-2);
}

.vibes-zone .vibes-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text);
    font-size: var(--text-md);
    font-weight: 600;
}

.vibes-zone .vibes-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.vibes-zone .vibes-preview {
    display: none;
    width: 100%;
}

.vibes-zone.has-image .vibes-placeholder {
    display: none;
}

.vibes-zone.has-image .vibes-preview {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.vibes-zone .vibes-preview img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    object-fit: cover;
    flex-shrink: 0;
}

.vibes-zone .vibes-preview .vibes-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    text-align: left;
}

.vibes-zone .vibes-preview .vibes-label {
    font-size: var(--text-xs);
    line-height: 1.2;
    color: var(--text-tertiary);
}

.vibes-zone .vibes-preview .vibes-name {
    font-size: var(--text-sm);
    line-height: 1.2;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vibes-zone .remove-vibes {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
    color: var(--text-tertiary);
    background: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.vibes-zone .remove-vibes:hover {
    color: var(--text);
    background: var(--surface-hover);
}

/* ==========================================================================
   Image Cards
   ========================================================================== */

.image-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-hover);
    cursor: pointer;
}

.image-card img {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.image-card.loaded img {
    opacity: 1;
}

/* Shimmer Placeholder — flat base + one clean sweeping highlight (skeleton loader) */
.image-card.placeholder {
    background: var(--surface-alt);
    overflow: hidden;
    border-radius: var(--radius);
}

.image-card.placeholder .shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        transparent 40%,
        rgba(var(--shimmer-highlight), 0.35) 50%,
        transparent 60%
    );
    animation: shimmerSweep 1.6s linear infinite;
}

/* Softer, dark-appropriate sweep — full-opacity white reads as a glare on dark cards */
[data-theme="dark"] .image-card.placeholder .shimmer {
    background: linear-gradient(
        100deg,
        transparent 40%,
        rgba(var(--shimmer-highlight), 0.07) 50%,
        transparent 60%
    );
}

@keyframes shimmerSweep {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.image-card.placeholder .spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 2.5px solid var(--on-surface-medium);
    border-top-color: var(--text-secondary);
    border-radius: var(--radius-round);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* List view placeholder */
.image-grid.view-list .image-card.placeholder {
    background: var(--surface-alt);
    overflow: hidden;
    max-height: 70vh;
    position: relative;
}

/* Overlay */
.image-card .overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: var(--space-2);
    gap: 6px;
}

.image-card:hover .overlay {
    opacity: 1;
}

/* Frosted Glass Buttons */
.overlay-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: rgba(var(--white-rgb), 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(var(--shadow-color), 0.25);
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
    color: var(--ink);
}

.overlay-btn:hover {
    transform: scale(1.05);
    background: rgba(var(--white-rgb), 1);
}

.overlay-btn.delete-btn:hover {
    background: var(--error);
    color: var(--white);
}

.overlay-btn.delete-btn:hover svg {
    stroke: var(--white);
}

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

/* Generation Group */
.generation-group {
    margin-bottom: var(--space-6);
}

/* Match the spacing generation-groups have so placeholders don't touch the first result */
.image-grid.view-list.placeholder-container {
    margin-bottom: var(--space-6);
}

.generation-header {
    display: none;
}

/* ==========================================================================
   Preview Modal
   ========================================================================== */

.modal.visible {
    display: flex;
}

.modal-content {
    max-width: 90vw;
    max-height: 90vh;
}

.modal-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius);
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.modal-btn {
    padding: 10px var(--space-5);
    font-size: var(--text-base);
    font-family: var(--font);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn.primary {
    background: var(--surface);
    color: var(--text);
    border: none;
}

.modal-btn.primary:hover {
    background: var(--surface-hover);
}

/* Preview Modal Close */
#preview-modal .modal-close {
    background: rgba(var(--white-rgb), 0.1);
    color: var(--white);
}

#preview-modal .modal-close:hover {
    background: rgba(var(--white-rgb), 0.2);
}

#preview-modal {
    background: rgba(var(--shadow-color), 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* ==========================================================================
   Auth Modal (App-specific overrides)
   ========================================================================== */

.modal.auth-modal,
.modal.topup-modal {
    background: rgba(var(--shadow-color), 0.5);
}

.auth-container,
.topup-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--space-8);
    width: 100%;
    max-width: 400px;
    position: relative;
}

.auth-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: var(--text-base);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--accent);
    color: var(--white);
}

/* ==========================================================================
   Top-up Modal
   ========================================================================== */

.topup-modal .topup-container {
    max-width: 680px;
    padding: var(--space-10);
}

.topup-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.topup-title {
    font-size: var(--text-3xl); /* 28px — matches production (.topup-title was 28px) */
    font-weight: 600;
    margin-bottom: var(--space-2);
    letter-spacing: -0.5px;
}

.topup-subtitle {
    font-size: var(--text-md);
    color: var(--text-secondary);
}

.package-row {
    display: flex;
    gap: var(--space-3);
}

.package-card {
    flex: 1;
    position: relative;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-6) var(--space-4) var(--space-5);
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
}

.package-card:hover {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(var(--accent-rgb), 0.14);
}

.package-card.popular {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.04);
}

.package-card.best-value {
    border-color: var(--success);
    background: rgba(var(--success-rgb), 0.02);
}

.package-card.best-value:hover {
    border-color: var(--success);
    box-shadow: 0 12px 24px rgba(var(--success-rgb), 0.12);
}

.package-badge {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--white);
    font-size: var(--text-2xs);
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--radius-toast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.package-card.best-value .package-badge {
    background: var(--success);
}

.package-credits {
    display: block;
    font-size: var(--text-6xl);
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.package-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.package-price {
    display: block;
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--accent);
    margin-bottom: var(--space-1);
}

.package-card.best-value .package-price {
    color: var(--success);
}

.package-per {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* Topup Icon */
.topup-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    background: linear-gradient(135deg, var(--accent) 0%, var(--ink) 100%);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.28);
}

/* Explainer Text */
.topup-explainer {
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 380px;
    margin: 0 auto;
}

/* Credit Footnote - Secondary info below packages */
.topup-footnote {
    margin-top: var(--space-5);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-align: center;
}

/* Security Badge */
.topup-security {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.topup-security svg {
    opacity: 0.6;
}

/* Savings Badge */
.package-savings {
    display: block;
    font-size: var(--text-xs);
    color: var(--success);
    font-weight: 600;
    margin-top: var(--space-1);
}

/* CTA Text */
.package-cta {
    display: block;
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--accent);
}

.package-card.best-value .package-cta {
    color: var(--success);
}

/* ==========================================================================
   First-Time Discount Modal
   ========================================================================== */

.modal.discount-modal {
    background: rgba(var(--shadow-color), 0.6);
}

.discount-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--space-10);
    width: 100%;
    max-width: 680px;
    position: relative;
    border: 2px solid var(--accent);
    box-shadow: 0 0 60px rgba(var(--accent-rgb), 0.22);
}

.discount-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.discount-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent) 0%, var(--ink) 100%);
    color: var(--white);
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-toast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-4);
}

.discount-title {
    font-size: var(--text-5xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
    letter-spacing: -0.5px;
}

.discount-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.discount-subtitle strong {
    color: var(--accent);
    font-weight: 600;
}

/* Strikethrough original price */
.package-original-price {
    display: block;
    font-size: var(--text-base);
    color: var(--text-tertiary);
    text-decoration: line-through;
    margin-bottom: 2px;
}

/* Make discounted price stand out */
.discount-modal .package-price {
    font-size: 22px;
    color: var(--accent);
}

.discount-modal .package-card.best-value .package-price {
    color: var(--success);
}

.discount-footnote {
    margin-top: var(--space-5);
    font-size: var(--text-md);
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

/* ==========================================================================
   Mobile Menu Button (matches view-switcher style exactly)
   ========================================================================== */

.mobile-menu-btn {
    display: none;
    padding: 0 10px;
    border: none;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: all 0.15s ease;
    height: 44px;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover {
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(var(--shadow-color), 0.12);
}

.mobile-menu-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* ==========================================================================
   Sidebar Overlay
   ========================================================================== */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(var(--shadow-color), 0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   Profile Dropdown Click State
   ========================================================================== */

.profile-dropdown-wrapper.dropdown-open .profile-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown-wrapper.dropdown-open .profile-chevron {
    transform: rotate(180deg);
}

/* ==========================================================================
   Context Menu
   ========================================================================== */

.context-menu {
    position: fixed;
    inset: 0;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s;
}

.context-menu.visible {
    opacity: 1;
    visibility: visible;
}

.context-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(var(--shadow-color), 0.1);
}

.context-menu-content {
    position: fixed;
    top: 0;
    left: 0;
    width: fit-content;
    min-width: 180px;
    padding: 6px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(var(--shadow-color), 0.22), 0 2px 8px rgba(var(--shadow-color), 0.14);
    transform-origin: top right;
    animation: contextMenuFadeIn 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px var(--space-3);
    border: none;
    background: transparent;
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
    text-align: left;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.context-menu-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: color 0.1s ease;
}

.context-menu-item:hover {
    background: var(--bg);
}

.context-menu-item:hover .context-menu-icon {
    color: var(--text);
}

.context-menu-item:active {
    background: var(--on-surface-medium);
}

.context-menu-item.danger {
    color: var(--error);
}

.context-menu-item.danger .context-menu-icon {
    color: var(--error);
}

.context-menu-item.danger:hover {
    background: rgba(var(--error-rgb), 0.10);
}

.context-menu-item.danger:hover .context-menu-icon {
    color: var(--error);
}

/* Submenu (Send to → Scene/Views/Edit) */
.context-menu-submenu-wrap {
    position: relative;
}

.context-menu-has-submenu .context-menu-chevron {
    width: 12px;
    height: 12px;
    margin-left: auto;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: color 0.1s ease, transform 0.15s ease;
}

.context-menu-has-submenu:hover .context-menu-chevron {
    color: var(--text);
}

.context-menu-submenu-wrap.submenu-open .context-menu-has-submenu {
    background: var(--bg);
}

.context-menu-submenu-wrap.submenu-open .context-menu-has-submenu .context-menu-icon {
    color: var(--text);
}

.context-menu-submenu {
    position: absolute;
    top: -6px;
    left: calc(100% + 4px);
    min-width: 160px;
    padding: 6px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(var(--shadow-color), 0.22), 0 2px 8px rgba(var(--shadow-color), 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-4px);
    transition: opacity 0.12s ease, visibility 0.12s, transform 0.12s ease;
    z-index: 1;
}

.context-menu-submenu-wrap.submenu-open .context-menu-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.context-menu-submenu.flip-left {
    left: auto;
    right: calc(100% + 4px);
    transform: translateX(4px);
}

.context-menu-submenu-wrap.submenu-open .context-menu-submenu.flip-left {
    transform: translateX(0);
}

.context-menu-submenu.flip-up {
    top: auto;
    bottom: -6px;
}

/* Mobile: Slightly larger touch targets */
@media (max-width: 768px) {
    .context-menu-item {
        padding: var(--space-3) var(--space-3);
        font-size: var(--text-md);
    }

    .context-menu-submenu {
        min-width: 180px;
    }
}

/* ==========================================================================
   Info Popover
   ========================================================================== */

.info-popover {
    position: fixed;
    inset: 0;
    z-index: 201;
    visibility: hidden;
    pointer-events: none;
}

.info-popover.visible {
    visibility: visible;
    pointer-events: auto;
}

.info-popover-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(var(--shadow-color), 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
}

.info-popover.visible .info-popover-backdrop {
    opacity: 1;
}

.info-popover-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 420px;
    max-height: 80vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(var(--shadow-color), 0.24), 0 2px 8px rgba(var(--shadow-color), 0.14);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: infoPopoverIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes infoPopoverIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.info-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.info-popover-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.2px;
}

.info-popover-close {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-round);
    background: var(--bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.info-popover-close:hover {
    background: var(--on-surface-medium);
    color: var(--text);
}

.info-popover-close:active {
    transform: scale(0.94);
}

.info-popover-close svg {
    width: 14px;
    height: 14px;
}

.info-popover-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
}

.info-section {
    margin-bottom: var(--space-5);
}

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

.info-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.info-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.info-value {
    font-size: var(--text-base);
    color: var(--text);
}

.info-prompt-text {
    font-size: var(--text-md);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: var(--space-3) 14px;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.info-prompt-text::-webkit-scrollbar {
    width: 6px;
}

.info-prompt-text::-webkit-scrollbar-track {
    background: transparent;
}

.info-prompt-text::-webkit-scrollbar-thumb {
    background: var(--on-surface-strong);
    border-radius: var(--radius-2xs);
}

.info-prompt-text::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.info-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.info-copy-btn:hover {
    background: var(--on-surface-medium);
    color: var(--text);
}

.info-copy-btn:active {
    transform: scale(0.96);
}

.info-copy-btn.copied {
    background: rgba(var(--success-rgb), 0.12);
    color: var(--success);
}

.info-copy-btn svg {
    width: 14px;
    height: 14px;
}

/* Mobile: Full-screen info popover */
@media (max-width: 768px) {
    .info-popover-content {
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
        animation: infoPopoverInMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes infoPopoverInMobile {
        from {
            opacity: 0;
            transform: translate(-50%, -45%);
        }
        to {
            opacity: 1;
            transform: translate(-50%, -50%);
        }
    }

    .info-popover-header {
        padding: 14px var(--space-4);
    }

    .info-popover-body {
        padding: var(--space-4);
    }

    .info-prompt-text {
        max-height: 300px;
    }
}

/* ==========================================================================
   Mobile Bottom Bar
   ========================================================================== */

.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    padding: var(--space-3) var(--space-4) var(--space-2);
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top,
        var(--surface) 0%,
        var(--surface) 80%,
        transparent 100%
    );
    pointer-events: none;
}

.mobile-disclaimer {
    pointer-events: none;
    text-align: center;
    font-size: var(--text-2xs);
    color: var(--text-secondary);
    margin-top: var(--space-2);
}

.bottom-bar-btn {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 52px;
    background: var(--text);
    color: var(--surface);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.2s ease;
    box-shadow: 0 4px 16px rgba(var(--shadow-color), 0.20), 0 2px 6px rgba(var(--shadow-color), 0.14);
}

.bottom-bar-btn:hover {
    background: var(--text-secondary);
}

.bottom-bar-btn:active {
    transform: scale(0.98);
}

.bottom-bar-btn svg {
    width: 20px;
    height: 20px;
}

/* Hide bottom bar when sidebar is open */
.sidebar.open ~ .main .mobile-bottom-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    /* Hide header hamburger on mobile - use bottom bar instead */
    .mobile-menu-btn {
        display: none !important;
    }

    /* Show bottom bar on mobile */
    .mobile-bottom-bar {
        display: block;
        animation: bottomBarIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
    }

    @keyframes bottomBarIn {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Sidebar slide-in */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Hide original expiration banner on mobile - using mobile-disclaimer instead */
    .expiration-banner {
        display: none !important;
    }

    /* Main header adjustments */
    .main-header {
        padding: 0 var(--space-4);
        height: 64px;
        gap: var(--space-3);
    }

    .main-title {
        flex: 1;
    }

    /* Hide profile label and chevron on mobile */
    .profile-label,
    .profile-chevron {
        display: none;
    }

    .profile-btn {
        padding: 0 var(--space-2);
        width: 34px;
        justify-content: center;
    }

    /* Feed padding - includes space for bottom bar with disclaimer */
    .feed {
        padding: var(--space-4);
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }

    /* Grid adjustments */
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    /* ==========================================
       Credit Purchase Modal - Mobile
       ========================================== */

    .topup-modal .topup-container {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: var(--space-5);
        display: flex;
        flex-direction: column;
    }

    .topup-header {
        margin-bottom: var(--space-5);
    }

    .topup-icon {
        width: 40px;
        height: 40px;
        margin-bottom: var(--space-3);
    }

    .topup-icon svg {
        width: 20px;
        height: 20px;
    }

    .topup-title {
        font-size: var(--text-2xl);
    }

    .topup-explainer {
        font-size: var(--text-md);
        line-height: 1.5;
    }

    .topup-footnote {
        margin-top: var(--space-4);
        font-size: var(--text-xs);
    }

    .topup-security {
        margin-top: var(--space-3);
        padding-top: var(--space-3);
        font-size: var(--text-2xs);
    }

    .package-cta {
        margin-top: 10px;
        padding-top: 10px;
        font-size: var(--text-xs);
    }

    .package-savings {
        font-size: var(--text-2xs);
    }

    /* 2x2 grid layout for packages */
    .package-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
        flex: 1;
        align-content: start;
    }

    .package-card {
        padding: var(--space-5) var(--space-3) var(--space-4);
        border-radius: var(--radius);
    }

    .package-credits {
        font-size: var(--text-4xl);
    }

    .package-label {
        font-size: var(--text-xs);
        margin-bottom: 10px;
    }

    .package-price {
        font-size: 16px;
    }

    .package-per {
        font-size: var(--text-2xs);
    }

    .package-badge {
        font-size: 9px;
        padding: 3px var(--space-2);
        top: -9px;
    }

    /* ==========================================
       Discount Modal - Mobile
       ========================================== */

    .discount-modal .discount-container {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: var(--space-5);
        display: flex;
        flex-direction: column;
        border: none;
        box-shadow: none;
    }

    .discount-header {
        margin-bottom: var(--space-5);
    }

    .discount-badge {
        font-size: var(--text-2xs);
        padding: 5px var(--space-3);
        margin-bottom: var(--space-3);
    }

    .discount-title {
        font-size: var(--text-3xl);
    }

    .discount-subtitle {
        font-size: var(--text-base);
    }

    .discount-footnote {
        margin-top: var(--space-4);
        font-size: var(--text-xs);
    }

    .package-original-price {
        font-size: var(--text-xs);
    }

    .discount-modal .package-price {
        font-size: var(--text-xl);
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .topup-modal .topup-container,
    .discount-modal .discount-container {
        padding: var(--space-4);
    }

    .package-row {
        gap: var(--space-2);
    }

    .package-card {
        padding: var(--space-4) var(--space-2) var(--space-3);
    }

    .package-credits {
        font-size: var(--text-3xl);
    }

    .package-price {
        font-size: var(--text-base);
    }
}

/* ==========================================================================
   Views Mode — context images uploader + shots
   ========================================================================== */

.views-context-zone {
    cursor: pointer;
}

.views-context-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-md);
    font-weight: 600;
    transition: background 0.2s ease;
}

.views-context-add:hover {
    background: var(--surface-hover);
}

.views-context-add .vibes-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.views-context-grid {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-1);
    margin-top: var(--space-2);
}

.views-context-grid.has-items {
    display: grid;
}

.views-context-grid .upload-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
}

.views-context-grid .upload-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.views-context-grid .upload-thumb .remove-thumb {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(var(--shadow-color), 0.6);
    color: var(--white);
    border: none;
    border-radius: var(--radius-round);
    font-size: var(--text-2xs);
    line-height: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.views-context-grid .upload-thumb:hover .remove-thumb {
    opacity: 1;
}

.views-quantity {
    cursor: not-allowed;
}

/* Dynamic View rows live in one .section — space them like the 16px gap between
   .section blocks elsewhere in the form so Scene/Views feel visually consistent.
   Each row is followed by a .custom-input-wrap (visible only when the row is
   set to Custom), so the gap rule targets the wrap → next row transition too. */
#views-shots .section-inline + .section-inline,
#views-shots .custom-input-wrap + .section-inline {
    margin-top: var(--space-4);
}

#views-shots .section-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.views-view-remove {
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-round);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Hidden by default; revealed when the user hovers the row (label + dropdown)
       or focuses within it for keyboard users. See reveal rules below. */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.views-view-remove svg {
    width: 10px;
    height: 10px;
    display: block;
}

/* Reveal the remove button when hovering anywhere on the row, or when focus
   lands inside the row (keyboard nav / tabbing to the button itself). */
#views-shots .section-inline:hover .views-view-remove,
#views-shots .section-inline:focus-within .views-view-remove {
    opacity: 0.6;
    pointer-events: auto;
}

.views-view-remove:hover,
.views-view-remove:focus-visible {
    opacity: 1;
    pointer-events: auto;
    color: var(--text);
    background: var(--surface-hover);
}

/* Touch devices have no hover state — keep the button permanently visible and
   give it a larger, finger-friendly tap target so it's easy to use on mobile. */
@media (hover: none), (pointer: coarse) {
    .views-view-remove {
        opacity: 0.7;
        pointer-events: auto;
        width: 30px;
        height: 30px;
        margin: -7px -8px -7px 0;
    }

    .views-view-remove svg {
        width: 13px;
        height: 13px;
    }

    .views-view-remove:active {
        opacity: 1;
        color: var(--text);
        background: var(--surface-hover);
    }
}

/* "+ Add view" — match the "Add context images" button styling so the two
   sidebar add-buttons feel like part of the same control family. */
.add-view-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--text-md);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.add-view-btn:hover {
    background: var(--surface-hover);
}

.add-view-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
