/* ============================================================
   批注层 · annotate.css
   独立于稿子本身的样式，不使用稿子的 token，避免与设计评审互相干扰。
   固定视觉：批注 UI 永远是"工具"，不参与被评审的设计。
   ============================================================ */

:root {
  --anno-accent: #E0492B;
  --anno-accent-dim: rgba(224, 73, 43, 0.14);
  --anno-panel: #16171A;
  --anno-panel-2: #1F2126;
  --anno-line: #32353C;
  --anno-text: #F2F2EF;
  --anno-text-2: #A5A9B0;
  --anno-ok: #3BA776;
  --anno-z: 2147483000;
}

/* ---- 悬浮控件：左＝进出批注模式，右＝打开批注列表 ----
   两个动作必须是两个按钮。合并成一个会出现「有批注后再也进不去批注模式」的死锁。 */
#anno-fab-wrap {
  position: fixed; right: 18px; bottom: 18px;
  z-index: var(--anno-z);
  display: flex; align-items: stretch; gap: 8px;
}
#anno-fab, #anno-open-list {
  background: var(--anno-panel); color: var(--anno-text);
  border: 1px solid var(--anno-line); border-radius: 999px;
  font: 600 14px/1 system-ui, -apple-system, "PingFang SC", sans-serif;
  cursor: pointer; box-shadow: 0 6px 24px rgba(0,0,0,.28);
  transition: background .15s, border-color .15s;
}
#anno-fab {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 17px;
}
#anno-fab:hover, #anno-open-list:hover { background: var(--anno-panel-2); }
#anno-fab.on { background: var(--anno-accent); border-color: var(--anno-accent); }
#anno-open-list {
  display: grid; place-items: center;
  min-width: 44px; padding: 0 13px;
}
#anno-open-list .anno-count {
  font-size: 14px; font-variant-numeric: tabular-nums;
}
#anno-fab:focus-visible, #anno-open-list:focus-visible {
  outline: 2px solid var(--anno-accent); outline-offset: 2px;
}

/* ---- 批注模式：可点元素高亮 ---- */
html.anno-mode * { cursor: crosshair !important; }
html.anno-mode .anno-hit {
  outline: 2px solid var(--anno-accent) !important;
  outline-offset: 1px;
  background: var(--anno-accent-dim) !important;
}
/* 已有批注的元素常驻标记 */
.anno-marked { position: relative; }
.anno-marked::after {
  content: attr(data-anno-n);
  position: absolute; top: -8px; right: -8px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  background: var(--anno-accent); color: #fff;
  border-radius: 999px; z-index: 50;
  font: 600 11px/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,.85);
}

/* ---- 点击后的 bar ---- */
#anno-bar {
  position: fixed; z-index: calc(var(--anno-z) + 1);
  display: none; align-items: center; gap: 8px;
  padding: 7px 8px 7px 12px;
  background: var(--anno-panel); color: var(--anno-text);
  border: 1px solid var(--anno-line); border-radius: 10px;
  box-shadow: 0 10px 34px rgba(0,0,0,.34);
  font: 500 13px/1.3 system-ui, -apple-system, "PingFang SC", sans-serif;
  max-width: min(92vw, 520px);
}
#anno-bar.show { display: flex; }
#anno-bar .anno-what {
  color: var(--anno-text-2); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 260px;
}
#anno-bar button {
  border: 0; border-radius: 7px; cursor: pointer; white-space: nowrap;
  font: 600 13px/1 system-ui, -apple-system, "PingFang SC", sans-serif;
  padding: 9px 13px;
}
#anno-bar .anno-add { background: var(--anno-accent); color: #fff; }
#anno-bar .anno-cancel { background: transparent; color: var(--anno-text-2); padding: 9px 6px; }

/* ---- 输入面板 ---- */
#anno-editor {
  position: fixed; inset: auto 0 0 0; z-index: calc(var(--anno-z) + 2);
  display: none; flex-direction: column; gap: 12px;
  padding: 20px 22px calc(20px + env(safe-area-inset-bottom));
  background: var(--anno-panel); color: var(--anno-text);
  border-top: 1px solid var(--anno-line);
  box-shadow: 0 -12px 44px rgba(0,0,0,.4);
  max-height: 84vh; overflow-y: auto;
}
#anno-editor.show { display: flex; }
@media (min-width: 900px) {
  #anno-editor {
    inset: auto 22px 22px auto; width: 460px; border-radius: 14px;
    border: 1px solid var(--anno-line);
  }
}
#anno-editor .anno-target {
  font-size: 12px; color: var(--anno-text-2); line-height: 1.5;
  background: var(--anno-panel-2); border: 1px solid var(--anno-line);
  border-radius: 8px; padding: 10px 12px;
  word-break: break-all;
}
#anno-editor .anno-target b { color: var(--anno-text); font-weight: 600; }
#anno-editor textarea {
  width: 100%; min-height: 108px; resize: vertical;
  background: var(--anno-panel-2); color: var(--anno-text);
  border: 1px solid var(--anno-line); border-radius: 8px;
  padding: 12px 13px;
  font: 400 15px/1.55 system-ui, -apple-system, "PingFang SC", sans-serif;
}
#anno-editor textarea:focus { outline: 2px solid var(--anno-accent); outline-offset: 1px; }
#anno-editor .anno-drop {
  border: 1px dashed var(--anno-line); border-radius: 8px;
  padding: 12px; text-align: center; font-size: 13px; color: var(--anno-text-2);
  cursor: pointer;
}
#anno-editor .anno-drop.over { border-color: var(--anno-accent); color: var(--anno-text); }
#anno-editor .anno-shots { display: flex; flex-wrap: wrap; gap: 8px; }
#anno-editor .anno-shot { position: relative; width: 76px; height: 76px; }
#anno-editor .anno-shot img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 7px; border: 1px solid var(--anno-line);
}
#anno-editor .anno-shot button {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 999px; border: 0;
  background: var(--anno-accent); color: #fff; cursor: pointer;
  font: 600 12px/1 system-ui, sans-serif;
}
#anno-editor .anno-acts { display: flex; gap: 9px; justify-content: flex-end; }
#anno-editor .anno-acts button {
  border: 0; border-radius: 8px; cursor: pointer;
  font: 600 14px/1 system-ui, -apple-system, "PingFang SC", sans-serif;
  padding: 11px 18px;
}
#anno-editor .anno-save { background: var(--anno-accent); color: #fff; }
#anno-editor .anno-del { background: transparent; color: var(--anno-accent); margin-right: auto; }
#anno-editor .anno-close { background: var(--anno-panel-2); color: var(--anno-text-2); }

/* ---- 批注列表 ---- */
#anno-list {
  position: fixed; inset: 0 0 0 auto; z-index: calc(var(--anno-z) + 3);
  width: min(560px, 100vw);
  display: none; flex-direction: column;
  background: var(--anno-panel); color: var(--anno-text);
  border-left: 1px solid var(--anno-line);
  box-shadow: -14px 0 44px rgba(0,0,0,.4);
}
#anno-list.show { display: flex; }
#anno-list header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--anno-line);
  padding-top: calc(16px + env(safe-area-inset-top));
}
#anno-list header h3 { margin: 0; font: 620 17px/1.2 system-ui, sans-serif; }
#anno-list header .grow { flex: 1; }
#anno-list header button {
  border: 0; border-radius: 8px; cursor: pointer; padding: 9px 14px;
  font: 600 13px/1 system-ui, -apple-system, "PingFang SC", sans-serif;
}
#anno-list .anno-copy { background: var(--anno-accent); color: #fff; }
#anno-list .anno-copy.done { background: var(--anno-ok); }
#anno-list .anno-x { background: var(--anno-panel-2); color: var(--anno-text-2); }
#anno-list .anno-body { flex: 1; overflow-y: auto; padding: 14px 20px 28px; }
#anno-list .anno-empty { color: var(--anno-text-2); font-size: 14px; line-height: 1.7; padding: 20px 0; }
#anno-list .anno-item {
  padding: 14px 0; border-bottom: 1px solid var(--anno-line);
  display: flex; flex-direction: column; gap: 8px;
}
#anno-list .anno-item:last-child { border-bottom: 0; }
#anno-list .anno-item .anno-h { display: flex; align-items: center; gap: 9px; }
#anno-list .anno-item .anno-n {
  width: 22px; height: 22px; display: grid; place-items: center;
  background: var(--anno-accent); color: #fff; border-radius: 999px;
  font: 600 12px/1 system-ui, sans-serif; flex: none;
}
#anno-list .anno-item .anno-loc {
  font: 500 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--anno-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#anno-list .anno-item p { margin: 0; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
#anno-list .anno-item .anno-thumbs { display: flex; gap: 7px; flex-wrap: wrap; }
#anno-list .anno-item .anno-thumbs img {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: 7px; border: 1px solid var(--anno-line); cursor: zoom-in;
}
#anno-list .anno-item .anno-go {
  align-self: flex-start; background: transparent; color: var(--anno-text-2);
  border: 1px solid var(--anno-line); border-radius: 7px; cursor: pointer;
  padding: 6px 11px; font: 500 12px/1 system-ui, sans-serif;
}
#anno-list .anno-hint {
  margin: 0 0 14px; padding: 11px 13px;
  background: var(--anno-panel-2); border-radius: 8px;
  font-size: 12.5px; line-height: 1.65; color: var(--anno-text-2);
}
#anno-list .anno-hint b { color: var(--anno-text); }

#anno-lightbox {
  position: fixed; inset: 0; z-index: calc(var(--anno-z) + 9);
  display: none; place-items: center; padding: 26px;
  background: rgba(0,0,0,.82); cursor: zoom-out;
}
#anno-lightbox.show { display: grid; }
#anno-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media print { #anno-fab-wrap, #anno-bar, #anno-editor, #anno-list { display: none !important; } }

/* ============================================================
   v2 增量（2026-08-17）· 上方内容为 wb-redesign 版逐字副本，未改动
   新增：批注列表头部的「图片写入目录」常驻入口
   ============================================================ */

/* 头部现在有三个按钮，窄屏（H5 375）下必须能换行，否则挤出面板 */
#anno-list header { flex-wrap: wrap; gap: 8px 10px; }

#anno-list .anno-dir {
  background: var(--anno-panel-2); color: var(--anno-text-2);
  max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; font-size: 12px; padding: 8px 10px;
}
#anno-list .anno-dir:hover { color: var(--anno-text); }

/* SVG 内部被批注的元素：编号角标看不见 —— SVG 元素不生成 CSS 伪元素盒，
   .anno-marked{position:relative} 对它也无效（position 保持 static）。
   实测坑（2026-08-18，system-canvas 稿）：getComputedStyle(el,"::after").content
   照样返回 "1"，看代码以为生效了，截图上什么都没有。
   outline 对 SVG 元素有效，用它兜底，至少能看出哪些已批注过。 */
svg .anno-marked {
  outline: 2px solid var(--anno-accent);
  outline-offset: 1px;
}

/* 列表头部：稿子名 + 清空入口（2026-08-20 串台事故后加）
   当时 system-canvas 显示的是 wb-redesign 的批注，界面上没有任何地方
   能看出「这是谁的批注」，也没有清理入口，只能开 console 删键。 */
#anno-list .anno-proj {
  font: 600 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 7px; border-radius: 999px;
  background: var(--anno-panel-2); color: var(--anno-text-2);
  max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#anno-list .anno-wipe {
  background: transparent; color: var(--anno-text-2);
  border: 1px solid var(--anno-line) !important; font-size: 12px; padding: 7px 10px;
}
#anno-list .anno-wipe:hover { color: var(--anno-accent); border-color: var(--anno-accent) !important; }
