/* AI 小说短剧工坊 — UI */
:root {
    --bg0: #07070c;
    --bg1: #0e0e16;
    --bg2: #141422;
    --line: rgba(255, 255, 255, 0.08);
    --text: #f4f1ea;
    --muted: #9b96b0;
    --accent: #d4af37;
    --accent2: #8b5cf6;
    --danger: #f87171;
    --ok: #4ade80;
    --radius: 14px;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    --font: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body.app-body,
body.guest-body {
    font-family: var(--font);
    color: var(--text);
    background: radial-gradient(1200px 600px at 10% -10%, rgba(139, 92, 246, 0.18), transparent 55%),
        radial-gradient(900px 500px at 90% 0%, rgba(212, 175, 55, 0.12), transparent 50%),
        var(--bg0);
}

.bg-grid {
    pointer-events: none;
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at 50% 20%, black, transparent 70%);
    opacity: 0.35;
    z-index: 0;
}

.app-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(20, 20, 34, 0.92), rgba(10, 10, 18, 0.92));
    backdrop-filter: blur(12px);
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #f5e6a1);
    color: #1a1203;
    box-shadow: 0 10px 30px rgba(212, 175, 55, 0.25);
}

.brand-title {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.nav-item {
    text-decoration: none;
    color: var(--muted);
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: 0.15s ease;
    font-weight: 500;
}

.nav-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    color: var(--text);
    border-color: rgba(212, 175, 55, 0.35);
    background: rgba(212, 175, 55, 0.08);
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

.user-chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--ok);
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
}

.logout-form {
    margin: 0;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent2);
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
    padding: 0;
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 28px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 10, 16, 0.65);
    backdrop-filter: blur(10px);
}

.page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.topbar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
}

.pill-accent {
    border-color: rgba(139, 92, 246, 0.45);
    color: #e9ddff;
}

.content {
    padding: 22px 28px 40px;
    flex: 1;
}

.panel {
    background: rgba(18, 18, 28, 0.72);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
}

.hero-panel {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 22px;
    margin-bottom: 22px;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .sidebar-foot {
        width: 100%;
    }
    .hero-panel {
        grid-template-columns: 1fr;
    }
}

.hero-kicker {
    margin: 0 0 10px;
    font-size: 26px;
    letter-spacing: 0.02em;
}

.hero-text {
    margin: 0 0 18px;
    color: var(--muted);
    line-height: 1.7;
    max-width: 62ch;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hero-stats {
    display: grid;
    gap: 12px;
}

.stat-card {
    border-radius: var(--radius);
    border: 1px solid var(--line);
    padding: 16px 18px;
    background: linear-gradient(145deg, rgba(212, 175, 55, 0.07), rgba(20, 20, 30, 0.9));
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
}

.stat-value {
    font-size: 34px;
    font-weight: 700;
    margin-top: 6px;
}

.flow-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.8;
}

.flow-list .num {
    color: var(--accent);
    font-weight: 700;
    margin-right: 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 11px;
    border: 1px solid transparent;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: 0.15s ease;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 13px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #ffe7a3);
    color: #1c1504;
    box-shadow: 0 12px 30px rgba(212, 175, 55, 0.22);
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--line);
    color: var(--text);
}

.btn-ghost:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

.btn-accent {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff;
}

.toolbar {
    margin-bottom: 16px;
    display: flex;
    justify-content: flex-end;
}

.table-wrap {
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.data-table th {
    color: var(--muted);
    font-weight: 600;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid var(--line);
    color: var(--muted);
}

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

.link {
    color: var(--accent2);
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.link.danger {
    color: var(--danger);
}

.inline-form {
    display: inline;
    margin: 0;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.project-form {
    max-width: 920px;
}

.field {
    display: grid;
    gap: 6px;
}

.field span {
    font-size: 13px;
    color: var(--muted);
}

.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
}

.field.inline {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 12px;
    max-width: 360px;
}

.field-full {
    grid-column: 1 / -1;
}

input,
select,
textarea {
    font: inherit;
    color: var(--text);
    background: rgba(8, 8, 14, 0.85);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(212, 175, 55, 0.45);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.form-actions.spread {
    justify-content: flex-start;
    gap: 12px;
}

.alert {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 14px;
}

.alert-warn {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

.alert-ok {
    background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.35);
    color: #dcfce7;
}

.muted {
    color: var(--muted);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

/* Guest auth */
.guest-body {
    min-height: 100vh;
}

.guest-center {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    position: relative;
    z-index: 1;
}

.card {
    width: min(460px, 100%);
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(16, 16, 26, 0.9);
    box-shadow: var(--shadow);
    padding: 26px 26px 28px;
}

.auth-badge {
    display: inline-block;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(212, 175, 55, 0.35);
    color: #ffe6a8;
    margin-bottom: 10px;
}

.auth-title {
    margin: 0 0 8px;
    font-size: 22px;
}

.auth-desc {
    margin: 0 0 16px;
    color: var(--muted);
    line-height: 1.6;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

/* Studio */
.studio-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.studio-title {
    margin: 0 0 6px;
    font-size: 24px;
}

.studio-head-actions {
    display: flex;
    gap: 10px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tab {
    text-decoration: none;
    color: var(--muted);
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 14px;
}

.tab:hover {
    color: var(--text);
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.tab.active {
    color: #1c1504;
    background: linear-gradient(135deg, var(--accent), #ffe7a3);
    border-color: rgba(212, 175, 55, 0.5);
}

.stepper {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

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

.stepper-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(12, 12, 20, 0.65);
}

.stepper-item.active {
    border-color: rgba(212, 175, 55, 0.45);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.stepper-item.done .stepper-dot {
    background: rgba(74, 222, 128, 0.25);
    border-color: rgba(74, 222, 128, 0.55);
}

.stepper-dot {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid var(--line);
    color: var(--muted);
}

.stepper-item.active .stepper-dot {
    color: #1c1504;
    background: linear-gradient(135deg, var(--accent), #ffe7a3);
    border-color: transparent;
}

.stepper-label {
    font-size: 13px;
    color: var(--muted);
}

.stepper-item.active .stepper-label {
    color: var(--text);
}

.step-jump {
    margin-bottom: 16px;
}

.pipeline-panel {
    position: relative;
}

.pipeline-step {
    padding-bottom: 22px;
    margin-bottom: 22px;
    border-bottom: 1px dashed var(--line);
}

.pipeline-step:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.code-block {
    margin: 12px 0 0;
    padding: 14px;
    border-radius: 12px;
    background: #050509;
    border: 1px solid var(--line);
    max-height: 320px;
    overflow: auto;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(20, 20, 32, 0.95);
    box-shadow: var(--shadow);
    max-width: min(420px, calc(100vw - 48px));
    z-index: 50;
    font-size: 14px;
}

/* Crew */
.crew-grid {
    display: grid;
    gap: 12px;
}

.crew-card {
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: rgba(18, 18, 28, 0.72);
    padding: 0 16px 16px;
}

.crew-card summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    font-weight: 600;
}

.crew-card summary::-webkit-details-marker {
    display: none;
}

.crew-name {
    font-size: 16px;
}

.crew-slug {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 400;
}

.chev {
    color: var(--muted);
    transition: 0.15s;
}

.crew-card[open] .chev {
    transform: rotate(90deg);
}

.crew-desc {
    margin: 0 0 12px;
    color: var(--muted);
    line-height: 1.6;
    font-size: 14px;
}

.settings-form {
    max-width: 900px;
}

/* Episodes */
.episode-list {
    display: grid;
    gap: 16px;
}

.episode-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    background: rgba(10, 10, 18, 0.55);
}

.episode-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.episode-card h4 {
    margin: 0 0 6px;
    font-size: 16px;
}

.panel-head h3 {
    margin: 0 0 12px;
}
