/* Character Creator */

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

:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-muted: #eef2f7;
    --ink: #17191f;
    --muted: #626979;
    --quiet: #8a92a3;
    --line: #dbe1eb;
    --line-strong: #bcc6d4;
    --accent: #2f7fa7;
    --accent-strong: #1d5f83;
    --success: #2f8f5b;
    --danger: #c34242;
    --warning: #b7791f;
}

body {
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: "Kumbh Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

.generate-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.generate-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(246, 247, 251, 0.96);
    border-bottom: 1px solid var(--line);
}

.header-content {
    width: min(var(--oto-shell-width), calc(100% - 40px));
    min-height: 72px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "left brand auth";
    align-items: center;
    gap: 20px;
    padding: 12px 0;
}

.header-left {
    grid-area: left;
    justify-self: start;
}

.header-center {
    grid-area: brand;
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.header-right {
    grid-area: auth;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-self: end;
}

.header-auth {
    justify-content: flex-end;
    gap: 10px;
}

.header-balance {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    color: var(--accent-strong);
    background: rgba(47, 127, 167, 0.08);
    border: 1px solid rgba(47, 127, 167, 0.25);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.header-balance:hover {
    background: rgba(47, 127, 167, 0.14);
    border-color: var(--accent);
}

.header-balance i {
    font-size: 11px;
    color: var(--accent);
}

.balance-unit-small {
    color: var(--quiet);
    font-weight: 600;
}

.auth-gate {
    width: min(500px, calc(100% - 40px));
    margin: 80px auto;
    padding: 48px 32px;
    text-align: center;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--oto-shadow-soft);
    backdrop-filter: blur(16px);
}

.auth-gate i {
    font-size: 40px;
    color: var(--quiet);
    margin-bottom: 12px;
}

.auth-gate h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-gate p {
    color: var(--muted);
    margin-bottom: 20px;
    font-size: 14px;
}

.generate-mobile-gate {
    max-width: 640px;
    margin: 48px auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 36px 32px;
    text-align: center;
}

.generate-mobile-gate .oto-page-kicker {
    margin: 0;
}

.generate-mobile-gate h2 {
    margin: 0;
}

.generate-mobile-gate p {
    margin: 0;
    max-width: 42ch;
}

.generate-mobile-gate-icon {
    width: 62px;
    height: 62px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-strong);
    background: rgba(47, 127, 167, 0.1);
    border: 1px solid rgba(47, 127, 167, 0.18);
    border-radius: 18px;
    font-size: 26px;
}

.generate-mobile-gate-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.generate-mobile-gate-actions > * {
    flex: 1 1 220px;
    justify-content: center;
}

.generate-mobile-gate-link {
    color: var(--accent-strong);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.generate-mobile-gate-link:hover,
.generate-mobile-gate-link:focus-visible {
    text-decoration: underline;
    outline: none;
}

.btn-auth-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 20px;
    color: #fff;
    background: #5865F2;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-auth-login:hover {
    background: #4752c4;
}

.credits-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15, 22, 35, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.credits-modal {
    background: rgba(255, 255, 255, 0.94);
    border-radius: 8px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    border: 1px solid var(--line);
    box-shadow: var(--oto-shadow-soft);
    backdrop-filter: blur(16px);
}

.credits-modal-icon {
    font-size: 40px;
    color: var(--warning);
    margin-bottom: 12px;
}

.credits-modal h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.credits-modal p {
    color: var(--muted);
    margin-bottom: 20px;
    font-size: 14px;
}

.credits-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.credits-modal-actions .btn-primary,
.credits-modal-actions .btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.credits-modal-actions .btn-primary {
    color: #fff;
    background: var(--accent);
}

.credits-modal-actions .btn-primary:hover {
    background: var(--accent-strong);
}

.credits-modal-actions .btn-secondary {
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line-strong);
}

.credits-modal-actions .btn-secondary:hover {
    border-color: var(--accent);
}

.header-login-btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    color: #fff;
    background: #5865F2;
    border: none;
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(88, 101, 242, 0.18);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.15s ease;
}

.header-login-btn:hover {
    background: #4752c4;
    transform: translateY(-1px);
}

.header-user-info {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 5px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(23, 25, 31, 0.06);
}

.header-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow: 0 0 0 1px rgba(188, 198, 212, 0.9);
}

.header-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    max-width: 152px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-wordmark {
    max-width: 100%;
    width: auto;
    height: 34px;
    display: block;
}

.back-button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.back-button:hover,
.back-button:focus-visible {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line-strong);
}

.loading-state {
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--muted);
    text-align: center;
}

.loading-spinner {
    color: var(--accent);
    font-size: 34px;
}

.loading-state p {
    font-size: 16px;
}

.main-content {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 10px 0 48px;
}

.generate-page-intro {
    width: 100%;
    margin: 0 0 6px;
    align-items: start;
}

.generate-page-intro .oto-page-intro-copy {
    max-width: none;
}

.generate-page-intro .oto-page-title {
    max-width: none;
}

.generate-page-description {
    margin: 10px 0 0;
    max-width: 66ch;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}

.generate-inline-link {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: none;
}

.generate-inline-link:hover,
.generate-inline-link:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}

.generate-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas: "main rail";
    gap: 18px;
    align-items: stretch;
}

.generate-workspace-main {
    grid-area: main;
    min-width: 0;
    display: grid;
    gap: 18px;
}

.generate-workspace-main > * {
    min-width: 0;
    max-width: 100%;
}

.generate-workspace-rail {
    grid-area: rail;
    min-width: 0;
    position: relative;
    align-self: stretch;
    --finalize-offset: 0px;
}

.finalize-card {
    padding: 20px;
    transform: translateY(var(--finalize-offset));
    transition: transform 220ms ease;
    will-change: transform;
}

.finalize-card .section-header {
    margin-bottom: 14px;
}

.finalize-card .section-header h2 {
    font-size: 22px;
}

.section-card {
    padding: 24px;
    min-width: 0;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--oto-shadow-soft);
    backdrop-filter: blur(16px);
}

.section-header {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.section-header-with-actions {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: start;
}

.section-kicker {
    color: var(--quiet);
    font-size: 13px;
    font-weight: 700;
}

.section-heading {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.section-header h2,
.section-heading h2 {
    color: var(--ink);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.section-description {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    max-width: 64ch;
}

.section-description-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    max-width: 64ch;
}

.section-description-list li {
    position: relative;
    padding-left: 14px;
}

.section-description-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.62em;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--quiet);
    color: var(--quiet);
}

.section-header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.setup-row {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.upload-area {
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    background: var(--surface-muted);
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
}

.upload-area:hover,
.upload-area:focus-within {
    background: #e8f2f7;
    border-color: var(--accent);
}

.hidden-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    pointer-events: none;
}

.upload-placeholder i {
    color: var(--accent);
    font-size: 28px;
}

.upload-placeholder span {
    color: var(--ink);
    font-weight: 700;
}

.upload-placeholder small {
    color: var(--muted);
    font-size: 13px;
}

.upload-preview {
    max-width: 100%;
    max-height: 280px;
    display: block;
    border-radius: 8px;
    object-fit: contain;
}

.chroma-preview {
    background: #f8fafc;
    border: 1px solid var(--line);
}

.setup-options {
    display: grid;
    gap: 18px;
}

.form-group {
    display: grid;
    gap: 8px;
}

.form-group label {
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
}

.form-group select,
.form-group textarea,
.form-group input[type="text"] {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 15px;
    resize: vertical;
}

.form-group select:focus,
.form-group textarea:focus,
.form-group input:focus {
    outline: 2px solid rgba(47, 127, 167, 0.25);
    outline-offset: 2px;
    border-color: var(--accent);
}

.chroma-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.chroma-color-row input[type="color"] {
    width: 48px;
    height: 38px;
    padding: 2px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
}

.chroma-hint {
    color: var(--muted);
    font-size: 14px;
}

.chroma-tolerance-row {
    display: grid;
    gap: 8px;
    padding-top: 4px;
}

.chroma-tolerance-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chroma-tolerance-label output {
    min-width: 3ch;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

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

.btn-generate-all {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    color: #ffffff;
    background: var(--ink);
    border: 1px solid var(--ink);
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.btn-generate-all:hover:not(:disabled),
.btn-generate-all:focus-visible {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-generate-all:disabled {
    opacity: 0.44;
}

.anim-row {
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.anim-row:last-of-type {
    margin-bottom: 0;
}

.anim-row.generating {
    border-color: rgba(183, 121, 31, 0.55);
    background: #fffaf2;
}

.anim-row.done {
    border-color: rgba(47, 143, 91, 0.45);
    background: #f5fbf7;
}

.anim-row.ready {
    border-color: rgba(47, 127, 167, 0.38);
}

.anim-row-grid {
    display: grid;
    grid-template-columns: 1fr;
}

.anim-row-grid.has-preview {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 300px);
    align-items: stretch;
}

.anim-row-left {
    min-width: 0;
}

.anim-row-main {
    display: grid;
    grid-template-columns: 180px minmax(260px, 1fr) auto;
    gap: 14px;
    align-items: start;
    padding: 14px;
}

.anim-mechanic {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mechanic-select {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
}

.mechanic-select:focus {
    outline: 2px solid rgba(47, 127, 167, 0.25);
    outline-offset: 2px;
    border-color: var(--accent);
}

.btn-remove-row {
    width: 34px;
    height: 34px;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    color: var(--quiet);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
}

.btn-remove-row:hover,
.btn-remove-row:focus-visible {
    color: var(--danger);
    background: #fff2f2;
    border-color: #f1b5b5;
}

.anim-prompt-wrap {
    min-width: 0;
}

.anim-prompt {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.45;
    resize: vertical;
}

.anim-prompt:focus {
    outline: 2px solid rgba(47, 127, 167, 0.25);
    outline-offset: 2px;
    border-color: var(--accent);
}

.anim-actions {
    min-width: 190px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.btn-generate {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 13px;
    color: #ffffff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.btn-generate:hover:not(:disabled),
.btn-generate:focus-visible {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-generate:disabled {
    opacity: 0.52;
}

.anim-status {
    max-width: 160px;
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-review {
    padding: 14px;
    border-top: 1px solid var(--line);
}

.video-review-grid {
    display: grid;
    grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.video-preview-panel,
.trim-panel {
    min-width: 0;
}

.anim-video {
    width: 100%;
    max-height: 360px;
    display: block;
    background: #111318;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
}

.trim-panel {
    display: grid;
    gap: 12px;
}

.video-meta,
.trim-range-note,
.strip-state {
    color: var(--muted);
    font-size: 13px;
}

.video-meta {
    font-weight: 700;
}

.trim-scrub-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
}

.trim-scrub-label span {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.trim-timeline {
    position: relative;
    height: 34px;
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

.trim-timeline-rail,
.trim-timeline-selection {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 999px;
}

.trim-timeline-rail {
    left: 0;
    right: 0;
    height: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
}

.trim-timeline-selection {
    left: var(--trim-start);
    width: calc(var(--trim-end) - var(--trim-start));
    height: 10px;
    background: rgba(47, 127, 167, 0.18);
    border: 1px solid rgba(47, 127, 167, 0.35);
}

.trim-handle {
    position: absolute;
    top: 50%;
    padding: 0;
    border: 0;
    transform: translate(-50%, -50%);
    cursor: grab;
    touch-action: none;
}

.trim-handle:hover,
.trim-handle:focus-visible {
    box-shadow: 0 0 0 3px rgba(47, 127, 167, 0.18);
}

.trim-handle:active {
    cursor: grabbing;
}

.trim-handle-start,
.trim-handle-end {
    width: 16px;
    height: 16px;
    background: #ffffff;
    border: 2px solid var(--accent-strong);
    border-radius: 999px;
    z-index: 2;
}

.trim-handle-start {
    left: var(--trim-start);
}

.trim-handle-end {
    left: var(--trim-end);
}

.trim-handle-current {
    left: var(--trim-current);
    width: 12px;
    height: 28px;
    background: var(--ink);
    border: 2px solid #ffffff;
    border-radius: 999px;
    z-index: 3;
}

.trim-timeline.is-dragging,
.trim-timeline.is-dragging .trim-handle {
    cursor: grabbing;
}

.trim-fields {
    display: grid;
    grid-template-columns: minmax(84px, 120px) minmax(84px, 120px) auto;
    gap: 8px;
    align-items: end;
}

.trim-fields label {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.trim-input {
    width: 100%;
    min-height: 34px;
    padding: 6px 8px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.btn-loop-toggle,
.btn-build-strip,
.btn-download-strip {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 11px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.btn-loop-toggle,
.btn-download-strip {
    color: var(--accent-strong);
    background: var(--surface);
    border: 1px solid var(--line-strong);
}

.btn-build-strip {
    color: #ffffff;
    background: var(--ink);
    border: 1px solid var(--ink);
}

.btn-loop-toggle:hover:not(:disabled),
.btn-download-strip:hover:not(:disabled),
.btn-loop-toggle:focus-visible,
.btn-download-strip:focus-visible {
    background: #e8f2f7;
    border-color: var(--accent);
}

.btn-loop-toggle.is-active {
    color: var(--accent-strong);
    background: #e8f2f7;
    border-color: var(--accent);
}

.btn-build-strip:hover:not(:disabled),
.btn-build-strip:focus-visible {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-build-strip:disabled,
.btn-download-strip:disabled {
    opacity: 0.5;
}

.strip-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.strip-state {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
}

.strip-state.ready {
    color: var(--success);
}

.strip-state.stale {
    color: var(--warning);
}

.anim-strip-row {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--line);
}

.player-wrap {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    max-width: 100%;
}

.playback-column {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    border-left: 1px solid var(--line);
}

.anim-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.btn-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: rgba(23, 25, 31, 0.68);
    border: 0;
    border-radius: 8px;
    transform: translate(-50%, -50%);
}

.btn-play-overlay:hover,
.btn-play-overlay:focus-visible {
    background: rgba(23, 25, 31, 0.86);
}

.btn-play-overlay.playing {
    opacity: 0;
}

.btn-play-overlay.playing:hover,
.btn-play-overlay.playing:focus-visible {
    opacity: 1;
}

.strip-scroll {
    overflow-x: auto;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.strip-img {
    height: 72px;
    width: auto;
    max-width: none;
    display: block;
}

.history-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
}

.history-thumb {
    position: relative;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    overflow: hidden;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
}

.history-thumb:hover,
.history-thumb:focus-visible,
.history-thumb.active {
    border-color: var(--accent);
}

.history-thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: left center;
}

.history-num {
    position: absolute;
    right: 2px;
    bottom: 2px;
    min-width: 14px;
    padding: 0 3px;
    color: #ffffff;
    background: rgba(23, 25, 31, 0.72);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.35;
}

.btn-add-row {
    width: 100%;
    min-height: 42px;
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-strong);
    background: transparent;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    font-weight: 700;
}

.btn-add-row:hover,
.btn-add-row:focus-visible {
    background: #e8f2f7;
    border-color: var(--accent);
}

/* Personality Section */

.personality-form {
    display: grid;
    gap: 18px;
}

.required-mark {
    color: var(--danger);
}

/* Preview Section */

.preview-disabled-msg {
    padding: 22px 0;
    color: var(--muted);
    text-align: center;
}

.preview-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(260px, 320px);
    gap: 24px;
    align-items: start;
}

.preview-stage-panel {
    display: grid;
    gap: 10px;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.preview-anim-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.preview-anim-tab {
    min-height: 30px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--quiet);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.preview-anim-tab:hover {
    color: var(--ink);
    border-color: var(--line-strong);
}

.preview-anim-tab.active {
    color: var(--accent-strong);
    background: rgba(47, 127, 167, 0.08);
    border-color: var(--accent);
}

.preview-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.preview-toolbar-btn,
.preview-lock-toggle {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    font-size: 13px;
    font-weight: 700;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.preview-toolbar-btn {
    color: var(--accent-strong);
}

.preview-toolbar-btn:hover,
.preview-toolbar-btn:focus-visible,
.preview-lock-toggle:hover,
.preview-lock-toggle:focus-visible {
    background: #e8f2f7;
    border-color: var(--accent);
}

.preview-lock-toggle {
    min-width: 188px;
    justify-content: space-between;
    color: var(--ink);
}

.preview-lock-toggle i {
    color: var(--quiet);
    transition: color 0.15s ease;
}

.preview-lock-toggle.active {
    color: var(--accent-strong);
    border-color: var(--accent);
    background: #e8f2f7;
}

.preview-lock-toggle.active i {
    color: var(--accent);
}

.preview-lock-copy {
    display: grid;
    gap: 0;
    text-align: left;
}

.preview-lock-label {
    color: var(--quiet);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preview-lock-state {
    font-size: 13px;
    font-weight: 700;
}

.preview-stage-wrap {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 420px;
    padding: 22px 24px 0;
    background: #0f1219;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.preview-stage {
    position: relative;
    width: 100%;
    min-height: 392px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 24px;
    touch-action: none;
}

.preview-centerline {
    position: absolute;
    top: 20px;
    bottom: 24px;
    left: 50%;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-50%);
    pointer-events: none;
}

.preview-pivot {
    position: absolute;
    left: 50%;
    bottom: 24px;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(121, 183, 255, 0.85);
    border-radius: 999px;
    background: #0f1219;
    box-shadow: 0 0 0 4px rgba(121, 183, 255, 0.16);
    transform: translate(-50%, 50%);
    pointer-events: none;
}

.preview-pivot::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 999px;
    background: rgba(121, 183, 255, 0.95);
}

.preview-ground {
    position: absolute;
    bottom: 24px;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.22);
    pointer-events: none;
}

.preview-hitbox {
    position: relative;
    z-index: 2;
    border: 2px solid rgba(72, 216, 118, 0.72);
    background: rgba(47, 200, 100, 0.08);
    box-shadow: 0 0 0 1px rgba(16, 28, 20, 0.45), 0 12px 24px rgba(0, 0, 0, 0.18);
    margin-bottom: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.preview-sprite {
    position: absolute;
    left: 50%;
    bottom: 50%;
    transform-origin: center bottom;
    transform: translate(-50%, 50%)
        translate(0px, 32px)
        translate(var(--preview-offset-cx, 0px), var(--preview-offset-cy, 0px));
    background: rgba(99, 180, 255, 0.06);
    cursor: grab;
    touch-action: none;
}

.preview-sprite::after {
    content: "";
    position: absolute;
    inset: -2px;
    border: 2px solid rgba(124, 192, 255, 0.95);
    border-radius: 6px;
    box-shadow: 0 0 0 1px rgba(8, 12, 18, 0.55);
    pointer-events: none;
}

.preview-sprite.is-free::after {
    border-style: dashed;
}

.preview-sprite-sheet {
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: 0 0;
    image-rendering: auto;
    border-radius: 4px;
    overflow: hidden;
}

@keyframes previewSpritePlay {
    from { background-position: 0 0; }
    to { background-position: 100% 0; }
}

/* Visual drag handles */

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

.preview-hitbox.is-active {
    border-color: rgba(112, 233, 145, 0.95);
    background: rgba(47, 200, 100, 0.12);
    box-shadow: 0 0 0 3px rgba(47, 200, 100, 0.18), 0 14px 28px rgba(0, 0, 0, 0.24);
}

.preview-sprite.is-active::after {
    border-color: rgba(143, 209, 255, 1);
    box-shadow: 0 0 0 3px rgba(99, 180, 255, 0.2);
}

.preview-sprite-handle,
.preview-hitbox-handle {
    position: absolute;
    z-index: 3;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
    touch-action: none;
}

.preview-sprite-handle {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: rgba(99, 180, 255, 0.95);
    cursor: nwse-resize;
}

.preview-sprite-handle-tr {
    top: -10px;
    right: -10px;
    cursor: nesw-resize;
}

.preview-hitbox-handle {
    background: rgba(47, 200, 100, 0.95);
}

.preview-hitbox-handle-right {
    top: 50%;
    right: -8px;
    width: 14px;
    height: 32px;
    border-radius: 999px;
    cursor: ew-resize;
    transform: translate(50%, -50%);
}

.preview-hitbox-handle-top {
    top: -8px;
    left: 50%;
    width: 32px;
    height: 14px;
    border-radius: 999px;
    cursor: ns-resize;
    transform: translate(-50%, -50%);
}

.preview-hitbox-handle-tr {
    top: -10px;
    right: -10px;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    cursor: nesw-resize;
}

.preview-live-readout {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 4;
    padding: 8px 10px;
    color: #f7f9ff;
    background: rgba(15, 18, 25, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
    pointer-events: none;
}

.preview-live-readout.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.preview-live-readout.is-live {
    border-color: rgba(99, 180, 255, 0.55);
}

.preview-hint {
    margin-top: 0;
    color: var(--muted);
    font-size: 13px;
}

/* Controls */

.preview-controls {
    display: grid;
    gap: 16px;
    align-content: start;
    padding-top: 6px;
}

.preview-control-group {
    display: grid;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.preview-control-group:first-child {
    padding-top: 0;
    border-top: 0;
}

.preview-group-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.preview-group-label {
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preview-group-meta {
    color: var(--quiet);
    font-size: 12px;
    font-weight: 600;
}

.preview-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.preview-field-row label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.preview-input {
    width: 100%;
    min-height: 38px;
    padding: 6px 8px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font-size: 14px;
}

.preview-input:focus {
    border-color: var(--accent);
    outline: none;
}

.preview-stage.is-interacting .preview-pivot {
    box-shadow: 0 0 0 5px rgba(121, 183, 255, 0.22);
}

/* Finalize Section */

.finalize-progress {
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}

.finalize-progress.is-ready {
    color: var(--success);
}

.finalize-checklist {
    margin-bottom: 16px;
}

.finalize-empty {
    padding: 22px 0;
    color: var(--muted);
    text-align: center;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.checklist-item:last-child {
    border-bottom: 0;
}

.checklist-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 13px;
}

.checklist-item.done .checklist-icon {
    color: #fff;
    background: var(--success);
}

.checklist-item.pending .checklist-icon {
    color: var(--quiet);
    background: var(--surface-muted);
    border: 1px solid var(--line-strong);
}

.checklist-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}

.checklist-item.pending .checklist-label {
    color: var(--muted);
}

.checklist-tag {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.checklist-item.done .checklist-tag {
    color: var(--success);
}

.checklist-item.pending .checklist-tag {
    color: var(--quiet);
}

.checklist-item.pending .checklist-tag.required-tag {
    color: var(--danger);
}

.finalize-actions {
    margin-top: 8px;
}

.btn-create-oto {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 24px;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 700;
    transition: background 0.15s;
}

.btn-create-oto:hover:not(:disabled) {
    background: var(--accent-strong);
}

.btn-create-oto:disabled {
    opacity: 0.45;
}

.btn-create-oto.creating {
    pointer-events: none;
}

.character-code-result {
    margin-bottom: 16px;
    padding: 24px;
    text-align: center;
    background: #eaf6ef;
    border: 1px solid #b6e2c8;
    border-radius: 10px;
}

.character-code-result .code-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.character-code-result .code-value {
    display: block;
    margin-bottom: 12px;
    color: var(--ink);
    font-size: 36px;
    font-weight: 700;
    font-family: "Kumbh Sans", monospace;
    letter-spacing: 0.15em;
}

.character-code-result .code-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    padding: 10px 16px;
    color: #1d6080;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(47, 127, 167, 0.24);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.character-code-result .code-link:hover,
.character-code-result .code-link:focus-visible {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(47, 127, 167, 0.38);
    outline: none;
}

.character-code-result .code-hint {
    color: var(--muted);
    font-size: 14px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid rgba(47, 127, 167, 0.35);
    outline-offset: 2px;
}

@media (max-width: 1080px) {
    .generate-workspace {
        grid-template-columns: 1fr;
        grid-template-areas:
            "rail"
            "main";
        gap: 14px;
    }

    .generate-workspace-rail {
        position: static;
        --finalize-offset: 0px;
    }

    .finalize-card {
        position: static;
        transform: none;
    }
}

@media (max-width: 900px) {
    .setup-row,
    .anim-row-grid.has-preview,
    .video-review-grid,
    .anim-row-main,
    .preview-layout {
        grid-template-columns: 1fr;
    }

    .trim-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .btn-loop-toggle {
        grid-column: 1 / -1;
    }

    .playback-column {
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .anim-actions {
        min-width: 0;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .preview-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .preview-lock-toggle {
        width: 100%;
    }

    .preview-stage-wrap {
        min-height: 380px;
    }
}

@media (max-width: 640px) {
    .header-content,
    .main-content {
        width: min(100% - 28px, var(--oto-shell-width));
    }

    .header-content {
        min-height: 0;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand auth"
            "left left";
        align-items: start;
        padding: 14px 0;
        gap: 12px;
    }

    .header-center {
        justify-self: start;
        max-width: min(100%, 240px);
    }

    .header-wordmark {
        height: 28px;
    }

    .header-right {
        align-self: start;
    }

    .header-user-name {
        max-width: 104px;
    }

    .main-content {
        padding: 18px 0 32px;
        gap: 14px;
    }

    .section-card {
        padding: 18px;
    }

    .finalize-card {
        padding: 18px;
    }

    .section-header {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .section-header-with-actions {
        grid-template-columns: 44px minmax(0, 1fr) auto;
        gap: 12px;
        align-items: start;
    }

    .preview-toolbar-actions {
        width: 100%;
    }

    .preview-toolbar-btn {
        flex: 1 1 140px;
        justify-content: center;
    }

    .preview-stage-wrap {
        min-height: 332px;
        padding: 16px 16px 0;
    }

    .preview-stage {
        min-height: 304px;
        padding-bottom: 22px;
    }

    .preview-centerline,
    .preview-ground {
        bottom: 22px;
    }

    .preview-pivot {
        bottom: 22px;
    }

    .preview-live-readout {
        top: 12px;
        left: 12px;
        max-width: calc(100% - 24px);
        white-space: normal;
    }

    .preview-group-header {
        align-items: start;
        flex-direction: column;
        gap: 4px;
    }

    .section-header h2 {
        font-size: 21px;
    }

    .section-header-actions {
        align-items: stretch;
    }

    .btn-generate-all,
    .btn-create-oto {
        width: 100%;
    }

    .section-header-with-actions .section-header-actions {
        align-items: flex-end;
    }

    .section-header-with-actions .btn-generate-all {
        width: auto;
    }

    .checklist-item {
        gap: 8px;
    }

    .strip-actions,
    .strip-actions button {
        width: 100%;
    }

    .strip-state {
        justify-content: center;
    }
}

/* ── Voice picker (reused from browse.css) ────────────────────────── */

.voice-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.voice-hint {
    color: var(--quiet, #6b7280);
    font-size: 13px;
    margin: 0 0 12px;
}

.required-mark {
    color: #d32f2f;
    margin-left: 4px;
}

.voice-search-input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.voice-search-input:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.voice-search-input::placeholder {
    color: #a0aec0;
}

.voice-buttons-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 12px 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    max-height: 260px;
    flex-wrap: wrap;
}

.voice-buttons-scroll::-webkit-scrollbar { height: 8px; }
.voice-buttons-scroll::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.3); border-radius: 4px; }
.voice-buttons-scroll::-webkit-scrollbar-thumb { background: rgba(102, 126, 234, 0.5); border-radius: 4px; }
.voice-buttons-scroll::-webkit-scrollbar-thumb:hover { background: rgba(102, 126, 234, 0.7); }

.voice-btn {
    padding: 10px 18px;
    border: 2px solid rgba(148, 163, 184, 0.45);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.voice-btn:hover {
    border-color: rgba(102, 126, 234, 0.6);
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.voice-btn.selected {
    border-color: #4CAF50;
    background: #e8f5e9;
    color: #2e7d32;
    font-weight: 600;
}

.voice-btn.playing {
    border-color: #2196F3;
    background: #e3f2fd;
    color: #1565c0;
}

.voice-btn.playing::after {
    content: '🔊';
    margin-left: 6px;
    animation: pulse-voice 1s infinite;
}

.voice-btn-custom {
    border-color: rgba(255, 193, 7, 0.6);
    background: linear-gradient(135deg, rgba(255, 248, 225, 0.95), rgba(255, 243, 205, 0.95));
}

.voice-btn-custom:hover {
    border-color: rgba(255, 193, 7, 0.9);
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
}

@keyframes pulse-voice {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.loading-voices {
    padding: 16px;
    text-align: center;
    color: var(--quiet, #6b7280);
    font-style: italic;
}

.voice-error {
    padding: 14px;
    background: rgba(244, 67, 54, 0.08);
    border: 1px solid rgba(244, 67, 54, 0.25);
    border-radius: 8px;
    color: #d32f2f;
    text-align: center;
}

/* ── Attempt tiles (multi-attempt generation) ─────────────────── */

.anim-attempt-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 0 0;
}

.anim-attempt-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 140px;
    min-height: 110px;
    padding: 6px;
    border: 2px solid var(--line, #d8e0ea);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.anim-attempt-tile:hover {
    border-color: rgba(102, 126, 234, 0.55);
    box-shadow: 0 4px 12px rgba(18, 31, 45, 0.08);
}

.anim-attempt-tile.is-selected {
    border-color: #4CAF50;
    background: #f1f9f2;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.15);
}

.anim-attempt-tile.is-running {
    border-color: rgba(33, 150, 243, 0.55);
    background: #eef5ff;
}

.anim-tile-badge {
    min-height: 28px;
    margin-bottom: 6px;
    color: var(--ink, #17191f);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.anim-tile-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 68px;
    border-radius: 6px;
    background: #f8fafc;
    overflow: hidden;
    margin-bottom: 4px;
}

.anim-tile-body--spinner {
    color: #2196F3;
    font-size: 20px;
}

.anim-tile-body--error {
    color: #d32f2f;
    font-size: 18px;
}

.anim-tile-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    background: #0b1420;
}

.anim-tile-status {
    font-size: 11px;
    color: var(--muted, #5e6778);
    line-height: 1.3;
    min-height: 14px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.anim-tile-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    font-size: 10px;
    transition: background 0.15s ease, color 0.15s ease;
}

.anim-tile-remove:hover {
    background: #ffeaea;
    color: #d32f2f;
}

.anim-attempt-tile.is-running .anim-tile-remove {
    opacity: 0.4;
    pointer-events: none;
}

/* ── Voice picker (card grid layout) ────────────────────────────── */

.voice-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.voice-toolbar .voice-search-input {
    flex: 1 1 260px;
    min-width: 0;
}

.voice-select {
    padding: 0.55rem 0.75rem;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.85);
    font-family: inherit;
    font-size: 0.92rem;
    color: inherit;
    cursor: pointer;
}

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

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

.voice-chip {
    padding: 4px 11px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    color: #4b5563;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.voice-chip:hover {
    border-color: rgba(102, 126, 234, 0.6);
    color: #3730a3;
}

.voice-chip.is-active {
    border-color: #4CAF50;
    background: #e8f5e9;
    color: #2e7d32;
}

.voice-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    max-height: 520px;
    overflow-y: auto;
    padding: 4px 4px 12px;
}

.voice-card-grid::-webkit-scrollbar { width: 8px; }
.voice-card-grid::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.45);
    border-radius: 4px;
}

.voice-card {
    position: relative;
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px;
    border: 2px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.voice-card:hover {
    border-color: rgba(102, 126, 234, 0.55);
    box-shadow: 0 6px 14px rgba(18, 31, 45, 0.08);
    transform: translateY(-1px);
}

.voice-card.selected {
    border-color: #4CAF50;
    background: #f1fbf3;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.18);
}

.voice-card--custom {
    background: linear-gradient(180deg, rgba(255, 248, 225, 0.9), rgba(255, 243, 205, 0.85));
    border-color: rgba(255, 193, 7, 0.55);
}

.voice-card-cover {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
    background: #e5e7eb;
    flex-shrink: 0;
}

.voice-card-cover--fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 18px;
}

.voice-card-body {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.voice-card-title {
    font-weight: 700;
    font-size: 14px;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-card-star {
    color: #f59e0b;
    margin-right: 4px;
}

.voice-card-meta {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-card-desc {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.voice-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.voice-card-tag {
    font-size: 10px;
    padding: 1px 7px;
    color: #4338ca;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 999px;
}

.voice-card-play {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #1f2937;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(18, 31, 45, 0.15);
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.voice-card-play:hover {
    background: #fff;
    color: #4338ca;
    transform: scale(1.05);
}

.voice-card-play.playing {
    background: #4338ca;
    color: #fff;
}

/* Shared app shell integration */

.generate-app-main > .loading-state {
    min-height: 360px;
    margin-top: 18px;
}

.generate-app-main > .auth-gate {
    margin-top: 56px;
    margin-bottom: 40px;
}

.generate-app-main > .main-content {
    padding-top: 24px;
}

body.generate-mobile-view .generate-app-main > .auth-gate,
body.generate-mobile-view .generate-app-main > .main-content {
    display: none !important;
}

@media (max-width: 980px) {
    .generate-app-main > .loading-state {
        margin-top: 8px;
    }

    .generate-app-main > .main-content {
        padding-top: 18px;
    }

    .generate-mobile-gate {
        width: min(100%, 560px);
        margin-top: 8px;
        padding: 30px 24px;
    }

    .generate-mobile-gate-actions {
        flex-direction: column;
    }

    .generate-mobile-gate-actions > * {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .generate-app-main > .auth-gate {
        width: min(100% - 28px, 500px);
        margin-top: 32px;
    }

    .generate-app-main > .main-content {
        padding-top: 12px;
    }

    .generate-mobile-gate {
        width: min(100% - 8px, 100%);
        padding: 28px 20px;
        border-radius: 22px;
    }
}

/* ── References drawer (Seedance multi-modal inputs) ─────────────── */

.anim-refs {
    margin-top: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
}

.anim-refs[open] {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(18, 31, 45, 0.04);
}

.anim-refs-summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    list-style: none;
    user-select: none;
}

.anim-refs-summary::-webkit-details-marker { display: none; }
.anim-refs-summary::marker { content: ""; }

.anim-refs-summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    color: #94a3b8;
    transition: transform 0.15s ease;
}

.anim-refs[open] > .anim-refs-summary::before {
    transform: rotate(90deg);
}

.anim-refs-body {
    display: grid;
    gap: 12px;
    padding: 4px 14px 14px;
}

.refs-slot {
    display: grid;
    gap: 6px;
}

.refs-slot-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    color: var(--muted, #5e6778);
}

.refs-slot-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
    color: var(--quiet, #6b7280);
}

.refs-slot-count {
    font-variant-numeric: tabular-nums;
    color: var(--quiet, #6b7280);
}

.refs-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.refs-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 9px;
    font-size: 12px;
    color: #1f2937;
    background: #eef2f7;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    max-width: 240px;
}

.refs-chip--uploading {
    background: rgba(102, 126, 234, 0.08);
    color: #3730a3;
}

.refs-chip--pinned {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.14), rgba(129, 199, 132, 0.12));
    border-color: rgba(76, 175, 80, 0.55);
    color: #2e7d32;
    padding-right: 10px;
}

.refs-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.refs-chip-remove {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #6b7280;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
}

.refs-chip-remove:hover {
    background: #fff;
    color: #d32f2f;
}

.refs-add {
    align-self: start;
    cursor: pointer;
}

.refs-add input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.refs-add-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #3730a3;
    background: rgba(102, 126, 234, 0.08);
    border: 1px dashed rgba(102, 126, 234, 0.45);
    border-radius: 8px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.refs-add:hover .refs-add-cta {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.75);
}

/* ── Video Generation Bar ─────────────────────────────────────── */
.video-gen-bar {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.video-gen-prompt {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: inherit;
    font: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 44px;
}
.video-gen-prompt:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.6);
}
.btn-generate-video {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    background: #6c5ce7;
    color: white;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.btn-generate-video:hover { background: #5b4bd5; }
.btn-generate-video:disabled { opacity: 0.5; cursor: default; }

.btn-upload-video {
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid rgba(108, 92, 231, 0.4);
    background: rgba(108, 92, 231, 0.08);
    color: #6c5ce7;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.btn-upload-video:hover {
    background: rgba(108, 92, 231, 0.16);
    border-color: rgba(108, 92, 231, 0.6);
}
.btn-upload-video:disabled { opacity: 0.5; cursor: default; }
.video-gen-cost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(108, 92, 231, 0.12);
    color: #6c5ce7;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.video-gen-cost[hidden] { display: none; }
.video-gen-status {
    margin-top: 8px;
    font-size: 13px;
    opacity: 0.7;
}

/* ── Video Bank ───────────────────────────────────────────────── */
.video-bank-grid {
    display: flex;
    gap: 16px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0 8px;
    align-items: stretch;
    -webkit-overflow-scrolling: touch;
}
.bank-empty-msg {
    width: 100%;
    flex: 0 0 100%;
    text-align: center;
    padding: 32px 16px;
    opacity: 0.5;
    font-size: 14px;
}
.video-bank-card {
    flex: 0 0 320px;
    width: 320px;
    min-width: 0;
    max-width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    overflow: hidden;
}
.vb-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 10px 12px;
    font-size: 13px;
}
.vb-card-prompt {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.8;
}
.vb-card-meta {
    font-size: 11px;
    opacity: 0.5;
    white-space: nowrap;
}
.vb-card-copy {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.35;
    cursor: pointer;
    padding: 4px;
    font-size: 12px;
    flex-shrink: 0;
}
.vb-card-copy:hover { opacity: 0.8; }
.vb-card-delete {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.4;
    cursor: pointer;
    padding: 4px;
}
.vb-card-delete:hover { opacity: 0.8; }
.vb-card-video {
    width: 100%;
    display: block;
    max-height: 200px;
    object-fit: contain;
    background: #000;
}
.vb-card-video:hover {
    cursor: pointer;
}
.vb-card-video::-webkit-media-controls {
    opacity: 0;
    transition: opacity 0.2s;
}
.vb-card-video:hover::-webkit-media-controls {
    opacity: 1;
}
.vb-card-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px 16px;
    font-size: 13px;
    opacity: 0.6;
}
.vb-card-body--loading i,
.vb-card-body--error i {
    font-size: 18px;
}
.vb-trim-section {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.vb-trim-actions {
    display: flex;
    gap: 8px;
}
.btn-build-anim {
    flex: 1;
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: #00b894;
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.btn-build-anim:hover { background: #00a381; }
.btn-build-anim:disabled { opacity: 0.5; cursor: default; }
.btn-flip-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}
.btn-flip-toggle input[type="checkbox"] {
    margin: 0;
}

.vb-chroma-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-top: 1px dashed rgba(148, 163, 184, 0.35);
    border-bottom: 1px dashed rgba(148, 163, 184, 0.35);
}
.vb-chroma-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
    user-select: none;
}
.vb-chroma-toggle input[type="checkbox"] {
    margin: 0;
}
.vb-chroma-toggle i {
    color: var(--quiet);
}
.vb-chroma-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}
.vb-chroma-color {
    width: 32px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}
.vb-chroma-tol-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    color: var(--muted);
}
.vb-chroma-tolerance {
    flex: 1 1 auto;
    min-width: 60px;
}
.vb-chroma-tolerance-value {
    min-width: 24px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

/* ── Animation Bank ───────────────────────────────────────────── */
.animation-bank-row {
    display: flex;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0 8px;
    min-height: 80px;
    align-items: flex-start;
    -webkit-overflow-scrolling: touch;
}
.anim-bank-card {
    flex-shrink: 0;
    width: 140px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    cursor: grab;
    position: relative;
    transition: transform 0.12s, box-shadow 0.12s;
}
.anim-bank-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.anim-bank-card.is-dragging {
    opacity: 0.4;
}
.anim-bank-thumb {
    width: 100%;
    aspect-ratio: 1;
    background-color: #111;
    background-repeat: no-repeat;
    background-position: 0 center;
    display: block;
}

@keyframes animBankPlay {
    from { background-position-x: 0%; }
    to { background-position-x: 100%; }
}
.anim-bank-info {
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.anim-bank-label {
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.anim-bank-meta {
    font-size: 11px;
    opacity: 0.5;
}
.anim-bank-expanded {
    display: none;
    padding: 6px 8px 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.anim-bank-card.is-expanded {
    width: 260px;
}
.anim-bank-card.is-expanded .anim-bank-expanded {
    display: block;
}
.anim-bank-prompt-full {
    margin: 0 0 6px;
    font-size: 11px;
    line-height: 1.4;
    opacity: 0.8;
    word-wrap: break-word;
    white-space: normal;
}
.anim-bank-prompt-copy {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: inherit;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.anim-bank-prompt-copy:hover {
    background: rgba(255,255,255,0.15);
}
.anim-bank-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.anim-bank-card:hover .anim-bank-delete { opacity: 1; }

/* ── Action Bank ──────────────────────────────────────────────── */
.action-bank-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
    max-height: min(56vh, 520px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}
.action-slot {
    min-width: 0;
    max-width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}
.action-slot--required {
    border-color: rgba(255, 107, 107, 0.3);
}
.action-slot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px 14px;
    font-size: 14px;
}
.action-slot-label {
    font-weight: 700;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.action-slot-count {
    font-size: 12px;
    opacity: 0.5;
    white-space: nowrap;
}
.action-slot-remove {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.3;
    cursor: pointer;
    padding: 4px;
}
.action-slot-remove:hover { opacity: 0.7; }
.action-slot-drop {
    min-height: 56px;
    margin: 0 12px 12px;
    padding: 8px;
    border: 2px dashed rgba(255,255,255,0.1);
    border-radius: 10px;
    display: flex;
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    transition: border-color 0.15s, background 0.15s;
    -webkit-overflow-scrolling: touch;
}
.action-slot-drop.drag-over {
    border-color: #6c5ce7;
    background: rgba(108, 92, 231, 0.08);
}
.action-slot-placeholder {
    width: 100%;
    text-align: center;
    font-size: 13px;
    opacity: 0.35;
    pointer-events: none;
}
.action-assigned-anim {
    position: relative;
    flex: 0 0 auto;
    width: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
}
.action-assigned-thumb {
    width: 100%;
    aspect-ratio: 1;
    background-color: #111;
    background-repeat: no-repeat;
    background-position: 0 center;
    display: block;
}
.action-assigned-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.6);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.action-assigned-anim:hover .action-assigned-remove { opacity: 1; }

/* ── Add Action Bar ───────────────────────────────────────────── */
.action-add-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    margin-top: 12px;
}
.add-action-select {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: inherit;
    font: inherit;
    font-size: 13px;
}
.btn-add-action-bottom {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px dashed rgba(255,255,255,0.2);
    background: transparent;
    color: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.btn-add-action-bottom:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.35);
}
