/* 乐尚 AI 创作台
   形状规则：按钮/输入框 8px，卡片/面板 12px，标签 chip 全圆角。只有一个强调色（--accent）。 */
:root {
  --bg: #111214;
  --surface: #17181b;
  --surface-2: #1e2024;
  --surface-3: #26292e;
  --line: #2a2d33;
  --line-strong: #383c43;
  --text: #ecedee;
  --text-2: #b4b7bd;
  --muted: #8b8f97;
  --accent: #c8f04b;
  --accent-hover: #d6f76d;
  --on-accent: #151a06;
  --accent-ink: #c8f04b;           /* 强调色作为文字时用 */
  --accent-soft: rgba(200, 240, 75, .12);
  --danger: #ff7a6b;
  --danger-soft: rgba(255, 122, 107, .12);
  --ok: #7fdc9c;
  --warn: #f2c14e;
  --shadow: 0 16px 48px rgba(0, 0, 0, .45);
  --r-ctl: 8px;
  --r-card: 12px;
  --rail-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f2f3f5;
  --surface-3: #e7e9ec;
  --line: #e2e4e8;
  --line-strong: #cfd2d8;
  --text: #16181c;
  --text-2: #3d4149;
  --muted: #6a6f78;
  --accent-ink: #4f6a00;
  --accent-soft: rgba(120, 160, 0, .12);
  --danger: #d23f2f;
  --danger-soft: rgba(210, 63, 47, .1);
  --ok: #1f8a4c;
  --warn: #a86d00;
  --shadow: 0 16px 48px rgba(30, 35, 45, .16);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, video { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }
.ph, .ph-fill { font-size: 18px; line-height: 1; }

/* ---------- 启动 ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.boot-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.82); opacity: .6; } }

/* ---------- 品牌 ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border-radius: 2px; background: var(--bg); }
.brand-lg { font-size: 20px; }
.brand-lg .brand-mark { width: 28px; height: 28px; }
.brand-lg .brand-mark::after { inset: 9px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font-weight: 550; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13.5px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-ctl);
  border: 0; background: transparent; color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.on { color: var(--accent-ink); }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label, .lbl { font-size: 13px; color: var(--text-2); font-weight: 550; }
.field-help { font-size: 12.5px; color: var(--muted); margin: 0; }
.field-err { font-size: 13px; color: var(--danger); margin: 0; min-height: 0; }
.field-err:empty { display: none; }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), textarea, select {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface-2);
  border-radius: var(--r-ctl); padding: 9px 12px; outline: none; transition: border-color .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); background: var(--surface); }
textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text-2); font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.ratio-ico { display: inline-block; border: 1.5px solid currentColor; border-radius: 2px; }

/* ---------- 登录 ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); }
.login-sub { color: var(--muted); margin: 10px 0 28px; }

/* ---------- 主框架 ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100dvh; }
.rail { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; padding: 18px 12px 14px; min-height: 0; }
.rail .brand { padding: 2px 8px 22px; font-size: 15px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px; border-radius: var(--r-ctl);
  color: var(--text-2); font-weight: 550; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--surface-3); color: var(--text); }
.nav a.on i { color: var(--accent-ink); }
.nav a .badge { margin-left: auto; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; font-style: normal; }
.rail-foot { margin-top: auto; display: grid; gap: 10px; position: relative; }
.load { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 0 12px; }
.load.busy { color: var(--text-2); }
.load.busy i { color: var(--accent-ink); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: transparent; border-radius: var(--r-ctl); text-align: left; }
.me:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text); display: grid; place-items: center; font-weight: 650; font-size: 14px; flex: none; }
.me-txt { display: grid; min-width: 0; flex: 1; }
.me-txt b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt small { color: var(--muted); font-size: 12px; }
.menu { position: absolute; bottom: 54px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 6px; z-index: 20; }
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 0; background: transparent; border-radius: var(--r-ctl); color: var(--text-2); }
.menu button:hover { background: var(--surface-2); color: var(--text); }
.stage { min-width: 0; min-height: 0; overflow: auto; position: relative; }
.tabbar { display: none; }

/* ---------- 页面通用 ---------- */
.page { padding: 28px 32px 48px; max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 56px 16px; }
.empty i { font-size: 40px; color: var(--line-strong); display: block; margin: 0 auto 12px; }
.empty b { color: var(--text-2); display: block; font-size: 16px; margin-bottom: 6px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; gap: 2px; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font-weight: 550; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }

/* ---------- 创作页（图片/视频） ---------- */
.studio { display: grid; grid-template-columns: 380px 1fr; height: 100%; min-height: 0; }
.panel { border-right: 1px solid var(--line); background: var(--surface); overflow: auto; padding: 24px 22px 28px; display: flex; flex-direction: column; gap: 22px; }
.panel h1 { font-size: 19px; margin: 0; font-weight: 650; }
.panel h1 small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 4px; }
.sect { display: grid; gap: 10px; }
.sect-head { display: flex; align-items: center; justify-content: space-between; }
.prompt-box { position: relative; }
.prompt-box textarea { min-height: 132px; padding-bottom: 42px; }
.prompt-tools { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; }
.prompt-tools .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.mini-btn { height: 28px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; }
.mini-btn:hover { color: var(--text); border-color: var(--muted); }
.mini-btn:disabled { opacity: .5; cursor: wait; }
.insp { display: flex; flex-wrap: wrap; gap: 6px; }
.insp button { border: 0; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; border-radius: 999px; padding: 5px 11px; text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp button:hover { color: var(--text); background: var(--surface-3); }

.drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-card); padding: 18px 14px; text-align: center;
  color: var(--muted); font-size: 13.5px; transition: border-color .15s, background .15s; position: relative;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.drop i { font-size: 26px; display: block; margin: 0 auto 6px; color: var(--text-2); }
.drop .drop-acts { display: flex; justify-content: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ref { display: grid; grid-template-columns: 88px 1fr; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--r-card); padding: 8px; background: var(--surface-2); }
.ref img { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; background: var(--surface-3); }
.ref-txt { font-size: 13px; color: var(--text-2); display: grid; gap: 6px; }
.ref-txt .acts { display: flex; gap: 6px; }
.uploading { display: flex; align-items: center; gap: 10px; justify-content: center; color: var(--text-2); }

.go-bar { position: sticky; bottom: -28px; margin: auto -22px -28px; padding: 14px 22px 22px; background: linear-gradient(to bottom, transparent, var(--surface) 30%); }
.go-bar .hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; text-align: center; }

.results { overflow: auto; padding: 24px 28px 48px; min-width: 0; }
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.results-head h2 { margin: 0; font-size: 16px; font-weight: 600; }

/* ---------- 作品卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; align-items: start; }
.grid.lg { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; display: flex; flex-direction: column; }
.card .media { position: relative; background: var(--surface-2); aspect-ratio: var(--ar, 1 / 1); overflow: hidden; cursor: zoom-in; }
.card .media img, .card .media video { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.card .media:hover img { transform: scale(1.03); }
.card .kind { position: absolute; top: 8px; left: 8px; height: 24px; padding: 0 8px; border-radius: 999px; background: rgba(10, 11, 13, .62); color: #fff; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; backdrop-filter: blur(6px); }
.card .fav { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(10, 11, 13, .55); color: #fff; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.card .fav.on { opacity: 1; color: var(--accent); }
.card:hover .fav, .card .fav:focus-visible { opacity: 1; }
.card .body { padding: 10px 12px 12px; display: grid; gap: 8px; }
.card .p { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.card .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.card .meta .grow { flex: 1; }
.card .acts { display: flex; gap: 2px; margin: -4px -6px -6px; }
.card .acts .icon-btn { width: 32px; height: 32px; }
.card .acts .icon-btn .ph { font-size: 17px; }

.pending { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 10px; padding: 16px; color: var(--text-2); font-size: 13.5px; }
.shimmer { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: sh 1.6s linear infinite; }
@keyframes sh { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.bar { width: 160px; height: 4px; border-radius: 4px; background: var(--line-strong); overflow: hidden; margin: 0 auto; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .6s var(--ease); }
.pending .stage-txt { font-weight: 600; color: var(--text); }
.failed { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 16px; gap: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.failed i { font-size: 26px; margin: 0 auto; }
.failed span { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.more { display: flex; justify-content: center; margin-top: 22px; }

/* ---------- 对话 ---------- */
.chat { display: grid; grid-template-columns: 272px 1fr; height: 100%; min-height: 0; }
.convs { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.convs-top { padding: 16px 12px 10px; display: grid; gap: 10px; }
.convs-list { overflow: auto; padding: 4px 8px 16px; flex: 1; }
.conv { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--r-ctl); color: var(--text-2); cursor: pointer; font-size: 14px; }
.conv:hover { background: var(--surface-2); color: var(--text); }
.conv.on { background: var(--surface-3); color: var(--text); }
.conv .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .pin { color: var(--accent-ink); font-size: 14px; }
.conv-group { font-size: 12px; color: var(--muted); padding: 12px 10px 4px; }
.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line); min-height: 58px; }
.thread-head .title { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head select { width: auto; height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 13.5px; }
.msgs { flex: 1; overflow: auto; padding: 24px 20px 12px; }
.msgs-inner { max-width: 820px; margin: 0 auto; display: grid; gap: 22px; }
.msg { display: grid; gap: 6px; }
.msg.user { justify-items: end; }
.msg.user .bubble { background: var(--surface-3); padding: 10px 14px; border-radius: 14px 14px 4px 14px; max-width: 85%; white-space: pre-wrap; word-break: break-word; }
.msg.ai .bubble { max-width: 100%; word-break: break-word; }
.msg .tools { display: flex; gap: 2px; opacity: .7; }
.msg:hover .tools { opacity: 1; }
.msg .tools .icon-btn { width: 30px; height: 30px; }
.msg .tools .icon-btn .ph { font-size: 16px; }
.msg.err .bubble { color: var(--danger); }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { transform: translateY(-4px); background: var(--text); } }
.wait-note { font-size: 13px; color: var(--muted); }
.composer { padding: 10px 20px 18px; }
.composer-box { max-width: 820px; margin: 0 auto; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 14px; padding: 10px 10px 8px 14px; display: grid; gap: 6px; transition: border-color .15s; }
.composer-box:focus-within { border-color: var(--accent); }
.composer-box textarea { border: 0; background: transparent; padding: 4px 0; min-height: 26px; max-height: 240px; resize: none; }
.composer-box textarea:focus { background: transparent; }
.composer-box textarea:focus-visible { outline: none; }   /* 外框 focus-within 已经高亮 */
.composer-row { display: flex; align-items: center; gap: 8px; }
.composer-row .note { font-size: 12px; color: var(--muted); flex: 1; }
.send { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.send:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.send.stop { background: var(--text); color: var(--bg); }
.att-row { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 2px; }
.att { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--line); }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att-busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 11, 13, .55); color: #fff; }
.att-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(10, 11, 13, .7); color: #fff; display: grid; place-items: center; padding: 0; }
.att-x .ph { font-size: 13px; }
.msg-imgs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 85%; }
.msg-imgs img { width: 168px; height: 168px; object-fit: cover; border-radius: 10px; background: var(--surface-3); }
.msg-imgs a:only-child img { width: auto; height: auto; max-width: 260px; max-height: 260px; }
.thread.drag .composer-box { border-color: var(--accent); background: var(--accent-soft); }
.chat-empty { max-width: 640px; margin: 8vh auto 0; text-align: center; }
.chat-empty h2 { font-size: 24px; margin: 0 0 6px; font-weight: 650; }
.chat-empty p { color: var(--muted); margin: 0 0 22px; }
.chat-empty .chips { justify-content: center; }
.starters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; text-align: left; }
.starters button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-card); padding: 12px 14px; color: var(--text-2); font-size: 14px; text-align: left; }
.starters button:hover { border-color: var(--line-strong); color: var(--text); }

/* Markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol { margin: .6em 0; }
.md ul, .md ol { padding-left: 1.4em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 .5em; line-height: 1.35; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.2em; } .md h3 { font-size: 1.08em; }
.md a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.md code { font-family: var(--mono); font-size: .9em; background: var(--surface-3); padding: .12em .4em; border-radius: 5px; }
.md pre { position: relative; background: #0d0e10; border: 1px solid var(--line); border-radius: 10px; padding: 0; overflow: hidden; margin: .8em 0; }
.md pre code { display: block; padding: 14px 16px; overflow: auto; background: transparent; font-size: 13.5px; line-height: 1.55; color: #e6e6e6; }
.md pre .copy-code { position: absolute; top: 6px; right: 6px; height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; border: 1px solid #2f3238; background: #1b1d21; color: #c9ccd1; }
.md blockquote { margin: .8em 0; padding: .2em 1em; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.md table { border-collapse: collapse; margin: .8em 0; display: block; overflow: auto; }
.md th, .md td { border: 1px solid var(--line-strong); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md img { border-radius: 8px; }

/* ---------- 列表/表格（任务、管理） ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .search { width: 240px; }
.rows { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.row .thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.row .thumb i { font-size: 24px; }
.row .info { min-width: 0; display: grid; gap: 4px; }
.row .info .p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .info .sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row .bar { margin: 0; width: 180px; }
.st { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.st.done { color: var(--ok); } .st.failed { color: var(--danger); background: var(--danger-soft); } .st.running, .st.submitted { color: var(--accent-ink); background: var(--accent-soft); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.tbl td.wrap { white-space: normal; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { font-family: var(--mono); font-size: 13px; }
.tbl .muted { color: var(--muted); }
.tbl .acts { display: flex; gap: 4px; justify-content: flex-end; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px; }
.stat .k { font-size: 12.5px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 650; font-family: var(--mono); margin-top: 4px; }
.pill-ok { color: var(--ok); } .pill-bad { color: var(--danger); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs button { border: 0; background: transparent; height: 40px; padding: 0 14px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; z-index: 40; background: rgba(6, 7, 9, .66); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px 16px; animation: fade .18s ease; overflow: auto; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); animation: rise .22s var(--ease); }
@keyframes rise { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 4px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 14px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 6px 18px 18px; }
.modal.wide { width: min(980px, 100%); }

.viewer { width: min(1280px, 100%); display: grid; grid-template-columns: 1fr 340px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); max-height: calc(100dvh - 40px); animation: rise .22s var(--ease); }
.viewer-media { background: #0a0b0c; display: grid; place-items: center; min-height: 320px; max-height: calc(100dvh - 40px); }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: calc(100dvh - 40px); object-fit: contain; }
.viewer-side { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 16px; border-left: 1px solid var(--line); }
.viewer-side .p { white-space: pre-wrap; font-size: 14px; color: var(--text-2); background: var(--surface-2); border-radius: var(--r-ctl); padding: 10px 12px; max-height: 220px; overflow: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.viewer-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; }
.viewer-acts .btn { width: 100%; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; max-height: 60vh; overflow: auto; }
.picker-grid button { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; }
.picker-grid button:hover { border-color: var(--accent); }
.picker-grid img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 提示 ---------- */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; pointer-events: none; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; animation: rise .22s var(--ease); pointer-events: auto; }
.toast i { margin-top: 2px; }
.toast.ok i { color: var(--ok); } .toast.err i { color: var(--danger); }

/* ---------- 角色库 ---------- */
.tip-box { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 14px; color: var(--text-2); font-size: 14px; margin-bottom: 20px; }
.tip-box i { color: var(--accent-ink); font-size: 20px; margin-top: 1px; }
.tip-box b { color: var(--text); }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.char-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; text-align: left; padding: 0; display: flex; flex-direction: column; color: var(--text); }
.char-imgs { display: grid; aspect-ratio: 3 / 4; background: var(--surface-2); gap: 2px; }
.char-imgs.n2 { grid-template-columns: 2fr 1fr; } .char-imgs.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.char-imgs.n3 img:first-child { grid-row: 1 / 3; }
.char-imgs img { width: 100%; height: 100%; object-fit: cover; min-height: 0; }
.char-body { padding: 10px 12px 12px; display: grid; gap: 6px; }
.char-card .nm { font-weight: 650; }
.char-card .nm small, .char-chip small { font-size: 11px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px; margin-left: 4px; }
.char-card .desc { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.char-card .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.char-grid.pick { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); max-height: 60vh; overflow: auto; }
.char-grid.pick .char-card { cursor: pointer; border-width: 2px; }
.char-grid.pick .char-card img { aspect-ratio: 3 / 4; width: 100%; object-fit: cover; }
.char-grid.pick .char-card .nm { padding: 8px 10px; font-size: 14px; }
.char-grid.pick .char-card.on { border-color: var(--accent); }
.char-grid.pick .tick { position: absolute; top: 6px; right: 6px; font-size: 24px; color: var(--accent); filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.char-sel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.char-chip { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 4px 0 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-strong); font-size: 13.5px; }
.char-chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.char-chip.scene img { border-radius: 6px; }
.char-chip > .ph { font-size: 14px; color: var(--accent-ink); margin-right: -3px; }
.char-card.scene .char-imgs { aspect-ratio: 4 / 3; }
.char-chip button { width: 24px; height: 24px; border: 0; background: transparent; color: var(--muted); border-radius: 50%; display: grid; place-items: center; padding: 0; }
.char-chip button:hover { color: var(--text); background: var(--surface-3); }
.slots { display: flex; gap: 8px; flex-wrap: wrap; }
.slot { position: relative; width: 88px; height: 112px; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line-strong); }
.slot img { width: 100%; height: 100%; object-fit: cover; }
.slot.empty { display: grid; place-content: center; justify-items: center; gap: 4px; color: var(--text-2); font-size: 12px; border-style: dashed; padding: 0; }
.slot.empty i { font-size: 20px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- 短剧 ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.proj-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s; }
.proj-card:hover { border-color: var(--line-strong); }
.proj-cover { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; color: var(--line-strong); overflow: hidden; }
.proj-cover i { font-size: 36px; }
.proj-cover video { width: 100%; height: 100%; object-fit: cover; }
.proj-cover .kind { position: absolute; top: 8px; left: 8px; height: 24px; padding: 0 8px; border-radius: 999px; background: rgba(10, 11, 13, .62); color: #fff; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.proj-cover .kind i { font-size: 14px; color: var(--accent); }
.proj-body { padding: 10px 12px 12px; display: grid; gap: 3px; }
.proj-body span { font-size: 12.5px; color: var(--muted); }
.proj-page { max-width: 1180px; }
.proj-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.proj-head h1 { font-size: 21px; margin: 0; font-weight: 650; cursor: text; }
.proj-head h1:hover { text-decoration: underline dotted var(--muted); text-underline-offset: 4px; }
.proj-meta { color: var(--muted); font-size: 13.5px; }
.grow { flex: 1; }
.card-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px; margin-bottom: 18px; }
details.card-box summary { cursor: pointer; display: flex; gap: 12px; align-items: baseline; list-style: none; }
details.card-box summary::-webkit-details-marker { display: none; }
details.card-box summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; flex: none; align-self: center; }
details.card-box[open] summary::before { transform: rotate(45deg); }
details.card-box summary span { font-size: 13px; color: var(--muted); }
details.card-box textarea { margin-top: 12px; min-height: 160px; }
.row-acts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.shots-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; }
.shots-head h2 { margin: 0; font-size: 17px; }
.shots-head h2 small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.shots { display: grid; gap: 12px; margin-bottom: 22px; }
.shot { display: grid; grid-template-columns: 200px 1fr; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px; }
.shot-left { display: grid; gap: 8px; align-content: start; }
.shot-media { position: relative; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.shot-media.r9-16 { aspect-ratio: 9 / 16; } .shot-media.r16-9 { aspect-ratio: 16 / 9; }
.shot-media video { width: 100%; height: 100%; object-fit: contain; background: #0a0b0c; }
.shot-media .pending, .shot-media .failed { font-size: 12.5px; }
.shot-media .bar { width: 120px; }
.takes { display: flex; gap: 6px; flex-wrap: wrap; }
.take { position: relative; width: 40px; height: 40px; border-radius: 6px; overflow: hidden; border: 2px solid transparent; background: var(--surface-2); padding: 0; display: grid; place-items: center; color: var(--muted); }
.take video { width: 100%; height: 100%; object-fit: cover; }
.take span { position: absolute; bottom: 1px; right: 3px; font-size: 10px; color: #fff; text-shadow: 0 1px 2px #000; }
.take.on { border-color: var(--accent); }
.take.bad { color: var(--danger); }
.take .spin { width: 14px; height: 14px; }
.shot-main { display: grid; gap: 8px; align-content: start; min-width: 0; }
.shot-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.shot-no { font-size: 14px; margin-right: 4px; }
.shot-bar select { width: auto; height: 32px; padding: 3px 28px 3px 10px; font-size: 13px; }
.shot-bar .icon-btn { width: 30px; height: 30px; }
.shot-bar .icon-btn:disabled { opacity: .35; cursor: default; }
.shot-main textarea { min-height: 72px; }
.shot-main input[data-f="note"] { font-size: 13px; padding: 7px 10px; }
.first-img { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.first-img img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.shot-acts { display: flex; align-items: center; gap: 8px; }
.save-note { font-size: 12px; color: var(--ok); }
.final-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.final-head h2 { margin: 0 0 4px; font-size: 17px; }
.final-head p { margin: 0; }
.final-body { display: flex; gap: 18px; margin-top: 14px; flex-wrap: wrap; align-items: flex-start; }
.final-video { background: #0a0b0c; border-radius: 10px; overflow: hidden; }
.final-video.r9-16 { width: 300px; aspect-ratio: 9 / 16; } .final-video.r16-9 { width: min(640px, 100%); aspect-ratio: 16 / 9; }
.final-video video { width: 100%; height: 100%; }
.final-info p { margin: 0 0 8px; }

/* ---------- 「我的」页（手机） ---------- */
.more-list { display: grid; gap: 8px; }
.more-list a, .more-list button { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); color: var(--text); width: 100%; text-align: left; font-size: 15px; }
.more-list .badge { margin-left: auto; }
.more-user { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.more-user .avatar { width: 44px; height: 44px; font-size: 18px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .studio { grid-template-columns: 340px 1fr; }
  .viewer { grid-template-columns: 1fr; }
  .viewer-side { border-left: 0; border-top: 1px solid var(--line); }
  .viewer-media { max-height: 60dvh; } .viewer-media img, .viewer-media video { max-height: 60dvh; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); background: var(--surface);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11.5px; color: var(--muted); position: relative; }
  .tabbar a i { font-size: 22px; }
  .tabbar a.on { color: var(--text); } .tabbar a.on i { color: var(--accent-ink); }
  .tabbar .badge { position: absolute; top: 3px; left: calc(50% + 6px); height: 17px; min-width: 17px; font-size: 11px; padding: 0 4px; }
  .page { padding: 18px 16px 32px; }
  .studio { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; padding: 18px 16px 20px; }
  .go-bar { position: static; margin: 0; padding: 0; background: none; }
  .results { padding: 18px 16px 32px; overflow: visible; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid.lg { grid-template-columns: repeat(2, 1fr); }
  .card .p { font-size: 12.5px; }
  .card .fav { opacity: 1; }
  .chat { grid-template-columns: 1fr; }
  .convs { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--shadow); }
  .convs.open { transform: none; }
  .thread-head { padding: 10px 12px; }
  .msgs { padding: 16px 14px 8px; }
  .composer { padding: 8px 12px 12px; }
  .starters { grid-template-columns: 1fr; }
  .toolbar .search { width: 100%; }
  .row { grid-template-columns: 52px 1fr; }
  .row .thumb { width: 52px; height: 52px; }
  .row > :last-child { grid-column: 1 / -1; justify-self: end; }
  .viewer { max-height: none; }
  .shot { grid-template-columns: 1fr; }
  .shot-left { grid-template-columns: 120px 1fr; align-items: start; }
  .final-video.r9-16 { width: 100%; max-width: 320px; }
}
@media (min-width: 861px) { .only-mobile { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
