:root {
  color-scheme: light;
  --ink: #17233b;
  --muted: #667085;
  --paper: #f5f3ee;
  --surface: #fffefb;
  --line: #e3dfd5;
  --navy: #172a4d;
  --navy-2: #213a68;
  --gold: #ba8138;
  --gold-soft: #f3e7d2;
  --green: #21715b;
  --green-soft: #e2f2eb;
  --slate-soft: #eef0f3;
  --danger: #a53c3c;
  --shadow: 0 18px 50px rgba(31, 42, 68, 0.09);
  --ui-font-scale: 1;
  --custom-paper: #f5f3ee;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

html[data-theme="white"] { --paper: #ffffff; --surface: #ffffff; --line: #dedede; }
html[data-theme="gray"] { --paper: #eceff3; --surface: #f9fafb; --line: #d8dde5; }
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef2f8;
  --muted: #aab4c3;
  --paper: #151a23;
  --surface: #202733;
  --line: #394352;
  --slate-soft: #303846;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}
html[data-theme="custom"] { --paper: var(--custom-paper); }
html[data-theme="custom"][data-custom-tone="dark"] {
  color-scheme: dark;
  --ink: #f4f6fa;
  --muted: #c5ccd6;
  --surface: color-mix(in srgb, var(--custom-paper), white 8%);
  --line: color-mix(in srgb, var(--custom-paper), white 24%);
  --slate-soft: color-mix(in srgb, var(--custom-paper), white 14%);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  text-rendering: optimizeLegibility;
}

.app-shell { zoom: var(--ui-font-scale); }

button, input, textarea, select { font: inherit; }
button { color: inherit; }

button,
a[href],
input:not([type="hidden"]),
textarea,
select,
.project-picker,
.model-enabled {
  transition: color .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

button:not(:disabled),
select:not(:disabled),
input[type="checkbox"]:not(:disabled) { cursor: pointer; }

button:disabled,
input:disabled,
select:disabled,
textarea:disabled { cursor: not-allowed; opacity: .58; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(186,129,56,.28);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  left: 1rem;
  top: -4rem;
  padding: .65rem 1rem;
  background: #fff;
  color: var(--navy);
  border-radius: .5rem;
  box-shadow: var(--shadow);
}

.skip-link:focus { top: 1rem; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 20px;
  color: #f7f8fc;
  background: var(--navy);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 25px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: block;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 13px;
  background: rgba(255,255,255,.08);
  object-fit: cover;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .04em; }
.brand small { margin-top: 3px; color: rgba(255,255,255,.72); font-size: 12px; }

.overview-link, .workflow-nav-item {
  width: 100%;
  border: 0;
  color: rgba(255,255,255,.72);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.overview-link {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 20px;
  padding: 11px 13px;
  border-radius: 9px;
}

.material-center-link, .settings-link { margin-top: 5px; }

.overview-link:hover, .workflow-nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.overview-link.is-active, .workflow-nav-item.is-active { color: #fff; background: rgba(255,255,255,.12); }
.overview-icon { font-size: 18px; }

.sidebar-label {
  margin: 25px 10px 8px;
  color: rgba(255,255,255,.42);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .15em;
}

.workflow-nav { display: grid; gap: 3px; }

.workflow-nav-item {
  display: grid;
  grid-template-columns: 30px 1fr 8px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 9px;
}

.nav-order { color: rgba(255,255,255,.58); font: 700 12px/1 ui-monospace, monospace; }
.nav-text strong, .nav-text small { display: block; }
.nav-text strong { font-size: 13px; font-weight: 600; }
.nav-text small { margin-top: 3px; color: rgba(255,255,255,.58); font-size: 11px; }
.nav-state { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.22); }
.nav-state.state-in_progress { background: #7fb2ef; box-shadow: 0 0 0 4px rgba(127,178,239,.14); }
.nav-state.state-awaiting { background: #f0b45a; box-shadow: 0 0 0 4px rgba(240,180,90,.18); }
.nav-state.state-completed { background: #57c79b; box-shadow: 0 0 0 4px rgba(87,199,155,.13); }
.nav-state.state-failed { background: #e07a6e; box-shadow: 0 0 0 4px rgba(224,122,110,.18); }

.workspace, main, .overview-view, .memoir-blueprint, .blueprint-heading, .memoir-orbit, .section-block { min-width: 0; }

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(24px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255,254,251,.88);
}

.eyebrow, .section-kicker {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.topbar h1 { margin: 0; font-family: SimSun, serif; font-size: clamp(20px, 2vw, 27px); font-weight: 700; white-space: nowrap; }
.topbar-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.project-picker { display: flex; align-items: center; gap: 7px; padding: 4px 5px 4px 10px; border: 1px solid var(--line); border-radius: 9px; color: #535e70; background: #fff; font-size: 11px; font-weight: 700; }
.project-picker select { min-width: 180px; max-width: 270px; padding: 6px 28px 6px 8px; border: 0; color: var(--ink); background: #f5f3ee; border-radius: 6px; font-size: 12px; outline: none; }
.project-picker select:focus { box-shadow: 0 0 0 2px rgba(186,129,56,.24); }

main { min-height: calc(100vh - 88px); }
.overview-view { max-width: 1420px; margin: 0 auto; padding: clamp(26px, 4vw, 55px); }

.memoir-blueprint {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(28px, 4vw, 48px);
  color: #fff;
  border: 1px solid rgba(226, 194, 143, .32);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 54%, rgba(202, 153, 78, .18), transparent 30%),
    linear-gradient(145deg, #132747 0%, #1b3157 55%, #10213e 100%);
  box-shadow: var(--shadow);
}

.memoir-blueprint::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  opacity: .26;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), transparent 86%);
}

.blueprint-heading {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 36px;
  align-items: start;
}

.blueprint-heading > *, .memoir-orbit > * { min-width: 0; }
.blueprint-heading h2 { max-width: 980px; margin: 0; font-family: SimSun, serif; font-size: clamp(28px, 2.65vw, 40px); line-height: 1.24; letter-spacing: .01em; text-wrap: balance; }
.blueprint-heading > div:first-child > p:last-child { max-width: 920px; margin: 14px 0 0; color: rgba(255,255,255,.88); font-size: 15px; line-height: 1.75; text-wrap: pretty; }
.memoir-blueprint .section-kicker { color: #edc98f; }

.memoir-orbit {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-areas:
    "source core narrative"
    "guard core delivery";
  grid-template-columns: minmax(170px, .85fr) minmax(430px, 1.8fr) minmax(170px, .85fr);
  gap: 18px clamp(20px, 2.5vw, 40px);
  align-items: center;
  margin-top: 22px;
}

.memoir-note {
  position: relative;
  min-height: 118px;
  padding: 17px 18px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 14px;
  background: rgba(255,255,255,.09);
  box-shadow: inset 0 1px rgba(255,255,255,.06);
  backdrop-filter: blur(6px);
}

.memoir-note::before,
.memoir-note::after {
  position: absolute;
  top: 50%;
  width: clamp(35px, 5vw, 72px);
  border-top: 1px solid rgba(237,201,143,.55);
  content: "";
}

.note-source { grid-area: source; }
.note-guard { grid-area: guard; }
.note-narrative { grid-area: narrative; }
.note-delivery { grid-area: delivery; }
.note-source::before, .note-guard::before { display: none; }
.note-source::after, .note-guard::after { right: clamp(-72px, -5vw, -35px); }
.note-narrative::before, .note-delivery::before { left: clamp(-72px, -5vw, -35px); }
.note-narrative::after, .note-delivery::after { display: none; }
.note-index { display: block; color: #f2d5a5; font-size: 11px; font-weight: 900; letter-spacing: .13em; }
.memoir-note h3 { margin: 7px 0 0; font-family: SimSun, serif; font-size: 19px; line-height: 1.35; text-wrap: balance; }
.memoir-note p { margin: 8px 0 0; color: rgba(255,255,255,.86); font-size: 13px; line-height: 1.65; text-wrap: pretty; }

.memoir-core {
  position: relative;
  grid-area: core;
  min-height: 560px;
  display: grid;
  place-items: center;
  align-content: center;
  margin: 0;
  text-align: center;
}

.core-halo { position: absolute; z-index: -1; border: 1px solid rgba(237,201,143,.28); border-radius: 50%; }
.halo-one { width: clamp(450px, 36vw, 540px); height: clamp(450px, 36vw, 540px); }
.halo-two { width: clamp(510px, 42vw, 620px); height: clamp(510px, 42vw, 620px); border-style: dashed; opacity: .55; }
.memoir-artwork { width: clamp(360px, 31.5vw, 495px); aspect-ratio: 1; filter: drop-shadow(0 24px 30px rgba(0,0,0,.38)); }
.memoir-artwork img { width: 100%; height: 100%; display: block; object-fit: contain; image-rendering: auto; }
.memoir-core figcaption { display: grid; gap: 3px; margin-top: -4px; }
.memoir-core figcaption span { color: #f2d5a5; font-size: 11px; font-weight: 900; letter-spacing: .16em; }
.memoir-core figcaption strong { font-family: SimSun, serif; font-size: 32px; letter-spacing: .08em; }
.memoir-core figcaption small { color: rgba(255,255,255,.72); font-size: 12px; }

.project-gate, .current-project-panel { margin-top: 18px; border: 1px solid #d8d1c5; border-radius: 15px; background: var(--surface); box-shadow: 0 8px 24px rgba(31,42,68,.035); }
.project-gate { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 25px; overflow: hidden; padding: 22px 25px 22px 29px; background: linear-gradient(90deg, #fffaf1 0, var(--surface) 38%); }
.project-gate::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--gold); content: ""; }
.project-gate h2, .current-project-panel h2 { margin: 0; font-family: SimSun, serif; font-size: 21px; }
.project-gate p:last-child, .current-project-panel p:last-child { margin: 7px 0 0; color: #596476; font-size: 13px; line-height: 1.7; text-wrap: pretty; }
.project-gate button { flex: 0 0 auto; padding: 10px 15px; border: 0; border-radius: 8px; color: #fff; background: var(--navy); cursor: pointer; font-size: 12px; font-weight: 800; }
.current-project-panel { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 18px 22px; }
.project-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: #724d1e; background: var(--gold-soft); font-family: SimSun, serif; font-size: 18px; }
.current-project-panel code { color: #655f56; font-size: 11px; }

.hero-progress { padding: 17px 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 13px; background: rgba(255,255,255,.07); }
.hero-progress strong, .hero-progress span { display: block; }
.hero-progress strong { font: 700 28px/1 ui-monospace, monospace; }
.hero-progress span { margin-top: 8px; color: rgba(255,255,255,.6); font-size: 12px; }
.progress-track { height: 4px; margin-top: 17px; background: rgba(255,255,255,.13); border-radius: 99px; overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0; background: #e9c58e; border-radius: inherit; transition: width .4s ease; }

.section-block { margin-top: 48px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 19px; }
.section-heading h2, .knowledge-heading h2 { margin: 0; font-family: SimSun, serif; font-size: 25px; line-height: 1.3; text-wrap: balance; }
.section-heading > p { max-width: 540px; margin: 0; color: #596476; font-size: 13px; line-height: 1.65; text-align: right; text-wrap: pretty; }

.workflow-map {
  display: flex;
  align-items: stretch;
  min-width: 0;
  overflow-x: auto;
  padding: 24px;
  border: 1px solid #d9d2c5;
  border-radius: 18px;
  background:
    linear-gradient(rgba(23,42,77,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23,42,77,.025) 1px, transparent 1px),
    #f1eee7;
  background-size: 24px 24px;
}

.workflow-stage { min-width: 118px; flex: 1 1 0; display: flex; flex-direction: column; }
.workflow-stage.is-parallel { min-width: 166px; flex-grow: 1.28; }
.stage-caption { min-height: 32px; display: flex; align-items: center; gap: 6px; margin: 0 4px 9px; color: #514c44; font-size: 11px; font-weight: 900; letter-spacing: .03em; text-wrap: balance; }
.stage-caption::before { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--gold); content: ""; }
.stage-node-stack { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.workflow-stage.is-parallel .stage-node-stack { padding: 7px; border: 1px dashed #ccb98f; border-radius: 16px; background: rgba(255,255,255,.28); }
.workflow-node-item { flex: 1; display: flex; }
.workflow-node {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 15px 13px 13px;
  border: 1px solid #d9d5cc;
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255,254,251,.96);
  text-align: left;
  box-shadow: 0 9px 22px rgba(31,42,68,.045);
}

.workflow-node::before { position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, #bac4d4, transparent); content: ""; }
.is-parallel .workflow-node { min-height: 120px; }
.workflow-node.is-available { border-color: #c89a57; box-shadow: 0 12px 26px rgba(135,91,31,.12); }
.workflow-node.is-available::before { background: linear-gradient(90deg, #c28a3e, #efd39d); }
.workflow-node-head { display: flex; align-items: center; gap: 7px; }
.flow-step { color: #766854; font: 800 10px/1 ui-monospace, monospace; }
.module-icon { width: 31px; height: 31px; display: grid; place-items: center; color: var(--navy); border-radius: 9px; background: #e9edf4; font-family: SimSun, serif; font-size: 15px; }
.workflow-node.is-available .module-icon { color: #7a531e; background: var(--gold-soft); }
.workflow-node-head .status-chip { margin-left: auto; }
.status-chip { display: inline-flex; align-items: center; justify-content: center; width: max-content; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-available { color: var(--green); background: var(--green-soft); }
.status-pending { color: #6c7079; background: var(--slate-soft); }
.status-framework { color: #76511f; background: var(--gold-soft); }
.workflow-node-title { display: flex; align-items: baseline; gap: 5px; margin-top: 12px; font-family: SimSun, serif; white-space: nowrap; }
.workflow-node-title strong { font-size: 17px; font-weight: 900; }
.workflow-node-title small { color: #4f5d73; font-size: 12px; font-weight: 800; }
.workflow-node-purpose { display: block; margin-top: 8px; color: #596476; font-size: 12px; line-height: 1.55; text-wrap: pretty; }
.workflow-node-route { display: block; margin-top: 10px; padding: 8px; border-radius: 8px; color: #49443d; background: #f2efe8; font-size: 11px; line-height: 1.5; text-wrap: pretty; }
.workflow-node-project { display: block; width: fit-content; max-width: 100%; margin-top: 9px; padding: 5px 8px; border-radius: 999px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 800; }
.workflow-node-project.is-bound { color: #245f50; background: var(--green-soft); }
.workflow-node-project.is-unbound { color: #76716a; background: var(--slate-soft); }
.workflow-node-action { display: block; margin-top: auto; padding-top: 11px; color: #704917; font-size: 11px; font-weight: 900; }
.workflow-node:hover { border-color: #bfa77e; box-shadow: 0 12px 28px rgba(31,42,68,.1); }
.flow-connector { position: relative; z-index: 2; width: clamp(30px, 2.8vw, 46px); flex: 0 0 clamp(30px, 2.8vw, 46px); align-self: stretch; color: #8a6b41; overflow: visible; }
.flow-connector::before { position: absolute; top: 50%; left: 0; width: 100%; border-top: 2px solid #c4a36e; content: ""; }
.flow-connector::after { position: absolute; top: 50%; right: 2px; width: 7px; height: 7px; border-top: 2px solid #a77736; border-right: 2px solid #a77736; content: ""; transform: translateY(-50%) rotate(45deg); }
.flow-connector-label { position: absolute; top: calc(50% - 24px); left: 50%; width: max-content; padding: 3px 6px; border: 1px solid #d7c29d; border-radius: 999px; color: #68491f; background: #f8f4eb; box-shadow: 0 2px 8px rgba(95,70,34,.08); font-size: 11px; font-weight: 900; line-height: 1.2; text-align: center; white-space: nowrap; transform: translateX(-50%); }
.flow-connector.is-split::before, .flow-connector.is-merge::before { border-top-style: dashed; }

.workflow-reuse { display: grid; grid-template-columns: auto minmax(230px, .85fr) minmax(360px, 1.15fr); gap: 13px; align-items: center; margin-top: 12px; padding: 15px 18px; border: 1px solid #d9d1c2; border-radius: 13px; background: #fffaf1; }
.reuse-symbol { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #7a531e; background: var(--gold-soft); font-size: 19px; }
.workflow-reuse strong { display: block; font-family: SimSun, serif; font-size: 14px; }
.workflow-reuse p { margin: 5px 0 0; color: #596476; font-size: 12px; line-height: 1.55; text-wrap: pretty; }
.reuse-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.reuse-tags span { padding: 6px 8px; border: 1px solid #ded3c1; border-radius: 999px; color: #624d30; background: #fff; font-size: 10px; font-weight: 800; }

.knowledge-panel { margin-top: 42px; padding: clamp(24px, 4vw, 38px); border: 1px solid #d7cdbd; border-radius: 18px; background: linear-gradient(135deg, #f0ece3, #eae5da); box-shadow: 0 10px 28px rgba(31,42,68,.035); }
.knowledge-heading { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.knowledge-mark { width: 45px; height: 45px; display: grid; place-items: center; border: 1px solid #c8bda9; border-radius: 13px; color: #6d4c20; background: rgba(255,255,255,.48); font-family: SimSun, serif; font-size: 20px; }
.knowledge-description { max-width: 950px; margin: 20px 0; color: #514c44; font-size: 14px; line-height: 1.8; }
.knowledge-capabilities { display: flex; flex-wrap: wrap; gap: 8px; }
.knowledge-capabilities span { padding: 7px 11px; border: 1px solid #d5cabb; border-radius: 7px; color: #4f4941; background: rgba(255,255,255,.52); font-size: 12px; }

.material-center-view { max-width: 1420px; margin: 0 auto; padding: clamp(26px, 4vw, 55px); }
.material-center-hero { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: clamp(24px, 3vw, 38px); color: #fff; border-radius: 18px; background: linear-gradient(135deg, var(--navy), #29456f); box-shadow: var(--shadow); }
.material-center-hero h2 { margin: 0; font-family: SimSun, serif; font-size: clamp(28px, 3.5vw, 42px); }
.material-center-hero p:last-child { max-width: 780px; margin: 13px 0 0; color: rgba(255,255,255,.72); font-size: 13px; line-height: 1.8; }
.material-center-hero .section-kicker { color: #e9c58e; }

.material-scope-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.material-scope-card { display: grid; grid-template-columns: auto 1fr; gap: 15px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.material-scope-card h3 { margin: 0; font-family: SimSun, serif; font-size: 21px; }
.material-scope-card p:not(.section-kicker) { margin: 8px 0 12px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.scope-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; font-family: SimSun, serif; font-size: 18px; }
.shared-scope .scope-mark { color: #744e1d; background: var(--gold-soft); }
.private-scope .scope-mark { color: #225a4b; background: var(--green-soft); }
.scope-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.scope-tags span { padding: 5px 8px; border-radius: 6px; color: #5f5a50; background: #f1eee7; font-size: 10px; }

.material-project-required { min-height: 330px; display: grid; place-items: center; align-content: center; margin-top: 18px; padding: 38px; border: 1px dashed #cfc7b8; border-radius: 15px; background: var(--surface); text-align: center; }
.material-project-required h2 { margin: 0; font-family: SimSun, serif; font-size: 25px; }
.material-project-required > p:not(.section-kicker) { max-width: 650px; margin: 12px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.material-project-required button, .material-heading-actions button { padding: 9px 13px; border: 1px solid #cdbfa9; border-radius: 8px; color: #744e1d; background: #fffaf2; cursor: pointer; font-size: 11px; font-weight: 800; }
.material-project-required button:hover, .material-heading-actions button:hover { background: var(--gold-soft); }

.material-project-content { margin-top: 18px; }
.material-project-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.material-project-heading h2 { margin: 0; font-family: SimSun, serif; font-size: 25px; }
.material-project-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.material-project-heading code { color: #777065; font-size: 10px; }
.material-heading-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.material-heading-actions button:last-child { color: #fff; border-color: var(--navy); background: var(--navy); }
.material-heading-actions button:last-child:hover { background: var(--navy-2); }

.material-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.material-stat { padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.material-stat span, .material-stat strong, .material-stat small { display: block; }
.material-stat span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.material-stat strong { margin-top: 8px; font: 700 24px/1 ui-monospace, monospace; }
.material-stat small { margin-top: 7px; color: #837c70; font-size: 10px; }

.material-production-ledger { margin: 14px 0; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.material-production-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.material-production-card { min-width: 0; padding: 14px; border: 1px solid #e2dbcf; border-radius: 11px; background: color-mix(in srgb, var(--surface), var(--paper) 42%); }
.material-production-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.material-production-head strong { font: 700 16px/1.2 SimSun, serif; }
.material-production-head code { max-width: 65%; color: var(--muted); font-size: 9px; overflow-wrap: anywhere; text-align: right; }
.material-production-counts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.material-production-counts span { padding: 5px 8px; border-radius: 999px; color: #66563f; background: var(--gold-soft); font-size: 9px; }
.material-production-counts b { font-size: 11px; }
.material-production-card p, .material-production-card small { display: block; margin: 9px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; overflow-wrap: anywhere; }

.material-relation-section { margin: 14px 0; padding: 20px; border: 1px solid #dfc99f; border-radius: 15px; background: #fffaf1; }
.material-operation-section { margin: 14px 0; padding: 20px; border: 1px solid #d8c59f; border-radius: 15px; background: #fffaf1; }
.material-trash-section { border-color: #d7c3bd; background: #fff8f5; }
.material-operation-list { display: grid; gap: 10px; margin-top: 15px; }
.material-operation-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px; border: 1px solid #e8ddc8; border-radius: 11px; background: var(--surface); }
.material-operation-copy { min-width: 0; }
.material-operation-copy strong, .material-operation-copy small { display: block; }
.material-operation-copy strong { font-size: 12px; }
.material-operation-copy small { margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.6; overflow-wrap: anywhere; }
.material-operation-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.material-operation-actions button { min-height: 36px; padding: 9px 13px; border: 1px solid var(--navy); border-radius: 8px; color: #fff; background: var(--navy); cursor: pointer; font-size: 10px; font-weight: 800; }
.material-operation-actions button.secondary { color: #744e1d; border-color: #cdbfa9; background: #fffaf2; }
.material-operation-actions button.danger { color: #8c302d; border-color: #dab4b0; background: #fff4f2; }
.material-operation-actions button:hover:not(:disabled) { filter: brightness(.94); transform: translateY(-1px); }
.material-operation-actions button:focus-visible { outline: 3px solid rgba(186,129,56,.28); outline-offset: 2px; }
.material-operation-actions button:disabled { cursor: wait; opacity: .62; transform: none; }
.material-operation-actions button.is-loading::after { display: inline-block; width: 10px; height: 10px; margin-left: 7px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -2px; content: ""; animation: spin .75s linear infinite; }
.material-relation-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; }
.material-relation-heading h3 { margin: 0; font-family: SimSun, serif; font-size: 22px; }
.material-relation-heading p:last-child { max-width: 780px; margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.material-relation-list { display: grid; gap: 10px; margin-top: 15px; }
.material-relation-card { display: grid; grid-template-columns: minmax(210px, 1.25fr) minmax(220px, 1fr) minmax(150px, .7fr) auto; align-items: end; gap: 11px; padding: 14px; border: 1px solid #e8ddc8; border-radius: 11px; background: var(--surface); }
.material-relation-identity { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; }
.material-relation-identity strong, .material-relation-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-relation-identity strong { font-size: 12px; }
.material-relation-identity small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.material-relation-card label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 800; }
.material-relation-card select, .material-relation-card input[type="text"], .material-relation-card input:not([type]) { width: 100%; padding: 9px 10px; border: 1px solid #d8d2c7; border-radius: 8px; background: #fff; outline: none; }
.material-relation-card select:hover, .material-relation-card input:hover { border-color: #c6b392; }
.material-relation-card select:focus, .material-relation-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(186,129,56,.12); }
.material-relation-card button { min-height: 36px; padding: 9px 13px; border: 1px solid var(--navy); border-radius: 8px; color: #fff; background: var(--navy); cursor: pointer; font-size: 10px; font-weight: 800; }
.material-relation-card button:hover:not(:disabled) { background: var(--navy-2); }
.material-relation-card button:focus-visible { outline: 3px solid rgba(186,129,56,.28); outline-offset: 2px; }
.material-relation-card button:disabled { cursor: wait; opacity: .62; }
.material-relation-confirm { grid-column: 2 / 4; display: flex !important; align-items: center; align-self: center; gap: 7px !important; }
.material-relation-message { grid-column: 1 / -1; min-height: 1em; margin: 0; color: #895818; font-size: 10px; }

.material-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(150px, 230px); gap: 12px; margin: 14px 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.material-toolbar label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 800; }
.material-toolbar input, .material-toolbar select { width: 100%; padding: 9px 10px; border: 1px solid #d8d2c7; border-radius: 8px; background: #fff; outline: none; }
.material-toolbar input:focus, .material-toolbar select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(186,129,56,.12); }
.material-loading, .material-error { margin: 14px 0; padding: 20px; border-radius: 12px; background: var(--surface); }
.material-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.material-error { color: var(--danger); border: 1px solid #e5bcbc; }
.material-groups { display: grid; gap: 18px; }
.material-group-section { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.material-group-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 13px; }
.material-group-heading h3 { margin: 0; font-family: SimSun, serif; font-size: 22px; }
.material-group-heading span { color: var(--muted); font-size: 10px; }
.material-category-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.material-category { min-width: 0; padding: 15px; border: 1px solid #e7e2d8; border-radius: 11px; background: #faf8f3; }
.material-category-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.material-category h4 { margin: 0; font-size: 14px; }
.material-category-path { display: block; margin-top: 5px; color: #8a8378; font: 10px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.material-category-owner { display: block; margin-top: 5px; color: #776b5b; font-size: 9px; line-height: 1.5; }
.material-count { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; color: #61594f; background: #ece8df; font-size: 9px; font-weight: 800; }
.material-file-list { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.material-file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 8px; background: #fff; }
.material-file-type { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; color: #6b5942; background: var(--gold-soft); font-size: 9px; font-weight: 800; }
.material-file-name { min-width: 0; }
.material-file-name strong, .material-file-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-file-name strong { font-size: 11px; }
.material-file-name small { margin-top: 3px; color: #8b8378; font-size: 9px; }
.material-file-meta { color: #8a8378; font-size: 9px; white-space: nowrap; }
.material-empty { margin: 12px 0 0; padding: 14px; color: #8a8378; border: 1px dashed #d8d1c5; border-radius: 8px; font-size: 10px; text-align: center; }
.material-no-results { padding: 30px; color: var(--muted); border: 1px dashed #d8d1c5; border-radius: 12px; background: var(--surface); text-align: center; }
.material-truncated { margin: 12px 0 0; color: #8b5d24; font-size: 10px; }

.settings-view { max-width: 1420px; margin: 0 auto; padding: clamp(26px, 4vw, 55px); }
.settings-hero { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: clamp(24px, 3vw, 36px); color: #fff; border-radius: 18px; background: linear-gradient(135deg, var(--navy), #29456f); box-shadow: var(--shadow); }
.settings-hero h2 { margin: 0; font-family: SimSun, serif; font-size: clamp(28px, 3.5vw, 42px); }
.settings-hero p:last-child { max-width: 830px; margin: 12px 0 0; color: rgba(255,255,255,.74); font-size: 13px; line-height: 1.8; }
.settings-hero .section-kicker { color: #e9c58e; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.settings-card { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 8px 26px rgba(31,42,68,.045); }
.settings-project-card, .settings-storage-card, .settings-model-routing-card { grid-column: 1 / -1; }
.settings-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.settings-card-heading h3 { margin: 0; font-family: SimSun, serif; font-size: 23px; }
.settings-card-heading code { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.settings-project-selector { display: grid; gap: 7px; margin-top: 15px; color: var(--muted); font-size: 11px; font-weight: 800; }
.settings-project-selector select { width: 100%; padding: 11px 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.settings-project-create { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--surface), var(--paper) 35%); }
.settings-project-create summary { padding: 12px 14px; color: #744e1d; cursor: pointer; font-size: 11px; font-weight: 900; }
.settings-project-create[open] summary { border-bottom: 1px solid var(--line); }
.settings-project-create .settings-form { margin: 0; padding: 15px; }
.settings-required { margin-top: 16px; padding: 20px; color: var(--muted); border: 1px dashed #cfc7b8; border-radius: 10px; background: color-mix(in srgb, var(--surface), var(--paper) 45%); text-align: center; font-size: 12px; line-height: 1.7; }
.settings-form { margin-top: 16px; }
.settings-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-form label { min-width: 0; display: grid; align-content: start; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.settings-form > label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.settings-wide { grid-column: 1 / -1; }
.tier-picker { min-width: 0; margin: 0; padding: 0; border: 0; display: grid; gap: 8px; }
.tier-picker legend { margin-bottom: 7px; padding: 0; color: var(--muted); font-size: 11px; font-weight: 800; }
.tier-picker > small { color: var(--muted); font-size: 11px; line-height: 1.6; }
.tier-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.settings-form .tier-option { position: relative; display: grid; gap: 5px; padding: 12px 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.tier-option input { position: absolute; opacity: 0; pointer-events: none; }
.tier-option strong { font-size: 14px; }
.tier-option span { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.55; }
.tier-option:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 1px var(--gold) inset; }
.tier-option:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(186,129,56,.25); }
.settings-form input, .settings-form select, .settings-form textarea { width: 100%; padding: 10px 11px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); outline: none; resize: vertical; }
.settings-form input[type="color"] { min-height: 44px; padding: 5px; }
.settings-form input:focus, .settings-form select:focus, .settings-form textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(186,129,56,.13); }
.settings-message { min-height: 18px; margin: 13px 0 0; color: #7a531e; font-size: 11px; line-height: 1.6; }
.settings-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; margin-top: 10px; }
.settings-actions button { min-width: 120px; padding: 10px 14px; border: 1px solid #cbbfae; border-radius: 8px; color: #744e1d; background: #fffaf2; font-size: 11px; font-weight: 900; }
.settings-actions .primary-action { color: #fff; border-color: var(--navy); background: var(--navy); }
.settings-actions button.danger { color: #8c302d; border-color: #dab4b0; background: #fff4f2; }
.settings-actions button.is-loading::after, .material-relation-card button.is-loading::after, .material-heading-actions button.is-loading::after, .project-danger-zone button.is-loading::after, .storage-picker-row button.is-loading::after, .delete-dialog button.is-loading::after, .module-model-picker select.is-loading + small::before { display: inline-block; width: 10px; height: 10px; margin-left: 7px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -2px; content: ""; animation: spin .75s linear infinite; }
.project-storage-panel { display: grid; gap: 11px; margin-bottom: 16px; padding: 15px; border: 1px solid #c9d3df; border-radius: 10px; background: color-mix(in srgb, var(--surface), #eef4fa 35%); }
.project-storage-panel strong { color: var(--navy); font-size: 12px; }
.project-storage-panel p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.project-asset-paths { display: grid; gap: 7px; }
.asset-path-row { display: grid; grid-template-columns: minmax(118px, .22fr) minmax(0, 1fr); align-items: start; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.asset-path-row span { color: var(--muted); font-size: 9px; font-weight: 900; }
.asset-path-row code { min-width: 0; color: var(--ink); font: 10px/1.6 "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.asset-path-row.is-confirmed { border-color: #acd2c0; background: color-mix(in srgb, var(--surface), #e7f5ed 45%); }
.asset-path-row.is-confirmed span { color: #28724f; }
.asset-path-row.is-rejected { border-color: #dfc0bc; background: color-mix(in srgb, var(--surface), #fff1ef 38%); }
.asset-path-row.is-rejected span { color: #923c36; }
.project-metrics-panel { margin-bottom: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--surface), var(--paper) 35%); }
.project-metrics-panel > div:first-child strong { color: var(--navy); font-size: 12px; }
.project-metrics-panel > div:first-child p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.project-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.project-metric { min-width: 0; padding: 11px 8px; border-radius: 8px; background: var(--surface); text-align: center; }
.project-metric span, .project-metric strong { display: block; }
.project-metric span { color: var(--muted); font-size: 9px; }
.project-metric strong { margin-top: 5px; color: var(--navy); font-size: 19px; }
.project-danger-zone { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: end; gap: 12px; margin-top: 18px; padding: 15px; border: 1px solid #dfb9b4; border-radius: 10px; background: #fff7f5; }
.project-danger-zone strong { color: #8c302d; font-size: 12px; }
.project-danger-zone p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.project-danger-zone button { min-height: 38px; padding: 9px 13px; color: #fff; border: 1px solid #973b35; border-radius: 8px; background: #a9443d; font-size: 10px; font-weight: 900; }
.settings-project-trash { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.settings-subheading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-subheading strong, .settings-subheading small { display: block; }
.settings-subheading small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.settings-subheading button, .settings-project-trash-item button { padding: 8px 11px; color: #744e1d; border: 1px solid #cbbfae; border-radius: 8px; background: #fffaf2; font-size: 10px; font-weight: 900; }
.settings-project-trash-list { display: grid; gap: 8px; margin-top: 11px; }
.settings-project-trash-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 9px; background: color-mix(in srgb, var(--surface), var(--paper) 35%); }
.settings-project-trash-item strong, .settings-project-trash-item small, .settings-project-trash-item code { display: block; }
.settings-project-trash-item strong { font-size: 12px; }
.settings-project-trash-item small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.settings-project-trash-item code { margin-top: 4px; color: var(--muted); font-size: 8px; overflow-wrap: anywhere; }
.settings-trash-empty { margin: 0; padding: 13px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; text-align: center; font-size: 10px; }
.settings-explanation, .settings-warning { color: var(--muted); font-size: 11px; line-height: 1.75; }
.settings-warning { padding: 10px 12px; border-radius: 8px; background: var(--gold-soft); color: #6e4b1f; }
.storage-paths { display: grid; gap: 8px; margin: 16px 0 0; }
.storage-paths > div { display: grid; grid-template-columns: minmax(135px, .28fr) minmax(0, 1fr); gap: 12px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--surface), var(--paper) 55%); }
.storage-paths dt { color: var(--muted); font-size: 10px; font-weight: 800; }
.storage-paths dd { min-width: 0; margin: 0; font: 10px/1.6 "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.storage-sync-panel { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--surface), var(--paper) 38%); }
.storage-sync-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.storage-sync-heading strong { font-size: 12px; }
.storage-sync-consumers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.storage-sync-consumer { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 10px; border-radius: 8px; color: var(--muted); background: var(--surface); font-size: 10px; }
.storage-sync-consumer::before { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #b24a3c; content: ""; }
.storage-sync-consumer.is-synced::before { background: #2d8a62; }
.storage-layout-details { margin-top: 12px; color: var(--muted); font-size: 10px; }
.storage-layout-details summary { cursor: pointer; font-weight: 800; }
.storage-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.storage-layout code { min-width: 0; padding: 7px 9px; border-radius: 6px; background: var(--surface); font-size: 9px; overflow-wrap: anywhere; }
.storage-picker-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.storage-picker-row button { min-width: 112px; padding: 10px 13px; color: #744e1d; border: 1px solid #cbbfae; border-radius: 8px; background: #fffaf2; font-size: 11px; font-weight: 900; }
.settings-card-heading > button, #model-routing-refresh { padding: 9px 12px; color: #744e1d; border: 1px solid #cbbfae; border-radius: 8px; background: #fffaf2; font-size: 10px; font-weight: 900; }
.model-routing-content { display: grid; gap: 14px; margin-top: 15px; }
.model-route-agent { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.model-route-agent-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; background: color-mix(in srgb, var(--surface), var(--paper) 55%); }
.model-route-agent-heading strong { font-size: 12px; }
.model-route-agent-heading span { color: var(--muted); font-size: 9px; }
.model-route-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.model-route-table th, .model-route-table td { padding: 10px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
.model-route-table th { color: var(--muted); font-size: 9px; white-space: nowrap; }
.model-route-purpose strong { display: block; color: var(--ink); }
.model-route-purpose small { display: block; margin-top: 3px; color: var(--muted); }
.model-route-controls { display: grid; grid-template-columns: minmax(92px, .42fr) minmax(180px, 1fr); gap: 7px; min-width: 280px; }
.model-route-controls select { min-width: 0; width: 100%; padding: 8px 9px; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.model-route-state { max-width: 360px; color: var(--muted); line-height: 1.55; }
.model-route-state.is-ready { color: #28724f; }
.model-route-state.is-missing { color: #9a4b36; }

html[data-theme="dark"] .topbar,
html[data-theme="custom"][data-custom-tone="dark"] .topbar { background: color-mix(in srgb, var(--surface), transparent 8%); }
html[data-theme="dark"] .project-picker,
html[data-theme="dark"] .project-picker select,
html[data-theme="dark"] .module-model-picker select,
html[data-theme="custom"][data-custom-tone="dark"] .project-picker,
html[data-theme="custom"][data-custom-tone="dark"] .project-picker select { color: var(--ink); background: var(--surface); }

.module-view { min-height: calc(100vh - 88px); padding: 20px clamp(20px, 3vw, 42px) 35px; }
.module-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; margin-bottom: 15px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.module-model-picker { grid-column: 2 / -1; display: grid; grid-template-columns: auto minmax(220px, 360px) minmax(0, 1fr); align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 800; }
.module-model-picker select { min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.module-model-picker small { color: #7a531e; font-weight: 600; }
.back-button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 12px; }
.back-button:hover { border-color: #b5ab9c; }
.module-identity { min-width: 0; }
.module-identity > * { display: block; }
.module-sequence { color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.module-identity strong { margin: 3px 0; font-size: 15px; }
.module-identity code { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.agent-frame-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.frame-notice { min-height: 42px; display: flex; align-items: center; gap: 16px; padding: 9px 14px; color: var(--muted); background: #f1efe9; border-bottom: 1px solid var(--line); font-size: 11px; }
.frame-notice span:nth-child(2) { margin-left: auto; }
.frame-notice button { padding: 5px 9px; border: 1px solid #d3cbbc; border-radius: 6px; background: #fff; cursor: pointer; font-size: 10px; }
#agent-frame { display: block; width: 100%; height: calc(100vh - 193px); min-height: 620px; border: 0; background: #fff; }
/* WO-06：窄屏由 JS 按内容设 height；去掉固定 min-height，避免再套一层滚动 */
#agent-frame.is-auto-height { min-height: 0; }
.pending-panel { min-height: 520px; display: grid; place-items: center; align-content: center; padding: 50px; border: 1px dashed #cbc4b8; border-radius: 15px; background: var(--surface); text-align: center; }
.pending-symbol { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 50%; color: #71695e; background: var(--slate-soft); font-size: 25px; }
.pending-panel h2 { margin: 0; font-family: SimSun, serif; font-size: 27px; }
.pending-panel > p:not(.section-kicker) { max-width: 550px; margin: 13px 0; color: var(--muted); line-height: 1.8; }
.pending-note { margin-top: 13px; padding: 9px 13px; color: #6a6256; border-radius: 8px; background: #f1ede5; font-size: 11px; }

.project-dialog { width: min(520px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 17px; color: var(--ink); background: var(--surface); box-shadow: 0 30px 90px rgba(17,30,55,.28); }
.project-dialog::backdrop { background: rgba(15,27,48,.55); backdrop-filter: blur(2px); }
.project-dialog form { padding: 28px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 0; font-family: SimSun, serif; font-size: 25px; }
.dialog-close { width: 32px; height: 32px; border: 0; border-radius: 50%; color: var(--muted); background: var(--slate-soft); cursor: pointer; font-size: 21px; }
.dialog-note { margin: 19px 0; padding: 11px 13px; color: #665f54; border-radius: 9px; background: #f1eee7; font-size: 11px; line-height: 1.7; }
.project-dialog label { display: grid; gap: 7px; margin-top: 15px; font-size: 12px; font-weight: 800; }
.project-dialog input { width: 100%; padding: 11px 12px; border: 1px solid #d8d2c7; border-radius: 8px; background: #fff; outline: none; }
.project-dialog input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(186,129,56,.12); }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 11px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 10px; }
.dialog-actions button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 11px; font-weight: 800; }
.dialog-actions button[type="submit"] { color: #fff; border-color: var(--navy); background: var(--navy); }
.delete-dialog { width: min(660px, calc(100vw - 30px)); }
.delete-dialog .dialog-note { color: #7f302b; background: #fff0ed; }
.delete-project-summary { display: grid; gap: 7px; margin: 0; }
.delete-project-summary > div { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; padding: 9px 11px; border-radius: 8px; background: color-mix(in srgb, var(--surface), var(--paper) 45%); }
.delete-project-summary dt { color: var(--muted); font-size: 10px; font-weight: 900; }
.delete-project-summary dd { min-width: 0; margin: 0; font-size: 11px; overflow-wrap: anywhere; }
.delete-project-summary code { font: 10px/1.5 "Cascadia Mono", Consolas, monospace; }
.delete-impact-list { margin: 16px 0; padding: 13px 14px 13px 34px; color: var(--muted); border: 1px solid #e2c0bc; border-radius: 9px; background: #fff8f6; font-size: 11px; line-height: 1.75; }
.delete-dialog .dialog-actions button.danger { color: #fff; border-color: #973b35; background: #a9443d; }
.model-dialog { width: min(920px, calc(100vw - 30px)); max-height: calc(100vh - 30px); overflow: auto; }
.model-profile-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin: 15px 0; }
.model-profile-toolbar label { margin: 0; }
.model-profile-toolbar select { width: 100%; padding: 10px 11px; border: 1px solid #d8d2c7; border-radius: 8px; background: #fff; }
.model-profile-toolbar button, .credential-box button { padding: 10px 12px; border: 1px solid #cbbfae; border-radius: 8px; background: #fffaf2; cursor: pointer; font-size: 11px; font-weight: 800; }
.model-dialog select { width: 100%; padding: 10px 11px; border: 1px solid #d8d2c7; border-radius: 8px; color: var(--ink); background: #fff; outline: none; }
.model-dialog select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(186,129,56,.12); }
.model-config-step { margin-top: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.model-step-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.model-step-heading > div { display: flex; align-items: center; gap: 9px; }
.model-step-heading > div > span { display: inline-grid; place-items: center; min-width: 48px; height: 24px; padding: 0 8px; border-radius: 999px; color: #7a531e; background: var(--gold-soft); font-size: 10px; font-weight: 900; }
.model-step-heading h3 { margin: 0; font-family: SimSun, serif; font-size: 17px; }
.model-step-heading > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.connection-state { padding: 6px 9px; border-radius: 999px; background: #eee9df; }
.connection-state[data-state="connected"] { color: #28724f; background: #e2f2e9; }
.connection-state[data-state="failed"] { color: #a53f36; background: #fae8e5; }
.model-step-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.model-step-actions button { padding: 10px 13px; border: 1px solid #cbbfae; border-radius: 8px; color: #744e1d; background: #fffaf2; cursor: pointer; font-size: 11px; font-weight: 900; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background-color .16s ease; }
.model-step-actions button:first-child, #import-provider-models { color: #fff; border-color: var(--navy); background: var(--navy); }
.model-step-actions button:disabled { cursor: not-allowed; opacity: .48; }
.model-search-field { max-width: 360px; }
.model-catalog-field select { min-height: 188px; font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; line-height: 1.6; }
.model-catalog-field option { padding: 6px 8px; }
.model-config-step > small { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.model-capability-grid { margin-top: 4px; }
.model-imported-step > select { min-height: 104px; margin-top: 12px; font-size: 11px; }
.model-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.model-form-grid label { min-width: 0; }
.model-field-wide { grid-column: 1 / -1; }
.model-enabled { display: flex !important; grid-column: 1 / -1; grid-template-columns: none !important; align-items: center; }
.model-enabled[hidden] { display: none !important; }
.model-enabled input { width: auto; }
.credential-box { display: grid; grid-template-columns: minmax(130px, .65fr) minmax(180px, 1fr) auto; align-items: end; gap: 10px; margin-top: 18px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #f7f4ed; }
.credential-box > div { display: grid; gap: 4px; font-size: 11px; }
.credential-box > div span { color: var(--muted); }
.credential-box label { margin: 0; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.loading-state, .error-state { max-width: 560px; margin: 90px auto; padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: center; }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 17px; height: 17px; border: 2px solid #d6d0c5; border-top-color: var(--gold); border-radius: 50%; animation: spin .75s linear infinite; }
.error-state strong { color: var(--danger); }
.error-state p { color: var(--muted); }
.error-state button { padding: 8px 14px; border: 0; border-radius: 7px; color: #fff; background: var(--navy); cursor: pointer; }
.is-hidden { display: none !important; }

@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):hover,
  a[href]:hover {
    transform: translateY(-1px);
  }

  button:not(:disabled):hover {
    box-shadow: 0 7px 18px rgba(31, 42, 68, .14);
  }

  .overview-link:hover,
  .workflow-nav-item:hover {
    box-shadow: none;
  }

  input:not([type="hidden"]):not([type="checkbox"]):not(:disabled):hover,
  textarea:not(:disabled):hover,
  select:not(:disabled):hover {
    border-color: #b9a98f;
    background-color: #fffdfa;
    box-shadow: 0 0 0 3px rgba(186, 129, 56, .10);
  }

  .project-picker:hover {
    border-color: #c9b58f;
    box-shadow: 0 5px 14px rgba(94, 70, 35, .09);
  }

  .project-picker select:hover {
    background-color: #eee9df;
  }

  input[type="checkbox"]:not(:disabled):hover {
    filter: drop-shadow(0 0 3px rgba(186, 129, 56, .35));
    transform: scale(1.08);
  }

  .model-enabled:hover {
    color: #744e1d;
  }

  .dialog-close:hover {
    color: var(--navy);
    background: var(--gold-soft);
  }

  .storage-picker-row button:not(:disabled):hover {
    color: var(--navy);
    border-color: var(--gold);
    background: var(--gold-soft);
  }

  .project-danger-zone button:not(:disabled):hover,
  .delete-dialog .dialog-actions button.danger:not(:disabled):hover {
    border-color: #7b2924;
    background: #8f342e;
  }

  .model-dialog .model-step-actions button:not(:disabled):hover,
  .model-dialog .model-profile-toolbar button:not(:disabled):hover,
  .model-dialog .credential-box button:not(:disabled):hover {
    border-color: var(--gold);
    background-color: var(--gold-soft);
  }

  .model-dialog .model-step-actions button:first-child:not(:disabled):hover,
  .model-dialog #import-provider-models:not(:disabled):hover {
    border-color: var(--navy-2);
    color: #fff;
    background-color: var(--navy-2);
  }
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 1280px) {
  .blueprint-heading h2,
  .section-heading > p { white-space: nowrap; }
}

@media (max-width: 1279px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-meta { width: 100%; justify-content: flex-start; }
  .project-picker { flex: 1 1 300px; }
  .project-picker select { flex: 1; }
  .blueprint-heading { grid-template-columns: 1fr; gap: 18px; }
  .blueprint-heading .hero-progress { width: min(190px, 100%); }
  .memoir-orbit { grid-template-columns: minmax(150px, 1fr) minmax(280px, 1.2fr) minmax(150px, 1fr); gap: 16px 24px; }
  .memoir-core { min-height: 430px; }
  .memoir-artwork { width: min(clamp(280px, 27vw, 360px), 100%); }
  .halo-one { width: 350px; height: 350px; }
  .halo-two { width: 410px; height: 410px; }
  .memoir-note::before, .memoir-note::after { width: 34px; }
  .note-source::after, .note-guard::after { right: -34px; }
  .note-narrative::before, .note-delivery::before { left: -34px; }
  .material-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1001px) and (max-width: 1359px) {
  .workflow-map {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(54px, 5vw, 72px) minmax(0, 1fr) clamp(54px, 5vw, 72px) minmax(0, 1fr);
    grid-template-rows: auto 64px auto;
    align-items: stretch;
    overflow: visible;
  }
  .workflow-stage, .workflow-stage.is-parallel { width: auto; min-width: 0; flex: none; }
  .workflow-map .flow-stage-1 { grid-area: 1 / 1; }
  .workflow-map .flow-link-1 { grid-area: 1 / 2; }
  .workflow-map .flow-stage-2 { grid-area: 1 / 3; }
  .workflow-map .flow-link-2 { grid-area: 1 / 4; }
  .workflow-map .flow-stage-3 { grid-area: 1 / 5; }
  .workflow-map .flow-link-3 { grid-area: 2 / 5; }
  .workflow-map .flow-stage-4 { grid-area: 3 / 5; }
  .workflow-map .flow-link-4 { grid-area: 3 / 4; }
  .workflow-map .flow-stage-5 { grid-area: 3 / 3; }
  .workflow-map .flow-link-5 { grid-area: 3 / 2; }
  .workflow-map .flow-stage-6 { grid-area: 3 / 1; }
  .flow-connector { width: 100%; min-width: 0; flex: none; }
  .flow-connector.is-turn { height: 64px; min-height: 64px; }
  .flow-connector.is-turn::before { top: 0; left: 50%; width: 0; height: 100%; border-top: 0; border-left: 2px solid #c4a36e; }
  .flow-connector.is-turn::after { top: auto; right: calc(50% - 5px); bottom: 5px; width: 7px; height: 7px; border-top: 0; border-right: 2px solid #a77736; border-bottom: 2px solid #a77736; transform: rotate(45deg); }
  .flow-connector.is-turn .flow-connector-label { top: 50%; left: calc(50% + 14px); transform: translateY(-50%); }
  .flow-connector.is-reverse::after { right: auto; left: 2px; width: 0; height: 0; border: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-right: 8px solid #a77736; transform: translateY(-50%); }
}

@media (max-width: 1000px) {
  .app-shell { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 15px; }
  .brand { padding-bottom: 14px; }
  .overview-link { margin-top: 12px; }
  .workflow-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 8px; }
  .workflow-nav-item { grid-template-columns: 1fr; text-align: center; padding: 8px 5px; }
  .nav-order, .nav-state, .nav-text small { display: none; }
  .topbar { min-height: 76px; padding: 14px 18px; }
  .topbar { align-items: start; flex-direction: column; }
  .topbar-meta { width: 100%; justify-content: flex-start; }
  .project-picker { flex: 1 1 100%; }
  .project-picker { width: 100%; min-width: 0; }
  .project-picker select { width: auto; min-width: 0; max-width: none; flex: 1; }
  .overview-view, .material-center-view, .settings-view { padding: 20px 15px 35px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-project-card, .settings-storage-card, .settings-model-routing-card { grid-column: auto; }
  .settings-form-grid { grid-template-columns: 1fr; }
  .tier-options { grid-template-columns: 1fr; }
  .settings-wide { grid-column: auto; }
  .project-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .memoir-blueprint { padding: 25px 20px; }
  .blueprint-heading { grid-template-columns: 1fr; gap: 18px; }
  .blueprint-heading h2, .blueprint-heading p, .section-heading h2, .section-heading p, .memoir-note { overflow-wrap: anywhere; }
  .blueprint-heading .hero-progress { width: min(190px, 100%); }
  .memoir-orbit {
    grid-template-areas:
      "core"
      "source"
      "guard"
      "narrative"
      "delivery";
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 15px;
  }
  .memoir-core { min-height: 420px; }
  .memoir-artwork { width: min(340px, 82vw); }
  .halo-one { width: min(390px, 92vw); height: min(390px, 92vw); }
  .halo-two { width: min(450px, 104vw); height: min(450px, 104vw); }
  .memoir-note { min-height: auto; }
  .memoir-note::before, .memoir-note::after { display: none; }
  .project-gate { align-items: start; flex-direction: column; }
  .current-project-panel { grid-template-columns: auto 1fr; }
  .current-project-panel code { grid-column: 1 / -1; }
  .workflow-map { width: 100%; max-width: 650px; flex-direction: column; margin-inline: auto; overflow: visible; padding: 18px; }
  .workflow-stage, .workflow-stage.is-parallel { width: 100%; min-width: 0; flex: none; }
  .stage-caption { min-height: 0; margin: 0 2px 8px; }
  .stage-node-stack { display: grid; grid-template-columns: 1fr; }
  .is-parallel .stage-node-stack { grid-template-columns: 1fr 1fr; }
  .workflow-node, .is-parallel .workflow-node { min-width: 0; min-height: 148px; overflow-wrap: anywhere; }
  .flow-connector { width: 100%; height: 62px; min-height: 62px; flex: 0 0 62px; padding: 0; }
  .flow-connector::before { top: 0; left: 50%; width: 0; height: 100%; border-top: 0; border-left: 2px solid #c4a36e; }
  .flow-connector::after { top: auto; right: calc(50% - 5px); bottom: 5px; width: 7px; height: 7px; border-top: 0; border-right: 2px solid #a77736; border-bottom: 2px solid #a77736; transform: rotate(45deg); }
  .flow-connector-label { top: 50%; left: calc(50% + 14px); padding: 4px 7px; border-radius: 999px; background: #f8f4eb; text-align: left; transform: translateY(-50%); }
  .flow-connector.is-split::before, .flow-connector.is-merge::before { border-left-style: dashed; }
  .workflow-reuse { grid-template-columns: auto 1fr; }
  .reuse-tags { grid-column: 2; justify-content: flex-start; }
  .material-center-hero, .material-project-heading { align-items: flex-start; flex-direction: column; }
  .material-scope-grid, .material-category-grid, .material-production-list { grid-template-columns: 1fr; }
  .material-relation-card, .material-operation-card { grid-template-columns: 1fr; align-items: stretch; }
  .material-operation-actions { justify-content: flex-start; }
  .material-relation-confirm, .material-relation-message { grid-column: 1; }
  .material-toolbar { grid-template-columns: 1fr; }
  .material-heading-actions { justify-content: flex-start; }
  .section-heading { align-items: start; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .knowledge-heading { grid-template-columns: auto 1fr; }
  .knowledge-heading .status-chip { grid-column: 1 / -1; }
  .module-view { padding: 12px; }
  .module-toolbar { grid-template-columns: 1fr auto; }
  .module-model-picker { grid-column: 1 / -1; grid-template-columns: 1fr; }
  .back-button { grid-column: 1 / -1; width: max-content; }
  .frame-notice span:nth-child(2) { display: none; }
  #agent-frame { height: calc(100vh - 245px); min-height: 520px; }
}

@media (max-width: 560px) {
  .is-parallel .stage-node-stack { grid-template-columns: 1fr; }
  .workflow-reuse { grid-template-columns: 1fr; }
  .reuse-symbol { display: none; }
  .reuse-tags { grid-column: auto; }
  .model-form-grid, .model-profile-toolbar, .credential-box { grid-template-columns: 1fr; }
  .settings-hero { align-items: flex-start; flex-direction: column; }
  .settings-card { padding: 18px; }
  .storage-paths > div { grid-template-columns: 1fr; }
  .storage-sync-consumers, .storage-layout { grid-template-columns: 1fr; }
  .storage-picker-row, .asset-path-row, .delete-project-summary > div { grid-template-columns: 1fr; }
  .project-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .model-route-table, .model-route-table tbody, .model-route-table tr, .model-route-table td { display: block; width: 100%; }
  .model-route-table thead { display: none; }
  .model-route-table td { border-top: 0; padding: 7px 12px; }
  .model-route-table tr { padding: 7px 0; border-top: 1px solid var(--line); }
  .model-route-controls { grid-template-columns: 1fr; min-width: 0; }
  .settings-actions { justify-content: stretch; }
  .settings-actions button { width: 100%; }
  .project-danger-zone, .settings-project-trash-item { grid-template-columns: 1fr; }
  .project-danger-zone button, .settings-project-trash-item button { width: 100%; }
  .model-field-wide { grid-column: auto; }
  .model-step-heading { align-items: flex-start; flex-direction: column; }
  .model-step-actions { justify-content: stretch; }
  .model-step-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .workflow-map,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .workflow-node,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .workflow-node-route,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-category,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-file,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-toolbar,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-relation-section,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-relation-card,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-operation-section,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-operation-card,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-production-ledger,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .material-production-card,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .settings-project-create,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .settings-project-trash-item,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .project-storage-panel,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .project-metrics-panel,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .delete-impact-list,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .project-danger-zone,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .model-config-step,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .credential-box,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) .frame-notice {
  color: var(--ink);
  background: var(--surface);
}

html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) input:not([type="color"]),
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) textarea,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) select,
html:is([data-theme="dark"], [data-theme="custom"][data-custom-tone="dark"]) button:not(.overview-link):not(.workflow-nav-item):not(.primary-action) {
  color: var(--ink);
  border-color: var(--line);
  background-color: var(--surface);
}

.capability-coverage { margin: 0 0 14px; border: 1px solid rgba(0,0,0,.12); border-radius: 10px; background: rgba(127,127,127,.05); }
.capability-coverage summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 13px; }
.capability-coverage[open] summary { border-bottom: 1px solid rgba(0,0,0,.1); }
.capability-coverage-body-wrap, #capability-coverage-body { padding: 10px 14px; max-height: 260px; overflow: auto; }
.coverage-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.coverage-table th, .coverage-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid rgba(0,0,0,.08); vertical-align: top; }
.coverage-table th { position: sticky; top: 0; background: inherit; }
.coverage-table code { display: block; color: rgba(0,0,0,.55); font-size: 11px; margin-top: 2px; }

/* ===== 界面结构（docs/界面结构设计.md）：主菜单、当前作品、左下角账号、顶栏提醒、账户中心 / 账号设置 / 控制台 ===== */
body:not([data-role="admin"]) .admin-only { display: none !important; }
/* 总部 (admin and staff) see how memoirs are made: model choices per memoir, second factor. */
body:not([data-role="admin"]):not([data-role="staff"]) .hq-only { display: none !important; }

.main-nav { display: grid; gap: 4px; margin-top: 14px; }
.main-nav .overview-link { margin-top: 0; }
.sidebar-label { display: grid; gap: 4px; }
.sidebar-label strong { color: rgba(255,255,255,.9); font-size: 13px; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-close { display: none; margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 8px; color: #fff; background: rgba(255,255,255,.1); font-size: 20px; cursor: pointer; }

/* The account card stays visible at the bottom of the sidebar, even when the step list scrolls. */
.account-area { position: sticky; bottom: -20px; z-index: 5; margin: auto 0 -20px; padding: 16px 0 20px; background: var(--navy); }
.account-card { display: grid; grid-template-columns: 38px 1fr 14px; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; color: #fff; background: rgba(255,255,255,.06); text-align: left; cursor: pointer; }
.account-card:hover, .account-card[aria-expanded="true"] { background: rgba(255,255,255,.12); }
.account-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: #1b2b4a; background: #edc98f; font: 800 16px/1 SimSun, serif; }
.account-text { min-width: 0; }
.account-text strong, .account-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text strong { font-size: 14px; }
.account-text small { margin-top: 3px; color: rgba(255,255,255,.66); font-size: 12px; }
.account-caret { color: rgba(255,255,255,.6); font-size: 12px; }
.account-menu { position: absolute; right: 0; bottom: calc(100% - 8px); left: 0; z-index: 30; display: grid; padding: 6px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface); box-shadow: 0 18px 40px rgba(16,28,52,.28); }
.account-menu[hidden] { display: none; }
.account-menu button { padding: 11px 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 14px; cursor: pointer; }
.account-menu button:hover, .account-menu button:focus-visible { background: var(--gold-soft); outline: none; }
.account-menu .is-logout { color: #8c302d; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }

.topbar-title { min-width: 0; }
.drawer-toggle { display: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 20px; cursor: pointer; }
.bell-wrap { position: relative; }
.bell-button { position: relative; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 17px; cursor: pointer; }
.bell-button:hover, .bell-button[aria-expanded="true"] { background: var(--gold-soft); }
.bell-count { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; color: #fff; background: #c2522f; font: 800 11px/20px ui-monospace, monospace; text-align: center; }
.bell-count[hidden] { display: none; }
.bell-panel { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; display: grid; gap: 4px; width: min(300px, 86vw); padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 18px 40px rgba(16,28,52,.18); }
.bell-panel[hidden] { display: none; }
.bell-heading { margin: 2px 4px 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.bell-item { padding: 10px; border: 0; border-radius: 8px; background: var(--paper); text-align: left; font-size: 14px; cursor: pointer; }
.bell-item:hover { background: var(--gold-soft); }

/* 工作台欢迎横幅：本账号进度，可收起 */
.hero-side { display: grid; gap: 10px; justify-items: stretch; }
.banner-toggle { padding: 7px 12px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; color: #fff; background: rgba(255,255,255,.08); font-size: 12px; cursor: pointer; }
.banner-toggle:hover { background: rgba(255,255,255,.16); }
.memoir-blueprint.is-collapsed { padding-block: 22px; }
.memoir-blueprint.is-collapsed .memoir-orbit,
.memoir-blueprint.is-collapsed .blueprint-heading > div:first-child > p:last-child { display: none; }
.memoir-blueprint.is-collapsed .blueprint-heading h2 { font-size: clamp(20px, 2vw, 26px); }

/* 账户中心、账号设置、控制台 */
.page-view { max-width: 1420px; margin: 0 auto; padding: clamp(22px, 3.5vw, 48px); }
.page-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: clamp(20px, 3vw, 32px); color: #fff; border-radius: 18px; background: linear-gradient(135deg, var(--navy), #29456f); box-shadow: var(--shadow); }
.page-hero h2 { margin: 0; font-family: SimSun, serif; font-size: clamp(26px, 3.2vw, 38px); }
.page-hero p:last-child { max-width: 830px; margin: 10px 0 0; color: rgba(255,255,255,.78); font-size: 14px; line-height: 1.7; }
.page-hero .section-kicker { color: #e9c58e; }
.panel-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 14px; }
.panel-tabs button { min-height: 38px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: var(--surface); cursor: pointer; font-size: 14px; }
.panel-tabs button[aria-selected="true"] { color: #fff; border-color: var(--navy); background: var(--navy); }
.panel-root, .panel-body { display: grid; gap: 16px; }
.ui-panel [hidden] { display: none !important; }
.ui-panel .panel-card, .ui-panel .settings-card { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 8px 26px rgba(31,42,68,.045); }
.ui-panel .panel-card h2, .ui-panel .panel-card h3 { margin: 0 0 12px; font-size: 17px; }
.ui-panel .panel-card > h3:not(:first-child) { margin-top: 18px; font-size: 15px; }
.panel-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-card-heading h3 { margin: 0 !important; }
.panel-card.is-soon { border-style: dashed; background: var(--paper); }
.soon-badge { padding: 4px 10px; border-radius: 999px; color: #704917; background: var(--gold-soft); font-size: 12px; font-weight: 800; white-space: nowrap; }
.panel-muted { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.panel-empty { margin: 0; padding: 18px; border-radius: 10px; color: var(--muted); background: var(--paper); text-align: center; }
.panel-error, .panel-alert { margin: 0 0 12px; padding: 10px 14px; border: 1px solid #efcaca; border-radius: 10px; color: var(--danger); background: #fbeaea; }
.panel-success { margin: 0 0 12px; padding: 10px 14px; border: 1px solid #bfe0d3; border-radius: 10px; color: var(--green); background: var(--green-soft); }
.panel-alert.info { color: var(--green); border-color: #c9e6da; background: var(--green-soft); }
.panel-alert[hidden] { display: none; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.metric { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.metric span, .metric small { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin: 4px 0 2px; font-size: 22px; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.data-table input[type="number"] { width: 92px; }
.tier-cell { display: grid; gap: 4px; min-width: 150px; }
.tier-cell select { width: 100%; }
.tier-cell small { color: var(--muted); font-size: 11px; }
.tier-cell.is-unavailable small { color: #b42318; }
.tier-purpose { display: grid; gap: 3px; min-width: 120px; }
.tier-purpose small { color: var(--muted); font-size: 11px; }
.tier-name-row > span { min-width: 1.5em; font-weight: 700; }
.tier-name-row input:nth-of-type(1) { width: 110px; }
.tier-name-row input:nth-of-type(2) { flex: 1 1 260px; min-width: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.positive { color: var(--green); }
.negative { color: var(--danger); }
.line-kind { display: inline-block; margin-right: 4px; padding: 1px 7px; border-radius: 999px; background: var(--slate-soft); font-size: 11px; }
.line-kind.kind-settle { color: #8c302d; background: #fbeaea; }
.line-kind.kind-release { color: var(--green); background: var(--green-soft); }
.filter-row, .inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 12px; }
.ui-panel select, .ui-panel input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), .ui-panel textarea { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); }
.ui-panel textarea { padding: 10px; }
.ui-panel .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); text-decoration: none; cursor: pointer; font-size: 14px; }
.ui-panel .button:disabled { opacity: .5; cursor: not-allowed; }
.ui-panel .button-primary { color: #fff; border-color: var(--navy); background: var(--navy); }
.ui-panel .button-secondary { background: var(--slate-soft); }
.ui-panel .button-ghost { background: transparent; }
.ui-panel .button-danger { color: #fff; border-color: var(--gold); background: var(--gold); }
.usage-list { display: grid; gap: 8px; }
.usage-item { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.usage-item summary { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; cursor: pointer; }
.usage-item .table-scroll { padding: 0 16px 12px; }
.panel-details { padding: 6px 0; }
.panel-details > summary { padding: 10px 0; color: var(--navy-2); font-weight: 700; cursor: pointer; }
.embedded-center { padding: 14px; border-radius: 12px; background: var(--paper); }
.embedded-center .panel-tabs { margin-top: 0; }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 12px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; }
.profile-panel { display: grid; gap: 16px; }
.profile-panel[hidden] { display: none; }
.console-system-host[hidden] { display: none; }
.console-system-host { margin-top: 16px; }
.prompt-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.prompt-keys { display: grid; gap: 4px; align-content: start; }
.prompt-keys button { padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; color: var(--ink); background: transparent; text-align: left; font-size: 13px; cursor: pointer; }
.prompt-keys button[aria-current="true"] { border-color: var(--line); background: var(--gold-soft); font-weight: 700; }
.prompt-editor { width: 100%; box-sizing: border-box; min-height: 360px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font: 13px/1.7 ui-monospace, Consolas, "Microsoft YaHei", monospace; }

.bottom-nav, .drawer-backdrop { display: none; }

/* 手机：侧栏改为抽屉，底部导航放主入口 */
@media (max-width: 760px) {
  .app-shell { display: block; padding-bottom: 72px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 86vw); height: 100vh; padding: 18px 14px; transform: translateX(-105%); transition: transform .22s ease; }
  .drawer-open .sidebar { transform: none; box-shadow: 0 0 50px rgba(0,0,0,.35); }
  .drawer-close { display: block; }
  .account-area { bottom: -18px; margin-bottom: -18px; padding-bottom: 18px; }
  .drawer-backdrop:not([hidden]) { position: fixed; inset: 0; z-index: 45; display: block; background: rgba(10,18,34,.45); }
  .sidebar-label { display: grid; }
  .workflow-nav { grid-template-columns: 1fr; }
  .workflow-nav-item { grid-template-columns: 30px 1fr 8px; text-align: left; padding: 10px; }
  .nav-order, .nav-state, .nav-text small { display: block; }
  .drawer-toggle { display: block; flex: none; }
  .topbar { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: auto 1fr auto; align-items: center; min-height: 0; gap: 10px; padding: 10px 12px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 20px; overflow: hidden; text-overflow: ellipsis; }
  .topbar-meta { display: contents; }
  .project-picker { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .bell-wrap { grid-column: 3; grid-row: 1; }
  .bottom-nav { position: fixed; inset: auto 0 0 0; z-index: 40; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav button { display: grid; justify-items: center; gap: 2px; min-height: 60px; padding: 8px 4px; border: 0; color: var(--muted); background: transparent; font-size: 12px; cursor: pointer; }
  .bottom-nav button span:first-child { font-size: 20px; line-height: 1; }
  .bottom-nav button.is-active { color: var(--navy); font-weight: 800; }
  .page-view { padding: 16px 12px 30px; }
  .page-hero { padding: 18px; border-radius: 14px; }
  .panel-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .panel-tabs button { flex: none; }
  .ui-panel .panel-card, .ui-panel .settings-card { padding: 16px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric strong { font-size: 18px; }
  .prompt-layout { grid-template-columns: 1fr; }
  .hero-side { grid-template-columns: 1fr auto; align-items: center; }
  /* 个人版适老：大字、大按钮 */
  body[data-edition="personal"] { font-size: 17px; }
  body[data-edition="personal"] .bottom-nav button { min-height: 66px; font-size: 14px; }
  body[data-edition="personal"] .topbar h1 { font-size: 22px; }
  body[data-edition="personal"] .workflow-nav-item { padding: 13px 10px; }
  body[data-edition="personal"] .nav-text strong { font-size: 16px; }
  body[data-edition="personal"] .account-menu button { padding: 14px 12px; font-size: 16px; }
}

/* WO-06：个人版素材卡片标题 / 模块提示条，至少 16px（宽屏个人版也适用） */
body[data-edition="personal"] .material-file-name strong,
body[data-edition="personal"] .material-file-name small { font-size: 16px; line-height: 1.6; }
body[data-edition="personal"] .material-stat span,
body[data-edition="personal"] .material-stat small,
body[data-edition="personal"] .material-group-heading span,
body[data-edition="personal"] .material-project-heading p:last-child,
body[data-edition="personal"] .material-scope-card p:not(.section-kicker),
body[data-edition="personal"] .frame-notice { font-size: 16px; line-height: 1.6; }
body[data-edition="personal"] .frame-notice button { font-size: 16px; padding: 8px 12px; }
body[data-edition="personal"] #agent-frame.is-auto-height { min-height: 0; }

/* WP-I2：个人版（手机）适老——说明文字、表单标签、数字标签不小于 15px */
@media (max-width: 760px) {
  body[data-edition="personal"] :is(.section-kicker, .note-index, .banner-toggle, .settings-explanation, .settings-warning, .settings-message, .settings-required,
    .settings-form label, .settings-project-selector span, .tier-option span, .project-metric span, .project-metrics-panel > div:first-child p, .project-metrics-panel > div:first-child strong,
    .metric span, .metric small, .panel-muted, .viz-empty, .status-chip, .knowledge-description, .hero-side small, .nav-text small, .project-picker span) { font-size: 15px; line-height: 1.6; }
  body[data-edition="personal"] :is(.tier-option strong, .project-metrics-panel .project-metric strong) { font-size: 18px; }
  body[data-edition="personal"] :is(.settings-form input, .settings-form select, .settings-form textarea, .panel-card input, .panel-card select, .project-picker select) { font-size: 17px; min-height: 48px; }
  body[data-edition="personal"] :is(.primary-action, .page-view button) { font-size: 17px; min-height: 48px; }
  body[data-edition="personal"] .project-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 账户中心的表格：手机上改成一条一张卡，“点数”不用横着划才看得到 */
  body[data-edition="personal"] .data-table thead { display: none; }
  body[data-edition="personal"] .data-table, body[data-edition="personal"] .data-table tbody, body[data-edition="personal"] .data-table tr { display: block; width: 100%; }
  body[data-edition="personal"] .data-table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  body[data-edition="personal"] .data-table td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; font-size: 16px; line-height: 1.5; }
  body[data-edition="personal"] .data-table td::before { content: attr(data-label); flex: none; color: var(--muted); }
  body[data-edition="personal"] .data-table td > * { text-align: right; }
  body[data-edition="personal"] .data-table td.num { font-size: 20px; font-weight: 700; }
  /* 工作台页面嵌在页面里：没撑高时仍占满一屏；有 .is-auto-height 时由 JS 设 height */
  body[data-edition="personal"] .frame-notice > span:nth-child(2) { display: none; }
  body[data-edition="personal"] #agent-frame { height: calc(100svh - 190px); min-height: 480px; }
}

/* WP-N: notices, reports and agreements in 账户中心 / 控制台 */
.announcement { padding: 10px 0; border-top: 1px solid var(--line); }
.announcement:first-of-type { border-top: 0; }
.announcement-body { margin: 6px 0 0; white-space: pre-wrap; }
.ui-panel .agreement-body { margin: 10px 0 0; max-height: 360px; overflow: auto; white-space: pre-wrap; font: inherit; line-height: 1.7; }
.ui-panel .panel-card textarea { width: 100%; box-sizing: border-box; }
.compliance-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.platform-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.platform-card .panel-card-heading h3 { font-size: 15px; }
.platform-state { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; color: var(--muted); background: var(--slate-soft); }
.platform-state.is-ready { color: var(--green); background: var(--green-soft); }
.platform-state.is-failed { color: var(--danger); background: #fbeaea; }
.platform-checked { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.platform-connect .inline-form input { flex: 1 1 260px; min-width: 0; }
.panel-error ul { margin: 6px 0 0; padding-left: 20px; }
.tier-auto { display: grid; gap: 3px; min-width: 150px; }
.tier-auto small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.tier-auto.is-missing strong { color: var(--danger); }
.platform-select { flex: 1 1 260px; min-width: 0; width: 100%; max-width: 100%; }
.platform-connect > * { max-width: 100%; }
.platform-connect, .platform-card { min-width: 0; }
.platform-connect .inline-form > * { min-width: 0; }
.platform-connect .inline-form button { flex: 0 0 auto; }
.platform-models { margin: 0 0 10px; }
.platform-models > summary { cursor: pointer; color: var(--accent, #1f3b63); font-size: 13px; font-weight: 700; }
.platform-card:has(.platform-models[open]) { grid-column: 1 / -1; }
.platform-model-group h4 { margin: 14px 0 6px; font-size: 13px; }
.platform-model-group td:first-child { word-break: break-all; }
.ui-panel .platform-delete { color: var(--danger); }
.builtin-functions { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: var(--slate-soft); font-size: 13px; }
.builtin-functions ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.7; }

/* 开通赠送：默认不勾选的复选项 */
.inline-check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ---------- 图表（public/charts.mjs） ----------
   分类色 --viz-1..3 与单色 --viz-seq 已用调色板校验脚本验过（浅色背景 #fffefb、深色背景 #202733）。
   浅色下 --viz-3 对比度 2.79 < 3:1，所以每个图都带“色块 + 名称 + 数值”图例。 */
:root {
  --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a;
  --viz-seq: #2a78d6; --viz-seq-soft: #86b6ef; --viz-seq-strong: #1c5cab;
  --viz-track: var(--slate-soft); --viz-grid: #e1e0d9; --viz-axis: #c3c2b7;
  --viz-good: #0ca30c; --viz-warning: #fab219; --viz-critical: #d03b3b;
}
html[data-theme="dark"], html[data-theme="custom"][data-custom-tone="dark"] {
  --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70;
  --viz-seq: #3987e5; --viz-seq-soft: #1c5cab; --viz-seq-strong: #5598e7;
  --viz-grid: #2c3442; --viz-axis: #4a5466;
}
.viz { margin: 0 0 14px; min-width: 0; }
.viz figcaption { margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.viz-slot-1 { background: var(--viz-1); } .viz-slot-2 { background: var(--viz-2); } .viz-slot-3 { background: var(--viz-3); }
.viz-stack { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; background: var(--viz-track); }
.viz-stack.is-empty { background: var(--viz-track); }
.viz-seg { min-width: 4px; cursor: default; outline-offset: 2px; }
.viz-seg:hover, .viz-seg:focus-visible { filter: brightness(1.12); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.viz-legend strong { color: var(--ink); font-weight: 700; }
.viz-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.viz-empty { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.viz-barlist ol { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.viz-barlist li { display: grid; grid-template-columns: minmax(80px, 30%) 1fr; gap: 4px 10px; align-items: center; font-size: 13px; }
.viz-barlist small { grid-column: 2; color: var(--muted); font-size: 12px; }
.viz-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.viz-bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; outline-offset: 2px; }
.viz-bar { height: 12px; border-radius: 0 4px 4px 0; background: var(--viz-seq); flex: none; }
.viz-bar-track { width: 100%; }
.viz-bar-track:hover .viz-bar, .viz-bar-track:focus-visible .viz-bar { filter: brightness(1.12); }
.viz-bar-track strong { color: var(--ink); font-size: 12px; white-space: nowrap; }
.viz-cols { position: relative; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: var(--viz-cols-height, 120px) auto; }
.viz-cols-tick { position: absolute; left: 0; width: 34px; text-align: right; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-cols-tick.is-top { top: -7px; }
.viz-cols-tick.is-zero { top: calc(var(--viz-cols-height, 120px) - 7px); }
.viz-cols-plot { grid-column: 2; display: flex; align-items: flex-end; gap: 2px; height: 100%;
  border-top: 1px solid var(--viz-grid); border-bottom: 1px solid var(--viz-axis); }
.viz-col { flex: 1 1 0; display: flex; justify-content: center; align-items: flex-end; height: 100%; min-width: 0; cursor: default; outline-offset: 2px; }
.viz-col-bar { width: min(24px, 70%); min-height: 0; border-radius: 4px 4px 0 0; background: var(--viz-seq-soft); }
.viz-col.is-current .viz-col-bar { background: var(--viz-seq-strong); }
.viz-col:hover .viz-col-bar, .viz-col:focus-visible .viz-col-bar { filter: brightness(1.12); }
.viz-cols-labels { grid-column: 2; display: flex; gap: 2px; margin-top: 4px; }
.viz-cols-labels span { flex: 1 1 0; min-width: 0; overflow: hidden; text-align: center; white-space: nowrap; color: var(--muted); font-size: 11px; }
.viz-meter { height: 12px; border-radius: 6px; background: var(--viz-track); overflow: hidden; outline-offset: 2px; }
.viz-meter-fill { display: block; height: 100%; border-radius: 6px; }
.viz-meter-fill.is-good { background: var(--viz-good); }
.viz-meter-fill.is-warning { background: var(--viz-warning); }
.viz-meter-fill.is-critical { background: var(--viz-critical); }
.viz-meter-note { display: flex; gap: 6px; align-items: baseline; margin: 6px 0 0; color: var(--ink); font-size: 13px; }
.viz-meter-note b { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: #fff; font-size: 11px; flex: none; }
.viz-meter-note.is-good b { background: var(--viz-good); }
.viz-meter-note.is-warning b { background: #b07800; }
.viz-meter-note.is-critical b { background: var(--viz-critical); }
.viz-data { margin-top: 6px; font-size: 12px; color: var(--muted); }
.viz-data summary { cursor: pointer; }
.viz-data table { margin-top: 6px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.viz-data caption { text-align: left; color: var(--muted); }
.viz-data th, .viz-data td { padding: 2px 12px 2px 0; text-align: left; font-weight: 400; color: var(--ink); }
.viz-tooltip { position: fixed; z-index: 1000; display: grid; gap: 2px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); box-shadow: var(--shadow); pointer-events: none; font-size: 12px; }
.viz-tooltip strong { color: var(--ink); font-size: 14px; }
.viz-tooltip span { color: var(--muted); }
@media (forced-colors: active) { .viz-seg, .viz-bar, .viz-col-bar, .viz-meter-fill { forced-color-adjust: none; } }

/* WP-E 点数一览（工作台头部）：可用点数、赠送到期、本作品预计还需。图形用共用的 charts.mjs。 */
.wpe-points { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 18px; }
.wpe-points[hidden] { display: none; }
.wpe-block { flex: 1 1 240px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 0; }
.wpe-block.is-soon { border: 2px solid var(--viz-warning); }
.wpe-estimate { flex-basis: 100%; }
.wpe-title { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.wpe-big { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.3; color: var(--ink); font-variant-numeric: tabular-nums; }
.wpe-small { margin: 4px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.wpe-expiry { display: flex; gap: 8px; align-items: baseline; margin: 0; font-size: 15px; line-height: 1.6; color: var(--ink); }
.wpe-expiry.is-soon { font-weight: 700; }
.wpe-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #b07800; color: #fff; font-size: 13px; flex: none; }
.wpe-estimate .viz-meter-figure { margin: 10px 0 0; }
.wpe-estimate .viz-meter { height: 16px; border-radius: 8px; }
.wpe-estimate .viz-meter-fill { border-radius: 8px; }
.wpe-estimate .viz-meter-note { font-size: 15px; }
.wpe-stages { margin-top: 10px; font-size: 14px; }
.wpe-stages summary { cursor: pointer; color: var(--muted); }
.wpe-stages .viz-barlist { margin-top: 8px; }
.wpe-large .wpe-title { font-size: 18px; }
.wpe-large .wpe-big { font-size: 34px; }
.wpe-large .wpe-small, .wpe-large .wpe-expiry, .wpe-large .wpe-estimate .viz-meter-note, .wpe-large .wpe-stages { font-size: 18px; }
.wpe-large .viz-barlist li, .wpe-large .viz-bar-track strong, .wpe-large .viz-data { font-size: 16px; }
.wpe-large .wpe-icon { width: 26px; height: 26px; font-size: 17px; }
.wpe-large .wpe-estimate .viz-meter { height: 22px; border-radius: 11px; }
@media (max-width: 640px) {
  .wpe-big { font-size: 28px; }
  .wpe-small, .wpe-expiry { font-size: 16px; }
}

/* 账户中心图表（acct-）：图表本身见 public/charts.mjs；这里只管它们在账户中心里的摆放。 */
.acct-chart-card { min-width: 0; margin-bottom: 12px; }
.ui-panel .acct-chart-card.panel-card { margin-top: 12px; }
.acct-chart-card .viz { margin: 0; }
.acct-chart-card .viz > figcaption { margin-bottom: 10px; font-size: 15px; font-weight: 700; }
.acct-chart-card .panel-muted { margin: 10px 0 0; }
.acct-expiry { display: flex; gap: 8px; align-items: baseline; margin: 12px 0 0; color: var(--ink); font-size: 14px; }
.acct-expiry.is-soon { padding: 8px 12px; border: 1px solid #b07800; border-radius: 10px; background: color-mix(in srgb, var(--viz-warning) 16%, transparent); font-weight: 700; }
.acct-expiry b { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #b07800; color: #fff; font-size: 12px; flex: none; }
.acct-usage-detail { padding: 0 16px 14px; }
.usage-item[open] > summary { margin-bottom: 4px; }
@media (max-width: 640px) {
  .acct-chart-card .viz-barlist li { grid-template-columns: minmax(70px, 34%) 1fr; }
}
@media (max-width: 640px) {
  .acct-metrics .metric:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* 中台图表（总览 / 账号）：图表本身见 public/charts.mjs；这里只管版面与“需要关注”的醒目底色。 */
.hq-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; margin-top: 16px; }
.hq-chart { min-width: 0; }
.hq-chart .viz:last-child { margin-bottom: 0; }
.hq-attention { margin-bottom: 16px; }
.hq-attention.has-items { border-color: var(--viz-warning); border-left-width: 5px; background: color-mix(in srgb, var(--viz-warning) 10%, var(--surface)); }
.hq-attention ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.hq-attention-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; color: #fff; background: #b07800; font-size: 12px; }
.ui-panel .panel-card > .viz { margin-top: 4px; }
.hq-chart.is-wide { grid-column: 1 / -1; }

/* 成品导出 (WP-F): 导出整本面板；字号偏大、按钮够高，手机上单列。 */
.export-panel { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); transition: box-shadow .2s, border-color .2s; }
.export-panel.is-attention { border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 28%, transparent); }
.export-head { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: start; gap: 12px 16px; }
.export-head strong { color: var(--ink); font-size: 18px; }
.export-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.export-build { min-height: 48px; padding: 10px 22px; color: #fff; border: 1px solid var(--navy); border-radius: 10px; background: var(--navy); font-size: 16px; font-weight: 900; white-space: nowrap; }
.export-build:disabled { opacity: .55; cursor: not-allowed; }
.export-build.is-loading::after { display: inline-block; width: 12px; height: 12px; margin-left: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -2px; content: ""; animation: spin .75s linear infinite; }
.export-status { margin: 12px 0 0; padding: 10px 12px; color: var(--ink); border-left: 4px solid var(--green); border-radius: 6px; background: var(--green-soft); font-size: 15px; line-height: 1.6; }
.export-status.is-warning { border-left-color: var(--gold); background: var(--gold-soft); }
.export-list { display: grid; gap: 10px; margin-top: 12px; }
.export-list:empty { display: none; }
.export-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.export-item strong { color: var(--ink); font-size: 15px; }
.export-item small { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.export-chip { display: inline-block; margin-left: 8px; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; color: var(--muted); background: var(--paper); }
.export-chip.is-ready { color: #fff; background: var(--green); }
.export-chip.is-done { color: var(--green); background: var(--green-soft); }
.export-chip.is-working { color: #7a531e; background: var(--gold-soft); }
.export-chip.is-failed { color: #fff; background: #a9443d; }
.export-download { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 20px; color: var(--navy); border: 2px solid var(--navy); border-radius: 10px; font-size: 15px; font-weight: 900; text-decoration: none; }
.export-delete-note { margin: 0 0 10px; padding: 8px 12px; color: var(--green); border-radius: 6px; background: var(--green-soft); font-size: 14px; }
@media (max-width: 640px) {
  .export-head, .export-item { grid-template-columns: 1fr; }
  .export-build, .export-download { width: 100%; }
}

/* WP-K2：控制台“成本”页的时间范围预设、调用结果标记，总览里的人工对账队列 */
.k2-range-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 0 0 10px; }
.k2-range { display: inline-flex; gap: 6px; }
.k2-range-btn { min-width: 84px; }
.k2-outcome { font-weight: 600; white-space: nowrap; }
.k2-outcome.is-failed { color: color-mix(in srgb, var(--viz-critical) 72%, var(--ink)); }
.k2-outcome.is-unknown { color: color-mix(in srgb, var(--viz-warning) 55%, var(--ink)); }
.k2-job-list { display: grid; gap: 12px; }
.k2-job { min-width: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.k2-job > header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.k2-job-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 16px; margin: 0 0 10px; }
.k2-job-facts dt { color: var(--muted); font-size: 12px; }
.k2-job-facts dd { margin: 2px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.k2-job-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.k2-confirm { margin-top: 10px; padding: 10px 12px; border-left: 4px solid var(--viz-warning); border-radius: 8px; background: var(--slate-soft); }
.k2-confirm p { margin: 0 0 8px; }
.k2-confirm input { flex: 1 1 220px; min-width: 0; }
@media (max-width: 640px) {
  .k2-range { display: flex; width: 100%; }
  .k2-range-btn { flex: 1 1 0; min-width: 0; }
  .k2-job-actions .button { flex: 1 1 100%; }
}
/* 列多的明细表：不挤成窄条换行，超出宽度时在表格内横向滚动 */
.k2-wide-table .data-table { min-width: 860px; }
.k2-wide-table.is-nowrap .data-table td { white-space: nowrap; }
.k2-alert-link { color: inherit; font-weight: 700; text-decoration: underline; }

/* 逐字稿说话人：转写平台分出的“说话人1 / 2…”按颜色区分，并对应到受访者或采访者 */
.spk-c1 { --spk: #2f6fb3; }
.spk-c2 { --spk: #b5642a; }
.spk-c3 { --spk: #2f8a5f; }
.spk-c4 { --spk: #8a4fb0; }
.spk-c5 { --spk: #b03f5e; }
.spk-c6 { --spk: #6b7a1f; }
.spk-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: color-mix(in srgb, var(--spk, var(--muted)) 78%, var(--ink)); background: color-mix(in srgb, var(--spk, var(--muted)) 16%, var(--surface)); }
.spk-seg { margin: 4px 0; padding-left: 10px; border-left: 3px solid transparent; line-height: 1.7; overflow-wrap: anywhere; }
.spk-seg[class*="spk-c"] { border-left-color: var(--spk); }
.spk-map { margin: 10px 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.spk-map h4 { margin: 0 0 4px; font-size: 15px; }
.spk-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.spk-who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; flex: 1 1 260px; }
.spk-who .studio-muted { overflow-wrap: anywhere; }
.spk-pick { display: inline-flex; align-items: center; gap: 6px; flex: 0 1 300px; min-width: 0; }
.spk-select { flex: 1 1 auto; width: 100%; min-width: 0; max-width: 100%; min-height: 40px; }
.spk-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.spk-message { margin: 8px 0 0; color: var(--danger); }
.spk-segments { margin-top: 6px; }
@media (max-width: 640px) {
  .spk-pick { flex: 1 1 100%; }
  .spk-actions .button { flex: 1 1 100%; }
}

/* 账号设置 → 安全: the SMS code field and its "获取验证码" button share one row. */
.settings-form .code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.settings-form .code-row button { padding: 10px 14px; border: 1px solid #cbbfae; border-radius: 8px; color: #744e1d; background: #fffaf2; font-weight: 900; white-space: nowrap; cursor: pointer; }
.settings-form .code-row button:disabled { opacity: .6; cursor: default; }
