/* 宠片工作室 · 剪映风深色主题 */
:root {
  --bg: #17171c;
  --bg2: #1e1e26;
  --bg3: #26262f;
  --panel: #202028;
  --line: #33333e;
  --txt: #e8e8ee;
  --txt2: #9a9aa8;
  --accent: #3ec8ff;
  --accent2: #2f7cf6;
  --pink: #ff4d7e;
  --gold: #ffd65c;
  --ok: #4ade80;
  --clip-img: #2c4a6e;
  --clip-vid: #5e3a8a;
  --clip-txt: #7a5a20;
  --clip-aud: #1f6e54;
  --clip-title: #8a3a3a;
  --radius: 10px;
  font-size: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--txt);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none;
}
button {
  background: var(--bg3); color: var(--txt); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px;
  font-family: inherit; transition: background .15s, border-color .15s;
}
button:hover { background: #32323e; border-color: #4a4a5a; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--accent2), var(--accent)); border: none; color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.12); }
button.ghost { background: transparent; }
button.danger { color: #ff8098; }
input[type=text], input[type=number], select, textarea {
  background: var(--bg); color: var(--txt); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: inherit;
  outline: none; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #3a3a46; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 布局骨架 ===== */
#app { display: grid; grid-template-rows: 52px 1fr 260px; height: 100vh; }
#app.start { grid-template-rows: 52px 1fr; }
#app.start #timeline { display: none; }

/* 顶栏 */
#topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
#topbar .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
#topbar .logo .mark {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; font-size: 13px;
}
#topbar .proj-name { color: var(--txt2); font-size: 13px; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topbar .spacer { flex: 1; }
#topbar .save-state { font-size: 12px; color: var(--txt2); }
#topbar .save-state.dirty { color: var(--gold); }

/* 主区:左面板 + 预览 + 属性 */
#main { display: grid; grid-template-columns: 320px 1fr 300px; min-height: 0; }
#left {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
#left .tabs { display: flex; border-bottom: 1px solid var(--line); }
#left .tabs button {
  flex: 1; border: none; background: none; border-radius: 0; padding: 11px 4px;
  color: var(--txt2); font-size: 13px; border-bottom: 2px solid transparent;
}
#left .tabs button.on { color: var(--txt); border-bottom-color: var(--accent); background: none; }
#left .pane { flex: 1; overflow-y: auto; padding: 12px; display: none; min-height: 0; }
#left .pane.on { display: block; }

/* 素材库 */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.media-item {
  position: relative; border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); aspect-ratio: 3/4; background: var(--bg3);
}
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .badge {
  position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.65);
  font-size: 10px; padding: 1px 6px; border-radius: 4px; color: var(--gold);
}
.media-item .dur {
  position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.65);
  font-size: 10px; padding: 1px 5px; border-radius: 4px;
}
.media-item.sensitive img { filter: grayscale(1) brightness(.5); }
.media-item.sensitive::after {
  content: "敏感"; position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--pink); font-size: 12px; font-weight: 700;
}
.media-item .add {
  position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 15px; line-height: 1;
  display: none; place-items: center; padding: 0;
}
.media-item:hover .add { display: grid; }
.media-cat { margin: 14px 0 8px; font-size: 12px; color: var(--txt2); display: flex; gap: 8px; align-items: center; }
.media-cat::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* 预览区 */
#center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 14px; min-width: 0; background: radial-gradient(ellipse at 50% 30%, #1c1c24, var(--bg));
}
#phone {
  position: relative; aspect-ratio: 9/16; height: min(100%, 58vh); max-width: 100%;
  background: #000; border-radius: 14px; overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.5), 0 0 0 1px var(--line);
}
#phone .layer { position: absolute; inset: 0; display: none; }
#phone .layer.active { display: block; }
#phone img.fill, #phone video.fill { width: 100%; height: 100%; object-fit: contain; }
#phone .img-wrap { position: absolute; inset: 0; }
#phone .fill-bg { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: blur(26px) brightness(.55); transform: scale(1.15); }
#phone .fill-fg { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; will-change: transform; }
#phone .title-card {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 32px; text-align: center;
  background: linear-gradient(180deg, #0c608a, #081e30);
}
#phone .title-card .big { font-size: clamp(15px, 4vh, 34px); font-weight: 800; line-height: 1.5; word-break: break-word; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
#phone .title-card .bar { width: 30%; height: 3px; background: var(--gold); border-radius: 2px; }
#phone .subtitle {
  position: absolute; left: 8%; right: 8%; bottom: 12%; text-align: center;
  font-size: clamp(13px, 2.6vh, 22px); font-weight: 700; line-height: 1.45;
  color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 4px #000; padding: 4px;
}
#phone .black { position: absolute; inset: 0; background: #000; }
#player-ctl { display: flex; align-items: center; gap: 10px; }
#player-ctl .t { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--txt2); min-width: 92px; text-align: center; }
#player-ctl button { padding: 6px 12px; }

/* 属性面板 */
#right {
  background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
#right h3 { font-size: 13px; color: var(--txt2); font-weight: 600; }
#right .empty { color: var(--txt2); font-size: 12px; line-height: 1.8; padding-top: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--txt2); }
.field .row { display: flex; gap: 8px; align-items: center; }
.field .row > * { flex: 1; }
.seg-group { display: flex; gap: 6px; }
.seg-group button { flex: 1; padding: 5px 4px; font-size: 12px; }
.seg-group button.on { border-color: var(--accent); color: var(--accent); }
.clip-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.clip-actions .wide { grid-column: 1 / -1; }

/* ===== 时间线 ===== */
#timeline {
  border-top: 1px solid var(--line); background: var(--bg2);
  display: flex; flex-direction: column; min-height: 0;
}
#tl-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}
#tl-toolbar button { padding: 4px 10px; font-size: 12px; }
#tl-toolbar .zoom { display: flex; align-items: center; gap: 6px; margin-left: auto; font-size: 12px; color: var(--txt2); }
#tl-wrap { flex: 1; overflow: auto; position: relative; touch-action: none; }
#tl-canvas { position: relative; min-width: 100%; }
#ruler {
  height: 26px; position: sticky; top: 0; z-index: 5; background: var(--bg2);
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid #3c3c48; font-size: 10px; color: var(--txt2); padding-left: 3px; padding-top: 4px; pointer-events: none; }
.tick.major { border-left-color: #5a5a6a; }
.track-label {
  position: sticky; left: 0; z-index: 4; width: 56px; height: 54px; margin: 6px 0 6px 6px;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; color: var(--txt2); gap: 2px; float: left; clear: both; pointer-events: none;
}
.track-lane { position: relative; height: 54px; margin: 6px 0 6px 66px; margin-right: 12px; }
.track-lane.drop-hint { outline: 1px dashed #4a4a5a; outline-offset: 2px; border-radius: 6px; }
.clip {
  position: absolute; top: 0; height: 100%; border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.18); cursor: grab; font-size: 11px;
  display: flex; align-items: center; padding: 0 6px; gap: 4px; touch-action: none;
}
.clip:active { cursor: grabbing; }
.clip.selected { border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); z-index: 3; }
.clip .label {
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,.8); font-weight: 600;
}
.clip img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .85; pointer-events: none; }
.clip .label { position: relative; z-index: 2; }
.clip.video { background: var(--clip-vid); }
.clip.image { background: var(--clip-img); }
.clip.title { background: var(--clip-title); }
.clip.subtitle { background: var(--clip-txt); }
.clip.tts, .clip.audio { background: var(--clip-aud); }
.clip .hnd { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; z-index: 4; }
.clip .hnd.l { left: 0; } .clip .hnd.r { right: 0; }
.clip .hnd::after { content: ""; position: absolute; top: 30%; bottom: 30%; left: 3px; width: 2px; background: rgba(255,255,255,.5); border-radius: 1px; }
#playhead {
  position: absolute; top: 0; bottom: 0; width: 1px; background: var(--pink);
  z-index: 8; pointer-events: none;
}
#playhead::before {
  content: ""; position: absolute; top: 0; left: -5px; border: 6px solid transparent;
  border-top: 9px solid var(--pink);
}
.clip-ghost { position: absolute; height: 54px; border: 1px dashed var(--accent); border-radius: 6px; z-index: 6; pointer-events: none; background: rgba(62,200,255,.08); }

/* ===== 开始页 ===== */
#start-page { overflow-y: auto; padding: 28px; }
#start-page .hero { max-width: 980px; margin: 0 auto; }
#start-page h1 { font-size: 26px; margin-bottom: 6px; }
#start-page .sub { color: var(--txt2); margin-bottom: 22px; line-height: 1.7; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 14px; }
.proj-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: border-color .15s, transform .15s;
}
.proj-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.proj-card .name { font-weight: 700; margin-bottom: 4px; }
.proj-card .meta { font-size: 12px; color: var(--txt2); line-height: 1.7; }
.proj-card .badge-line { margin-top: 8px; font-size: 11px; color: var(--ok); }
.start-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lan-box {
  display: flex; gap: 16px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 18px 0;
}
.lan-box img { width: 108px; height: 108px; border-radius: 8px; background: #fff; padding: 4px; }
.lan-box .txt { font-size: 13px; line-height: 1.9; color: var(--txt2); }
.lan-box .txt b { color: var(--txt); }

/* ===== 对话框 / 提示 ===== */
dialog {
  background: var(--bg2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; min-width: 380px; max-width: 92vw; max-height: 86vh;
}
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
dialog h3 { margin-bottom: 14px; font-size: 16px; }
dialog .body { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; }
dialog .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.progress-outer { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.progress-inner { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .4s; }
.draft-view { font-size: 13px; line-height: 1.8; color: var(--txt);
  background: var(--bg); padding: 12px; border-radius: 8px; max-height: 46vh; overflow-y: auto; user-select: text; }
.draft-view h2, .draft-view h3, .draft-view h4 { margin: 10px 0 6px; color: var(--accent); }
.draft-view h2 { font-size: 15px; } .draft-view h3 { font-size: 14px; } .draft-view h4 { font-size: 13px; }
.draft-view code { background: var(--bg3); border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.draft-view ul { padding-left: 20px; }
.draft-view .md-img { display: block; max-width: 100%; max-height: 300px; margin: 8px auto;
  border-radius: 8px; border: 1px solid var(--line); }
.md-ref { display: flex; align-items: center; gap: 10px; margin: 6px 0; padding: 6px;
  background: var(--bg3); border-radius: 8px; border: 1px solid var(--line); }
.md-ref img { width: 54px; height: 72px; object-fit: cover; border-radius: 6px; flex: none; }
.md-ref span { font-size: 11px; color: var(--txt2); word-break: break-all; }
#draft-gallery { max-height: 30vh; overflow-y: auto; }
.draft-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.draft-gallery-grid a { position: relative; display: block; aspect-ratio: 3/4; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--line); }
.draft-gallery-grid img { width: 100%; height: 100%; object-fit: cover; }
.draft-gallery-grid span { position: absolute; left: 4px; bottom: 4px; font-size: 10px;
  background: rgba(0,0,0,.65); padding: 1px 6px; border-radius: 4px; color: var(--gold); }
#toast-wrap { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 99;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--bg3); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 18px rgba(0,0,0,.4);
  animation: pop .2s;
}
.toast.err { border-color: var(--pink); color: #ffb0c4; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }

/* ===== 移动端 ===== */
@media (max-width: 920px) {
  #app { grid-template-rows: 48px 1fr 220px; }
  #main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #left { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: 46vh;
    z-index: 20; border-top: 1px solid var(--line); display: none; }
  #left.open { display: flex; }
  #right { display: none; position: fixed; right: 0; bottom: 0; width: 100%; height: 46vh;
    z-index: 21; border-top: 1px solid var(--line); }
  #right.open { display: flex; }
  #center { padding: 8px; }
  #phone { height: 44vh; }
  #tl-toolbar .mob-btn { display: inline-block; }
  .track-label { width: 44px; margin-left: 4px; }
  .track-lane { margin-left: 52px; }
  dialog { min-width: 86vw; }
}
#btn-media-drawer, #btn-props-drawer { display: none; }
@media (max-width: 920px) {
  #btn-media-drawer, #btn-props-drawer { display: inline-block; }
}

/* ---------- 分步成片向导 ---------- */
.wiz-steps{display:flex;gap:8px;margin:2px 0 12px}
.wiz-steps span{flex:1;text-align:center;padding:6px 4px;border-radius:6px;background:var(--bg2,#232330);color:var(--txt2,#9aa);font-size:12px}
.wiz-steps span.on{background:var(--acc,#176b5b);color:#fff}
.wiz-row2{display:flex;gap:10px;align-items:end}
.wiz-row2 .field{flex:1}
.wiz-row2 button{white-space:nowrap}
.seg-row{border:1px solid var(--bd,#333);border-radius:8px;padding:8px;margin-top:8px;display:flex;flex-direction:column;gap:6px}
.seg-head{display:flex;align-items:center;gap:8px;font-size:12px}
.seg-head b{color:var(--txt2,#9aa)}
.seg-dur{color:var(--txt2,#9aa)}
.seg-kind{flex:1}
.seg-del{padding:2px 8px}
.seg-nar,.seg-ov{width:100%;box-sizing:border-box}
#wiz-segs{max-height:38vh;overflow:auto}

/* ---------- 替换素材选择器 ---------- */
#pick-grid{max-height:46vh;overflow:auto}
.prop-src{font-size:12px;color:var(--txt2,#9aa);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-bottom:6px}
.prop-src + button{width:100%}

/* ---------- 快捷编辑文字 ---------- */
#qe-text{width:100%;box-sizing:border-box}

/* 病历质量体检提示(分步成片向导①) */
#wiz-quality{background:#fff7ed;border:1px solid #fdba74;border-radius:8px;padding:8px 10px;font-size:12px;line-height:1.55;color:#7c2d12;margin:0 0 10px}
