/* ============================================================
 * 教案碎片收纳盒 —— 样式表
 * 风格：浅米色办公风，纸张质感，克制动效，适配大屏
 * ============================================================ */

/* ---------- 设计变量 ---------- */
:root {
  /* 纸张色系：宣纸米黄，去 AI 工具风的「奶白 + 柔光阴影」感 */
  --paper: #f1e9d3;        /* 页面背景：宣纸米黄 */
  --paper-deep: #e8dcc0;   /* 侧栏 / 面板底色：旧纸 */
  --card: #faf4e3;         /* 卡片底色：微黄纸 */
  --line: #dcd0b3;         /* 细边框线：纸缝 */
  --line-dark: #c6b689;    /* 稍深的边框线 */

  /* 文字色系：纯墨，沉稳偏暖 */
  --ink: #322c22;          /* 主文字：墨色 */
  --ink-weak: #8a7c5d;     /* 次级文字：灰褐 */

  /* 点缀色系：沉稳朱砂，避免高饱和跳色 */
  --red: #a2402c;          /* 朱砂红（主操作色） */
  --red-dark: #7e2f1f;     /* 悬停 / 按下：印泥深红 */
  --red-soft: #eed9cb;     /* 浅朱砂底色 */
  --green: #48644c;        /* 竹青（成功提示） */

  /* 圆角与阴影：圆角小而收敛，阴影低而实，避免新拟态漂浮感 */
  --radius: 6px;
  --shadow: 0 1px 2px rgba(88, 68, 40, 0.10), 0 2px 6px rgba(88, 68, 40, 0.06);
}

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* 通用显隐类：所有需要动态隐藏的元素共用 */
.hidden { display: none !important; }

html { height: 100%; }

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  line-height: 1.6;
  font-size: 15px;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1720px;
  margin: 0 auto;
  min-height: 64px;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-icon {
  width: 38px;
  height: 38px;
  flex: none;
}

.brand-text h1 {
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "PingFang SC", serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand-text p {
  font-size: 12px;
  color: var(--ink-weak);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat { font-size: 13px; color: var(--ink-weak); white-space: nowrap; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
  user-select: none;
}

.btn:hover { border-color: var(--red); color: var(--red); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }

.btn-primary {
  background: var(--red);
  border-color: var(--red);
  color: #fdf2de;
}

.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fdf2de; }

.btn-mini {
  padding: 3px 10px;
  font-size: 13px;
  border-radius: 4px;
  border-style: dashed;
}

.btn-text {
  background: none;
  border: none;
  color: var(--red);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.btn-text:hover { background: var(--red-soft); }
.btn-text.danger { color: var(--red); }

.edit-tip { color: var(--ink-weak); }
.edit-tip:hover { color: var(--ink); background: none; }

/* 按钮加载态（占位） */
.btn.is-busy { opacity: 0.75; pointer-events: none; }

/* ---------- 主体 ---------- */
.main {
  max-width: 1720px;
  margin: 0 auto;
  padding: 22px 28px 90px;
}

/* ---------- 录入区 ---------- */
.composer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 20px;
}

.composer textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f4ead3;
  color: var(--ink);
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.7;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(162, 64, 44, 0.16);
}

.composer textarea::placeholder { color: #a4946e; }

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* 标签选择条 */
.tag-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }

.picker-label { font-size: 13px; color: var(--ink-weak); flex: none; }

.picker-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 11px;
  font-size: 13px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.tag-chip:hover { border-color: var(--red); color: var(--red); }

.tag-chip.active {
  background: var(--red);
  border-color: var(--red);
  color: #fdf2de;
}

.composer-actions { display: flex; align-items: center; gap: 10px; }

.char-count { font-size: 12px; color: var(--ink-weak); }

/* ---------- 工作区 ---------- */
.workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

/* 左侧标签栏 */
.sidebar {
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 12px;
  position: sticky;
  top: 88px;
}

.sidebar-head {
  font-size: 13px;
  color: var(--ink-weak);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--line-dark);
}

.tag-list { list-style: none; margin-top: 6px; max-height: calc(100vh - 320px); overflow-y: auto; }

.tag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  margin: 2px 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.tag-item:hover { background: rgba(250, 244, 227, 0.8); }

.tag-item.active {
  background: var(--card);
  border-color: var(--line);
  color: var(--red);
  font-weight: 600;
}

.tag-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.tag-count {
  font-size: 12px;
  color: var(--ink-weak);
  background: rgba(80, 62, 36, 0.10);
  border-radius: 4px;
  padding: 0 8px;
  flex: none;
}

.tag-item.active .tag-count { color: var(--red); }

/* 标签操作按钮：常显但弱化，悬停提亮，键盘聚焦可见 */
.tag-ops { display: inline-flex; gap: 2px; flex: none; opacity: 0.55; transition: opacity 0.15s ease; }

.tag-item:hover .tag-ops { opacity: 1; }

.tag-op {
  border: none;
  background: none;
  color: var(--ink-weak);
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  border-radius: 3px;
  line-height: 1.4;
}

.tag-op:hover { color: var(--red); background: var(--red-soft); }
.tag-op:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }

.side-new-tag { margin-top: 8px; width: 100%; text-align: center; }

/* 右侧列表 */
.content {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-height: 320px;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.list-title { font-size: 16px; font-weight: 600; }

.list-tools { display: flex; align-items: center; gap: 12px; }

.select-all {
  font-size: 13px;
  color: var(--ink-weak);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--red);
  cursor: pointer;
}

.hint-bar {
  font-size: 12px;
  color: var(--ink-weak);
  padding: 8px 2px 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.drag-dots { font-style: normal; color: var(--line-dark); letter-spacing: 0; transform: rotate(90deg); display: inline-block; font-size: 11px; }

/* 素材搜索框 */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px 2px;
}

.search-bar input {
  flex: 1;
  max-width: 360px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: #f4ead3;
  color: var(--ink);
  padding: 5px 10px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(162, 64, 44, 0.16);
}

.search-bar input::placeholder { color: #a4946e; }

.search-clear { flex: none; }

/* ---------- 素材卡片 ---------- */
.list { margin-top: 6px; }

.card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px;
  border-bottom: 1px dashed var(--line);
  transition: background 0.15s ease, opacity 0.15s ease;
}

.card:last-child { border-bottom: none; }

.card:hover { background: #f3ead6; }

.card.dragging { opacity: 0.35; }

.card.drop-before { box-shadow: 0 -2px 0 0 var(--red); }
.card.drop-after { box-shadow: 0 2px 0 0 var(--red); }

/* 拖拽手柄（点阵） */
.drag-handle {
  cursor: grab;
  color: #b3a274;
  font-size: 14px;
  letter-spacing: 0;
  padding: 4px 2px;
  line-height: 1;
  user-select: none;
  flex: none;
  transition: color 0.15s ease;
}

.drag-handle:hover { color: var(--red); }

.card .check { flex: none; padding-top: 4px; }

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

.card-content {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.75;
  padding-top: 2px;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.card-tags { display: flex; gap: 5px; flex-wrap: wrap; }

.card-tag {
  font-size: 12px;
  color: #fdf2de;              /* 红底上用浅色文字保证对比 */
  background: var(--red);
  border: 1px solid var(--line-dark);  /* 与 chip 统一标签语言 */
  border-radius: 4px;
  padding: 1px 8px;
}

/* 卡片操作按钮：常显但弱化（opacity .55），悬停提亮到 1 */
.card-actions {
  display: flex;
  gap: 4px;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.card:hover .card-actions { opacity: 1; }

.card-action {
  border: 1px solid transparent;
  background: none;
  color: var(--ink-weak);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.card-action:hover { color: var(--red); border-color: var(--line-dark); background: var(--card); }
.card-action:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }

.card-time { font-size: 11px; color: #a8986f; flex: none; }

/* ---------- 空状态 ---------- */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-weak);
  font-size: 14px;
  border: 1px dashed var(--line-dark);
  border-radius: var(--radius);
}

.empty-icon {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  opacity: 0.7;
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- 粉笔彩蛋入口 ---------- */
.chalk {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.25;
  transform: scale(0.8);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s ease;
  border-radius: 50%;
}

.chalk svg { width: 34px; height: 34px; }

.chalk:hover,
.chalk:focus-visible {
  opacity: 1;
  transform: scale(1);
  outline: none;
  background: rgba(250, 244, 227, 0.9);
  box-shadow: 0 2px 12px rgba(90, 70, 40, 0.15);
}

/* 悬停时的气泡提示 */
.chalk-tip {
  position: absolute;
  right: 52px;
  bottom: 8px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--red);
  background: var(--card);
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  padding: 4px 10px;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.chalk:hover .chalk-tip,
.chalk:focus-visible .chalk-tip { opacity: 1; transform: translateX(0); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden { display: none; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(47, 37, 20, 0.42);
  backdrop-filter: blur(1px);
}

.modal-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(55, 42, 22, 0.26);
  width: 100%;
  max-width: 420px;
  padding: 22px 24px;
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-card h3 { font-size: 17px; margin-bottom: 14px; }

.modal-card input {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: #f4ead3;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--ink);
  font-family: inherit;
}

.modal-card input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 2px rgba(162, 64, 44, 0.16); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* 教师节祝福弹窗 */
.modal-card.greet { max-width: 460px; text-align: center; padding: 30px 34px 26px; }

.greet-chalk { margin-bottom: 6px; }

.greet-chalk svg { width: 60px; height: 60px; }

.greet-title {
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 28px;
  color: var(--red);
  letter-spacing: 3px;
  margin: 2px 0 4px;
}

.greet-date { font-size: 12px; color: var(--ink-weak); letter-spacing: 2px; }

.greet-body {
  margin-top: 18px;
  font-size: 15px;
  line-height: 2;
  text-align: center;
  color: var(--ink);
}

.greet-body p { margin-bottom: 12px; }

.greet .modal-actions { justify-content: center; margin-top: 24px; }

/* 导出 Markdown 预览弹窗 */
.modal-card.export { max-width: 640px; }

.export-hint { font-size: 12px; color: var(--ink-weak); margin-bottom: 8px; }

.modal-card.export textarea {
  width: 100%;
  height: 300px;
  resize: vertical;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: #f4ead3;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  font-family: inherit;
  white-space: pre;
}

.modal-card.export textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 2px rgba(162, 64, 44, 0.16); }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--ink);
  color: #f6f0e2;
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 14px;
  box-shadow: 0 4px 18px rgba(40, 30, 15, 0.25);
  opacity: 1;
  transition: opacity 0.25s ease;
  max-width: 80vw;
}

.toast.hidden { display: none; }

/* ---------- 响应式：窄屏退化为单列 ---------- */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .topbar-inner { flex-wrap: wrap; }
  .brand-text p { display: none; }
}

/* ---------- 滚动条（细而克制） ---------- */
.list::-webkit-scrollbar,
.tag-list::-webkit-scrollbar { width: 8px; }

.list::-webkit-scrollbar-thumb,
.tag-list::-webkit-scrollbar-thumb { background: #c2b083; border-radius: 4px; }