:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary: #ec4899;
    --bg-dark: #0f172a;
    --surface: rgba(30, 41, 59, 0.7);
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
    --accent: #22d3ee;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(124, 58, 237, 0.15) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.1) 0, transparent 50%);
    color: var(--text-main);
    font-family: 'Outfit', -apple-system, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    padding: 0;
}

/* Header Styles */
.glass-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 70px;
    display: flex;
    align-items: center;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 0.8;
}

.hidden-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.card {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

textarea {
    resize: vertical;
    min-height: 350px;
    width: 100%;
    box-sizing: border-box;
    flex-grow: 1;
}

#text {
    height: 100%;
}

.upload-zone {
    width: 100%;
    min-height: 120px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background: rgba(124, 77, 255, 0.05);
    transform: translateY(-2px);
}

.upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(124, 77, 255, 0.1);
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.2);
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
    text-align: center;
    padding: 20px;
}

.upload-content svg {
    opacity: 0.8;
    transition: transform 0.3s ease;
}

.upload-zone:hover .upload-content svg {
    transform: scale(1.1);
    color: var(--accent-primary);
}

.upload-zone.has-files .upload-content {
    display: none;
}

/* --- BGM picker (library + upload toggle) ---------------------------- */
.bgm-mode-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.bgm-mode-btn {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: var(--text-secondary, #cbd5e1);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.bgm-mode-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.bgm-mode-btn.active {
    background: rgba(124, 77, 255, 0.18);
    border-color: var(--accent-primary, #7c4dff);
    color: #fff;
}

.bgm-library-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 14px;
}

.bgm-mood-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.bgm-mood-chip {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    color: var(--text-secondary, #cbd5e1);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.bgm-mood-chip:hover {
    background: rgba(255, 255, 255, 0.08);
}

.bgm-mood-chip.active {
    background: var(--accent-primary, #7c4dff);
    border-color: var(--accent-primary, #7c4dff);
    color: #fff;
}

.bgm-track-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.bgm-track-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.bgm-track-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.bgm-track-item.selected {
    background: rgba(124, 77, 255, 0.12);
    border-color: var(--accent-primary, #7c4dff);
}

.bgm-track-item .track-radio {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

.bgm-track-item.selected .track-radio {
    border-color: var(--accent-primary, #7c4dff);
}

.bgm-track-item.selected .track-radio::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary, #7c4dff);
}

.bgm-track-item .track-title {
    flex: 1;
    color: #fff;
    font-size: 0.95rem;
}

.bgm-track-item .track-duration {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.bgm-track-item .track-play {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.bgm-track-item .track-play:hover {
    background: var(--accent-primary, #7c4dff);
}

.bgm-track-item.playing .track-play {
    background: var(--accent-primary, #7c4dff);
}

.bgm-library-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.9rem;
}

.upload-zone {
    width: 100%;
    min-height: 120px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.file-count {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(124, 77, 255, 0.15);
    padding: 12px 24px;
    border-radius: 12px;
    display: none;
    border: 1px solid rgba(124, 77, 255, 0.3);
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-count::before {
    content: '✓';
    font-size: 2rem;
    display: block;
}

.file-count.active {
    display: flex;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    margin-top: 12px;
    /* Min height so an empty state still presents a drop target before the
       first upload (rare path) and a non-zero hover-able area when only a
       few thumbs are present. */
    min-height: 48px;
    border-radius: 10px;
    transition: background 0.15s, outline 0.15s;
}
.preview-grid.drag-over {
    background: rgba(124, 77, 255, 0.08);
    outline: 2px dashed rgba(167, 139, 250, 0.55);
    outline-offset: 4px;
}

/* --- Per-image narration (Advanced Settings → toggle) ---------------- */
.per-image-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.per-image-row {
    display: grid;
    grid-template-columns: 72px 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 6px;
    align-items: start;
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    position: relative;             /* anchor for the absolutely-placed
                                       checkbox below — keeps it pinned
                                       directly under the thumb regardless
                                       of how tall the right column grows */
}
.per-image-row .per-image-thumb {
    grid-column: 1;
    grid-row: 1;
}
.per-image-row .per-image-enable-wrap {
    /* Pulled out of grid placement: absolutely positioned so it always sits
       directly below the thumb (10px row padding + 72px thumb + 6px gap),
       independent of row 2's actual height. Previously checkbox was
       grid-row:2 which made it stretch downward whenever col 2 (textarea
       + sub_text + history) grew taller than the thumb. */
    position: absolute;
    top: calc(10px + 72px + 6px);
    left: 10px;
    width: 72px;
    justify-content: center;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 2px;
    margin: 0;
}
.per-image-row .per-image-text {
    grid-column: 2;
    grid-row: 1 / span 2;
}
.per-image-row .per-image-history-btn {
    /* Pinned to the bottom-left of the row, aligned with col 2's bottom
       (sub_text bottom edge). Decoupled from the thumb+checkbox stack
       above so the button hugs the row footer regardless of how tall the
       row grows. Padding matches `.per-image-row`'s 10px row-padding. */
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 72px;
    margin: 0;
    padding: 0.4rem 0.5rem;
    justify-content: center;
    z-index: 2;
}

/* Per-image kinetic card text input. Single-line, sparkly yellow
   accent so the user reads it as "the bouncy decoration text", not
   another narration. Empty value = no card on this image. Lives in a
   3rd grid row below the narration / sub_text. */
.per-image-row {
    grid-template-rows: auto auto auto;
}
/* Card row: text input + template picker side by side. The picker is
   compact since the choice list is short (1-5 templates). */
.per-image-row .per-image-card-wrap {
    grid-column: 2;
    grid-row: 3;
    display: flex;
    gap: 6px;
    align-items: stretch;
    margin-top: 4px;
}
.per-image-card-text {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.55rem 0.4rem 1.85rem;
    background: rgba(255, 215, 70, 0.04)
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='%23FFD746'><path d='M12 2l1.6 4.8L18 8l-4 2.4L15 16l-3-2-3 2 1-5.6L6 8l4.4-1.2z'/></svg>")
        no-repeat 0.55rem 50%;
    background-size: 14px 14px;
    border: 1px solid rgba(255, 215, 70, 0.25);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 13px;
}
.per-image-card-text::placeholder {
    color: rgba(255, 215, 70, 0.5);
    font-style: italic;
}
.per-image-card-text:focus {
    outline: none;
    border-color: rgba(255, 215, 70, 0.7);
    background-color: rgba(255, 215, 70, 0.08);
}
.per-image-card-picker {
    flex: 0 0 auto;
    max-width: 130px;
    padding: 0.3rem 1.6rem 0.3rem 0.5rem;
    background: rgba(255, 215, 70, 0.08)
        linear-gradient(45deg,  transparent 50%, #FFD746 50%) no-repeat,
        linear-gradient(135deg, #FFD746 50%, transparent 50%) no-repeat;
    background-position:
        calc(100% - 14px) 50%,
        calc(100% - 9px) 50%;
    background-size: 5px 5px, 5px 5px;
    border: 1px solid rgba(255, 215, 70, 0.25);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}
.per-image-card-picker:focus {
    outline: none;
    border-color: rgba(255, 215, 70, 0.7);
}
.per-image-card-picker option {
    background: #1e293b;
    color: #fff;
}

/* Narration history button (shared by unified textarea + per-image rows) */
.textarea-with-history {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.narration-history-btn {
    background: rgba(167, 139, 250, 0.12);
    border: 1px solid rgba(167, 139, 250, 0.4);
    color: #c4b5fd;
    padding: 0.3rem 0.65rem;
    border-radius: 0.4rem;
    font-size: 0.78rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s, color 0.15s;
}
.narration-history-btn:hover,
.narration-history-btn.is-open {
    background: rgba(167, 139, 250, 0.28);
    color: #fff;
}

/* Popover containing the history list */
.narration-history-popover {
    position: fixed;
    z-index: 9999;
    width: min(420px, calc(100vw - 16px));
    max-height: min(60vh, 480px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #1a1d2a;
    border: 1px solid rgba(167, 139, 250, 0.45);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    color: #e5e7eb;
    font-size: 13px;
}
.narration-history-popover.hidden { display: none; }
.narration-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(167, 139, 250, 0.12);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.narration-history-title {
    font-weight: 600;
    color: #c4b5fd;
}
.narration-history-close {
    background: transparent;
    border: none;
    color: #c4b5fd;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 8px;
}
.narration-history-close:hover { color: #fff; }
.narration-history-body {
    overflow-y: auto;
    padding: 6px;
}
.narration-history-empty,
.narration-history-loading {
    padding: 24px 16px;
    text-align: center;
    color: rgba(229, 231, 235, 0.6);
}
.narration-history-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
}
.narration-history-item + .narration-history-item {
    margin-top: 4px;
}
.narration-history-item:hover {
    background: rgba(167, 139, 250, 0.12);
    border-color: rgba(167, 139, 250, 0.35);
}
.narration-history-text {
    color: #e5e7eb;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
    /* Cap visible lines so a 5-paragraph entry doesn't dominate the popover */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.narration-history-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: rgba(229, 231, 235, 0.55);
}
.narration-history-times {
    background: rgba(167, 139, 250, 0.18);
    color: #c4b5fd;
    padding: 1px 6px;
    border-radius: 999px;
}
.narration-history-del {
    margin-left: auto;
    background: transparent;
    border: none;
    color: rgba(229, 231, 235, 0.5);
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 4px;
}
.narration-history-del:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* Brief flash on the textarea when an item is applied — gives the user a
   visual receipt that "yes, the value got dropped in here". */
@keyframes narration-history-flash {
    0%   { box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.7); }
    100% { box-shadow: 0 0 0 0   rgba(167, 139, 250, 0);   }
}
.narration-history-flash {
    animation: narration-history-flash 0.7s ease-out;
}

/* Trim button on each video preview tile (✂️). Bottom-left corner so it
   doesn't collide with the X (top-right) or the move arrows (bottom). */
.preview-trim-btn {
    position: absolute;
    /* Top-left already has index badge (8px, 22×22). Park ✂️ next to it. */
    top: 8px;
    left: 36px;
    z-index: 3;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(12, 16, 32, 0.82);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.32);
    transition: background 0.15s, transform 0.15s;
}
.preview-trim-btn:hover { background: rgba(124, 77, 255, 0.9); transform: scale(1.08); }
.preview-trim-btn.has-trim {
    background: rgba(124, 77, 255, 0.9);
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.55);
}

/* Video trim modal */
.video-trim-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.video-trim-modal.hidden { display: none; }
.video-trim-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
}
.video-trim-panel {
    position: relative;
    width: min(720px, 100%);
    max-height: calc(100vh - 32px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #1a1d2a;
    border: 1px solid rgba(167, 139, 250, 0.45);
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    color: #e5e7eb;
}
.video-trim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(167, 139, 250, 0.12);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.video-trim-title { font-weight: 600; color: #c4b5fd; font-size: 1rem; }
.video-trim-close {
    background: transparent; border: 0; color: #c4b5fd;
    font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 8px;
}
.video-trim-close:hover { color: #fff; }
.video-trim-body { padding: 14px 16px; overflow-y: auto; }
.video-trim-body video {
    width: 100%;
    max-height: 50vh;
    background: #000;
    border-radius: 8px;
    display: block;
}
.video-trim-range-wrap { margin-top: 16px; }
.video-trim-range {
    position: relative;
    height: 32px;
    margin: 0 14px; /* leave room for handle overflow */
    touch-action: none;
}
.video-trim-track {
    position: absolute;
    top: 50%; left: 0; right: 0;
    height: 6px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}
.video-trim-selected {
    position: absolute;
    top: 50%;
    height: 6px;
    transform: translateY(-50%);
    background: linear-gradient(90deg, #7c4dff, #c4b5fd);
    border-radius: 3px;
    pointer-events: none;
}
.video-trim-handle {
    position: absolute;
    top: 50%;
    width: 22px;
    height: 22px;
    margin-left: -11px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 999px;
    background: #c4b5fd;
    cursor: ew-resize;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    z-index: 2;
    touch-action: none;
}
.video-trim-handle:hover, .video-trim-handle:active { background: #fff; transform: translateY(-50%) scale(1.1); }
.video-trim-times {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    font-size: 0.85rem;
    color: rgba(229, 231, 235, 0.7);
    gap: 12px;
    flex-wrap: wrap;
}
.video-trim-times strong { color: #c4b5fd; margin: 0 2px; }
.video-trim-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
}

/* FFmpeg process monitor on admin home dashboard */
.ffmpeg-monitor-status {
    font-size: 0.75rem;
    font-weight: normal;
    color: rgba(229, 231, 235, 0.5);
    margin-left: 0.5rem;
}
.ffmpeg-monitor-wrap {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 1.5rem;
}
.ffmpeg-monitor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}
.ffmpeg-monitor-summary {
    color: rgba(229, 231, 235, 0.8);
    font-size: 0.9rem;
}
.ffmpeg-monitor-summary strong {
    color: #c4b5fd;
    margin: 0 4px;
}
.ffmpeg-monitor-table .ffmpeg-cmdline {
    display: inline-block;
    max-width: 540px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: rgba(229, 231, 235, 0.6);
    vertical-align: middle;
}
.ffmpeg-kill-btn {
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}
.ffmpeg-kill-btn:hover {
    background: rgba(239, 68, 68, 0.32);
    color: #fff;
}
.ffmpeg-kill-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.per-image-thumb {
    position: relative;
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
}

.per-image-thumb img,
.per-image-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.per-image-thumb-clickable {
    cursor: zoom-in;
    transition: transform 0.12s ease, border-color 0.12s ease;
}
.per-image-thumb-clickable:hover {
    transform: scale(1.04);
    border-color: rgba(255, 255, 255, 0.25);
}

/* Per-image enable checkbox — small box sitting below the thumbnail so it
   doesn't eat the click-to-zoom area on the thumb. Unchecking dims the row
   and hints to the user that this image will be skipped during /generate. */
.per-image-enable {
    width: 13px;
    height: 13px;
    margin: 0;
    cursor: pointer;
    accent-color: #7c4dff;
    flex: 0 0 auto;
}
.per-image-row.per-image-disabled {
    opacity: 0.45;
}
.per-image-row.per-image-disabled .per-image-text,
.per-image-row.per-image-disabled .per-image-subtext {
    pointer-events: none;
    background: rgba(255, 255, 255, 0.015);
}

.subtitle-zoom-media {
    display: flex;
    justify-content: center;
    align-items: center;
}
.subtitle-zoom-media .subtitle-zoom-img {
    max-width: 100%;
    max-height: 80vh;
}

.per-image-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--accent-primary, #7c4dff);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    pointer-events: none;
}

.per-image-text {
    flex: 1;
    min-height: 72px;
    resize: vertical;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: #fff;
    font-size: 0.92rem;
    font-family: inherit;
    line-height: 1.5;
}

.per-image-text:focus {
    outline: none;
    border-color: var(--accent-primary, #7c4dff);
    background: rgba(255, 255, 255, 0.05);
}

.per-image-text::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Step 2 disabled overlay when per-image mode is on */
.per-image-notice {
    background: rgba(99, 102, 241, 0.12);
    border-left: 3px solid var(--accent-primary, #7c4dff);
    padding: 10px 14px;
    margin-bottom: 14px;
    border-radius: 6px;
    color: var(--text-secondary, #cbd5e1);
    font-size: 0.88rem;
    line-height: 1.55;
}

/* Per-image mode → the unified textarea is ignored by the backend, but
   we keep it selectable + editable so users can copy chunks out of it
   into per-image rows ("I wrote the master script here, now I'm splitting
   it up"). Just dim it a touch so the inactive-for-generation status stays
   visually clear. */
.unified-text-disabled textarea#text {
    opacity: 0.7;
}

.unified-text-disabled label[for="text"] {
    opacity: 0.6;
}

/* Toggle checkbox inside Advanced Settings */
.toggle-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    color: #fff;
    font-size: 0.95rem;
}

.toggle-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--accent-primary, #7c4dff);
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: scaleIn 0.3s ease;
}

.preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 999px;
    background: rgba(12, 16, 32, 0.82);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    transition: background 0.18s ease, transform 0.18s ease;
}

.preview-remove:hover {
    background: rgba(220, 38, 38, 0.92);
    transform: scale(1.06);
}

/* Mobile reorder buttons — Sortable.js' touch support is unreliable
   without a long-press handle, so we expose explicit ↑/↓ buttons. They
   sit in the bottom corners of each preview tile so the thumbnail is
   still tappable for preview / drag on desktop. */
.preview-move {
    position: absolute;
    bottom: 6px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: rgba(12, 16, 32, 0.82);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.32);
    transition: background 0.15s ease, transform 0.15s ease;
    touch-action: manipulation;
}
.preview-move-up   { left: 6px; }
.preview-move-down { right: 6px; }
.preview-move:hover,
.preview-move:active {
    background: rgba(124, 77, 255, 0.9);
    transform: scale(1.08);
}
/* Desktop: drag-handle is the primary reorder UX; hide the explicit
   buttons to keep the tile cleaner. Touch-pointer devices show them. */
@media (hover: hover) and (pointer: fine) and (min-width: 768px) {
    .preview-move { display: none; }
}

.preview-item img,
.preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-list {
    margin-top: 12px;
}

.audio-preview-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(124, 77, 255, 0.1);
    padding: 8px 42px 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(124, 77, 255, 0.2);
    color: var(--accent-primary);
    font-size: 0.9rem;
    animation: slideIn 0.3s ease;
}

.preview-remove-audio {
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
}

.preview-remove-audio:hover {
    transform: translateY(-50%) scale(1.06);
}

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

.logo-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}

.logo h1 {
    font-size: 1.25rem !important;
    font-weight: 600;
    margin-bottom: 0 !important;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: left;
}

.version {
    font-size: 0.75rem;
    opacity: 0.5;
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.locale-switcher {
    position: relative;
}

.locale-button {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.2s ease, background 0.2s ease;
}

.locale-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.08);
}

.locale-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

.locale-icon {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.locale-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 116px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
    padding: 10px 0;
    overflow: hidden;
    z-index: 1002;
}

.locale-option {
    width: 100%;
    border: none;
    background: transparent;
    color: #334155;
    font-family: inherit;
    font-size: 0.95rem;
    text-align: left;
    padding: 13px 20px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.locale-option:hover {
    background: #f8fafc;
    color: #0f172a;
}

.locale-option.active {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.04));
    color: #2563eb;
    font-weight: 600;
}

.btn-signin {
    position: relative;
    border: 1px solid rgba(167, 139, 250, 0.45);
    background:
        linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(236, 72, 153, 0.18)),
        rgba(255, 255, 255, 0.06);
    color: #f8fafc;
    padding: 0.72rem 1.2rem;
    min-height: 42px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 10px 22px rgba(15, 23, 42, 0.26);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn-signin:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.5);
    background:
        linear-gradient(135deg, rgba(139, 92, 246, 0.34), rgba(236, 72, 153, 0.26)),
        rgba(255, 255, 255, 0.1);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.16),
        0 14px 28px rgba(15, 23, 42, 0.32);
}

.btn-signin:active {
    transform: translateY(0);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 8px 18px rgba(15, 23, 42, 0.24);
}

.btn-signin:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(34, 211, 238, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.16),
        0 14px 28px rgba(15, 23, 42, 0.32);
}

.user-tools {
    position: relative;
}

.avatar-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 4px 12px 4px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-main);
    transition: all 0.2s;
}

.avatar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
}

.arrow-down {
    font-size: 0.7rem;
    opacity: 0.85;
    line-height: 1;
}

.chevron {
    font-size: 0.6rem;
    opacity: 0.6;
}


.user-profile {
    position: relative;
    display: flex;
    align-items: center;
}

/* OncePing 風格 Pill 按鈕 */
.avatar-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 2px 10px 2px 2px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.avatar-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
    transform: translateY(-1px);
}

/* OncePing 風格下拉選單 */
.dropdown-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 260px;
    background: #ffffff; /* OncePing 純白底色 */
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    transform-origin: top right;
    transition: all 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    z-index: 1001;
    overflow: hidden;
}

.dropdown-panel.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(-5px);
    pointer-events: none;
}

/* Hero Section Enhancement */
.hero-section {
    padding: 80px 20px;
    text-align: center;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
}

.hero-section h1 {
    font-size: 3.2rem;
    font-weight: 800;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-section p[data-i18n="hero.subtitle"] {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto 50px;
}

@media (max-width: 768px) {
    .hero-section h1 { font-size: 2.2rem; }
}

.user-info {
    padding: 18px 20px 14px 20px;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 4px;
}

.identity-badge {
    font-size: 0.95rem;
    font-weight: 400;
    color: #111827;
    margin: 0;
}

.user-email {
    font-size: 0.85rem;
    color: #9ca3af; /* 更優雅的淡灰色 */
    margin-top: 2px;
}

.wallet-info {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid #f3f4f6;
}

.balance-row, .expiry-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #4b5563;
}

.balance-row {
    margin-bottom: 8px;
}

/* Dropdown panel has a white background, so this hint uses dark ink + a
   light blue tint (mirrors OncePing's info-note pattern). */
.trial-refill-hint {
    margin-top: 10px;
    padding: 8px 10px;
    font-size: 0.75rem;
    line-height: 1.45;
    color: #1e3a8a;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
}

.balance-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
    background: #222;
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: 600;
}

.balance-pill small {
    display: inline-block;
    font-weight: 400;
    opacity: 0.9;
    margin-left: 0;
}

.expiry-val {
    font-family: 'Outfit', sans-serif;
    color: #111827;
    font-weight: 500;
}

/* OncePing 風格選單項目 - 色彩與風格 */
.dropdown-item {
    display: flex;
    align-items: center;
    font-weight: 400;
    color: #111827;
    padding: 13px 20px; /* 增加高度，更有質感 */
    gap: 12px;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s;
    border: none;
    background: transparent;
    width: 100%;
    cursor: pointer;
    text-align: left;
}

.dropdown-item:hover {
    background: #f3f4f6;
    color: #000;
}

.dropdown-item.logout-item {
    color: #ef4444 !important; /* Once 標準紅 */
}

.dropdown-item.logout-item:hover {
    background: #fef2f2;
}

.item-icon {
    width: 18px;
    height: 18px;
    color: #374151;
}

.logout-item .item-icon {
    color: #ef4444;
}

.dropdown-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 0px 0;
}


.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 18px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.hero-section {
    text-align: center;
    padding: 3rem 0;
    margin: 0 auto;
    /* No max-width here — the 繁中 title (21 chars) wants ~1000px at 2.8rem
       and would overflow the old 800px cap. The subtitle stays narrow via
       its own .hero-subtitle rule below. */
}

.hero-section h1 {
    /* clamp: shrinks from 2.8rem down to 1.6rem on narrow viewports so
       Chinese (21 chars) stays on a single line. English / European
       titles are 60+ chars and CANNOT fit on one desktop line at any
       legible size — we used to force `white-space: nowrap` here, which
       clipped the right edge of "1-minute \"motion showcase\" videos"
       on en/fr/de/etc. Allow natural wrap for those locales by leaving
       white-space at its default `normal`. Chinese still renders single
       line because its content is short enough not to wrap.

       Width-cap added so very wide viewports (>1400px) don't stretch the
       wrap to one ugly long line of English — keeps the title to ~2
       balanced lines centered on the page. */
    font-size: clamp(1.6rem, 4.2vw, 2.8rem);
    font-weight: 800;
    margin: 0 auto 1rem;
    max-width: 16em;
    background: linear-gradient(135deg, #fff 0%, var(--primary) 50%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 0 1rem;
    line-height: 1.2;
}
/* Hero forced-break: only applies on phones (rule under @media max-width 640px
   re-enables it). On desktop the title stays on a single line so the <br> in
   the i18n string would split it weirdly — hide it. */
.hero-mobile-break { display: none; }

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-dim);
    line-height: 1.6;
    max-width: 680px;
    margin: 0 auto;
    font-weight: 400;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.workspace-shell {
    position: relative;
}

.locked-content {
    transition: filter 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
}

.workspace-shell.is-locked .locked-content {
    /* Relaxed: Allow users to see the UI even if not logged in */
    /* filter: blur(6px); */
    /* opacity: 0.4; */
    /* pointer-events: none; */
}

/* Blur only when the guest gate is active */
body.gate-active .workspace-shell .locked-content {
    filter: blur(10px);
    opacity: 0.4;
    pointer-events: none;
    user-select: none;
}

.guest-gate {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.btn-close-gate {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-gate:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: rotate(90deg);
}

.guest-gate-panel {
    width: min(620px, 100%);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.94));
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.42);
    padding: 2rem;
    text-align: center;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.guest-gate-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(167, 139, 250, 0.32);
    color: #e9d5ff;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.guest-gate-panel h2 {
    font-size: 1.9rem;
    line-height: 1.2;
    margin-bottom: 0.9rem;
}

.guest-gate-panel p {
    color: #cbd5e1;
}

.guest-gate-actions {
    display: flex;
    gap: 0.9rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.btn-auth-primary,
.btn-auth-secondary {
    min-width: 160px;
    justify-content: center;
}

.guest-gate-note {
    margin-top: 1rem;
    font-size: 0.92rem;
    color: #a5b4fc;
}

.card-grid {
    display: grid;
    /* Two columns on desktop: step 1 (tall — images + BGM library) and
       step 2 (narration textarea) sit side-by-side at 50/50, textarea stays
       wide and readable. Step 3 (影片設定) opts into card-full-row below
       and takes a dedicated full-width row instead of a cramped third
       column — its content is just a radio toggle so narrow-column was
       wasteful. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: min-content;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

/* Opt-in: span the whole grid row. Used on step 3 so it drops to its own
   row below step 1 + step 2 instead of squashing into a third column. */
.card-full-row {
    grid-column: 1 / -1;
}

.card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.step {
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    color: var(--text-dim);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="search"],
input[type="url"],
input[type="date"],
textarea,
select {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    color: white;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="tel"]::placeholder,
input[type="search"]::placeholder,
input[type="url"]::placeholder,
textarea::placeholder {
    color: rgba(148, 163, 184, 0.55);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.8);
}

textarea {
    height: 120px;
    resize: none;
}

.row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap; /* Ensure multi-row wrapping if needed */
}

.half {
    flex: 1;
    min-width: 140px;
}

.full {
    flex: 1 1 100%;
}

.toggle-group {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    padding: 4px;
    border-radius: 0.75rem;
    gap: 4px;
}

.toggle-group input {
    display: none;
}

.toggle-group label {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-bottom: 0;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.toggle-group input:checked + label {
    background: var(--primary);
    color: white;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

.action-bar {
    text-align: center;
    margin: 3rem 0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: white;
    padding: 1rem 3rem;
    border-radius: 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

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

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6);
}

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

.btn-affiliate {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    border: none;
    color: white;
    padding: 1rem 3rem;
    border-radius: 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-affiliate:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(234, 88, 12, 0.5);
}

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

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4) !important;
}

.btn-dashboard {
    background: linear-gradient(135deg, #14b8a6, #0284c7) !important;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.4) !important;
}
.btn-dashboard:hover {
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.6) !important;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 2rem;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-text {
    border: 1px solid rgba(167, 139, 250, 0.45);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(236, 72, 153, 0.14));
    color: #f8fafc;
    padding: 0.56rem 1rem;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    box-shadow: 0 6px 16px rgba(16, 24, 40, 0.28);
}

.btn-text::before {
    content: "←";
    opacity: 0.9;
}

.btn-text:hover {
    transform: translateY(-1px);
    border-color: rgba(167, 139, 250, 0.72);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(236, 72, 153, 0.2));
    box-shadow: 0 9px 20px rgba(16, 24, 40, 0.38);
}

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

.btn-text:focus-visible {
    outline: 2px solid rgba(34, 211, 238, 0.85);
    outline-offset: 2px;
}

/* Status and Result */
.status-card, .result-card {
    background: var(--surface);
    border-radius: 1.5rem;
    padding: 2rem;
    text-align: center;
    margin-top: 2rem;
}

.hidden {
    display: none !important;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    animation: rotation 1s linear infinite;
    margin-bottom: 1rem;
}

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

.log-console {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 1.5rem;
    height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    text-align: left;
    color: var(--accent);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.log-item {
    margin-bottom: 0.25rem;
    border-left: 2px solid var(--primary);
    padding-left: 8px;
}

.video-preview {
    margin: 2rem 0;
    border-radius: 1rem;
    overflow: hidden;
    background: black;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

video {
    width: 100%;
    display: block;
}

small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.input-group select, .input-group input {
    margin-bottom: 0 !important;
}

.input-suffix {
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.05);
    height: 100%;
    display: flex;
    align-items: center;
    border-radius: 0.5rem;
    color: var(--primary);
    font-weight: 600;
}

.advanced-settings {
    margin: 2rem 0;
}

.advanced-settings summary {
    font-weight: 600;
    color: var(--text-dim);
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.advanced-settings summary::before {
    content: '▶';
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.advanced-settings[open] summary::before {
    transform: rotate(90deg);
}

.advanced-content {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 0 1rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--primary);
}

.marketing-footer {
    width: 100%;
    margin-top: 6rem;
    padding: 80px 0 40px;
    background: rgba(9, 15, 28, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.marketing-footer-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 0.8fr));
    gap: 40px;
}

.marketing-footer-brand {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.marketing-footer-mark {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 12px;
}

.marketing-footer-brand strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.marketing-footer-brand p {
    margin: 0;
    color: var(--text-dim);
    line-height: 1.8;
}

.marketing-footer-list {
    display: grid;
    align-content: start;
    gap: 10px;
}

.marketing-footer-list h3 {
    margin: 0 0 2px;
    color: #dce8f7;
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.marketing-footer-list a {
    color: #c2d3ea;
    line-height: 1.7;
    text-decoration: none;
}

.marketing-footer-list a:hover {
    color: #ffffff;
}

.marketing-footer-bottom {
    max-width: 1200px;
    margin: 40px auto 0;
    padding: 24px 40px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: #9eb5d3;
    font-size: 0.85rem;
    opacity: 0.6;
}

@media (max-width: 640px) {
    .guest-gate {
        padding: 1rem 0.25rem 1.5rem;
    }

    .guest-gate-panel {
        border-radius: 22px;
        padding: 1.4rem 1rem;
    }

    .guest-gate-panel h2 {
        font-size: 1.45rem;
    }

    .guest-gate-actions {
        flex-direction: column;
    }

    .btn-auth-primary,
    .btn-auth-secondary {
        width: 100%;
        min-width: 0;
    }

    .marketing-footer {
        margin: 4rem 0 0;
        padding: 40px 0 20px;
        border-radius: 0;
    }

    .marketing-footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 0 24px;
    }
    
    .marketing-footer-brand {
        flex-direction: column;
        gap: 12px;
    }
    
    .marketing-footer-brand p {
        max-width: 100%;
        font-size: 0.95rem;
    }

    .marketing-footer-bottom {
        text-align: center;
        margin-top: 32px;
        padding: 20px 24px 0;
    }

    .hero-section {
        padding: 2.5rem 0 1.5rem;
    }

    .hero-section h1 {
        /* Mobile: previously hard-locked at 2.2rem which on a 21-char 繁中
           title wraps into 3 chunky lines and dominates the screen. Use
           clamp again so the size scales with viewport width — 1.4rem on
           ~360px phones, ~1.6rem on tablets, capped at 1.9rem above. */
        font-size: clamp(1.35rem, 4.5vw, 1.9rem);
        line-height: 1.25;
        white-space: normal;
        padding: 0 8px;
    }
    /* Forced line break in the hero title on phones — without this the
       21-char 繁中 title wraps awkwardly mid-word ("…動態展\n示片」").
       The <br> sits in the i18n string with class hero-mobile-break and
       is display:none on desktop so the title stays on one line there. */
    .hero-mobile-break { display: inline; }

    .hero-subtitle {
        font-size: 0.9rem;
        padding: 0 10px;
    }

    textarea {
        min-height: 200px;
    }
}

/* Modal System */
/* Lock page scroll while any modal is visible. Without this, both the body
   and the modal panel show their own scrollbars simultaneously. */
body:has(.modal:not(.hidden)) {
    overflow: hidden;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none !important;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal-panel {
    position: relative;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    max-width: 1300px; /* Widened by 30% from 1000px */
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.btn-close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.btn-close-modal:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(90deg);
}

/* Pricing Section */
.pricing-header {
    text-align: center;
    margin-bottom: 3rem;
}

.pricing-header h2 {
    font-size: 2.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pricing-header p {
    color: var(--text-dim);
    font-size: 1.1rem;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.plan-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.plan-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.plan-card.featured {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.15);
}

.plan-badge {
    position: absolute;
    top: 1.2rem;
    right: -2.5rem;
    background: var(--primary);
    color: white;
    padding: 0.25rem 3rem;
    font-size: 0.75rem;
    font-weight: 700;
    transform: rotate(45deg);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.plan-name {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-price {
    margin-bottom: 2rem;
}

.plan-amount {
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.plan-currency {
    font-size: 0.95rem;
    color: var(--text-dim);
    display: block;
    margin-top: 0.2rem;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin-bottom: 2.5rem;
    flex-grow: 1;
}

.plan-features li {
    font-size: 0.95rem;
    color: #cbd5e1;
    padding: 0.6rem 0;
    display: flex;
    align-items: center;
}

.plan-features li::before {
    content: "✓";
    color: var(--accent);
    margin-right: 1rem;
    font-weight: bold;
    font-size: 1.1rem;
}

.btn-buy {
    width: 100%;
    padding: 1rem;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-buy:hover {
    filter: brightness(1.2);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

/* Dev-only instant-pay button (rendered below .btn-buy when window.IS_DEV_MODE) */
.btn-dev-instant {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    border: 1px dashed rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.08);
    color: #fbbf24;
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.btn-dev-instant:hover {
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.8);
    transform: translateY(-1px);
}
.btn-dev-instant:disabled {
    opacity: 0.55;
    cursor: wait;
    transform: none;
}

.pricing-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.pricing-note {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.payment-methods {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.payment-logo {
    height: 60px;
    background: white;
    padding: 8px 20px;
    border-radius: 10px;
    object-fit: contain;
    opacity: 0.85;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.payment-logo:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* Buyout Card Special Styles */
.buyout-card {
    background: linear-gradient(165deg, rgba(139, 92, 246, 0.15) 0%, rgba(236, 72, 153, 0.1) 100%);
    border: 1px solid rgba(139, 92, 246, 0.4);
    position: relative;
    overflow: hidden;
}

.buyout-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
    opacity: 0.5;
    pointer-events: none;
    animation: pulseGlow 4s infinite alternate;
}

@keyframes pulseGlow {
    0% { transform: scale(1); opacity: 0.3; }
    100% { transform: scale(1.1); opacity: 0.6; }
}

.buyout-badge {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.highlight-glow {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.highlight-glow:hover {
    box-shadow: 0 0 35px rgba(139, 92, 246, 0.4);
}

.price-escalator {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 12px;
    padding: 1rem;
    margin: 1.25rem 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.escalator-title {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.schedule-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.schedule-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 10px;
    align-items: center;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.2s;
}

.schedule-item.active {
    color: #fff;
    font-weight: 700;
}

.schedule-item.missed {
    color: var(--text-dim);
    opacity: 0.5;
    font-size: 0.85rem;
}

.schedule-item.missed .schedule-price {
    color: var(--text-dim);
}

.schedule-date {
    font-family: 'Courier New', monospace;
    white-space: nowrap;
}

.schedule-price {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.schedule-item.active .schedule-price {
    color: var(--accent);
}

/* Next row (upcoming increase) — amber warning */
.schedule-item.next {
    color: rgba(251, 191, 36, 0.95);
}

.schedule-item.next .schedule-price {
    color: #fbbf24;
    font-weight: 700;
}

/* Only highlight "?" when date is truly undetermined (backend pending). */
.schedule-item.pending .schedule-date {
    font-size: 1.15em;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: rgba(251, 191, 36, 0.85);
}

.schedule-item.future {
    color: rgba(255, 255, 255, 0.55);
}

.schedule-item.future .schedule-price {
    color: rgba(255, 255, 255, 0.75);
    font-weight: 600;
}

/* Date width accommodates "4/1 起" etc. */
.schedule-tag,
.schedule-tag-placeholder {
    display: inline-block;
    min-width: 58px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: nowrap;
}

.schedule-tag-placeholder {
    /* Keeps the 3rd grid column reserved so all rows align */
    visibility: hidden;
}

.schedule-tag.current {
    background: rgba(124, 58, 237, 0.2);
    color: #c084fc;
    border: 1px solid rgba(124, 58, 237, 0.4);
}

.schedule-tag.next {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.4);
}

.btn-buyout {
    background: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
}

.btn-buyout:hover {
    box-shadow: 0 8px 25px rgba(236, 72, 153, 0.4);
}

.btn-download-active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-download-active:hover {
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.6) !important;
}

@media (max-width: 1100px) {
    .pricing-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .modal-panel {
        padding: 2rem 1.5rem;
    }
    .pricing-grid {
        grid-template-columns: 1fr;
    }
    .pricing-header h2 {
        font-size: 1.75rem;
    }
}

/* History Modal */
.history-panel {
    max-width: 1235px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem 1.5rem 0.5rem;
}

.history-content {
    overflow-y: auto;
    padding: 1.5rem;
}

.table-container {
    width: 100%;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    color: white;
}

.history-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    font-weight: 600;
}

.history-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-success {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.status-pending {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

/* Draggable Previews */
.preview-item {
    position: relative;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-item:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

.preview-item:active {
    cursor: grabbing;
}

.preview-drag-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    background: rgba(0, 0, 0, 0.4);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.preview-item:hover .preview-drag-handle {
    opacity: 1;
}

.preview-number-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--primary);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 3;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.sortable-ghost {
    opacity: 0.4;
    background: var(--primary) !important;
    transform: scale(0.95);
    box-shadow: 0 0 15px var(--primary);
}

/* Affiliate Program Sections */
.affiliate-section {
    animation: affiliateFadeIn 0.4s ease-out;
    padding: 10px 0;
}

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

.affiliate-intro-hero {
    text-align: center;
    padding: 3rem 1rem;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    border-radius: 30px;
    margin-bottom: 2rem;
}

.affiliate-faq {
    max-width: 800px;
    margin: 0 auto 3rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 2rem 2.5rem;
}

.faq-list {
    list-style: none;
    counter-reset: none;
    padding: 0;
    margin: 0;
}

.faq-item {
    padding: 1.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.faq-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.faq-item:first-child {
    padding-top: 0;
}

.faq-question {
    font-size: 1.05rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 0.6rem;
}

.faq-answer {
    font-size: 0.93rem;
    color: #94a3b8;
    line-height: 1.75;
    margin: 0;
    text-align: justify;
}


.badge-gold {
    background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
    color: #451a03;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(217, 119, 6, 0.3);
}

.affiliate-cta {
    text-align: center;
    padding: 2.5rem 0 1rem;
}

.btn-large {
    padding: 16px 48px;
    font-size: 1.15rem;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.affiliate-intro-hero h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: white;
}

.affiliate-intro-hero p {
    color: var(--text-dim);
    font-size: 1.2rem;
}

.intro-action-row {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Pending commission stat card — subtly amber so it reads as "waiting" not "earned". */
.stat-card-pending h3 {
    color: #fcd34d;
}
.stat-card .stat-hint {
    margin: 0.35rem 0 0;
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.4;
}

/* Partner table: fixed layout + colgroup widths so zh-TW headers never collide
   or wrap into narrow vertical strips (e.g. "狀態" → "狀"/"態"). */
.partner-table-fixed {
    table-layout: fixed;
    width: 100%;
}
.partner-table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.partner-table td {
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Commission columns in the partner table — right-aligned numbers, nowrap,
   and enough min-width that NT$ X,XXX doesn't break onto two lines. */
.partner-table .col-commission {
    text-align: right;
    white-space: nowrap;
    min-width: 90px;
}
/* Main partner row: columns 4 and 5 are the commission cells (earned / pending).
   Right-align the values to match the header alignment. */
.partner-table tbody tr.partner-main-row td:nth-child(4),
.partner-table tbody tr.partner-main-row td:nth-child(5) {
    text-align: right;
    white-space: nowrap;
}
.partner-table td .commission-amount {
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
    text-align: right;
    min-width: 80px;
}
.partner-table td .commission-amount.earned {
    color: #22d3ee;
}
.partner-table td .commission-amount.pending {
    color: #fcd34d;
}
.partner-table td .commission-amount.zero {
    color: #64748b;
    font-weight: 400;
}

/* Per-order commission status badge (in partner expanded history) */
.commission-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-left: 0.5rem;
}
.commission-tag-unlocked {
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
    border: 1px solid rgba(34, 211, 238, 0.3);
}
.commission-tag-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.32);
}
.commission-tag-cancelled {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.28);
}
.commission-tag-none {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}
.partner-purchase-commission {
    color: #22d3ee;
    font-weight: 700;
    font-size: 0.82rem;
    margin-left: 0.5rem;
}

/* Read-only snapshot of the user's affiliate application data. */
.application-info-card {
    margin-bottom: 2rem;
}
.application-info-card .application-info-header {
    margin-bottom: 1.25rem;
}
.application-info-card h3 {
    margin: 0 0 0.25rem;
}
.application-info-card .card-subtitle {
    margin: 0;
    color: #94a3b8;
    font-size: 0.82rem;
    line-height: 1.5;
}
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}
.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.85rem 1rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 10px;
    transition: border-color 0.15s;
}
.info-item:hover {
    border-color: rgba(148, 163, 184, 0.25);
}
.info-label {
    color: #94a3b8;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.info-value {
    color: #e2e8f0;
    font-weight: 500;
    font-size: 0.95rem;
    word-break: break-word;
}
.info-value.info-value-mono {
    font-family: 'SF Mono', Consolas, Menlo, monospace;
    color: #22d3ee;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
}
.info-value.info-value-empty {
    color: #64748b;
    font-style: italic;
    font-weight: 400;
}

.affiliate-base-reward {
    max-width: 800px;
    margin: 0 auto 2.5rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(37, 99, 235, 0.02) 100%);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 16px;
    padding: 2.2rem;
    text-align: center;
}

.base-rate-box {
    margin: 0.8rem 0;
}

.base-rate-value {
    font-size: 3.8rem;
    font-weight: 800;
    color: #3b82f6;
    line-height: 1;
    display: block;
}

.base-rate-unit {
    font-size: 1rem;
    color: #3b82f6;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.base-reward-desc {
    color: #94a3b8;
    max-width: 520px;
    margin: 1.2rem auto 0;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Tier Table */
.tier-table-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1.8rem;
    text-align: center;
}

.tier-table-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 2.5rem;
    padding: 2.5rem 1.5rem 1.5rem;
}

/* 搶位規則說明：放在標題和表格之間，用琥珀色系與 info icon 讓使用者注意到 */
.tier-rules-callout {
    margin: 0 0 1.5rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.10), rgba(251, 191, 36, 0.06));
    border: 1px solid rgba(251, 191, 36, 0.32);
    border-radius: 12px;
}
.tier-rules-title {
    color: #fbbf24;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.55rem;
    letter-spacing: 0.01em;
}
.tier-rules-list {
    margin: 0;
    padding-left: 1.4rem;
    color: #e2e8f0;
    font-size: 0.85rem;
    line-height: 1.75;
}
.tier-rules-list li {
    margin-bottom: 0.3rem;
}
.tier-rules-list li:last-child { margin-bottom: 0; }
.tier-rules-list strong { color: #fcd34d; }

/* Tier status pill — base + 席位已滿 / 開放挑戰 states */
.tier-status-pill {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.2;
}
.tier-status-pill.status-available {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #4ade80;
}
/* 席位已滿 — 醒目紅/橘漸層 + glow 讓人一眼看到 */
.tier-status-pill.status-full {
    background: linear-gradient(135deg, #dc2626, #ea580c);
    border: 1px solid #f87171;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18), 0 2px 8px rgba(220, 38, 38, 0.35);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Occupant chips below the status pill — shows masked name of seat holder(s)
   as a public "hall of fame" when tier is full. Own seat is unmasked + 紫色
   gradient to stand out from other golden chips. */
.tier-occupants {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.tier-occupant-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.7rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(251, 191, 36, 0.4);
    color: #fcd34d;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.tier-occupant-chip.is-self {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(236, 72, 153, 0.24));
    border-color: rgba(192, 132, 252, 0.7);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
}
.tier-occupant-you {
    margin-left: 0.25rem;
    font-size: 0.7rem;
    color: #fde68a;
    font-weight: 400;
}
.tier-occupant-chip.is-self .tier-occupant-you {
    color: rgba(255, 255, 255, 0.8);
}

.tier-table {
    width: 100%;
    border-collapse: collapse;
}

.tier-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.25rem;
    text-align: left;
    font-size: 0.9rem;
    opacity: 0.6;
    color: #e2e8f0;
}

.tier-table td {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 1rem;
    color: #cbd5e1;
}

.tier-table tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.tier-rate {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
}

.tier-strategy-label {
    font-weight: 700;
    color: #fbbf24;
    font-size: 1rem;
}

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

.leaderboard-container {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1rem;
}

.leaderboard-container.single-column {
    grid-template-columns: 1fr;
}

.leaderboard-container.single-column .occupants-list {
    display: none;
}

.occupants-list,
.sprinters-list {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 1rem;
}

.occupants-list {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.occupant-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    background: rgba(11, 18, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.occupant-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.occupant-tier-icon {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.35);
    flex: 0 0 34px;
}

.occupant-name {
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.2;
}

.occupant-tier-name {
    font-size: 0.8rem;
    color: rgba(226, 232, 240, 0.72);
    margin-top: 0.1rem;
}

.occupant-sales {
    font-weight: 700;
    color: #22d3ee;
    white-space: nowrap;
}

.sprinters-list h4 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: #e2e8f0;
}

#sprintersList {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sprinter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    background: rgba(11, 18, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sprinter-main {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.sprinter-rank {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ede9fe;
    background: rgba(99, 102, 241, 0.35);
    border: 1px solid rgba(129, 140, 248, 0.45);
    flex: 0 0 24px;
}

.sprinter-name {
    color: #f8fafc;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sprinter-value {
    color: #22d3ee;
    font-weight: 700;
    white-space: nowrap;
}

.sprint-progress-card {
    padding: 1.6rem 1.8rem;
}

.sprint-bar-container {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    margin: 0.9rem 0 0.8rem;
}

.sprint-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #22d3ee 0%, #8b5cf6 50%, #ec4899 100%);
    transition: width 0.25s ease;
}

.sprint-text {
    color: #e2e8f0;
    font-size: 1.05rem;
    font-weight: 600;
}

.leaderboard-empty {
    opacity: 0.5;
    padding: 1rem;
}

/* Apply Card */
.card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 2.5rem;
    margin-bottom: 2rem;
}

.apply-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 500px;
    margin: 2rem auto 0;
}

.form-hint {
    text-align: center;
    color: var(--text-dim);
    opacity: 0.7;
    font-size: 0.9rem;
}

.policy-agreement {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 1rem;
}

.policy-agreement a {
    color: var(--primary);
    text-decoration: none;
}

.policy-consent-status {
    margin-top: -0.25rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.policy-consent-status.ready {
    color: #22c55e;
}

.affiliate-policy-panel {
    max-width: 920px;
    padding: 2rem 2.25rem;
}

.policy-modal-hint {
    color: var(--text-dim);
    margin: 0.5rem 0 1rem;
}

.affiliate-policy-body {
    max-height: 52vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.65);
    padding: 1.25rem 1.1rem;
}

.affiliate-policy-markdown {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-light);
}

.policy-loading,
.policy-load-fail {
    margin: 0;
    color: var(--text-dim);
}

.affiliate-policy-body .affiliate-faq {
    margin-top: 0;
}

.affiliate-policy-body .faq-list {
    margin: 0;
    padding-left: 1.2rem;
}

.affiliate-policy-body .faq-item + .faq-item {
    margin-top: 1.1rem;
}

.policy-modal-footer {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.policy-read-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    color: var(--text-light);
    font-size: 0.95rem;
}

.policy-read-row input[type="checkbox"] {
    margin-top: 0.2rem;
}

.policy-scroll-hint {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.policy-scroll-hint.ready {
    color: #22c55e;
}

/* Dashboard */
/* --- Apply-form region picker (radio pair) ------------------------------ */
.apply-region-picker {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.apply-region-option {
    flex: 1 1 220px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.apply-region-option input[type="radio"] { margin: 0; }
.apply-region-option:has(input:checked) {
    border-color: var(--accent, #c4b5fd);
    background: rgba(196, 181, 253, 0.06);
}

/* INTL warning banner inside the PayPal group */
.apply-intl-warning {
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 8px;
    color: #fde68a;
    font-size: 0.85rem;
    line-height: 1.55;
}
.apply-intl-warning strong { font-weight: 600; }

/* --- Region tab switcher (TW / INTL) ------------------------------------ */
.affiliate-region-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.affiliate-region-tab {
    padding: 0.6rem 1.25rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.affiliate-region-tab:hover { color: rgba(255, 255, 255, 0.85); }
.affiliate-region-tab.active {
    color: var(--accent, #c4b5fd);
    border-bottom-color: var(--accent, #c4b5fd);
}

/* --- Region-empty CTA card (shown when current tab has no APPROVED row) - */
.affiliate-region-empty { margin-bottom: 2rem; }
.region-empty-card {
    padding: 1.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    text-align: center;
}
.region-empty-card h3 {
    margin: 0 0 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.15rem;
}
.region-empty-card p {
    margin: 0 0 1rem;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.9rem;
}
.dashboard-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.dashboard-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.btn-text.btn-text-accent {
    color: var(--accent);
}
.btn-text.btn-text-accent:hover {
    color: #fff;
}
/* btn-text inherits a "←" via ::before; suppress it for the accent variant
   (the accent button has its own icon — see payoutSettingsBtn). */
.btn-text.btn-text-accent::before {
    content: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    padding: 2rem;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-card.gold {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1) 0%, rgba(217, 119, 6, 0.05) 100%);
    border-color: rgba(251, 191, 36, 0.3);
}

.stat-card label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.stat-value.secondary {
    color: #94a3b8;
}

.tier-badge {
    color: #fbbf24;
    font-size: 1.25rem;
    font-weight: 800;
}

.btn-withdraw-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.9rem;
    padding: 0.5rem 1.15rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-withdraw-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.5);
    filter: brightness(1.08);
}

.btn-withdraw-small:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.35);
}

.btn-withdraw-small:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

/* Small hint line under the "申請提領" button */
.withdraw-window-hint {
    margin: 0.55rem 0 0;
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.45;
}
.withdraw-window-hint.in-window {
    color: #86efac;
}
.withdraw-window-hint.out-of-window {
    color: #fbbf24;
}
.withdraw-window-hint.dev-bypass {
    color: #fbbf24;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Withdraw modal policy box */
.withdraw-policy {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.22);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.withdraw-policy-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
}
.withdraw-policy-label {
    color: #cbd5e1;
    white-space: nowrap;
}
.withdraw-policy-value {
    color: #e2e8f0;
    font-weight: 600;
    text-align: right;
}
.withdraw-policy.out-of-window {
    background: rgba(245, 158, 11, 0.10);
    border-color: rgba(245, 158, 11, 0.32);
}
.withdraw-policy.out-of-window .withdraw-policy-value {
    color: #fcd34d;
}

/* Live-breakdown panel under the amount input */
.withdraw-breakdown {
    margin: 0.5rem 0 1rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 10px;
    font-size: 0.88rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.withdraw-breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    color: #cbd5e1;
}
.withdraw-breakdown-row:nth-child(2) {
    color: #f87171;
}
.withdraw-breakdown-total {
    margin-top: 0.35rem;
    padding-top: 0.55rem;
    border-top: 1px dashed rgba(148, 163, 184, 0.18);
    font-weight: 600;
    color: #22d3ee !important;
    font-size: 0.98rem;
}

/* Referral & Partners */
.copy-input-group {
    display: flex;
    gap: 10px;
    margin-top: 1.5rem;
}

.copy-input-group input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2) !important;
}

.partners-table,
.partner-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.partners-table th,
.partner-table th {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.82);
    font-weight: 700;
}

.partners-table td,
.partner-table td {
    padding: 1rem;
    vertical-align: middle;
    color: rgba(255, 255, 255, 0.92);
}

.partner-table th:nth-child(1),
.partner-table td:nth-child(1) {
    width: 40%;
}

.partner-table th:nth-child(2),
.partner-table td:nth-child(2) {
    width: 15%;
}

.partner-table th:nth-child(3),
.partner-table td:nth-child(3) {
    width: 15%;
}

.partner-table th:nth-child(4),
.partner-table td:nth-child(4) {
    width: 30%;
}


.partner-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.partner-avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    object-fit: cover;
    flex: 0 0 38px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.partner-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.partner-status {
    white-space: nowrap;
}

.partner-status-pill {
    display: inline-block;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
.partner-status-pill.paid {
    background: rgba(74, 222, 128, 0.12);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.35);
}
.partner-status-pill.unpaid {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-member-link {
    color: inherit;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    transition: color 0.15s;
}
.admin-member-link:hover {
    color: #c4b5fd;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.admin-member-link .sub {
    color: rgba(255, 255, 255, 0.55);
}

/* Operational settings page */
.admin-settings-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    max-width: 720px;
}
.admin-settings-card h3 {
    margin: 0 0 0.3rem;
    color: #fff;
}
.admin-settings-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}
.admin-settings-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.admin-settings-row label {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}
.admin-settings-row input[type="number"] {
    width: 160px;
    padding: 0.55rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #fff;
    font-size: 0.95rem;
}
.admin-settings-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.6rem;
}
.admin-settings-status {
    font-size: 0.85rem;
}

.partner-status-sub {
    margin-top: 0.35rem;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.62);
}

.partner-purchase-row td {
    padding-top: 0;
    padding-bottom: 0.85rem;
}

.partner-purchase-list {
    margin: 0 0 0.4rem 0;
    padding: 0;
    list-style: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(10, 16, 34, 0.45);
    overflow: hidden;
}

.partner-purchase-item {
    display: grid;
    grid-template-columns: 180px 1fr 1fr 140px;
    gap: 0.75rem;
    align-items: center;
    padding: 0.55rem 0.7rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.partner-purchase-item:first-child {
    border-top: 0;
}

.partner-purchase-time {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

.partner-purchase-order {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.75);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.partner-purchase-plan {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.82);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.partner-purchase-amount {
    font-size: 0.88rem;
    color: #9fe8ff;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.partner-purchase-empty {
    margin: 0 0 0.4rem 0;
    padding: 0.55rem 0.7rem;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.85rem;
}

/* "顯示全部 / 收起" toggle under a partner's purchase list */
.partner-purchase-toggle {
    display: inline-flex;
    align-items: center;
    margin-top: 0.4rem;
    padding: 0.35rem 0.9rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.10);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.partner-purchase-toggle:hover {
    background: rgba(139, 92, 246, 0.22);
    border-color: rgba(139, 92, 246, 0.55);
    color: #fff;
}

@media (max-width: 900px) {
    .partner-purchase-item {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .partner-purchase-amount {
        text-align: left;
    }
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .leaderboard-container {
        grid-template-columns: 1fr;
    }
}

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

/* Promotion Copy Blocks */
.copy-assets-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.copy-assets-section .sub-title {
    font-size: 1rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 1rem;
}

.copy-block {
    position: relative;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-block:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--primary-color);
}

.copy-block p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: rgba(255,255,255,0.85);
    white-space: pre-wrap;
    word-break: break-all;
}

.copy-tag {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.copy-block:active {
    transform: scale(0.995);
}

.ref-link-placeholder {
    display: block;
    margin-top: 0.5rem;
    padding: 4px 8px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 4px;
    color: var(--primary-color);
    font-size: 0.85rem;
    word-break: break-all;
}

.ref-link-placeholder:empty::after {
    content: "（推廣連結將於載入後自動顯示）";
    color: rgba(255,255,255,0.3);
    font-style: italic;
}

/* Category chip tabs for promo copies */
.promo-category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.promo-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.95rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(255, 255, 255, 0.03);
    color: #cbd5e1;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
.promo-chip:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(148, 163, 184, 0.4);
    color: #fff;
    transform: translateY(-1px);
}
.promo-chip.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.8), rgba(236, 72, 153, 0.7));
    border-color: rgba(236, 72, 153, 0.6);
    color: #fff;
    box-shadow: 0 4px 14px -4px rgba(139, 92, 246, 0.6);
}
.promo-chip-icon {
    font-size: 0.95rem;
    line-height: 1;
}
.promo-category-desc {
    margin: 0 0 1.25rem;
    color: #94a3b8;
    font-size: 0.82rem;
    line-height: 1.55;
    padding: 0.55rem 0.85rem;
    background: rgba(139, 92, 246, 0.06);
    border-left: 3px solid rgba(139, 92, 246, 0.45);
    border-radius: 0 6px 6px 0;
}
.promo-category-desc:empty { display: none; }

/* Grid of promo cards */
.promo-copies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.9rem;
}
.promo-copies-grid .copy-block {
    margin-bottom: 0;
}

/* Length badges on each card */
.promo-len-badge {
    display: inline-block;
    font-size: 0.68rem;
    padding: 1px 7px;
    border-radius: 999px;
    margin-left: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.promo-len-badge.len-short  { background: rgba(34, 197, 94, 0.15);  color: #86efac; }
.promo-len-badge.len-medium { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.promo-len-badge.len-long   { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }

/* Variant title under badge (e.g. "房仲") */
.promo-variant-title {
    display: block;
    font-size: 0.72rem;
    color: #94a3b8;
    margin: 0.2rem 0 0.4rem;
    font-weight: 500;
}

/* =========================================================
   Desktop buyout edition (standalone .exe).
   body.is-desktop-mode is set by Flask when rendering the
   same template inside DesktopStandalone — hides the SaaS-only
   chrome (login, pricing, affiliate, history, footer) so the
   user only sees the video-generator form.
========================================================= */
body.is-desktop-mode #loginBtn,
body.is-desktop-mode #userMenu,
body.is-desktop-mode #guestGate,
body.is-desktop-mode .marketing-footer,
body.is-desktop-mode .affiliate-entry,
body.is-desktop-mode #pricingModal,
body.is-desktop-mode #historyModal,
body.is-desktop-mode #videosModal {
    display: none !important;
}
body.is-desktop-mode #lockedContent,
body.is-desktop-mode .workspace-shell.is-locked {
    pointer-events: auto !important;
    opacity: 1 !important;
    filter: none !important;
}


/* =========================================================================
 * Subtitle settings (M4 UI)
 * ========================================================================= */
#subtitleConfig.hidden {
    display: none;
}

.subtitle-config-label {
    display: block;
    margin-bottom: 0.5rem;
}

.subtitle-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.subtitle-template-tile {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.08);
    transition: border-color 160ms ease, transform 160ms ease;
    aspect-ratio: 9 / 16;
    display: block;
    padding: 0;
    text-align: center;
}
.subtitle-template-tile:hover {
    border-color: rgba(99, 102, 241, 0.6);
    transform: translateY(-2px);
}
.subtitle-template-tile.is-active {
    border-color: #a78bfa;
    box-shadow:
        0 0 0 3px rgba(167, 139, 250, 0.55),
        0 0 18px 4px rgba(167, 139, 250, 0.45);
    transform: translateY(-2px);
}
.subtitle-template-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.subtitle-template-tile .subtitle-template-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.25rem 0.4rem;
    font-size: 11px;
    background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0));
    color: #fff;
    line-height: 1.3;
}

.subtitle-template-loading {
    grid-column: 1 / -1;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    padding: 1rem;
    text-align: center;
}

.subtitle-advanced-panel {
    margin-top: 1rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 0.75rem 1rem;
}
.subtitle-advanced-panel > summary {
    cursor: pointer;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    user-select: none;
    padding: 0.25rem 0;
}
.subtitle-advanced-panel[open] > summary {
    margin-bottom: 0.75rem;
}
.subtitle-advanced-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.subtitle-advanced-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

.btn-text-small {
    background: rgba(167, 139, 250, 0.12);
    border: 1px solid rgba(167, 139, 250, 0.4);
    color: #c4b5fd;
    padding: 0.4rem 0.85rem;
    border-radius: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-text-small:hover {
    background: rgba(167, 139, 250, 0.22);
    color: #fff;
}
/* Primary variant — same dimensions as .btn-text-small but solid gradient
   fill so it reads as the "main action" without growing larger than the
   sibling Cancel button. Used for modal Save / Confirm where visual
   hierarchy matters but layout consistency matters more. */
.btn-text-small.btn-text-small-primary {
    background: linear-gradient(135deg, #7c4dff 0%, #c4b5fd 100%);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}
.btn-text-small.btn-text-small-primary:hover {
    filter: brightness(1.1);
    color: #fff;
}

.subtitle-cat {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0;
}
.subtitle-cat > legend {
    padding: 0 0.5rem;
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    font-weight: 500;
}

.subtitle-mode-group {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.subtitle-mode-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.85);
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.subtitle-mode-btn:hover {
    background: rgba(255,255,255,0.08);
}
.subtitle-mode-btn.is-active {
    background: rgba(99, 102, 241, 0.25);
    border-color: #6366f1;
    color: #fff;
}

.subtitle-anchor-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 120px;
}
.subtitle-anchor-cell {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease;
}
.subtitle-anchor-cell:hover {
    background: rgba(255,255,255,0.1);
}
.subtitle-anchor-cell.is-active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}

.range-value {
    color: #a5b4fc;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    margin-left: 0.5rem;
}

input[type="color"] {
    width: 100%;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.12);
    background: transparent;
    cursor: pointer;
}

/* Per-image sub-text input — stacked below narration so neither textarea
   gets squeezed. Thumb spans both rows on the left. */
.per-image-row.has-subtext {
    /* base .per-image-row already provides the 2-col / 2-row grid; just tune
       row gap. Thumb stays in (1,1), enable-wrap stays in (1,2) — narration
       and subtext occupy column 2. */
    row-gap: 8px;
}
.per-image-row.has-subtext .per-image-text {
    grid-column: 2;
    grid-row: 1;
    flex: none;
}
.per-image-subtext {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    height: 35px;
    min-height: 35px;
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    resize: vertical;
}

/* Magnifier button on each picker tile (M4 zoom preview) */
.subtitle-template-zoom {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 120ms ease, transform 120ms ease;
    z-index: 2;
}
.subtitle-template-zoom:hover {
    background: rgba(99, 102, 241, 0.85);
    transform: scale(1.08);
}

/* Zoom modal */
.subtitle-zoom-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.subtitle-zoom-modal.hidden {
    display: none;
}
.subtitle-zoom-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
}
.subtitle-zoom-panel {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}
.subtitle-zoom-img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    background: #000;
}
.subtitle-zoom-caption {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    text-align: center;
    user-select: none;
}
.subtitle-zoom-close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    color: #111;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.subtitle-zoom-close:hover {
    background: #f1f1f1;
}
body.subtitle-zoom-locked {
    overflow: hidden;
}

/* Per-template usage hint — only visible when picked template carries a
   hint_i18n_key (e.g., keyword_yellow's [bracket] syntax). */
.subtitle-template-hint {
    margin-top: 0.6rem;
    padding: 0.6rem 0.85rem;
    background: rgba(255, 214, 10, 0.08);
    border: 1px solid rgba(255, 214, 10, 0.28);
    border-radius: 8px;
    color: #ffe7a3;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.subtitle-template-hint.hidden {
    display: none;
}
.subtitle-template-hint-icon {
    flex: 0 0 auto;
    font-size: 14px;
}
.subtitle-template-hint-text {
    flex: 1 1 auto;
}
