/* ═══════════════════════════════════════════════════════
    OFM Studio Mini App — Theme
   ═══════════════════════════════════════════════════════ */

:root {
    --bg: #0a0a0a;
    --bg-card: #1a1a1a;
    --bg-input: #1e1e1e;
    --bg-elevated: #252525;
    --text-primary: #f5f5f5;
    --text-secondary: #888;
    --text-muted: #555;
    --accent: #e8a838;
    --accent-hover: #f0b84c;
    --danger: #e53935;
    --success: #43a047;
    --border: #2a2a2a;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --transition: 0.2s ease;
    --tabs-offset: 56px;
}

body.theme-light {
    --bg: #f5f5f5;
    --bg-card: #ffffff;
    --bg-input: #f0f0f0;
    --bg-elevated: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --text-muted: #999;
    --accent: #e8a838;
    --accent-hover: #d49520;
    --danger: #d32f2f;
    --success: #388e3c;
    --border: #ddd;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html,
body {
    height: 100%;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

/* ═══ Header ═══ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    min-height: 58px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.header__logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header__right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header__history {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    transition: color var(--transition);
}

.header__history:hover { color: var(--text-primary); }

.header__queue {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: color var(--transition);
}

.header__queue:hover { color: var(--text-primary); }

.header__queue-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background: var(--accent);
    color: #000;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.header__theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), transform var(--transition);
}

.header__theme-toggle:hover { color: var(--text-primary); }

.header__theme-toggle:active {
    transform: scale(0.92);
}

.header__balance {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-elevated);
    padding: 7px 10px;
    border-radius: 22px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition), background var(--transition);
}

.header__balance:active {
    transform: scale(0.94);
}

.header__balance-icon { flex: 0 0 auto; }

.header__balance-value {
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
}

.header__balance .token-icon {
    width: 28px;
    height: 28px;
    background-size: 145%;
}

.token-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background-image: url("../assets/edited-photo.png?v=20260319editedkey1");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 150%;
    filter: drop-shadow(0 2px 8px rgba(56, 189, 248, 0.22));
    flex: 0 0 auto;
}

.token-icon--xs {
    width: 28px;
    height: 28px;
    transform: translateY(-1px);
}

.token-icon--sm {
    width: 34px;
    height: 34px;
}

.token-icon--md {
    width: 44px;
    height: 44px;
}

.star-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #f6c343;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    flex: 0 0 auto;
}

.star-icon--xs {
    font-size: 12px;
    transform: translateY(-1px);
}

.star-icon--md {
    font-size: 20px;
}

/* ═══ Tabs ═══ */
.tabs {
    display: flex;
    align-items: stretch;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    height: 56px;
    padding: 0 8px;
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    z-index: 99;
}

.tabs__btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    padding: 8px 0 6px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.tabs__btn:active {
    transform: scale(0.94);
}

.tabs__btn--active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

.tabs__icon {
    width: 20px;
    height: 20px;
    margin-top: 0;
    flex: 0 0 auto;
}

.tabs__btn span {
    display: block;
    min-height: 11px;
    line-height: 1;
    white-space: nowrap;
}

.tabs__badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    background: var(--accent);
    color: #000;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ═══ Content ═══ */
.content {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    position: relative;
    padding-top: var(--tabs-offset);
}

.tab-panel {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-panel--active {
    display: flex;
}

.ui-fade-section {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.22s ease, transform 0.22s ease;
    will-change: opacity, transform;
}

.ui-fade-section.is-hidden {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

.ui-fade-section.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.stagger-card {
    opacity: 0;
    transform: translateY(10px);
    animation: cardStaggerIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: calc(var(--stagger-index, 0) * 40ms);
}

.ui-action-feedback {
    animation: actionPulse 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes cardStaggerIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes actionPulse {
    0% {
        transform: scale(1);
    }
    35% {
        transform: scale(0.95);
    }
    70% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-block,
.skeleton-line,
.skeleton-chip {
    background: linear-gradient(90deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.06) 100%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s linear infinite;
}

.skeleton-block {
    border-radius: var(--radius);
}

.skeleton-block--photo {
    aspect-ratio: 1;
}

.skeleton-block--wide {
    aspect-ratio: 16 / 9;
    width: 100%;
}

.skeleton-line {
    height: 12px;
    border-radius: 999px;
}

.skeleton-line--title {
    width: 68%;
    height: 14px;
    margin-bottom: 10px;
}

.skeleton-line--meta {
    width: 44%;
}

.skeleton-line--progress {
    width: 100%;
    height: 6px;
    margin: 12px 0 10px;
}

.skeleton-chip {
    flex: 1;
    height: 32px;
    border-radius: var(--radius-xs);
}

/* ═══ Empty State ═══ */
.panel-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.panel-empty__icon {
    margin-bottom: 16px;
    opacity: 0.5;
}

.panel-empty__title {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.panel-empty__subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

#photoEmpty {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px 20px 12px;
}

#photoEmpty.photo-empty--with-previews {
    align-items: stretch;
    justify-content: flex-start;
    min-height: 0;
    padding: 18px 16px 10px;
}

#photoEmpty.photo-empty--with-previews .panel-empty__icon,
#photoEmpty.photo-empty--with-previews .panel-empty__title,
#photoEmpty.photo-empty--with-previews .panel-empty__subtitle {
    display: none;
}

.photo-composer {
    margin-top: auto;
    padding-bottom: 0;
}

/* ═══ Prompt Bar (Photo Tab) ═══ */
.prompt-bar {
    padding: 4px 16px 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    background: var(--bg);
}

.prompt-bar__input-wrap {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 10px 12px 8px;
    margin-bottom: 8px;
    position: relative;
    min-height: 88px;
}

.prompt-bar__library {
    background: rgba(232, 168, 56, 0.12);
    border: 1px solid rgba(232, 168, 56, 0.25);
    color: var(--accent);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition), transform var(--transition);
    flex: 0 0 auto;
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 2;
    touch-action: manipulation;
}

.prompt-bar__library:hover {
    background: rgba(232, 168, 56, 0.22);
    color: var(--text-primary);
}

.prompt-bar__library svg {
    display: block;
}

.prompt-bar__input {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    font-family: inherit;
    line-height: 1.3;
    min-height: 52px;
    max-height: 132px;
    padding-right: 52px;
}

.prompt-bar__input::placeholder {
    color: var(--text-muted);
}

.prompt-bar__tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    overflow: visible;
    flex-wrap: wrap;
    row-gap: 6px;
}

.prompt-bar__attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1;
}

.prompt-bar__attach svg {
    display: block;
    flex: 0 0 16px;
}

.prompt-bar__attach-count {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1;
}

.prompt-bar__sep {
    width: 1px;
    height: 16px;
    background: var(--border);
}

.prompt-bar__ratio,
.prompt-bar__enhance {
    background: var(--bg-elevated);
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 0 8px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition);
}

.prompt-bar__ratio:hover,
.prompt-bar__enhance:hover {
    color: var(--text-primary);
    background: var(--border);
}

.prompt-ideas {
    position: relative;
    display: flex;
}

.prompt-bar__idea {
    background: rgba(232, 168, 56, 0.12);
    border: 1px solid rgba(232, 168, 56, 0.25);
    color: var(--accent);
    font-size: 14px;
    line-height: 1;
    padding: 0 8px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.prompt-bar__idea:hover,
.prompt-ideas--open .prompt-bar__idea {
    color: var(--text-primary);
    background: rgba(232, 168, 56, 0.22);
}

.prompt-ideas__menu {
    position: absolute;
    left: calc(100% + 8px);
    right: auto;
    bottom: 0;
    min-width: 196px;
    max-width: min(220px, calc(100vw - 48px));
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    z-index: 20;
}

.prompt-ideas__item {
    width: 100%;
    border: none;
    border-radius: 10px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    text-align: center;
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.prompt-ideas__item:hover {
    background: rgba(232, 168, 56, 0.18);
    color: var(--accent-hover);
}

.prompt-bar__model-tag {
    margin-left: auto;
    font-size: 12px;
    color: var(--accent);
    background: rgba(232, 168, 56, 0.1);
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 500;
}

/* ═══ Model Dropdown ═══ */
.model-dropdown {
    margin-left: auto;
    position: relative;
}

.model-dropdown__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 12px;
    color: var(--accent);
    background: rgba(232, 168, 56, 0.12);
    padding: 0 8px;
    height: 28px;
    border-radius: 6px;
    font-weight: 500;
    border: 1px solid rgba(232, 168, 56, 0.25);
    cursor: pointer;
    white-space: nowrap;
}

.model-dropdown__trigger:hover {
    background: rgba(232, 168, 56, 0.2);
}

.model-dropdown__icon {
    font-size: 13px;
}

.model-dropdown__arrow {
    opacity: 0.6;
    transition: transform 0.2s;
}

.model-dropdown--open .model-dropdown__arrow {
    transform: rotate(180deg);
}

.model-dropdown__menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    z-index: 100;
}

.model-dropdown--open .model-dropdown__menu {
    display: block;
}

.model-dropdown__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
    color: var(--text-primary);
}

.model-dropdown__item:hover {
    background: var(--bg-secondary);
}

.model-dropdown__item--active {
    background: var(--bg-secondary);
}

.model-dropdown__item-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
}

.model-dropdown__item-name {
    flex: 1;
}

.model-dropdown__item-badge {
    font-size: 12px;
    color: var(--text-muted);
}

.model-dropdown__check {
    color: var(--accent);
    flex-shrink: 0;
}

/* ═══ Photo Previews Bar ═══ */
.photo-previews {
    display: flex;
    gap: 8px;
    padding: 2px 0 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.photo-previews--stage {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0;
    overflow: visible;
}

.photo-previews::-webkit-scrollbar {
    display: none;
}

.photo-preview-item {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-item__order {
    position: absolute;
    top: 4px;
    left: 4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.photo-preview-item__remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(0,0,0,0.65);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-preview-item__remove:hover {
    background: rgba(220,50,50,0.8);
}

.photo-preview-item__actions {
    position: absolute;
    left: 4px;
    bottom: 4px;
    display: flex;
    gap: 4px;
}

.photo-preview-item__move {
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.65);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-preview-item__move:hover:not(:disabled) {
    background: rgba(232, 168, 56, 0.9);
}

.photo-preview-item__move:disabled {
    opacity: 0.45;
    cursor: default;
}

.upload-card__lib-btn {
    font-size: 12px;
    color: var(--accent);
    background: rgba(232, 168, 56, 0.12);
    border: 1px solid rgba(232, 168, 56, 0.25);
    border-radius: 6px;
    padding: 3px 10px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.upload-card__lib-btn:hover {
    background: rgba(232, 168, 56, 0.22);
}

/* ═══ Generate Button ═══ */
.generate-btn {
    width: 100%;
    background: var(--bg-elevated);
    border: none;
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.generate-btn__label {
    line-height: 1.1;
}

.generate-btn:active {
    transform: scale(0.96);
}

.generate-btn--ready {
    background: var(--accent);
    color: #000;
}

.generate-btn--ready .generate-btn__cost {
    color: #000;
}

.generate-btn--ready .token-icon {
    filter: drop-shadow(0 1px 3px rgba(39, 117, 202, 0.3));
}

.generate-btn__cost {
    font-size: 14px;
    font-weight: 600;
    color: inherit;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    line-height: 1;
    letter-spacing: -0.01em;
    opacity: 0.92;
}

.generate-btn__cost .token-icon {
    width: 18px;
    height: 18px;
    background-size: 140%;
    transform: none;
}

/* ═══ Section ═══ */
.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}

.section-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ═══ Upload Card ═══ */
.upload-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.upload-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.upload-card__label {
    font-size: 14px;
    font-weight: 600;
}

.upload-card__zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: border-color var(--transition);
    text-align: center;
}

.upload-card__zone p {
    font-size: 13px;
    color: var(--text-secondary);
}

.upload-card__zone:hover {
    border-color: var(--text-muted);
}

.upload-card__icon-btn {
    background: rgba(232, 168, 56, 0.12);
    border: 1px solid rgba(232, 168, 56, 0.25);
    color: var(--accent);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    touch-action: manipulation;
}

.upload-card__icon-btn:hover {
    background: rgba(232, 168, 56, 0.22);
    color: var(--text-primary);
}

.upload-card__preview {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.upload-card__preview img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.upload-card__remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══ TikTok Input ═══ */
.tiktok-input {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.tiktok-input__field {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.tiktok-input__field:focus {
    border-color: var(--text-muted);
}

.tiktok-input__field::placeholder {
    color: var(--text-muted);
}

.tiktok-input__btn {
    width: 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--accent);
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition);
}

.tiktok-input__btn:hover {
    background: var(--border);
}

/* ═══ File List ═══ */
.file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.file-list__item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    padding: 10px 12px;
    border-radius: var(--radius-xs);
    font-size: 13px;
}

.file-list__thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.file-list__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-list__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-list__remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 4px;
}

/* ═══ Video Tab ═══ */
.video-tab {
    padding: 28px 16px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.generate-btn--video {
    margin-top: 8px;
    align-items: center;
    text-align: center;
}

/* ═══ Video Prompt ═══ */
.video-prompt {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.video-prompt__input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    resize: none;
    transition: border-color var(--transition);
    min-height: 96px;
}

.video-prompt__input:focus {
    border-color: var(--text-muted);
}

.video-prompt__input::placeholder {
    color: var(--text-muted);
}

/* ═══ Library Tab ═══ */
.library-tab {
    padding: 20px 16px;
}

.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.library-header__add {
    background: var(--accent);
    border: none;
    color: #000;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background var(--transition);
}

.library-header__add:hover {
    background: var(--accent-hover);
}

.model-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.model-grid--loading {
    pointer-events: none;
}

.model-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition);
    position: relative;
}

.model-card:active {
    transform: scale(0.95);
}

.model-card__media {
    position: relative;
}

/* Selection checkmark */
.model-card__check {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 3;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Floating 3-dot menu */
.library-fab {
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 100;
    animation: fabSlideIn 0.2s ease-out;
}

@keyframes fabSlideIn {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

.library-fab__trigger {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-fab__trigger:active {
    transform: scale(0.9);
}

.library-fab__dropdown {
    position: absolute;
    bottom: 42px;
    right: 0;
    background: var(--bg-elevated);
    border-radius: var(--radius-xs);
    box-shadow: 0 4px 20px rgba(0,0,0,0.45);
    flex-direction: column;
    min-width: 160px;
    overflow: hidden;
}

.library-fab__item {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    padding: 12px 16px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, transform 0.15s;
}

.library-fab__item:active {
    background: rgba(255,255,255,0.08);
    transform: scale(0.97);
}

.library-fab__item--danger {
    color: #f44336;
}

.model-card__img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--bg-elevated);
}

.model-card__preview-btn {
    position: absolute;
    right: 10px;
    bottom: 10px;
    border: none;
    border-radius: 999px;
    background: rgba(15, 15, 18, 0.82);
    color: #fff;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(6px);
}

.model-card__preview-btn:active {
    transform: scale(0.93);
}

.model-card__info {
    padding: 10px 12px;
}

.model-card__name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.model-card__meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.model-card--active {
    box-shadow: 0 0 0 2px var(--accent);
}

/* ═══ Queue Tab ═══ */
.queue-tab {
    padding: 20px 16px;
}

/* ═══ Queue Overlay ═══ */
.queue-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
}

.queue-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: var(--bg-card);
    padding: 20px 16px;
    overflow-y: auto;
    animation: slideRight 0.25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}

.queue-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.queue-panel__header h3 {
    font-size: 17px;
    font-weight: 700;
}

/* ═══ History Tab ═══ */
.history-tab {
    padding: 20px 16px;
}

.history-info-banner {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-list--loading {
    pointer-events: none;
}

.history-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.history-card__thumb {
    width: 100%;
    overflow: hidden;
}

.history-card__thumb--video {
    position: relative;
    aspect-ratio: 16 / 9;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}

.history-card__thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: var(--text-secondary);
}

.history-card__thumb img,
.history-card__thumb video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    max-height: 300px;
}

.history-card__thumb--video img {
    height: 100%;
    max-height: none;
}

.history-card__thumb-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.history-card__body {
    padding: 14px 16px;
}

.history-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 6px;
    flex-wrap: wrap;
}

.history-card__title {
    font-size: 14px;
    font-weight: 600;
}

.history-card__status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.history-card__status--failed {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
}

.history-card__status--cancelled {
    background: rgba(232, 168, 56, 0.15);
    color: var(--accent);
}

.history-card__date {
    font-size: 11px;
    color: var(--text-muted);
}

.history-card__meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.history-card__error {
    font-size: 12px;
    color: #f44336;
    margin-bottom: 10px;
    line-height: 1.4;
}

.history-card__actions {
    display: flex;
    gap: 8px;
}

.history-card__btn {
    flex: 1;
    padding: 8px 4px;
    border-radius: var(--radius-xs);
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.history-card__btn:active {
    opacity: 0.75;
    transform: scale(0.96);
}

.history-card__btn--download {
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
}

.history-card__btn--share {
    background: rgba(33, 150, 243, 0.15);
    color: #2196f3;
}

.history-card__btn--remake {
    background: rgba(232, 168, 56, 0.15);
    color: var(--accent);
}

.history-card__btn--delete {
    background: rgba(244, 67, 54, 0.12);
    color: #f44336;
}

/* ═══ Batch Toggle ═══ */
.batch-toggle {
    display: flex;
    gap: 0;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: 3px;
    margin-bottom: 16px;
}

.batch-toggle__btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.batch-toggle__btn--active {
    background: var(--accent);
    color: #000;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.queue-list--loading {
    pointer-events: none;
}

.queue-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.queue-item--skeleton,
.history-card--skeleton,
.model-card--skeleton {
    pointer-events: none;
}

.history-card--skeleton .history-card__body,
.model-card--skeleton .model-card__info {
    display: flex;
    flex-direction: column;
}

.queue-item__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 8px;
}

.queue-item__title {
    flex: 1 1 220px;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.queue-item__status {
    flex: 0 1 auto;
    max-width: 100%;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
}

.queue-item__status--waiting {
    background: rgba(232, 168, 56, 0.15);
    color: var(--accent);
}

.queue-item__status--uploading {
    background: rgba(124, 77, 255, 0.16);
    color: #8b6bff;
}

.queue-item__status--processing {
    background: rgba(33, 150, 243, 0.15);
    color: #42a5f5;
}

.queue-item__status--done {
    background: rgba(67, 160, 71, 0.15);
    color: var(--success);
}

.queue-item__status--error {
    background: rgba(229, 57, 53, 0.15);
    color: var(--danger);
}

.queue-item__progress {
    width: 100%;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.queue-item__progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.5s ease;
}

.queue-item__meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.queue-item__meta-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.queue-item__meta-row > span {
    min-width: 0;
}

.queue-item__meta-row > span:first-child {
    flex: 1 1 180px;
}

.queue-item__actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.queue-item__btn {
    flex: 1;
    padding: 8px;
    border-radius: var(--radius-xs);
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.queue-item__btn--cancel {
    background: rgba(229, 57, 53, 0.15);
    color: var(--danger);
}

.queue-item__btn--download {
    background: rgba(67, 160, 71, 0.15);
    color: var(--success);
}

.queue-item__btn--retry {
    background: rgba(232, 168, 56, 0.15);
    color: var(--accent);
}

/* ═══ Modal ═══ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}

.modal__content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    padding: 20px 16px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    overflow-y: auto;
    animation: slideUp 0.25s ease;
}

.modal__content--model-add {
    min-height: 62vh;
    display: flex;
    flex-direction: column;
}

.modal__content--preview {
    max-width: 520px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal__header h3 {
    font-size: 17px;
    font-weight: 700;
}

.modal__body {
    flex: 1;
}

.modal__body--preview {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal__close {
    background: var(--bg-elevated);
    border: none;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition);
}

.input:focus {
    border-color: var(--text-muted);
}

#modalAddModel .modal__body {
    display: flex;
    flex-direction: column;
}

#modelPhotoZone {
    margin-top: 0;
}

#modelSaveBtn {
    margin-top: auto;
}

.input::placeholder {
    color: var(--text-muted);
}

.model-photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.model-photo-preview {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.model-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.model-photo-preview__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.model-photo-preview__remove:active {
    transform: scale(0.9);
}

.model-preview__image {
    width: 100%;
    max-height: min(72vh, 640px);
    object-fit: contain;
    border-radius: 16px;
    background: var(--bg-elevated);
}

.model-preview__download {
    margin-top: 16px;
}

/* ═══ Queue Overlay ═══ */
.queue-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
}

.queue-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: var(--bg-card);
    padding: 20px 16px;
    overflow-y: auto;
    animation: slideRight 0.25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}

.queue-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.queue-panel__header h3 {
    font-size: 17px;
    font-weight: 700;
}

/* ═══ History Tab ═══ */
.history-tab {
    padding: 20px 16px;
}

@keyframes slideRight {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.history-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.history-panel__header h3 {
    font-size: 17px;
    font-weight: 700;
}

/* ═══ Photo Grid ═══ */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px 16px;
    flex: 1;
    overflow-y: auto;
}

.photo-grid__item {
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
}

.photo-grid__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ═══ Payment Modal ═══ */
.payment-amounts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.payment-copy {
    margin: 0 0 14px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.45;
}

.payment-amount {
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 16px 14px;
    color: var(--text-primary);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.payment-amount__label {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.15;
}

.payment-amount__meta {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.payment-amount:hover {
    border-color: var(--text-muted);
}

.payment-amount--selected {
    border-color: var(--accent);
    background: rgba(232, 168, 56, 0.1);
}

.payment-methods__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.payment-method {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 8px;
}

.payment-method[disabled] {
    opacity: 1;
    cursor: default;
}

.payment-method:hover {
    border-color: var(--text-muted);
}

.payment-method--selected {
    border-color: var(--accent);
    background: rgba(232, 168, 56, 0.1);
}

.payment-method__icon {
    width: 32px;
    height: 32px;
    text-align: center;
    flex: 0 0 32px;
}

.payment-method__name {
    font-weight: 500;
}

.header__balance {
    cursor: pointer;
}
