/* ==========================================================================
   组件：表面、按钮、输入、勾选、状态点、折叠行、扫光、弹层、菜单、提示条
   表面会重绑文字和线的变量（照 Harness 的做法），放在纸上的组件自动换成纸上的颜色。
   ========================================================================== */

/* —— 表面 —— */
/* 桌垫：成组的内容放在上面 */
.card,
.mat {
  --ink: var(--mat-ink);
  --ink-2: var(--mat-ink-2);
  --ink-3: var(--mat-ink-3);
  --line: var(--mat-line);
  min-width: 0;
  color: var(--ink);
  background: var(--mat);
  border-radius: var(--r-xl);
  border: 0.5px solid var(--mat-line);
  box-shadow: var(--shadow-1);
}
/* 纸：现在做、索引卡、要读的东西 */
.paper {
  --ink: var(--paper-ink);
  --ink-2: var(--paper-ink-2);
  --ink-3: var(--paper-ink-2);
  --line: var(--paper-line);
  --line-2: var(--paper-line);
  --hover: rgba(120, 90, 50, 0.07);
  --accent-ink: #9a560a;
  color: var(--paper-ink);
  background: var(--paper);
  border-radius: var(--r-paper);
  box-shadow: var(--shadow-2);
  background-image: radial-gradient(rgba(120, 90, 50, 0.045) 1px, transparent 1px);
  background-size: 3px 3px;
}
/* 浮起的面板：导师面板、弹层、菜单 */
.panel {
  color: var(--ink);
  background: var(--panel);
  border-radius: var(--r-panel);
  box-shadow: var(--elev-prominent);
}

/* —— 页面版式 —— */
.page {
  max-width: var(--page-w);
  margin: 0 auto;
  min-width: 0;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 26px;
  flex-wrap: wrap;
}
.page-head h1 {
  font: var(--t-title);
}
.page-head p {
  margin-top: 4px;
  color: var(--ink-2);
  font: var(--t-small);
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.section {
  margin-top: 36px;
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 14px;
}
.section-title h2 {
  font: var(--t-section);
}
.section-title small,
.section-title h2 small {
  margin-left: 10px;
  color: var(--ink-3);
  font: var(--t-small);
}
.grid {
  display: grid;
  gap: 20px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@container main (max-width: 780px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* —— 按钮 —— */
/* 默认：一块浮起的小面板；主按钮：琥珀色键帽（底下 3px 键程，按下沉下去） */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--elev-panel);
  font: 500 14px/22px var(--font);
  white-space: nowrap;
  user-select: none;
  transition: transform var(--d-fast) var(--ease), background var(--d) var(--ease), box-shadow var(--d) var(--ease), opacity var(--d);
}
.btn svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.btn:hover {
  background: var(--panel-2);
}
.btn:active {
  transform: translateY(1px) scale(0.985);
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}
.btn.primary {
  background: linear-gradient(180deg, #eaa64c, #d98a2a);
  color: #24170a;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 -1px 0 rgba(0, 0, 0, 0.1) inset, 0 3px 0 #a7671e, 0 8px 16px -8px rgba(120, 60, 10, 0.55);
  margin-bottom: 3px;
}
:root:not([data-theme='dark']) .btn.primary {
  background: linear-gradient(180deg, #ad6516, #8e4e08);
  color: #fff9ef;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 3px 0 #6d3c06, 0 8px 16px -8px rgba(90, 45, 5, 0.5);
}
.btn.primary:hover {
  filter: brightness(1.04);
}
.btn.primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 1px 0 #a7671e, 0 4px 10px -6px rgba(120, 60, 10, 0.5);
}
:root:not([data-theme='dark']) .btn.primary:active {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 0 #6d3c06, 0 4px 10px -6px rgba(90, 45, 5, 0.4);
}
/* 不能点的主按钮退成灰的，不留一块发白的琥珀 */
.btn.primary:disabled {
  opacity: 1;
  filter: none;
  background: var(--panel-3);
  color: var(--ink-3);
  box-shadow: 0 3px 0 var(--line-2);
}
.btn.ghost {
  background: transparent;
  box-shadow: none;
  color: var(--ink-2);
}
.btn.ghost:hover {
  background: var(--hover);
  color: var(--ink);
}
.btn.ghost.on {
  color: var(--accent);
}
.btn.danger {
  color: var(--danger);
}
.btn.danger.solid {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--danger) 60%, #000), 0 8px 16px -8px rgba(120, 30, 10, 0.5);
  margin-bottom: 3px;
}
.btn.ai {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}
.btn.sm {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
}
.btn.xs {
  height: 26px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  gap: 4px;
}
.btn.xs svg {
  width: 14px;
  height: 14px;
}
.btn.lg {
  height: 44px;
  padding: 0 22px;
  font-size: 15px;
  font-weight: 600;
}
/* 纸上的按钮：纸面上的一块，不浮起来 */
.paper .btn:not(.primary):not(.ghost) {
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 0.5px var(--paper-line), 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 2px 0 rgba(43, 33, 24, 0.12);
}
.paper .btn:not(.primary):not(.ghost):hover {
  background: rgba(255, 255, 255, 0.8);
}
.paper .btn.ghost {
  color: var(--paper-ink-2);
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink-2);
  flex: none;
  transition: background var(--d-fast), color var(--d-fast), transform var(--d-fast);
}
.icon-btn svg {
  width: 19px;
  height: 19px;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn.sm {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
}
.icon-btn.sm svg {
  width: 16px;
  height: 16px;
}
.icon-btn.danger,
.icon-btn.danger:hover {
  color: var(--danger);
}
/* 行内的编辑、删除：有鼠标时移到这一行才出现；触屏照常显示 */
@media (hover: hover) and (pointer: fine) {
  .row-tool {
    opacity: 0;
    transition: opacity var(--d-fast), background var(--d-fast), color var(--d-fast);
  }
  :is(.item, .goal, .mt-item, .link-card, .mem-row):hover .row-tool,
  .row-tool:focus-visible {
    opacity: 1;
  }
}

/* —— 输入 —— */
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.field > label,
.label {
  font: 500 13px/20px var(--font);
  color: var(--ink-2);
}
.field .hint {
  font: var(--t-caption);
  color: var(--ink-3);
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--elev-soft);
  font: var(--t-ui);
  caret-color: var(--accent);
  transition: box-shadow var(--d-fast);
}
:is(.card, .mat) .input,
:is(.card, .mat) .select,
:is(.card, .mat) .textarea {
  background: var(--mat-2);
  box-shadow: 0 0 0 0.5px var(--mat-line) inset;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-3);
}
.textarea {
  resize: vertical;
  line-height: 1.65;
  min-height: 90px;
}
.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23998877' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.input.sm,
.select.sm {
  min-height: 30px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font: var(--t-small);
}
/* 手机：低于 16px 时 iOS 聚焦会放大整页 */
@media (max-width: 760px) {
  .input,
  .select,
  .textarea,
  .input.sm,
  .select.sm {
    font-size: 16px;
  }
}
.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-grid .full {
  grid-column: 1 / -1;
}
@container main (max-width: 540px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 560px) {
  .sheet .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* —— 分段：外圈 R12、内缩 4、分段 R8；选中的是一块浮起的小板 —— */
.seg {
  position: relative;
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-md);
  background: var(--hover);
  box-shadow: 0 0 0 0.5px var(--line) inset;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar {
  display: none;
}
.seg button {
  position: relative;
  z-index: 1;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font: 500 13px/20px var(--font);
  white-space: nowrap;
  transition: color var(--d), background var(--d), box-shadow var(--d);
}
.seg button:hover {
  color: var(--ink);
}
.seg button.on {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--elev-panel);
}

/* —— 科目：一个小色点加文字 —— */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0;
  font: 500 13px/20px var(--font);
  white-space: nowrap;
  color: var(--ink-2);
}
.chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c, #8e8e93) 80%, var(--ink-3));
  flex: none;
}
.chip.plain,
.chip.warn,
.chip.danger,
.chip.ok,
.chip.ai {
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  font-weight: 600;
  font-size: 12px;
}
.chip.plain::before,
.chip.warn::before,
.chip.danger::before,
.chip.ok::before,
.chip.ai::before {
  display: none;
}
.chip.plain {
  background: var(--hover);
  color: var(--ink-2);
}
.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.chip.danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.chip.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.chip.ai {
  background: var(--accent-soft);
  color: var(--accent);
}
/* 状态词：只用字色 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 500 12px/18px var(--font);
  color: var(--ink-3);
  white-space: nowrap;
}
.tag.danger {
  color: var(--danger);
}
.tag.warn {
  color: var(--warn);
}
.tag.ok {
  color: var(--ok);
}
.tag svg {
  width: 12px;
  height: 12px;
}
.filter-chip {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 0;
  background: var(--panel);
  box-shadow: var(--elev-panel);
  color: var(--ink-2);
  font: 500 13px/20px var(--font);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.filter-chip.on {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 0.5px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* —— 进度：细的灯槽 —— */
.ring {
  --size: 56px;
  width: var(--size);
  height: var(--size);
  position: relative;
  flex: none;
}
.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}
.ring .track {
  stroke: var(--hover);
}
.ring .val {
  stroke: var(--c, var(--accent));
  transition: stroke-dashoffset 0.9s var(--ease-out);
}
.ring b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 600 14px/1 var(--font-num);
}

/* —— 勾选：铅笔画的圈；勾上时一笔画出一个墨水勾 —— */
.check {
  position: relative;
  width: 22px;
  height: 22px;
  flex: none;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-3);
}
.check svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.check .ring-path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  opacity: 0.62;
  transition: opacity var(--d), stroke var(--d);
}
/* 一笔墨：勾选框里的勾和打在字上的勾是同一笔（ui/kit.js 的 Ink）。
   遮罩沿笔画中线往前露：先慢后快、末尾一甩；擦掉时快一些。线头用平头，没勾时一点墨都不留 */
.ink-reveal {
  fill: none;
  stroke: #fff;
  stroke-width: 7;
  stroke-linecap: butt;
  stroke-linejoin: round;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.18s cubic-bezier(0.4, 0, 1, 1);
}
.check.on .ink-reveal,
.ink-tick.on .ink-reveal {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s cubic-bezier(0.62, 0.02, 0.24, 1);
}
.check .ink {
  fill: var(--check-ink, var(--ink-blue));
  /* 圈很小：墨描粗一点，缩小以后笔锋还看得出来 */
  stroke: var(--check-ink, var(--ink-blue));
  stroke-width: 1.5;
  stroke-linejoin: round;
}
/* 夜里桌垫、面板是深色的，墨水勾换成浅蓝；纸、便利贴、卡片上还是深蓝墨水 */
:root[data-theme='dark'] {
  --check-ink: #b8c9ec;
}
.paper,
.sticky,
.life,
.tray,
.icard,
.scard,
.dpaper {
  --check-ink: var(--ink-blue);
}
.check:hover .ring-path {
  opacity: 0.9;
}
.check:active {
  transform: scale(0.9);
}
.check.on .ring-path {
  opacity: 0.22;
}
.check.pop {
  animation: check-pop 0.42s var(--ease-out);
}
@keyframes check-pop {
  40% {
    transform: scale(1.18) rotate(-5deg);
  }
}
/* 进行中：圈是琥珀色的，里面铅笔涂了一部分 */
.check.half .ring-path {
  stroke: var(--accent);
  opacity: 0.9;
}
.check.half::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: conic-gradient(color-mix(in srgb, var(--accent) 55%, transparent) var(--p, 50%), transparent 0);
}

/* —— 开关 —— */
.switch {
  width: 40px;
  height: 24px;
  border-radius: 12px;
  border: 0;
  padding: 0;
  background: var(--press);
  box-shadow: 0 0 0 0.5px var(--line-2) inset;
  position: relative;
  transition: background var(--d) var(--ease);
  flex: none;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform var(--d-slow) var(--ease-click);
}
.switch.on {
  background: var(--accent);
}
.switch.on::after {
  transform: translateX(16px);
}

/* —— 状态点：完成 / 等待 / 警告 / 出错 / 进行中（转圈）。全站只用这五种 —— */
.sd {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: none;
  color: var(--idle);
}
.sd::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: currentColor;
}
.sd[data-s='done'] {
  color: var(--ok);
}
.sd[data-s='warn'] {
  color: var(--warn);
}
.sd[data-s='error'] {
  color: var(--danger);
}
.sd[data-s='ongoing'] {
  width: 14px;
  height: 14px;
  color: var(--ink-3);
}
.sd[data-s='ongoing']::after {
  inset: 0;
  background: none;
  border: 1.6px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* —— 折叠行：24 高；图标在悬停时换成箭头；字是三级色，悬停变二级 —— */
.dis {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 28px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font: var(--t-small);
  text-align: left;
  transition: color var(--d-fast);
}
.dis:hover,
.dis[aria-expanded='true'] {
  color: var(--ink-2);
}
.dis .dis-lead {
  position: relative;
  width: 16px;
  height: 16px;
  flex: none;
  display: grid;
  place-items: center;
}
.dis .dis-lead > * {
  transition: opacity var(--d-fast);
}
.dis .dis-lead svg {
  width: 15px;
  height: 15px;
}
.dis .dis-chev {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
}
.dis .dis-chev svg {
  transition: transform var(--d) var(--ease);
}
.dis[aria-expanded='true'] .dis-chev svg {
  transform: rotate(180deg);
}
.dis:hover .dis-icon,
.dis:focus-visible .dis-icon,
.dis[aria-expanded='true'] .dis-icon {
  opacity: 0;
}
.dis:hover .dis-chev,
.dis:focus-visible .dis-chev,
.dis[aria-expanded='true'] .dis-chev {
  opacity: 1;
}
.dis .dis-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dis .dis-tail {
  margin-left: auto;
  flex: none;
  font-variant-numeric: tabular-nums;
}

/* —— 扫光：运行中的一行，一道光从左扫到右 —— */
.shimmer {
  --sh: var(--ink-3);
  color: transparent;
  background: linear-gradient(105deg, var(--sh) 0 40%, rgba(var(--warm), 1) 50%, var(--sh) 60% 100%) 0 0 / 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: shimmer 1.8s linear 0.3s infinite;
}
@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -150% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .shimmer {
    animation: none;
    color: var(--sh);
    background: none;
  }
}

/* —— 列表行 —— */
.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-top: 0.5px solid var(--line);
  min-width: 0;
}
.item:first-child {
  border-top: 0;
}
.item-main {
  flex: 1;
  min-width: 0;
}
.item-title {
  font: var(--t-item);
  word-break: break-word;
}
.item-title.done {
  color: var(--ink-3);
  text-decoration: line-through;
  text-decoration-color: var(--line-2);
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 4px;
  font: var(--t-small);
  color: var(--ink-3);
}
.item-meta .late {
  color: var(--danger);
  font-weight: 600;
}
.item-meta .soon {
  color: var(--warn);
  font-weight: 600;
}
.group-label {
  font: 600 12px/18px var(--font);
  color: var(--ink-3);
  letter-spacing: 0.04em;
  margin: 14px 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.group-label.late {
  color: var(--danger);
}

/* —— 空、提示 —— */
.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 26px 10px;
  text-align: center;
  color: var(--ink-3);
  font: var(--t-ui);
}
.empty svg {
  width: 28px;
  height: 28px;
  opacity: 0.6;
}
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--r-lg);
  font: var(--t-ui);
}
.alert svg {
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 2px;
}
.alert.warn {
  background: var(--warn-soft);
  color: color-mix(in srgb, var(--warn) 85%, var(--ink));
}
.alert.ok {
  background: var(--ok-soft);
  color: color-mix(in srgb, var(--ok) 85%, var(--ink));
}
.alert.info {
  background: var(--accent-soft);
  color: color-mix(in srgb, var(--accent) 80%, var(--ink));
}
.alert.danger {
  background: var(--danger-soft);
  color: color-mix(in srgb, var(--danger) 85%, var(--ink));
}

/* —— 弹层：桌面居中（R28），手机从底下升起；遮罩是黑色半透明，不模糊 —— */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--mask);
  animation: fade-in 0.26s var(--ease);
}
.overlay.closing {
  animation: fade-out 0.2s var(--ease-in) forwards;
}
.sheet {
  width: min(560px, 100%);
  max-height: min(86dvh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: var(--r-panel);
  box-shadow: var(--elev-prominent);
  animation: sheet-in 0.4s var(--ease);
  overflow: hidden;
}
.overlay.closing .sheet {
  animation: sheet-out 0.2s var(--ease-in) forwards;
}
.sheet.wide {
  width: min(760px, 100%);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 10px 24px;
}
.sheet-head h3 {
  font: var(--t-section);
  flex: 1;
  min-width: 0;
}
.sheet-body {
  padding: 10px 24px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 16px 24px;
  border-top: 0.5px solid var(--line);
}
.grabber {
  display: none;
}
@media (max-width: 760px) {
  .overlay {
    place-items: end center;
    padding: 0;
  }
  .sheet,
  .sheet.wide {
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-panel) var(--r-panel) 0 0;
    padding-bottom: var(--safe-b);
    animation: sheet-up 0.44s var(--ease);
  }
  .overlay.closing .sheet {
    animation: sheet-down 0.26s var(--ease-in) forwards;
  }
  .grabber {
    display: block;
    width: 38px;
    height: 5px;
    border-radius: 3px;
    background: var(--line-2);
    margin: 8px auto -6px;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.975);
  }
}
@keyframes sheet-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
@keyframes sheet-down {
  to {
    transform: translateY(100%);
  }
}

/* —— 提示条：顶部居中，深色，带“撤销” —— */
.toasts {
  position: fixed;
  left: 50%;
  top: calc(var(--topbar-h) + 18px);
  transform: translateX(-50%);
  z-index: 110;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
  width: min(560px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 10px 10px 16px;
  border-radius: var(--r-lg);
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.08) inset, 0 14px 32px -10px rgba(0, 0, 0, 0.5);
  font: var(--t-ui);
  animation: toast-in 0.32s var(--ease-out);
}
.toast.error {
  background: #8f3424;
}
.toast > svg {
  width: 17px;
  height: 17px;
  flex: none;
  color: #9fd08a;
}
.toast.error > svg {
  color: #ffd0c4;
}
.toast span {
  flex: 1;
  min-width: 0;
}
.toast button {
  border: 0;
  background: none;
  color: #ffc77d;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font: 600 13px/20px var(--font);
  flex: none;
}
.toast button:hover {
  background: rgba(255, 255, 255, 0.08);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

/* —— 菜单：外圈 R16、内缩 4、行 R12；半透明材质加模糊 —— */
.menu {
  position: absolute;
  z-index: 70;
  min-width: 190px;
  padding: 4px;
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  box-shadow: var(--elev-prominent);
  animation: menu-in 0.18s var(--ease);
  transform-origin: top right;
}
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  font: var(--t-ui);
}
.menu button svg {
  width: 17px;
  height: 17px;
  color: var(--ink-2);
}
.menu button:hover {
  background: var(--hover);
}
.menu button.danger,
.menu button.danger svg {
  color: var(--danger);
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* —— 拖拽 —— */
.drag-clone {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  margin: 0;
  cursor: grabbing;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18), 0 34px 60px -14px rgba(0, 0, 0, 0.5) !important;
  will-change: transform;
}
.drop-before {
  position: relative;
}
.drop-before::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: -6px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
}
.drop-end::after {
  content: '';
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  margin: 2px 4px;
}

/* —— Markdown —— */
.md {
  font: var(--t-body);
  line-height: 1.75;
  word-break: break-word;
}
.md > * + * {
  margin-top: 0.6em;
}
.md h1,
.md h2,
.md h3,
.md h4 {
  font-family: var(--font-kai);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.4;
  margin-top: 1em;
}
.md ul,
.md ol {
  padding-left: 1.3em;
  margin-bottom: 0;
}
.md li + li {
  margin-top: 0.25em;
}
.md code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  background: var(--hover);
}
.md pre {
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--hover);
  overflow-x: auto;
}
.md pre code {
  padding: 0;
  background: none;
}
.md blockquote {
  margin-left: 0;
  padding-left: 12px;
  border-left: 2px solid var(--line-2);
  color: var(--ink-2);
}
.md strong {
  font-weight: 650;
}
.md hr {
  border: 0;
  border-top: 0.5px solid var(--line);
}
.md table {
  border-collapse: collapse;
  font: var(--t-small);
}
.md td,
.md th {
  border: 0.5px solid var(--line-2);
  padding: 4px 8px;
}
.md a {
  font-weight: 500;
}
