/* 漫剧创作中心 - 公共样式 */
:root {
    --brand: #667eea;
    --brand-2: #764ba2;
    --brand-soft: #eef0ff;
    --ink: #1f2235;
    --ink-2: #3d425c;
    --muted: #7a809a;
    --line: #e8eaf3;
    --bg: #f5f6fb;
    --card: #ffffff;
    --ok: #12b76a;
    --warn: #f79009;
    --danger: #f04438;
    --info: #2e90fa;
    --radius: 16px;
    --shadow: 0 10px 40px rgba(31, 34, 53, .08);
    --shadow-sm: 0 2px 10px rgba(31, 34, 53, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: linear-gradient(180deg, #eef1fb 0, var(--bg) 280px) no-repeat, var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { opacity: .85; }

.studio-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 22px 0 26px;
}
.studio-header.compact { padding: 20px 0 22px; }

.container {
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 40px;
}
.container.narrow { max-width: 880px; }

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
    width: 42px; height: 42px; border-radius: 12px;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
}
.brand h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; font-size: 13px; opacity: .82; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-user { font-size: 13px; opacity: .9; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: #fff;
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s ease;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }
.btn-ghost { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.3); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-danger { background: #fff1f0; color: var(--danger); border-color: #ffd6d2; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }

.card {
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 14px 48px rgba(31, 34, 53, .09);
    padding: 28px;
}
.card + .card { margin-top: 18px; }
.card-title {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-title h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.card-title p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }

.section-gap { margin-top: 22px; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 20px;
    background: #f0f2f8; color: var(--muted);
}
.badge.ok { background: #e8f8f0; color: var(--ok); }
.badge.warn { background: #fef4e6; color: var(--warn); }
.badge.danger { background: #fff1f0; color: var(--danger); }
.badge.info { background: #eaf4ff; color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.dark { background: rgba(255,255,255,.2); color: #fff; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.text-right { text-align: right; }

/* 表单 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, .select, .textarea {
    width: 100%;
    padding: 10px 13px;
    border: 2px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .18s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.textarea.script { min-height: clamp(460px, calc(100vh - 430px), 820px); font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; }

/* 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
    background: var(--card); border-radius: 14px; padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat .num { font-size: 24px; font-weight: 800; line-height: 1.3; }
.stat .lbl { font-size: 12px; color: var(--muted); }

/* 项目卡片 */
/* 网格限宽 1500px：5 列至少需要 5*300 + 4*20 = 1580px，被挡在外面，
   超宽屏也稳定停在 4 列，单卡约 360px；窄屏由 auto-fill 按 300px 下限自动降列。 */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    max-width: 1500px;
}
.project-card {
    background: var(--card); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-sm); transition: all .2s ease; cursor: pointer;
    display: flex; flex-direction: column;
}
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.project-cover {
    height: 112px; position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,.9); font-size: 34px; font-weight: 800;
}
.project-cover img { width: 100%; height: 100%; object-fit: cover; }
.project-cover .cover-stage {
    position: absolute; left: 12px; top: 12px;
    background: rgba(0,0,0,.28); color: #fff; padding: 2px 10px;
    border-radius: 999px; font-size: 11px; font-weight: 600;
}
.project-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; }
.project-body h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.project-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.project-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 10px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.project-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* 标签页 */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
    padding: 13px 18px; border: none; background: none; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--muted);
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin-left: 4px; vertical-align: middle; }

.panel { display: none; }
.panel.active { display: block; }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #fafbff; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbfcff; }
.table .input, .table .select { padding: 6px 9px; border-width: 1px; font-size: 13px; border-radius: 7px; }
.table .input.tiny { width: 66px; }
.table .input.mini { width: 88px; }

/* 空状态 */
.empty {
    text-align: center; padding: 46px 20px; color: var(--muted);
    background: #fbfcff; border: 1px dashed var(--line); border-radius: 12px;
}
.empty .icon { font-size: 34px; margin-bottom: 8px; }
.empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--ink-2); }
.empty p { margin: 0 0 16px; font-size: 13px; }

/* 弹窗 */
.modal-mask {
    position: fixed; inset: 0; background: rgba(20,22,36,.55);
    display: none; align-items: center; justify-content: center;
    z-index: 9000; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
    background: #fff; border-radius: 18px; width: 100%; max-width: 560px;
    max-height: 90vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 70px rgba(0,0,0,.28);
    animation: studioPop .2s ease;
}
.modal.wide { max-width: 860px; }
@keyframes studioPop { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
    padding: 18px 22px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* 提示 */
.studio-toast {
    position: fixed; left: 50%; top: 26px; transform: translateX(-50%);
    background: #252a41; color: #fff; padding: 10px 20px; border-radius: 10px;
    font-size: 13px; z-index: 12000; box-shadow: 0 10px 30px rgba(0,0,0,.24);
    max-width: 80vw; animation: studioPop .2s ease;
}
.studio-toast.ok { background: #0e9f6e; }
.studio-toast.error { background: #e02424; }

/* 进度条 */
.progress { height: 8px; background: #eef0f8; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #667eea, #764ba2); border-radius: 999px; transition: width .4s ease; }

/* 阶段条 */
.stage-bar {
    background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 800;
}
.stage-bar .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stage-bar .tabs { border-bottom: none; margin-bottom: 0; }

/* 角色时间线 */
.character-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 14px; background: #fff; }
.character-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.character-name { font-size: 15px; font-weight: 700; }
.character-avatar {
    width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft);
    color: var(--brand); display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
/* 有定妆照时头像换成人像：定妆照是全剧人物一致性的唯一基准，
   放在列表里能一眼看出哪个角色还没做，比藏进弹窗有效得多 */
.character-avatar-img { object-fit: cover; padding: 0; cursor: zoom-in; background: #f2f4fb; }

.portrait-box { display: flex; gap: 14px; align-items: flex-start; }
.portrait-preview {
    width: 88px; height: 117px; border-radius: 10px; border: 1px dashed var(--line);
    background: #f7f8fc; overflow: hidden; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; text-align: center;
}
.portrait-preview img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.portrait-actions { display: flex; flex-direction: column; gap: 8px; }
.portrait-actions .btn { white-space: nowrap; }
.timeline { border-left: 2px solid var(--line); margin: 12px 0 0 18px; padding-left: 16px; }
.timeline-item { position: relative; padding: 6px 0 12px; }
.timeline-item::before {
    content: ''; position: absolute; left: -22px; top: 12px;
    width: 9px; height: 9px; border-radius: 50%; background: var(--brand);
    box-shadow: 0 0 0 3px #eef0ff;
}

/* 分镜 */
.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.shot-card { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; }
.shot-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #fafbff; border-bottom: 1px solid var(--line); }
.shot-media { height: 150px; background: #f2f4fb; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; position: relative; }
.shot-media img { width: 100%; height: 100%; object-fit: cover; }
.shot-body { padding: 12px 14px; }
.shot-field { margin-bottom: 8px; }
.shot-field span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.shot-foot { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); }

/* 任务 */
.job-row { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.job-row .job-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }

/* 时间线列表 */
.activity { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.activity:last-child { border-bottom: none; }
.activity .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex-shrink: 0; }
.activity .what { font-size: 13px; color: var(--ink-2); }
.activity .when { font-size: 11px; color: var(--muted); }

/* 评论 */
.comment { padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: none; }
.comment .meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.comment .body { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.comment.reply { margin-left: 26px; padding-left: 12px; border-left: 2px solid var(--line); }

/* 锁提示 */
.lock-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px; border-radius: 10px; background: #fef4e6; color: #93510a;
    font-size: 13px; margin-bottom: 14px;
}

/* 用量 */
.usage-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.usage-row:last-child { border-bottom: none; }
.bar-line { height: 6px; background: #eef0f8; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar-line > i { display: block; height: 100%; background: linear-gradient(90deg, #667eea, #764ba2); }

/* 登录页/邀请页 */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.center-card { background: #fff; border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.25); width: 100%; max-width: 460px; padding: 34px 30px; }
.center-card h1 { margin: 0 0 6px; font-size: 21px; }
.center-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

/* ==================== 工作台双栏 ==================== */
.project-title {
    font-size: 26px; font-weight: 700; letter-spacing: .5px; line-height: 1.25;
}
h1.project-title { font-size: 26px; }

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 20px;
    align-items: start;
}
.workspace-grid > .card + .card { margin-top: 0; }

.overview-card { position: sticky; top: 74px; padding: 24px; }
.overview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.overview-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.overview-head p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

.overview-list { margin-top: 12px; }
.overview-row {
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
    padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.overview-row:last-child { border-bottom: none; }
.overview-row .k { color: var(--muted); flex-shrink: 0; }
.overview-row .v {
    font-weight: 600; color: var(--ink-2); text-align: right;
    word-break: break-word; min-width: 0;
}
.overview-actions { display: grid; gap: 8px; margin-top: 18px; }
.overview-actions .btn { width: 100%; }

@media (max-width: 1180px) {
    .workspace-grid { grid-template-columns: 1fr; }
    .overview-card { position: static; }
}

@media (max-width: 860px) {
    .container { padding: 0 16px; }
    .grid-2, .grid-3, .grid-4, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .textarea.script { min-height: 260px; }
    .card { padding: 18px; }
    h1.project-title { font-size: 20px; }
}
@media (max-width: 540px) {
    .stat-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .brand h1 { font-size: 18px; }
    .header-actions .btn { padding: 8px 12px; font-size: 13px; }
}
