/* ============================================================
   备课本 Lesson Notebook — 全站样式
   设计方向：教师的备课笔记本
   - 黑板绿（导航 / 强调结构）
   - 牛皮纸卡片（内容承载）
   - 红笔批注色（操作 / 强调）
   字体：标题用衬线（教材质感），正文用无衬线（屏幕可读性）
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  /* 色板 */
  --ink-green-900: #16281f;
  --ink-green-800: #1f3a2e;
  --ink-green-700: #2a4d3c;
  --chalk: #f2ede0;
  --paper: #fbf8f1;
  --paper-card: #fffdf8;
  --kraft: #e9e0cb;
  --kraft-line: #d8cba9;
  --pencil-red: #ac3b2a;
  --pencil-red-dark: #8c2f21;
  --ink: #2b2620;
  --ink-soft: #635a4c;
  --ink-faint: #8d8371;
  --border: #ddd2b4;

  /* 语义别名：强调文字色（深色主题下单独指定，与用作背景的绿色解耦） */
  --heading: #16281f;
  --accent-text: #2a4d3c;
  --accent-text-strong: #1f3a2e;

  --font-serif: 'Source Serif 4', 'Songti SC', serif;
  --font-sans: 'IBM Plex Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* 圆角：从「扁平」升级为「柔和精致」，同一比例贯穿全站控件 */
  --radius-xs: 4px;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --radius-pill: 999px;

  /* 阴影：统一用墨绿色调而非纯灰，与主题色调一致，分四档层级 */
  --shadow-xs: 0 1px 2px rgba(22, 40, 31, 0.08);
  --shadow-sm: 0 2px 10px rgba(22, 40, 31, 0.12);
  --shadow-md: 0 12px 32px rgba(22, 40, 31, 0.22);
  --shadow-lg: 0 22px 56px rgba(22, 40, 31, 0.32);

  /* 统一缓动曲线，让所有过渡动效手感一致 */
  --ease: cubic-bezier(.4, 0, .2, 1);

  --shadow-card: var(--shadow-xs);

  color-scheme: light;
}

/* ---------- 深色主题（夜读模式） ---------- */
/* 黑板绿导航保持不变；内容区切换为深色纸张 */
[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1d221e;
  --paper-card: #252b26;
  --kraft: #2f3630;
  --kraft-line: #3f4841;
  --ink: #e7e2d6;
  --ink-soft: #b4ad9e;
  --ink-faint: #8a8477;
  --border: #3c443d;
  --heading: #d8ecde;
  --accent-text: #93d2b1;
  --accent-text-strong: #abe0c2;
  --pencil-red: #d97757;
  --pencil-red-dark: #b44531;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 20px 52px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

/* ---------- 全站统一滚动条 ---------- */
/* 细胶囊 + 主题色调，所有可滚动区域（页面、弹窗、消息区、文本框等）共用 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--kraft-line) transparent;
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--kraft-line);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner {
  background: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 0.4em 0;
}

a { color: var(--accent-text); }

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

/* ---------- 顶部结构 ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-rail {
  width: 224px;
  flex-shrink: 0;
  background: linear-gradient(165deg, var(--ink-green-900) 0%, #122019 100%);
  color: var(--chalk);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  /* 底部预留空间，避免左下角的主题按钮压住引言文字 */
  padding-bottom: 52px;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
  /* 侧栏固定不动：视口高度 + 固定定位，主内容区域独立滚动 */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.app-rail .brand {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-rail .brand small {
  display: block;
  margin-top: 6px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: rgba(242,237,224,0.5);
}

.app-rail nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.app-rail nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(242,237,224,0.8);
  text-decoration: none;
  padding: 9px 11px;
  border-radius: var(--radius-s);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}

.app-rail nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.app-rail nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: var(--pencil-red);
  font-weight: 600;
}

.app-rail .rail-foot {
  margin-top: auto;
  font-size: 12px;
  font-style: italic;
  line-height: 1.7;
  color: rgba(242,237,224,0.5);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
  position: relative;
}
.app-rail .rail-foot .rail-foot-text {
  font-family: var(--font-serif);
  font-size: 12.5px;
  color: rgba(242,237,224,0.68);
}

/* ---------- 主题切换（深浅色） ---------- */

.app-rail .theme-toggle {
  position: absolute;
  left: 14px;
  bottom: 14px;
  background: rgba(255,255,255,0.05);
  color: rgba(242,237,224,0.7);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 11px;
  line-height: 1.5;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.app-rail .theme-toggle:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.26);
}

/* ---------- 左栏：已打开教案的标签页 ---------- */

.app-rail .rail-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 32vh;
  overflow-y: auto;
  /* 滚动条样式使用全站统一规则 */
}

.app-rail .rail-tabs-head {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(242,237,224,0.4);
  padding: 0 10px 6px;
}

.app-rail .rail-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(242,237,224,0.8);
  font-size: 13px;
  line-height: 1.4;
  padding: 7px 6px 7px 10px;
  border-radius: var(--radius-xs);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}

.app-rail .rail-tab:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.app-rail .rail-tab.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: var(--pencil-red);
  font-weight: 500;
}

.rail-tab-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-tab-close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: rgba(242,237,224,0.45);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: var(--radius-xs);
  transition: background .14s var(--ease), color .14s var(--ease);
}

.rail-tab-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.18);
}

/* 标签拖拽排序反馈 */
.app-rail .rail-tab.dragging { opacity: 0.4; }
.app-rail .rail-tab.drop-above { box-shadow: inset 0 2px 0 rgba(255,255,255,0.85); }
.app-rail .rail-tab.drop-below { box-shadow: inset 0 -2px 0 rgba(255,255,255,0.85); }

.app-main {
  flex: 1;
  min-width: 0;
  padding: 36px 44px 40px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--paper-card);
  color: var(--ink);
  padding: 8px 15px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  box-shadow: var(--shadow-xs);
  transition: border-color .16s var(--ease), background .16s var(--ease),
              box-shadow .16s var(--ease), transform .16s var(--ease), color .16s var(--ease);
}
.btn:hover {
  border-color: var(--ink-green-700);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }
.btn:focus-visible {
  outline: 2px solid var(--ink-green-700);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--ink-green-800);
  border-color: var(--ink-green-800);
  color: #fff;
}
.btn-primary:hover { background: var(--ink-green-700); border-color: var(--ink-green-700); }

.btn-accent {
  background: var(--pencil-red);
  border-color: var(--pencil-red);
  color: #fff;
}
.btn-accent:hover { background: var(--pencil-red-dark); border-color: var(--pencil-red-dark); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
  box-shadow: none;
}
.btn-ghost:hover { color: var(--ink); background: var(--kraft); box-shadow: none; }
.btn-ghost:active { background: var(--kraft-line); }

.btn-danger { color: var(--pencil-red-dark); }
.btn-danger:hover { color: #fff; background: var(--pencil-red-dark); border-color: var(--pencil-red-dark); }
.btn-ghost.btn-danger:hover { color: var(--pencil-red-dark); background: rgba(172, 59, 42, 0.1); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--radius-xs); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- 本地文件夹连接按钮状态 ---------- */

.btn.fs-btn-connected {
  background: #1a7f37;
  border-color: #1a7f37;
  color: #fff;
}
.btn.fs-btn-connected:hover { background: #1f8f41; border-color: #1f8f41; }

.btn.fs-btn-need-perm {
  background: #9a6700;
  border-color: #9a6700;
  color: #fff;
}
.btn.fs-btn-need-perm:hover { background: #b88500; border-color: #b88500; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- 卡片 / 索引卡（Dashboard） ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(266px, 1fr));
  gap: 18px;
}

.plan-card {
  position: relative;
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pencil-red);
  border-radius: var(--radius-m);
  padding: 18px 20px 15px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 9px;
  cursor: pointer;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}

.plan-card:hover {
  border-color: var(--ink-green-700);
  border-left-color: var(--pencil-red);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.plan-card .plan-course {
  display: inline-flex;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent-text-strong);
  background: var(--kraft);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
}

.plan-card h3 {
  font-size: 17.5px;
  line-height: 1.4;
  margin: 2px 0 0;
}

.plan-card .plan-meta {
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* 教师 / 上课时间 / 学时：每一项单独一行，长短都不影响排版 */
.plan-card .plan-meta-lines {
  flex-direction: column;
  gap: 4px;
}
.plan-card .plan-meta-lines span { display: flex; align-items: center; gap: 6px; }

.plan-card .plan-updated {
  color: var(--ink-faint);
  font-size: 11.5px;
}

.plan-card .plan-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 11px;
}
.plan-card .plan-actions .btn { box-shadow: none; }

/* ---------- 资源管理器（文件夹） ---------- */

.breadcrumb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--paper-card);
  border-radius: var(--radius-m);
  padding: 10px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 13.5px;
}
.crumb {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  font-size: 13.5px;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.crumb:hover { background: var(--kraft); color: var(--ink); }
.crumb.active { color: var(--accent-text-strong); font-weight: 600; }
.crumb-sep { color: var(--ink-faint); }

.breadcrumb-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.breadcrumb-tools input[type="search"] {
  width: 230px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-size: 13px;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.breadcrumb-tools input[type="search"]:focus {
  outline: none;
  border-color: var(--ink-green-700);
  box-shadow: 0 0 0 3px rgba(30, 74, 55, 0.12);
}

.explorer {
  display: flex;
  gap: 22px;
  align-items: flex-start;
}

/* ---------- 文件夹侧栏收起/展开按钮（抽屉把手） ---------- */
.sidebar-toggle {
  flex-shrink: 0;
  align-self: flex-start;
  position: sticky; /* 跟随侧栏一起吸附在视口顶部 */
  top: 16px;
  z-index: 20;
  margin-left: -22px; /* 紧贴侧栏右边缘（抵消 .explorer 的 22px 间距） */
  margin-top: 14px;
  width: 24px;
  height: 44px;
  border: 1px solid var(--border);
  border-left: none; /* 与侧栏贴合，避免双线 */
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
  background: var(--paper-card);
  color: var(--ink-faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: var(--shadow-xs);
  transition: background .14s var(--ease), color .14s var(--ease), transform .18s var(--ease);
}
.sidebar-toggle:hover {
  background: var(--kraft);
  color: var(--ink);
}
/* 雪佛龙箭头：CSS 描边绘制，粗细统一、不依赖字体字形 */
.sidebar-toggle .st-arrow {
  display: block;
  width: 7px;
  height: 7px;
  border-style: solid;
  border-width: 0 2px 2px 0;
  border-color: currentColor;
  border-radius: 1px;
  transform: rotate(135deg); /* 展开态：指向左侧（收起方向） */
  transition: transform .3s var(--ease);
}
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

/* 桌面端：侧栏宽度平滑动画收起（内容裁切而非重排） */
@media (min-width: 901px) {
  .explorer-sidebar {
    transition: width .3s var(--ease), margin-right .3s var(--ease), opacity .25s var(--ease), padding .3s var(--ease), border-color .3s var(--ease);
  }
  /* 收起动画期间内容保持原宽、被逐渐裁切，避免文字挤压重排 */
  .explorer-sidebar > * { min-width: 190px; }
  body.sidebar-collapsed .explorer-sidebar {
    width: 0;
    min-width: 0;
    margin-right: -22px; /* 吃掉与主区之间的 22px 间距 */
    padding-left: 0;
    padding-right: 0;
    border-color: transparent;
    opacity: 0;
    overflow: hidden;
  }
  body.sidebar-collapsed .sidebar-toggle .st-arrow { transform: rotate(-45deg); } /* 收起态：指向右侧（展开方向） */
  /* 悬停时把手轻轻向外滑出，增强可点击感 */
  .explorer .sidebar-toggle:hover { transform: translateX(2px); }
}

/* 收起状态：按钮移入面包栏最左侧，方形小钮与栏内控件统一 */
.breadcrumb-bar .sidebar-toggle {
  position: static;
  margin: 0 2px 0 0;
  width: 30px;
  height: 30px;
  align-self: center;
  border: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 0;
  flex-shrink: 0;
  box-shadow: none;
}

.explorer-sidebar {
  width: 214px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--paper-card);
  border-radius: var(--radius-m);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-xs);
}

.xsidebar-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding: 12px 8px 5px;
}

.xsidebar-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--radius-s);
  border-left: 3px solid transparent;
}
.xsidebar-row.active { background: var(--kraft); border-left-color: var(--ink-green-700); }
.xsidebar-row .xsidebar-item { flex: 1; min-width: 0; }

.xsidebar-item {
  display: flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 13.5px;
  padding: 8px 9px;
  border-radius: var(--radius-s);
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.xsidebar-item:hover { background: var(--kraft); }
.xsidebar-item.active { background: var(--kraft); color: var(--accent-text-strong); font-weight: 600; }
.xsidebar-item .xcount {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--ink-faint);
  background: var(--paper);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
  flex-shrink: 0;
}
.xsidebar-item.active .xcount { color: var(--accent-text); }

.xsidebar-actions { display: none; gap: 2px; }
.xsidebar-row:hover .xsidebar-actions { display: inline-flex; }
.xsidebar-actions button {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 5px;
  border-radius: var(--radius-xs);
  line-height: 1;
  transition: color .14s var(--ease), background .14s var(--ease);
}
.xsidebar-actions button:hover { color: var(--pencil-red-dark); background: rgba(172, 59, 42, 0.08); }

.xsidebar-add {
  margin-top: 10px;
  border: 1px dashed var(--border);
  color: var(--ink-faint);
  justify-content: center;
}
.xsidebar-add:hover { color: var(--accent-text-strong); border-color: var(--accent-text); background: var(--kraft); }

.explorer-main { flex: 1; min-width: 0; }

/* ---------- 文件夹卡片（基于 plan-card，绿色主题） ---------- */

.folder-card {
  border-left-color: var(--ink-green-700);
  align-items: center;
}

.folder-card:hover {
  border-left-color: var(--ink-green-800);
}

.folder-card .folder-card-icon {
  font-size: 34px;
  text-align: center;
  margin-bottom: 2px;
  filter: drop-shadow(0 2px 3px rgba(22,40,31,0.15));
}

.folder-card h3 {
  font-size: 16px;
  text-align: center;
  color: var(--heading);
}

.folder-card .plan-meta {
  justify-content: center;
  font-size: 12px;
  color: var(--ink-faint);
}

/* 拖拽反馈 */
.drag-over { outline: 2px dashed var(--ink-green-700); outline-offset: 2px; border-radius: var(--radius-m); }
.plan-card.dragging { opacity: 0.45; }

/* 文件夹命名弹窗输入框 */
#folder-name-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 9px 10px;
  background: var(--paper);
  font-size: 14px;
}
#folder-name-input:focus {
  outline: 2px solid var(--ink-green-700);
  outline-offset: -1px;
}

/* 树形侧栏层级符 */
.xcaret {
  font-size: 10px;
  color: var(--ink-faint);
  flex-shrink: 0;
}

/* ---------- 移动教案弹窗 ---------- */

.move-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 40, 31, 0.5);
  backdrop-filter: blur(2px);
}

@keyframes modal-pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.move-modal-content {
  position: relative;
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-lg);
  padding: 22px 24px;
  width: min(92vw, 360px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: modal-pop-in 0.2s var(--ease);
}
.move-modal-content h3 {
  font-size: 16px;
  margin-bottom: 14px;
}

.move-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.move-item {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--paper);
  border-radius: var(--radius-s);
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .14s var(--ease), background .14s var(--ease), transform .14s var(--ease);
}
.move-item:hover {
  border-color: var(--ink-green-700);
  background: var(--kraft);
  transform: translateX(2px);
}

.move-modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius-m);
  padding: 60px 24px;
  text-align: center;
  color: var(--ink-soft);
}

.empty-state h2 { color: var(--accent-text-strong); font-size: 19px; margin-bottom: 8px; }

/* ---------- 表单（编辑器） ---------- */

.form-section {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.form-section h2 {
  font-size: 15px;
  text-transform: none;
  color: var(--accent-text-strong);
  border-bottom: 1px solid var(--kraft-line);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 18px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field .hint {
  font-size: 11.5px;
  color: var(--ink-faint);
  font-weight: 400;
}

input[type="text"], input[type="date"], input[type="number"], input[type="url"], textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 9px 11px;
  background: var(--paper);
  width: 100%;
  resize: vertical;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}

textarea { min-height: 88px; line-height: 1.6; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ink-green-700);
  box-shadow: 0 0 0 3px rgba(30, 74, 55, 0.12);
}

/* 参考资料 / 内容大纲 的动态行 */

.repeat-row {
  display: grid;
  grid-template-columns: 110px 1fr auto auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

/* ---------- 教学内容及过程：Word 式富文本编辑 ---------- */

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.rich-toolbar .rt-btn {
  border: 1px solid var(--border);
  background: var(--paper-card);
  border-radius: var(--radius-s);
  padding: 5px 10px;
  font-size: 12.5px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
}
.rich-toolbar .rt-btn:hover {
  border-color: var(--accent-text);
  color: var(--accent-text-strong);
  background: var(--paper);
}
.rich-toolbar .rt-italic,
.rich-toolbar .rt-underline { font-family: var(--font-serif); }
.rich-toolbar .rt-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.rich-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--paper);
  min-height: 260px;
  overflow-y: auto;
  /* 允许拖动右下角把手调整高度 */
  resize: vertical;
  padding: 12px 16px;
  font-size: 14.5px;
  line-height: 1.8;
  outline-offset: 1px;
}
.rich-editor:focus { outline: 2px solid var(--ink-green-700); }
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-faint);
  pointer-events: none;
}

/* 编辑器内列表样式与导出效果保持一致（所见即所得） */
.rich-editor ul {
  margin: 0;
  padding-left: 1.6em;
  list-style-type: disc;
}
.rich-editor ul ul { list-style-type: circle; }
.rich-editor ul ul ul { list-style-type: square; }
.rich-editor > ul > li { font-weight: 700; }
.rich-editor li { margin: 3px 0; }
.rich-editor p { margin: 0 0 6px; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--paper-card);
  border-radius: var(--radius-xs);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-soft);
  transition: border-color .14s var(--ease), color .14s var(--ease), background .14s var(--ease);
}
.icon-btn:hover { border-color: var(--accent-text); color: var(--accent-text-strong); background: var(--kraft); }

/* 参考资料跳转按钮：无边框幽灵样式，极简 */
.ref-open {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  width: 28px;
  height: 28px;
  padding: 0;
}
.ref-open svg { width: 15px; height: 15px; display: block; }
.ref-open:hover:not(:disabled) {
  background: var(--kraft);
  color: var(--accent-text-strong);
}
.ref-open:disabled { opacity: 0.25; cursor: default; background: transparent; }

.add-row-btn {
  margin-top: 4px;
}

/* 底部保存条 */

.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding: 14px 0 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.save-status {
  font-size: 12.5px;
  color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.save-status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.save-status[data-status="saved"] { color: #2a7d4a; }
.save-status[data-status="unsaved"] { color: #ac3b2a; }
.save-status[data-status="saving"] { color: #2a5d8c; }

/* ---------- AI 占位区（暂不启用） ---------- */

.ai-placeholder {
  border: 1px dashed var(--kraft-line);
  background: var(--kraft);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- AI 悬浮对话窗口 ---------- */

/* 悬浮按钮 */
.ai-fab {
  position: fixed;
  bottom: 60px;
  right: 24px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(155deg, var(--ink-green-700), var(--ink-green-900));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: var(--shadow-md);
  z-index: 99;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.ai-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.ai-fab:active { transform: scale(1.02); }

.ai-fab-badge {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 13px;
  height: 13px;
  background: var(--pencil-red);
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(196, 68, 46, 0.5);
  animation: ai-badge-pulse 2.4s infinite;
}
@keyframes ai-badge-pulse {
  0% { box-shadow: 0 0 0 0 rgba(196, 68, 46, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(196, 68, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(196, 68, 46, 0); }
}

/* 聊天窗口 */
.ai-chat {
  position: fixed;
  bottom: 122px;
  right: 24px;
  width: 380px;
  max-height: 600px;
  background: var(--paper);
  border: none;
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ai-chat-in 0.22s var(--ease);
}

@keyframes ai-chat-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 聊天头部 */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: linear-gradient(120deg, var(--ink-green-800), var(--ink-green-700));
  color: #fff;
}

.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 14px;
}
.ai-chat-title::before {
  content: "✦";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.16);
  font-size: 11px;
}

.ai-chat-tools {
  display: flex;
  gap: 4px;
}

.ai-chat-tool {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .16s var(--ease), transform .16s var(--ease);
}
.ai-chat-tool:active { transform: scale(0.92); }

.ai-chat-tool:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* 拖动/缩放支持 */
.ai-chat-header { cursor: move; }

.ai-chat-resize {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 20px;
  height: 20px;
  cursor: nesw-resize;
  z-index: 3;
}

.ai-chat-resize::before {
  content: "";
  position: absolute;
  left: 5px;
  bottom: 5px;
  width: 9px;
  height: 9px;
  border-left: 2px solid var(--ink-faint);
  border-bottom: 2px solid var(--ink-faint);
  border-bottom-left-radius: 4px;
  opacity: 0.55;
  transition: opacity .14s var(--ease), border-color .14s var(--ease);
}

.ai-chat-resize:hover::before {
  opacity: 1;
  border-color: var(--ink-green-700);
}

/* 用户手动调整过大小后，解除默认的尺寸上限，让设置生效 */
.ai-chat.ai-chat-resized { max-height: none; }
.ai-chat.ai-chat-resized .ai-messages { max-height: none; }

/* 快捷功能 */
.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--kraft);
}

.ai-quick-btn {
  padding: 5px 11px;
  font-size: 12px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  color: var(--ink);
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), transform .16s var(--ease);
}

.ai-quick-btn:hover {
  background: var(--ink-green-700);
  border-color: var(--ink-green-700);
  color: #fff;
  transform: translateY(-1px);
}

/* 消息区域 */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  min-height: 120px;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.ai-message {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: var(--radius-m);
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
}

.ai-message-user {
  align-self: flex-end;
  background: var(--ink-green-700);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: none;
}

.ai-message-ai {
  align-self: flex-start;
  background: var(--kraft);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.ai-message-error {
  align-self: flex-start;
  background: rgba(196, 68, 46, 0.08);
  border: 1px solid rgba(196, 68, 46, 0.25);
  color: var(--pencil-red-dark);
  border-bottom-left-radius: 4px;
  box-shadow: none;
}

.ai-message-content {
  white-space: pre-wrap;
}

/* AI 回复消息操作（悬停显示的复制/编辑小图标，位于气泡下方） */
.ai-message-row {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.ai-message-row-user { align-self: flex-end; }
.ai-message-row-ai { align-self: flex-start; }

/* 气泡在行内占满宽度，对齐交给行容器 */
.ai-message-row .ai-message { align-self: stretch; max-width: 100%; }

.ai-message-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  /* 默认隐藏，悬停消息时浮现 */
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s var(--ease);
  /* 与气泡边缘对齐 */
  align-self: flex-start;
}

.ai-message-row-user .ai-message-actions { align-self: flex-end; }

.ai-message-row:hover .ai-message-actions,
.ai-message-row:has(.ai-edit-area) .ai-message-actions {
  opacity: 1;
  pointer-events: auto;
}

.ai-msg-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}

.ai-msg-btn svg { width: 13px; height: 13px; display: block; }

.ai-msg-btn:hover {
  background: rgba(0, 0, 0, 0.09);
  color: var(--ink);
}

/* 用户消息是深绿底，图标用浅色 */
.ai-message-user .ai-msg-btn { color: rgba(255, 255, 255, 0.7); }
.ai-message-user .ai-msg-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* 消息编辑态 */
.ai-edit-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  width: 100%;
}

.ai-edit-area textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  border: 1px solid var(--ink-green-700);
  border-radius: var(--radius-s);
  padding: 7px 9px;
  font-size: 13px;
  line-height: 1.55;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper-card);
}

.ai-edit-area textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 74, 55, 0.14);
}

.ai-edit-btns {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.ai-edit-save,
.ai-edit-cancel {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease);
}

.ai-edit-cancel {
  background: transparent;
  color: var(--ink-soft);
}

.ai-edit-cancel:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--ink);
}

.ai-edit-save {
  border: none;
  background: var(--ink-green-800);
  color: #fff;
}

.ai-edit-save:hover:not(:disabled) { background: var(--ink-green-700); }
.ai-edit-save:disabled { opacity: 0.45; cursor: not-allowed; }

/* 输入区域 */
.ai-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 11px 12px;
  border-top: 1px solid var(--border);
  background: var(--paper-card);
}

.ai-input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.5;
  min-height: 36px;
  max-height: 80px;
  font-family: inherit;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}

.ai-input-area textarea:focus {
  outline: none;
  border-color: var(--ink-green-700);
  box-shadow: 0 0 0 3px rgba(30, 74, 55, 0.12);
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--ink-green-700);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  transition: background 0.16s var(--ease), transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.ai-send-btn:hover {
  background: var(--ink-green-800);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 加载动画 */
.ai-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--ink-soft);
  border-radius: 50%;
  animation: ai-typing-bounce 1.2s infinite;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* AI 设置弹窗 */
.ai-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 40, 31, 0.5);
  backdrop-filter: blur(2px);
}

.ai-modal-content {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 26px;
  width: 90%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  /* 滚动条不贴着内容，留一点呼吸感 */
  scrollbar-gutter: stable;
  padding-right: 22px;
  box-shadow: var(--shadow-lg);
  animation: modal-pop-in 0.2s var(--ease);
}
/* 滚动条样式使用全站统一规则 */

.ai-modal-content h3 {
  margin-bottom: 18px;
}

.ai-modal-content .field {
  margin-bottom: 16px;
}

.ai-setup-notice {
  background: var(--kraft);
  border: 1px solid var(--kraft-line);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 13px;
}

.ai-setup-notice strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.ai-setup-notice ol {
  margin: 8px 0;
  padding-left: 18px;
}

.ai-setup-notice li {
  margin: 4px 0;
}

.ai-setup-notice a {
  color: var(--accent-text);
}

.ai-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.ai-test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.ai-test-result {
  font-size: 12px;
  color: var(--ink-soft);
}

.ai-test-result.success {
  color: var(--accent-text);
}

.ai-test-result.error {
  color: var(--pencil-red);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* 移动端适配 */
@media (max-width: 600px) {
  .ai-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
  .ai-chat {
    bottom: 72px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 70vh;
  }
  .ai-messages {
    max-height: 40vh;
  }
  .ai-quick-btn {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--ink-green-900);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--radius-m);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* 深色主题下微调（保存状态、状态提示等硬编码色的可读性） */
[data-theme="dark"] .save-status[data-status="saved"] { color: #7fd39a; }
[data-theme="dark"] .save-status[data-status="unsaved"] { color: #e89380; }
[data-theme="dark"] .save-status[data-status="saving"] { color: #93c2ef; }

/* ---------- 打印视图（导出 PDF 用） ---------- */

#print-root { display: none !important; }

@media print {
  /* 整个应用外壳（侧栏 + 主区域）在打印时完全隐藏，
     否则其 min-height:100vh 会占据一整页空白，使 #print-root 从第二页开始 */
  .app-shell,
  .ai-fab, .ai-chat, .ai-modal, .ai-fab-badge,
  .toast {
    display: none !important;
  }
  #print-root { display: block !important; }

  @page {
    size: A4;
    margin: 20mm 18mm;
  }

  body {
    background: #fff;
    font-family: "Songti SC", "SimSun", "Times New Roman", serif;
    font-size: 11pt;
    line-height: 1.6;
    color: #000;
  }

  /* 居中大标题 */
  .doc-title {
    text-align: center;
    font-size: 30pt;
    font-weight: 700;
    letter-spacing: 0.25em;
    margin: 28pt 0 34pt;
    color: #000;
  }

  /* 标题下信息行：标签 + 加粗下划线的值 */
  .doc-info { margin: 0 0 8pt 4em; }
  .doc-info p { margin: 0 0 10pt; font-size: 13pt; }
  .doc-info .doc-label { display: inline-block; min-width: 5.5em; }
  .doc-info .doc-value {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3pt;
    text-decoration-thickness: 1pt;
  }

  /* 灰色斜纹横幅条 */
  .doc-banner {
    border: 1px solid #aaa;
    background: repeating-linear-gradient(45deg, #ececec 0 5px, #fafafa 5px 10px);
    padding: 3pt 8pt;
    font-size: 10.5pt;
    margin: 14pt 0 10pt;
    page-break-after: avoid;
  }
  .doc-banner.page-break {
    page-break-before: always;
    margin-top: 0;
  }

  /* 教案表格：黑色细线 */
  table.doc-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    border: none;
    margin-bottom: 12pt;
  }
  table.doc-table th, table.doc-table td {
    border: 0.3pt solid #000;
    padding: 6pt 8pt;
    vertical-align: top;
    text-align: left;
    word-break: break-word;
  }
  table.doc-table th {
    width: 15%;
    font-weight: 700;
    text-align: center;
    vertical-align: middle;
  }
  tr { page-break-inside: avoid; }

  /* 讲稿部分大表：允许在单元格内自然跨页，避免出现空白页 */
  table.doc-process { page-break-inside: auto; }
  table.doc-process td { page-break-inside: auto; }
  table.doc-process tr { page-break-inside: auto; }

  /* 空内容单元格保留最小高度，便于打印后手写 */
  table.doc-table td.doc-multiline { min-height: 26pt; }

  /* 讲稿部分大表 */
  table.doc-table th.doc-process-head {
    width: auto;
    text-align: center;
    font-size: 14pt;
    letter-spacing: 0.2em;
    padding: 8pt;
  }
  td.doc-process-content { width: 78%; }
  td.doc-process-remarks { width: 22%; }
  th.doc-process-remarks-head { width: 22%; font-weight: 600; }
  td.doc-row-label { letter-spacing: 0.1em; }
  td.doc-tall { min-height: 80pt; }
  td.doc-process-content .cn-num { font-weight: 700; }

  /* 多级讲稿列表：与编辑器一致的圆点 + 悬挂缩进（所见即所得） */
  table.doc-table td.doc-process-content ul {
    margin: 0;
    padding-left: 1.5em;
    list-style-type: disc;
  }
  table.doc-table td.doc-process-content ul ul { list-style-type: circle; }
  table.doc-table td.doc-process-content ul ul ul { list-style-type: square; }
  table.doc-table td.doc-process-content > ul > li { font-weight: 700; }
  table.doc-table td.doc-process-content li { margin: 3pt 0; }
  table.doc-table .doc-bullet { padding-left: 1.6em; text-indent: -1.3em; margin: 2pt 0; }
}

/* ---------- PDF 捕获模式（html2canvas 截图用） ---------- */
/* 通过 .pdf-capture 类让打印视图在屏幕可见，同时复用打印样式 */

body.pdf-capture .app-rail,
body.pdf-capture .app-main > *:not(#print-root) { display: none !important; }
body.pdf-capture #print-root {
  display: block !important;
  position: fixed;
  left: 0;
  top: 0;
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  z-index: -1;
  font-family: "Songti SC", "SimSun", "Times New Roman", serif;
  font-size: 11pt;
  line-height: 1.6;
  color: #000;
  padding: 20mm 18mm;
  box-sizing: border-box;
}
body.pdf-capture { background: #fff; }

/* 打印视图元素样式（在 PDF 捕获模式下生效） */
body.pdf-capture .doc-title {
  text-align: center;
  font-size: 30pt;
  font-weight: 700;
  letter-spacing: 0.25em;
  margin: 28pt 0 34pt;
  color: #000;
}
body.pdf-capture .doc-info { margin: 0 0 8pt 4em; }
body.pdf-capture .doc-info p { margin: 0 0 10pt; font-size: 13pt; }
body.pdf-capture .doc-info .doc-label { display: inline-block; min-width: 5.5em; }
body.pdf-capture .doc-info .doc-value {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3pt;
  text-decoration-thickness: 1pt;
}
body.pdf-capture .doc-banner {
  border: 1px solid #aaa;
  background: repeating-linear-gradient(45deg, #ececec 0 5px, #fafafa 5px 10px);
  padding: 3pt 8pt;
  font-size: 10.5pt;
  margin: 14pt 0 10pt;
}
body.pdf-capture table.doc-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  border: none;
  margin-bottom: 12pt;
}
body.pdf-capture table.doc-table th,
body.pdf-capture table.doc-table td {
  border: 0.3pt solid #000;
  padding: 6pt 8pt;
  vertical-align: top;
  text-align: left;
  word-break: break-word;
}
body.pdf-capture table.doc-table th {
  width: 15%;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
}
body.pdf-capture table.doc-table td.doc-multiline { min-height: 26pt; }
body.pdf-capture table.doc-table th.doc-process-head {
  width: auto;
  text-align: center;
  font-size: 14pt;
  letter-spacing: 0.2em;
  padding: 8pt;
}
body.pdf-capture td.doc-process-content { width: 78%; }
body.pdf-capture td.doc-process-remarks { width: 22%; }
body.pdf-capture th.doc-process-remarks-head { width: 22%; font-weight: 600; }
body.pdf-capture td.doc-row-label { letter-spacing: 0.1em; }
body.pdf-capture td.doc-tall { min-height: 80pt; }
body.pdf-capture td.doc-process-content .cn-num { font-weight: 700; }
body.pdf-capture table.doc-table td.doc-process-content ul {
  margin: 0;
  padding-left: 1.5em;
  list-style-type: disc;
}
body.pdf-capture table.doc-table td.doc-process-content ul ul { list-style-type: circle; }
body.pdf-capture table.doc-table td.doc-process-content ul ul ul { list-style-type: square; }
body.pdf-capture table.doc-table td.doc-process-content > ul > li { font-weight: 700; }
body.pdf-capture table.doc-table td.doc-process-content li { margin: 3pt 0; }
body.pdf-capture table.doc-table .doc-bullet { padding-left: 1.6em; text-indent: -1.3em; margin: 2pt 0; }

/* ---------- 响应式 ---------- */

/* 平板横屏 (900px 以下) */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  /* 平板/手机上侧栏回到文档流正常滚动（顶部横条不固定） */
  .app-rail {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 14px 18px;
    gap: 18px;
    position: static;
    height: auto;
    overflow: visible;
  }
  .app-rail .brand { border-bottom: none; padding-bottom: 0; }
  .app-rail nav { flex-direction: row; }
  .app-rail .rail-tabs { flex-direction: row; align-items: center; max-height: none; overflow-y: hidden; overflow-x: auto; flex: 1; gap: 4px; min-width: 0; }
  .app-rail .rail-tabs-head { display: none; }
  .app-rail .rail-tab { border-left: none; border-bottom: 3px solid transparent; padding: 5px 8px; flex-shrink: 0; }
  .app-rail .rail-tab.active { border-left-color: transparent; border-bottom-color: var(--pencil-red); }
  .rail-tab-title { max-width: 120px; }
  .app-rail .rail-foot { display: none; }
  /* 平板：主题按钮回到文档流，靠右排列，不再绝对定位 */
  .app-rail .theme-toggle {
    position: static;
    margin-left: auto;
    flex-shrink: 0;
  }
  .app-main { padding: 24px; }
  .field-grid { grid-template-columns: 1fr; }

  /* 资源管理器：侧栏变横向滚动条 */
  .explorer { flex-direction: column; gap: 12px; }
  .explorer-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    position: static;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
  }
  /* 收起按钮：文件夹条上方的胶囊小按钮（order 提到侧栏之前） */
  .sidebar-toggle {
    order: -1;
    position: static;
    margin: 0;
    width: auto;
    height: auto;
    align-self: flex-start;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 8px 12px;
  }
  /* 文件夹条平滑收起：高度收缩 + 淡出 */
  .explorer-sidebar {
    max-height: 140px;
    transition: max-height .3s var(--ease), opacity .22s var(--ease), margin-bottom .3s var(--ease), padding .3s var(--ease), border-color .3s var(--ease);
  }
  body.sidebar-collapsed .explorer-sidebar {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: -12px; /* 吃掉与主区之间的 12px 间距 */
    border-color: transparent;
    opacity: 0;
    overflow: hidden;
  }
  body.sidebar-collapsed .sidebar-toggle .st-arrow { transform: rotate(45deg); } /* 收起态：指向下方（展开方向） */
  /* 展开态箭头向上（收起方向） */
  .sidebar-toggle .st-arrow { transform: rotate(-135deg); }
  .xsidebar-label { display: none; }
  .xsidebar-row, .xsidebar-item { flex-shrink: 0; }
  .xsidebar-row { flex-direction: row; }
  .xsidebar-actions { display: inline-flex; }
  .breadcrumb-bar { flex-wrap: wrap; }
}

/* 手机竖屏 (600px 以下) */
@media (max-width: 600px) {
  /* ---------- 顶栏：紧凑两行（品牌行 + 导航行） ---------- */
  .app-rail {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px 12px;
    box-shadow: var(--shadow-sm);
  }
  .app-rail .brand {
    font-size: 17px;
    width: auto;
    flex: 1;
    min-width: 0;
    border-bottom: none;
    padding-bottom: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
  }
  .app-rail .brand small {
    margin-top: 0;
    font-size: 11px;
  }
  .app-rail nav {
    order: 3;
    width: 100%;
    flex-direction: row;
    gap: 5px;
  }
  .app-rail nav a {
    flex: 1;
    justify-content: center;
    text-align: center;
    padding: 9px 6px;
    font-size: 13px;
    border-left: none;
    background: rgba(255,255,255,0.05);
  }
  .app-rail nav a.active {
    border-left: none;
    background: rgba(255,255,255,0.14);
  }
  .app-rail .rail-tabs {
    order: 2;
    width: 100%;
    flex: none;
  }

  /* ---------- 主区域 ---------- */
  .app-main {
    padding: 16px 14px 28px;
  }
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-head h1 { font-size: 21px; }
  .page-head p { font-size: 12.5px; }
  /* ---------- 工具栏：流式换行布局（无横向溢出） ---------- */
  .toolbar {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar .btn {
    /* 自动换行：每行尽量放满，同行按钮等宽拉伸 */
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    justify-content: center;
    padding: 10px 12px;
    font-size: 13px;
  }

  /* ---------- 表单 ---------- */
  .form-section {
    padding: 15px 14px;
    margin-bottom: 14px;
  }
  .form-section h2 {
    font-size: 14px;
    padding-bottom: 8px;
    margin-bottom: 12px;
  }
  .field-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .field label {
    font-size: 12.5px;
  }
  .field .hint {
    font-size: 11.5px;
  }
  /* 16px 起始字号，避免 iOS Safari 聚焦时自动放大页面 */
  input[type="text"], input[type="date"], input[type="number"],
  input[type="url"], input[type="password"], input[type="search"],
  textarea, select {
    font-size: 16px;
    padding: 10px 11px;
  }
  textarea {
    min-height: 72px;
  }

  /* 富文本编辑器 */
  .rich-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }
  .rt-btn {
    padding: 7px 10px;
    font-size: 12px;
    min-height: 32px;
  }
  .rich-editor {
    min-height: 180px;
    padding: 12px;
    font-size: 15px;
  }

  /* ---------- 参考资料：标签+按钮一行，链接独占一行 ---------- */
  .repeat-row {
    grid-template-columns: 1fr 30px 30px;
    grid-template-areas:
      "label open remove"
      "url url url";
    gap: 6px;
    margin-bottom: 10px;
  }
  .repeat-row .ref-label { grid-area: label; }
  .repeat-row .ref-url   { grid-area: url; }
  .repeat-row .ref-open  { grid-area: open; }
  .repeat-row .ref-remove { grid-area: remove; }
  /* 图标按钮在触屏上加大点击区域 */
  .repeat-row .icon-btn {
    width: 32px;
    height: 32px;
  }

  /* ---------- 底部保存条 ---------- */
  .save-bar {
    flex-direction: column-reverse;
    gap: 10px;
    padding: 12px 0 6px;
  }
  .save-bar .btn {
    width: 100%;
    justify-content: center;
    padding: 13px;
    font-size: 14.5px;
  }
  .save-status {
    text-align: center;
    font-size: 12px;
  }

  /* ---------- 首页卡片 ---------- */
  .card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .plan-card {
    padding: 14px 14px 12px;
  }
  .plan-card h3 {
    font-size: 16px;
  }
  .plan-card .plan-meta {
    font-size: 12px;
  }
  .plan-card .plan-actions {
    gap: 6px;
  }
  .plan-card .plan-actions .btn {
    flex: 1 1 40%;
    justify-content: center;
    padding: 9px 6px;
    font-size: 12.5px;
  }

  /* 搜索框（面包屑栏内） */
  .breadcrumb-bar {
    padding: 10px 12px;
    margin-bottom: 14px;
  }
  .breadcrumb-tools {
    width: 100%;
    margin-left: 0;
  }
  .breadcrumb-tools input[type="search"] {
    flex: 1;
    width: auto;
    min-width: 0;
    padding: 10px 12px;
  }

  /* 空状态 */
  .empty-state {
    padding: 40px 16px;
  }
  .empty-state h2 {
    font-size: 17px;
  }

  /* AI 占位 */
  .ai-placeholder {
    padding: 12px;
    font-size: 12px;
  }

  /* ---------- 移动端适配 ---------- */

  /* AI 悬浮按钮缩小、贴边 */
  .ai-fab {
    bottom: 20px;
    right: 16px;
    width: 46px;
    height: 46px;
  }
  /* 编辑页保存条 sticky 常驻屏幕底部，AI 按钮整体上移避让 */
  body:has(.save-bar) .ai-fab {
    bottom: 84px;
  }

  /* AI 窗口：铺满小屏（留出边距），重置拖拽产生的内联样式 */
  .ai-chat {
    left: 8px !important;
    right: 8px !important;
    top: 8px !important;
    bottom: 8px !important;
    width: auto !important;
    height: auto !important;
    max-height: none;
  }
  .ai-chat .ai-messages { max-height: none; flex: 1; }

  /* 触屏没有悬停：消息操作图标常显 */
  .ai-message-row .ai-message-actions {
    opacity: 1;
    pointer-events: auto;
  }

  /* AI 设置弹窗：贴边铺满 */
  .ai-modal-content {
    width: calc(100% - 24px);
    max-height: 88vh;
  }

  /* 触屏禁用拖拽把手的光标提示（拖拽仍可用鼠标场景） */
  .ai-chat-header { cursor: default; }
  .ai-chat-resize { display: none; }

  /* 手机：主题按钮钉在顶栏右上角（品牌文字短，右侧空间充足） */
  .app-rail .theme-toggle {
    position: absolute;
    left: auto;
    bottom: auto;
    top: 11px;
    right: 14px;
  }

  /* Toast：居中显示，避开右下角 AI 悬浮按钮 */
  .toast {
    left: 16px;
    right: 16px;
    bottom: 82px;
    text-align: center;
  }
  /* 编辑页：Toast 再上移，避开常驻保存条 + AI 按钮 */
  body:has(.save-bar) .toast {
    bottom: 146px;
  }
}

/* 小屏手机 (380px 以下) */
@media (max-width: 380px) {
  .app-rail .brand {
    font-size: 16px;
  }
  .app-rail nav a {
    font-size: 12.5px;
    padding: 8px 4px;
  }
  .toolbar {
    gap: 6px;
  }
  .page-head h1 {
    font-size: 19px;
  }
  .form-section {
    padding: 13px 11px;
  }
  .app-main {
    padding: 14px 10px 24px;
  }
  /* 卡片操作按钮在极窄屏下允许换行，避免溢出 */
  .plan-card .plan-actions .btn {
    white-space: normal;
    line-height: 1.3;
  }
}
