/* ============================================================
   企业内训课程开发辅助系统 · 样式
   ------------------------------------------------------------
   设计取向：与 books/seminars/english 同套语言（米白纸面/衬线正文/克制动效）。
   三区 Grid：左 220px 步骤导航 + 中 1fr 工作区 + 右 300px 产物面板。
   三态视觉：字段左竖条（绿=已确认 / 蓝=推测 / 灰=待确认）+ 角标。
   ============================================================ */

:root {
  --bg: #f4f0e6;
  --paper: #fbf7ec;
  --ink: #2b2a26;
  --ink-soft: #4e4b44;
  --muted: #8b8678;
  --accent: #0284c7;            /* 天空蓝（推测） */
  --accent-soft: #0ea5e9;
  --accent-bg: #e8f4fb;         /* 浅蓝底 */
  --accent-ink: #ffffff;
  --rule: #d9d2c2;
  --highlight: #fff3b8;
  --danger: #b3261e;
  --success: #2f7d4f;           /* 绿（已确认） */
  --success-bg: #eaf5ee;
  --warn: #b8860b;              /* 黄（存疑/黄灯） */
  --warn-bg: #fdf6e3;
  --shadow-sm: 0 1px 2px rgba(31, 28, 22, .08);
  --shadow-md: 0 8px 28px rgba(31, 28, 22, .12);
  --radius: 12px;
}

[data-theme="dark"] {
  --bg: #0c1f2e;
  --paper: #11283a;
  --ink: #ece4d2;
  --ink-soft: #c0b89f;
  --muted: #8c8472;
  --accent: #38bdf8;
  --accent-soft: #7dd3fc;
  --accent-bg: #0f2c3f;
  --accent-ink: #0c1f2e;
  --rule: #1f3a52;
  --highlight: #574f1f;
  --danger: #ff8979;
  --success: #6dd49a;
  --success-bg: #12352a;
  --warn: #e5c158;
  --warn-bg: #3a3214;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 12px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ===== topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-family: "Noto Sans SC", sans-serif; font-weight: 700; font-size: 15px;
}
.brand__title { font-size: 17px; font-weight: 600; }
.brand__title em { font-style: normal; font-weight: 400; opacity: .7; }
.brand__sep { margin: 0 6px; opacity: .35; }
.topbar__right { display: flex; gap: 8px; align-items: center; }
.topbar__course {
  font-size: 14px; color: var(--ink-soft);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink-soft);
  cursor: pointer;
}
.chip:hover { background: var(--bg); }
.chip--user { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip__avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }

/* ===== 三区布局 ===== */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px;
  min-height: calc(100vh - 56px);
  align-items: start;
}

.rail, .panel, .work {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.rail { position: sticky; top: 72px; }
.panel { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; }

/* ===== 左区：步骤导航 ===== */
.rail { padding: 12px; }
.rail__head { font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 6px 10px; letter-spacing: .05em; }
.step {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 8px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent;
  position: relative;
}
.step:hover { background: var(--bg); }
.step[data-active="true"] { background: var(--accent-bg); border-color: var(--accent-soft); }
.step[data-disabled="true"] { opacity: .5; cursor: not-allowed; }
.step__dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--rule); background: transparent;
  display: grid; place-items: center; font-size: 10px; color: var(--accent-ink);
  margin-top: 2px;
}
.step__dot[data-state="done"] { background: var(--success); border-color: var(--success); color: #fff; }
.step__dot[data-state="active"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.step__body { flex: 1; min-width: 0; }
.step__name { font-size: 13px; font-weight: 500; line-height: 1.35; }
.step__meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.step__tag { font-size: 10px; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; }
.step__count {
  font-size: 11px; font-weight: 700; color: #fff;
  background: #e8890c; border-radius: 999px; padding: 0 6px; min-width: 16px; text-align: center;
}
.step__bar { height: 3px; background: var(--rule); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.step__bar > span { display: block; height: 100%; background: var(--success); border-radius: 2px; }

/* 闸门徽标 */
.gate { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 600; padding: 0 4px; border-radius: 4px; }
.gate--green { background: var(--success); color: #fff; }
.gate--red { background: var(--danger); color: #fff; }
.gate--yellow { background: var(--warn); color: #fff; }
.gate--gray { background: transparent; color: var(--muted); border: 1px solid var(--rule); }

/* ===== 中区：工作区 ===== */
.work { padding: 20px 24px; min-height: 60vh; }
.work__step-label {
  position: sticky; top: 0; z-index: 5;
  font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .05em;
  background: var(--paper); padding: 4px 0 8px; margin: -8px 0 12px;
}
.placeholder { text-align: center; padding: 70px 20px; }
.placeholder__big { font-size: 18px; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); }
.spinner {
  display: inline-block; width: 22px; height: 22px;
  border: 3px solid var(--rule); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 对话流 ---- */
.chatflow { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg--system { align-self: flex-start; }
.msg--user { align-self: flex-end; }
.msg__bubble {
  padding: 10px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.7; white-space: pre-wrap;
}
.msg--system .msg__bubble { background: var(--bg); border: 1px solid var(--rule); border-radius: 12px 12px 12px 4px; }
.msg--user .msg__bubble { background: var(--accent); color: var(--accent-ink); border-radius: 12px 12px 4px 12px; }
.msg__basis { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg__basis::before { content: '基于：'; opacity: .7; }

/* 追问说明卡 */
.askcard {
  background: var(--highlight); border: 1px solid var(--warn);
  border-radius: 10px; padding: 14px 16px; align-self: flex-start; max-width: 92%;
}
.askcard__reason { font-size: 14px; margin: 0 0 8px; }
.askcard__questions { margin: 0 0 10px; padding-left: 20px; font-size: 13px; }
.askcard__questions li { margin: 3px 0; }
.askcard__hint { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.askcard__actions { display: flex; gap: 8px; }

/* 落点分流选项卡 */
.typetabs { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 6px 0; }
.typetab {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--paper); cursor: pointer; text-align: left;
}
.typetab:hover { border-color: var(--accent-soft); background: var(--accent-bg); }
.typetab__name { font-weight: 600; font-size: 14px; }
.typetab__desc { font-size: 12px; color: var(--muted); }
.typetab__tag { font-size: 10px; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 5px; }

/* 聊天输入 */
.chatinput { display: flex; gap: 8px; margin-top: 16px; }
.chatinput textarea {
  flex: 1; min-height: 52px; resize: vertical;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--bg); color: var(--ink); font-family: inherit; font-size: 14px;
}
.chatinput textarea:focus { outline: none; border-color: var(--accent); }
.chatinput .btn { align-self: flex-end; }

/* ===== 产物卡 + 三态字段 ===== */
.card {
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--paper); overflow: hidden;
}
.card--locked { border-color: var(--success); }
.card--doubt { border-color: var(--warn); }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--rule); background: var(--bg);
}
.card__title { font-size: 15px; font-weight: 700; margin: 0; }
.card__badges { display: flex; gap: 6px; align-items: center; }
.card__status { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); }
.card--locked .card__status { background: var(--success); color: #fff; border-color: var(--success); }
.card--doubt .card__status { background: var(--warn); color: #fff; border-color: var(--warn); }
.card__lock { font-size: 14px; }
.card__body { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.card__foot { padding: 12px 16px; border-top: 1px solid var(--rule); display: flex; gap: 8px; flex-wrap: wrap; }

/* 三态字段容器 */
.field {
  position: relative;
  padding: 8px 12px 8px 16px;
  border-left: 3px solid var(--muted);
  border-radius: 0 8px 8px 0;
  background: var(--paper);
}
.field--confirmed { border-left-color: var(--success); background: var(--success-bg); }
.field--inferred { border-left-color: var(--accent); background: var(--accent-bg); }
.field--pending { border-left-color: var(--muted); background: var(--bg); }
.field__label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.field__value { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.field--pending .field__value { color: var(--muted); font-style: italic; }
.field__badge {
  position: absolute; top: 6px; right: 8px;
  font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 600;
}
.field--inferred .field__badge { background: var(--accent); color: #fff; }
.field--pending .field__badge { background: var(--muted); color: #fff; }
.field--confirmed .field__badge { background: var(--success); color: #fff; }
.field__basis { font-size: 11px; color: var(--muted); margin-top: 3px; display: none; }
.field--inferred:hover .field__basis, .field__basis.is-shown { display: block; }
.field__src { font-size: 11px; color: var(--muted); margin-top: 2px; }
.field__src::before { content: '来源：'; opacity: .7; }
.field__tools { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

/* 列表值（数组/对象） */
.field__list { margin: 0; padding-left: 18px; }
.field__list li { margin: 3px 0; font-size: 13px; }
.field__obj { margin: 0; padding: 6px 10px; background: rgba(0,0,0,.03); border-radius: 6px; font-size: 13px; white-space: pre-wrap; }

/* ===== 多实例：列表 + 详情 ===== */
.instancelist { display: flex; flex-direction: column; gap: 6px; }
.instance {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; cursor: pointer;
}
.instance:hover { border-color: var(--accent-soft); }
.instance[data-active="true"] { border-color: var(--accent); background: var(--accent-bg); }
.instance__name { font-weight: 600; font-size: 13px; }
.instance__meta { display: flex; gap: 4px; align-items: center; }
.dot3 { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot3--confirmed { background: var(--success); }
.dot3--inferred { background: var(--accent); }
.dot3--pending { background: var(--muted); }

/* ===== 右区：产物面板 ===== */
.panel { padding: 12px; }
.panel__head { font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 6px 10px; letter-spacing: .05em; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree__item { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.tree__item:hover { background: var(--bg); }
.tree__item[data-active="true"] { background: var(--accent-bg); }
.tree__row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tree__name { font-weight: 500; }
.tree__bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; width: 54px; flex-shrink: 0; }
.tree__bar span { display: block; }
.tree__children { list-style: none; margin: 4px 0 0; padding-left: 14px; }
.tree__empty { font-size: 12px; color: var(--muted); padding: 6px 8px; }

/* 待确认清单 */
.pendinglist { list-style: none; margin: 0; padding: 0; }
.pendinglist__group { font-size: 11px; color: var(--muted); font-weight: 600; margin: 10px 0 4px; }
.pendinglist__item {
  font-size: 12px; padding: 5px 8px; border-radius: 6px; cursor: pointer; line-height: 1.5;
}
.pendinglist__item:hover { background: var(--bg); }
.pendinglist__item .field--inferred { background: transparent; border: none; padding: 0; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-family: inherit;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  cursor: pointer; transition: all .15s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn--accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--accent:hover { filter: brightness(.95); }
.btn--success { background: var(--success); color: #fff; border-color: var(--success); }
.btn--danger { color: var(--danger); border-color: var(--danger); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 4px 10px; font-size: 12px; }
.btn--block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 提示横幅 ===== */
.banner {
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--warn); background: var(--warn-bg); color: var(--ink);
  margin-bottom: 12px;
}
.banner--error { border-color: var(--danger); background: rgba(179,38,30,.08); color: var(--danger); }
.banner--warn { border-color: var(--warn); background: var(--warn-bg); color: var(--ink); }

/* ===== 顶栏设置芯片（免登录模式） ===== */
.chip__gear { font-size: 14px; line-height: 1; }
.chip__owner { font-size: 11px; opacity: .6; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ===== LLM 设置模态框 ===== */
.llm-modal {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
}
.llm-modal[hidden] { display: none; }
.llm-modal__backdrop {
  position: absolute; inset: 0; background: rgba(20, 18, 14, .45);
}
.llm-modal__panel {
  position: relative; z-index: 1;
  background: var(--paper); border-radius: var(--radius); padding: 22px 24px;
  width: min(420px, 92vw); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 12px;
}
.llm-modal__title { margin: 0; font-size: 18px; font-weight: 700; }
.llm-modal__lead { margin: 0; font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.llm-modal__field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.llm-modal__field span { color: var(--ink-soft); font-weight: 600; }
.llm-modal__field input {
  padding: 8px 10px; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--bg); color: var(--ink); font-family: inherit; font-size: 13px;
}
.llm-modal__field input:focus { outline: none; border-color: var(--accent); }
.llm-modal__presets { display: flex; gap: 6px; flex-wrap: wrap; }
.llm-modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ===== 预览页 ===== */
.preview-banner {
  position: sticky; top: 0; z-index: 10;
  background: var(--warn-bg); border-bottom: 1px solid var(--warn);
  padding: 8px 20px; font-size: 13px; text-align: center;
}

/* ===== 建课入口 ===== */
.entry {
  max-width: 640px; margin: 40px auto;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 28px 30px; box-shadow: var(--shadow-sm);
}
.entry__title { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.entry__lead { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; }
.entry textarea {
  width: 100%; min-height: 110px; resize: vertical;
  padding: 12px 14px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--bg); color: var(--ink); font-family: inherit; font-size: 14px;
}
.entry textarea:focus { outline: none; border-color: var(--accent); }
.entry__actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.entry__demo { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* ===== toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 8px;
  background: var(--ink); color: var(--paper);
  font-size: 14px; box-shadow: var(--shadow-md); z-index: 100; max-width: 80%;
}

/* ===== 可编辑字段占位 ===== */
.field__value[contenteditable="true"] { min-height: 22px; outline: none; border-bottom: 1px dashed transparent; }
.field__value[contenteditable="true"]:hover, .field__value[contenteditable="true"]:focus { border-bottom-color: var(--accent-soft); }
.field__value[data-empty="1"]:empty::before { content: '暂缺——你可以说说实际情况'; color: var(--muted); font-style: italic; }
.field__value .field__placeholder { color: var(--muted); font-style: italic; }

/* ===== 导出弹窗 ===== */
.export-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 18, 14, .45);
  display: grid; place-items: center;
}
.export-modal {
  background: var(--paper); border-radius: var(--radius); padding: 20px 22px;
  width: 320px; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 10px;
}
.export-modal h3 { margin: 0 0 4px; font-size: 17px; }
.export-modal .muted { margin: 0 0 6px; }

/* ===== 预览页 ===== */
.preview-head { padding: 4px 0 16px; }
.preview-head h2 { margin: 0 0 4px; font-size: 22px; }
.preview-head .muted { margin: 0; }
.preview-section { font-size: 16px; font-weight: 700; margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.preview-sub { font-size: 14px; font-weight: 600; margin: 16px 0 8px; color: var(--ink-soft); }
.preview-banner + .preview-head { margin-top: 16px; }

/* ===== 响应式：窄屏降级 ===== */
@media (max-width: 1279px) {
  .layout { grid-template-columns: 200px 1fr; }
  .panel { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 10px; }
  .rail { position: static; }
  .panel { position: static; }
  .topbar { flex-wrap: wrap; gap: 8px; }
}
