/* ==============================================================================
   WP3 · 小说 / 剧本工作台 —— apple-studio.css
   ------------------------------------------------------------------------------
   范围：编辑器外壳换令牌；右侧 Agent 的标题栏（压缩条 + 对话历史）、
        输入区模型 chip、对话历史弹层、Skill chips 的视觉统一。
   不碰：正文排版与纸色（.n-body / .s-episode-body 保持楷体/纸色）、
        作品库数据流、向导流程、编辑器内的「润色本集 / 润色选区」。
   ============================================================================== */

/* ---------- Agent 面板外壳 ---------- */
html[data-apple="on"] .n-agent{
  border-left:1px solid var(--line);
  background:var(--surface-1);
}
html[data-apple="on"] .n-agent-head{
  gap:6px;
  padding:12px 14px;
  background:var(--surface-1);
  border-bottom:1px solid var(--line);
}
html[data-apple="on"] .n-agent-head h2{
  font-size:var(--text-13);
  font-weight:600;
  letter-spacing:0;
  color:var(--text-1);
}
html[data-apple="on"] .n-agent-head .n-icon-tool{ width:28px; height:28px; min-width:28px; }
html[data-apple="on"] .n-agent-tabs{ border-bottom:1px solid var(--line); }
html[data-apple="on"] .n-agent-tab.is-active{ color:var(--text-1); }
html[data-apple="on"] .n-agent-scroll{ background:var(--surface-1); }

/* ---------- 上下文压缩条（contextMeterHTML） ---------- */
html[data-apple="on"] .n-ctx-meter{
  display:inline-flex; align-items:center; gap:4px;
  height:22px; padding:0 8px;
  border:1px solid var(--line);
  border-radius:999px;
  font:500 var(--text-11)/1 var(--font-mono);
  font-variant-numeric:tabular-nums;
  color:var(--text-3);
  white-space:nowrap;
  cursor:default;
}
html[data-apple="on"] .n-ctx-meter.is-hot{ border-color:color-mix(in srgb,var(--warning) 55%,var(--line)); color:var(--warning); }
html[data-apple="on"] .n-ctx-compress{
  height:22px; padding:0 8px;
  border-radius:999px;
  font-size:var(--text-11);
  border:1px solid var(--line);
  background:transparent; color:var(--text-2);
}
html[data-apple="on"] .n-ctx-compress:hover{ background:var(--surface-3); color:var(--text-1); }

/* ---------- 输入区模型 chip（原来是一行灰字） ---------- */
html[data-apple="on"] .n-model-chip{
  display:inline-flex; align-items:center; gap:5px;
  height:24px; max-width:60%;
  padding:0 8px;
  border:1px solid var(--line);
  border-radius:var(--radius-control);
  background:var(--surface-2);
  color:var(--text-2);
  font:inherit; font-size:var(--text-11); font-weight:500;
  cursor:pointer;
}
html[data-apple="on"] .n-model-chip span{
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
html[data-apple="on"] .n-model-chip:hover{ border-color:var(--line-strong); color:var(--text-1); }

/* ---------- 对话历史弹层 ---------- */
html[data-apple="on"] .n-threads{ display:flex; flex-direction:column; gap:0; }
html[data-apple="on"] .n-threads header{
  display:flex; align-items:center; justify-content:space-between;
  padding:4px 6px 8px;
  border-bottom:1px solid var(--line);
}
html[data-apple="on"] .n-threads header b{ font-size:var(--text-12); font-weight:600; color:var(--text-2); }
html[data-apple="on"] .n-threads header button{
  border:0; background:none; padding:0 2px;
  color:var(--text-2); font:inherit; font-size:var(--text-12); cursor:pointer;
}
html[data-apple="on"] .n-threads header button:hover{ color:var(--text-1); }
html[data-apple="on"] .n-thread-list{ display:flex; flex-direction:column; padding:4px 0; max-height:280px; overflow:auto; }
html[data-apple="on"] .n-thread{
  display:grid; grid-template-columns:minmax(0,1fr) auto auto;
  align-items:center; gap:8px;
  padding:7px 8px;
  border:1px solid transparent; border-radius:8px;
  background:transparent; color:inherit;
  font:inherit; text-align:left; cursor:pointer;
}
html[data-apple="on"] .n-thread:hover{ background:var(--surface-3); }
html[data-apple="on"] .n-thread.is-on{ border-color:var(--line-strong); background:var(--surface-3); }
html[data-apple="on"] .n-thread-title{
  font-size:var(--text-12); color:var(--text-1);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
html[data-apple="on"] .n-thread small{ font:500 var(--text-11)/1 var(--font-mono); color:var(--text-3); white-space:nowrap; }
html[data-apple="on"] .n-thread em{ font-style:normal; font-size:var(--text-11); color:var(--text-3); }
html[data-apple="on"] .n-thread-empty{ margin:10px 8px; font-size:var(--text-12); color:var(--text-3); }
html[data-apple="on"] .n-threads footer{
  display:flex; gap:6px;
  padding:8px 6px 2px;
  border-top:1px solid var(--line);
}
html[data-apple="on"] .n-threads footer button{
  flex:1;
  height:28px;
  border:1px solid var(--line); border-radius:8px;
  background:transparent; color:var(--text-2);
  font:inherit; font-size:var(--text-12); cursor:pointer;
}
html[data-apple="on"] .n-threads footer button:hover{ background:var(--surface-3); color:var(--text-1); }
html[data-apple="on"] .n-threads footer button.is-danger:hover{ border-color:var(--danger); color:var(--danger); }

/* ---------- 对话气泡：与工作台同一套节奏 ---------- */
html[data-apple="on"] .n-agent .n-message.n-user{
  border-radius:14px;
  background:var(--surface-3);
  color:var(--text-1);
}
html[data-apple="on"] .n-agent .n-agent-message .n-message-body{ font-size:var(--text-15); line-height:1.8; }

/* ---------- 作品库卡片的字体层级（只动外壳，不动数据） ---------- */
html[data-apple="on"] .n-books .n-book,
html[data-apple="on"] .s-project-grid .s-project{
  border-radius:var(--radius-card);
  border-color:var(--line);
  background:var(--surface-1);
}
html[data-apple="on"] .n-books .n-book h3,
html[data-apple="on"] .s-project-grid .s-project h3{ font-size:var(--text-15); font-weight:600; }

/* ---------- 正文与纸色保持不变：这里只固定字体族，不改字号/行高/颜色 ---------- */
html[data-apple="on"] .n-body,
html[data-apple="on"] .s-episode-body{ font-family:inherit; }

/* ── Agent 空状态的魔女插画（独立巡检发现：深色下几乎看不见，且 AGENTS §9.6.1 只留站点头像）──
   换成中性圆点标记，深浅两色都清楚。 */
html[data-apple="on"] .n-agent-empty-mark{
  display:grid; place-items:center;
  width:34px; height:34px;
  border:1px solid var(--line); border-radius:50%;
  background:var(--surface-2);
}
html[data-apple="on"] .n-agent-empty-mark img{ display:none; }
html[data-apple="on"] .n-agent-empty-mark::after{
  content:""; width:6px; height:6px; border-radius:50%; background:var(--text-3);
}
/* 2026-11-04 · 作品库空态：原来是一块占满整行的大虚线框，压成 180px 的卡片，
   和一键成片项目库的空态同一套语言。 */
html[data-apple="on"] #app .s-project-grid .empty,
html[data-apple="on"] #app .n-books .empty{
  grid-column:1/-1;
  min-height:180px;
  padding:26px;
  border:1px dashed var(--line-strong);
  border-radius:14px;
  background:transparent;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px;
}
html[data-apple="on"] #app .s-project-grid .empty p,
html[data-apple="on"] #app .n-books .empty p{ margin:0; font-size:13px; color:var(--text-3) }

/* ---------- Updream Cinema Liquid Glass · 工作台流转按钮 & 小说改编台 ---------- */
html[data-apple="on"] .n-work-head .n-handoff-pill{
  display:inline-flex;
  align-items:center;
  gap:5px;
  height:30px;
  min-height:30px;
  padding:0 11px;
  border-radius:999px;
  border:1px solid var(--lg-rim, var(--line));
  background:var(--lg-glass-pill, var(--surface-2));
  color:var(--lg-text-1, var(--text));
  font-size:12px;
  font-weight:500;
  white-space:nowrap;
  flex-shrink:0;
  transition:border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
html[data-apple="on"] .n-work-head .n-handoff-pill:hover{
  border-color:var(--lg-rim-glow, var(--accent));
  background:var(--lg-glass-pill-hover, var(--surface-3));
  transform:translateY(-1px);
}
html[data-apple="on"] .n-work-head .n-handoff-pill.is-accent{
  border-color:color-mix(in srgb, var(--accent, #f5f5f7) 36%, var(--lg-rim, var(--line)));
  background:color-mix(in srgb, var(--accent, #f5f5f7) 10%, var(--lg-glass-pill, var(--surface-2)));
  color:var(--lg-text-1, var(--text));
}
html[data-apple="on"] .n-work-head .n-handoff-pill.is-accent:hover{
  border-color:var(--accent, #ffffff);
  background:color-mix(in srgb, var(--accent, #ffffff) 16%, var(--lg-glass-pill, var(--surface-2)));
  box-shadow:0 6px 18px rgba(0, 0, 0, 0.28);
}
@media(max-width:640px){
  html[data-apple="on"] .n-work-head .n-handoff-pill{
    padding:0 9px;
    min-width:34px;
    min-height:34px;
    justify-content:center;
  }
  html[data-apple="on"] .n-work-head .n-handoff-pill span{ display:none; }
}

/* ---------- 小说改编工作区 (#/scripts/adapt) & 导演模式弹窗 ---------- */
html[data-apple="on"] .s-adapt-grid{
  gap:20px;
  align-items:start;
}
html[data-apple="on"] .s-adapt-panel{
  display:flex;
  flex-direction:column;
  gap:16px;
  min-width:0;
  padding:20px;
  border-radius:18px;
  border:1px solid var(--lg-rim, var(--line));
  background:var(--lg-glass-card, var(--surface-1));
  box-shadow:var(--lg-shadow-card, var(--shadow));
  backdrop-filter:var(--lg-blur, blur(18px) saturate(165%));
  -webkit-backdrop-filter:var(--lg-blur, blur(18px) saturate(165%));
}
html[data-apple="on"] .s-adapt-side{
  position:sticky;
  top:20px;
}
html[data-apple="on"] .s-adapt-panel .field{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin:0;
}
html[data-apple="on"] .s-chapter-import{
  border:1px solid var(--lg-rim, var(--line));
  border-radius:14px;
  padding:12px 14px;
  background:var(--lg-glass-pill, var(--surface-2));
}
html[data-apple="on"] .s-chapter-import summary{
  cursor:pointer;
  font-size:13px;
  font-weight:600;
  color:var(--lg-text-1, var(--text));
}
html[data-apple="on"] .s-chapter-import-list{
  max-height:240px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top:10px;
  padding-right:2px;
}
html[data-apple="on"] .s-chapter-import .s-chapter-choice{
  margin-bottom:0;
  padding:10px 12px;
  border-radius:10px;
  border-color:var(--lg-rim, var(--line));
  background:var(--lg-glass-card, var(--surface));
  color:var(--lg-text-1, var(--text));
  align-items:center;
}
html[data-apple="on"] .s-chapter-import .s-chapter-choice:hover{
  border-color:var(--lg-rim-glow, var(--accent));
  background:var(--lg-glass-card-hover, var(--surface-2));
}
html[data-apple="on"] .s-adapt-chapters-bar{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
}
html[data-apple="on"] .s-adapt-source{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding-top:10px;
  border-top:1px solid var(--lg-rim, var(--line));
  font-size:12px;
  color:var(--lg-text-2, var(--muted));
}
html[data-apple="on"] .s-director-send{
  display:flex;
  flex-direction:column;
  gap:12px;
}
html[data-apple="on"] .s-director-mode{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin:0;
}
html[data-apple="on"] .s-director-mode span{
  font-size:12px;
  font-weight:600;
  color:var(--lg-text-2, var(--muted));
}
@media(max-width:900px){
  html[data-apple="on"] .s-adapt-side{ position:static; }
}

/* ---------- #/write · LibTV 故事板创作台 (TV Director) 三模式直达入口 ---------- */
html[data-apple="on"] #app .apple-write .write-libtv-studio{
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:20px 22px;
  border-radius:20px;
  border:1px solid rgba(255,255,255,0.10);
  background:#0D0E12;
  color:#F4F4F6;
}
html[data-apple="on"] #app .apple-write .write-libtv-studio-head{
  display:flex;
  flex-wrap:wrap;
  align-items:flex-end;
  justify-content:space-between;
  gap:10px 16px;
}
html[data-apple="on"] #app .apple-write .write-libtv-studio-copy{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0;
}
html[data-apple="on"] #app .apple-write .write-libtv-studio-kicker{
  margin:0;
  font-size:10.5px;
  font-weight:650;
  letter-spacing:0.14em;
  text-transform:uppercase;
  color:#8A8B93;
}
html[data-apple="on"] #app .apple-write .write-libtv-studio-title{
  margin:0;
  font-size:18px;
  line-height:1.25;
  font-weight:700;
  letter-spacing:-0.015em;
  color:#F4F4F6;
}
html[data-apple="on"] #app .apple-write .write-libtv-studio-sub{
  margin:0;
  font-size:13px;
  line-height:1.5;
  color:#B2B3BA;
}
html[data-apple="on"] #app .apple-write .write-libtv-studio-badge{
  display:inline-flex;
  align-items:center;
  height:26px;
  padding:0 11px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.12);
  background:#16171C;
  font-size:11.5px;
  font-weight:500;
  color:#B2B3BA;
  white-space:nowrap;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
}
html[data-apple="on"] #app .apple-write .write-libtv-studio-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
}
html[data-apple="on"] #app .apple-write .write-libtv-launch-card{
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:10px;
  min-width:0;
  padding:18px 18px 16px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,0.11);
  background:#16171C;
  color:#F4F4F6;
  text-align:left;
  font:inherit;
  cursor:pointer;
  overflow:hidden;
  isolation:isolate;
  transition:transform 0.2s cubic-bezier(0.2,0.8,0.2,1), border-color 0.2s ease, background 0.2s ease;
}
html[data-apple="on"] #app .apple-write .write-libtv-launch-card:hover:not(:disabled),
html[data-apple="on"] #app .apple-write .write-libtv-launch-card:focus-visible{
  transform:translateY(-2px);
  border-color:rgba(255,255,255,0.26);
  background:#1C1D23;
  outline:none;
}
html[data-apple="on"] #app .apple-write .write-libtv-launch-card:hover .aw3-card-spot{
  opacity:1;
}
html[data-apple="on"] #app .apple-write .write-libtv-launch-card.is-loading,
html[data-apple="on"] #app .apple-write .write-libtv-launch-card:disabled{
  opacity:0.65;
  cursor:wait;
  transform:none;
}
html[data-apple="on"] #app .apple-write .write-libtv-card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  width:100%;
  gap:10px;
}
html[data-apple="on"] #app .apple-write .write-libtv-card-ico{
  display:grid;
  place-items:center;
  width:36px;
  height:36px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.14);
  background:#0D0E12;
  color:#F4F4F6;
}
html[data-apple="on"] #app .apple-write .write-libtv-card-eyebrow{
  font-size:10.5px;
  font-weight:650;
  letter-spacing:0.12em;
  color:#8A8B93;
}
html[data-apple="on"] #app .apple-write .write-libtv-card-title{
  margin:2px 0 0;
  font-size:15.5px;
  line-height:1.3;
  font-weight:680;
  color:#F4F4F6;
}
html[data-apple="on"] #app .apple-write .write-libtv-card-desc{
  margin:0;
  font-size:12.5px;
  line-height:1.55;
  color:#B2B3BA;
  flex:1 1 auto;
}
html[data-apple="on"] #app .apple-write .write-libtv-launch-cta{
  display:inline-flex;
  align-items:center;
  gap:6px;
  height:32px;
  padding:0 14px;
  margin-top:4px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.92);
  background:#FFFFFF;
  color:#0D0E12;
  font-size:12.5px;
  font-weight:650;
  transition:background 0.18s ease, transform 0.18s ease;
}
html[data-apple="on"] #app .apple-write .write-libtv-launch-card:hover:not(:disabled) .write-libtv-launch-cta{
  background:#EAEAEF;
}
html[data-apple="on"] #app .apple-write .write-libtv-launch-cta i{
  display:inline-flex;
  align-items:center;
  transition:transform 0.2s ease;
}
html[data-apple="on"] #app .apple-write .write-libtv-launch-card:hover:not(:disabled) .write-libtv-launch-cta i{
  transform:translateX(2px);
}

/* 日间模式 (.theme-light / [data-theme="light"] / [data-theme="day"]) */
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio,
.theme-light #app .apple-write .write-libtv-studio{
  border-color:rgba(17,17,20,0.11);
  background:#F5F5F7;
  color:#111114;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio-kicker,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio-kicker,
.theme-light #app .apple-write .write-libtv-studio-kicker,
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-card-eyebrow,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-card-eyebrow,
.theme-light #app .apple-write .write-libtv-card-eyebrow{
  color:#71727A;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio-title,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio-title,
.theme-light #app .apple-write .write-libtv-studio-title,
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-card-title,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-card-title,
.theme-light #app .apple-write .write-libtv-card-title{
  color:#111114;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio-sub,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio-sub,
.theme-light #app .apple-write .write-libtv-studio-sub,
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-card-desc,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-card-desc,
.theme-light #app .apple-write .write-libtv-card-desc{
  color:#55565C;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio-badge,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-studio-badge,
.theme-light #app .apple-write .write-libtv-studio-badge{
  border-color:rgba(17,17,20,0.12);
  background:#FFFFFF;
  color:#55565C;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-card,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-card,
.theme-light #app .apple-write .write-libtv-launch-card{
  border-color:rgba(17,17,20,0.11);
  background:#FFFFFF;
  color:#111114;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-card:hover:not(:disabled),
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-card:focus-visible,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-card:hover:not(:disabled),
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-card:focus-visible,
.theme-light #app .apple-write .write-libtv-launch-card:hover:not(:disabled),
.theme-light #app .apple-write .write-libtv-launch-card:focus-visible{
  border-color:rgba(17,17,20,0.26);
  background:#EFEFF2;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-card-ico,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-card-ico,
.theme-light #app .apple-write .write-libtv-card-ico{
  border-color:rgba(17,17,20,0.12);
  background:#F5F5F7;
  color:#111114;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-cta,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-cta,
.theme-light #app .apple-write .write-libtv-launch-cta{
  border-color:#111114;
  background:#111114;
  color:#FFFFFF;
}
:root:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-card:hover:not(:disabled) .write-libtv-launch-cta,
html:is([data-theme="day"],[data-theme="light"],.theme-light) #app .apple-write .write-libtv-launch-card:hover:not(:disabled) .write-libtv-launch-cta,
.theme-light #app .apple-write .write-libtv-launch-card:hover:not(:disabled) .write-libtv-launch-cta{
  background:#28282E;
}

@media(max-width:960px){
  html[data-apple="on"] #app .apple-write .write-libtv-studio-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}
@media(max-width:640px){
  html[data-apple="on"] #app .apple-write .write-libtv-studio{
    padding:16px 14px;
    border-radius:16px;
  }
  html[data-apple="on"] #app .apple-write .write-libtv-studio-grid{
    grid-template-columns:minmax(0,1fr);
  }
}
