/* SumiRedact 正式版 UI/UX 樣式（對齊 brand/sumi-family-tokens.css；無明朝體、無 prefers-color-scheme、無內聯樣式） */

:root {
  --hdr: 48px;
  --ok: #59a87a;
  --ok-bg: #1e3328;
  --warn: #d6a44c;
  --warn-bg: #332a19;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.36);

  /* Appendix C5: z-index scale */
  --z-page-label: 5;
  --z-banner: 20;
  --z-dock: 21;
  --z-toolbar: 22;
  --z-pii-popover: 30;
  --z-hint: 35;
  --z-coach: 36;
  --z-toast: 40;
  --z-sheet-backdrop: 59;
  --z-sheet: 60;
  --z-header-menu: 65;
  --z-focus-chrome: 70;

  /* Appendix C5: mobile layout & overlay tokens */
  --tb-edge: 6px;
  --tb-pad: 3px;
  --tb-gap: 2px;
  --tb-h: 52px;
  --tb-bottom: calc(6px + env(safe-area-inset-bottom));
  --dock-h: 32px;
  --dock-bottom: calc(var(--tb-bottom) + var(--tb-h) + 8px);
  --toast-bottom: calc(var(--dock-bottom) + var(--dock-h) + 8px);
  --banner-inset: 0px;
  --rs-dot: var(--ink2);
  --coach-left: 12px;
  --coach-arrow-x: 20px;
}

:root[data-theme="light"] {
  --ok: #2e6b4a;
  --ok-bg: #e1efe6;
  --warn: #8a5a00;
  --warn-bg: #f6ecd2;
  --shadow-sm: 0 2px 10px rgba(32, 39, 42, 0.1);
  --shadow-lg: 0 12px 28px rgba(32, 39, 42, 0.16);
  --rs-dot: var(--ink2);
}

:root[data-banner="none"] {
  --banner-inset: 0px;
}

:root[data-banner="expanded"] {
  --banner-inset: 62px;
}

:root[data-banner="chip"] {
  --banner-inset: 34px;
}

@media (max-width: 640px) {
  :root {
    --hdr: 44px;
    --dock-h: 50px;
  }
}

@media (min-width: 360px) and (max-width: 640px) {
  :root {
    --tb-edge: 8px;
    --tb-pad: 4px;
    --tb-gap: 4px;
    --tb-h: 54px;
    --tb-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 14px/1.6 var(--sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

h1,
h2,
h3,
strong {
  font-family: var(--head);
  font-weight: var(--headw);
}

h1,
h2,
h3,
p {
  margin: 0;
}

p {
  text-wrap: pretty;
}

h1,
h2,
h3,
button,
.btn,
.rs-headline-inner,
.rs-pop-headline,
.limit-title {
  text-wrap: balance;
}

.hidden {
  display: none !important;
}

.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sr-only-offscreen {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.muted {
  color: var(--ink3);
}

.small {
  font-size: 12.5px;
}

/* 觸控區 ≥44×44px（以偽元素補足不破壞精簡版面高度） */
.touch-expand {
  position: relative;
}

.touch-expand::after {
  content: "";
  position: absolute;
  inset: -7px;
}

/* ── App 殼層：empty vs editing ── */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app[data-state="empty"] .editing-only {
  display: none !important;
}

.app[data-state="editing"] {
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--hdr) 1fr;
  overflow: hidden;
}

.app[data-state="editing"] .empty-only,
.app[data-state="editing"] .empty-stage {
  display: none !important;
}

/* ── 狀態橫幅（輕薄不搶眼；編輯態浮貼不佔畫布高度） ── */
.preview-banner {
  background: var(--surface2);
  color: var(--ink2);
  border-bottom: 1px solid var(--line);
  padding: 4px 12px;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

/* Editor: compact non-overlapping chip in the header (never over the PDF canvas). */
.app[data-state="editing"] .preview-banner {
  position: static;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  z-index: auto;
  pointer-events: none;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 7.5em;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--ink3);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

/* Fallback if the banner has not yet been moved into the header. */
.app[data-state="editing"] > .preview-banner {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app[data-state="editing"] .sumi-head-inner > .preview-banner {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  clip: auto;
  overflow: hidden;
  white-space: nowrap;
  border: 1px solid var(--line);
}

@media (max-width: 640px) {
  .app[data-state="editing"] .sumi-head-inner > .preview-banner {
    display: none !important;
  }
}

/* ── 頁首：落地頁走家族通欄（高 68/58、內距 72/24/18）；編輯態列高維持 ≤48/44，內距仍用家族規則 ── */
.hdr {
  /* Landing height comes from .sumi-site-head (68/58). Do not set height here
     or it will override the family mobile rule at equal specificity. */
  flex: 0 0 auto;
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: relative;
  z-index: 50;
  min-width: 0;
}

.hdr .sumi-head-inner {
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}

.app[data-state="editing"] .hdr.sumi-site-head {
  height: var(--hdr);
}

.hdr-spacer {
  flex: 1;
}

.filename {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--ink2);
}

.engine-status {
  font-size: 12px;
  color: var(--ink3);
  white-space: nowrap;
}

.hdr-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.hdr-icon-btn:hover {
  background: var(--surface2);
}

/* 深淺主題切換圖示 */
.theme-icon-moon {
  display: none;
}

:root[data-theme="light"] .theme-icon-sun {
  display: none;
}

:root[data-theme="light"] .theme-icon-moon {
  display: inline;
}

/* ── 頁首縮放控制 ── */
.zoom-btn.touch-expand::after {
  /* Visible size is already 44×44; a looser inset would steal clicks from the adjacent ±. */
  inset: 0;
}

.zoom-toolbar {
  display: inline-flex;
  align-items: center;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  overflow: visible;
}

.zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.zoom-btn:hover:not(:disabled) {
  background: var(--surface2);
}

.zoom-btn:disabled {
  opacity: 0.42;
}

.zoom-percent-btn {
  min-width: 62px;
  border-left: 1px solid var(--line2);
  border-right: 1px solid var(--line2);
}

.zoom-fit-btn {
  border-left: 1px solid var(--line);
  border-radius: 0 var(--rm) var(--rm) 0;
  font-size: 12px;
}

.zoom-btn.is-active {
  background: var(--acctint);
  color: var(--acc);
}

.zoom-menu-wrap {
  position: relative;
}

.zoom-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 118px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.zoom-menu-item {
  width: 100%;
  min-height: 36px;
  text-align: left;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--rs);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.zoom-menu-item:hover,
.zoom-menu-item.is-active {
  background: var(--acctint);
  color: var(--acc);
}

.zoom-menu-sep {
  height: 1px;
  background: var(--line);
  margin: 3px 4px;
}

/* ── 頁首單一「頁面檢視 n/N」Pill ── */
.pill-icon {
  display: none;
}

.review-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--frame);
  border-radius: 999px;
  background: var(--acctint);
  color: var(--acc);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.review-pill.is-long {
  font-size: 11px;
}

.review-pill:hover {
  border-color: var(--acc);
}

.review-pill.is-complete {
  background: var(--acc);
  border-color: var(--acc);
  color: var(--onacc);
}

.review-dan-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--dan);
  flex-shrink: 0;
}

/* ── 頁首匯出按鈕與阻擋原因清單 ── */
.export-wrap {
  position: relative;
  flex-shrink: 0;
}

.hdr-export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 63px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--rm);
  background: var(--primary);
  color: var(--onprimary);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.hdr-export-btn:hover:not([aria-disabled="true"]) {
  opacity: 0.92;
}

.hdr-export-btn[aria-disabled="true"] {
  border-color: var(--line);
  background: var(--surface2);
  color: var(--ink3);
  cursor: pointer;
}

.hdr-export-btn:not([aria-disabled="true"]) .export-lock-icon {
  display: none;
}

.export-block-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - var(--hdr) - 24px);
  z-index: var(--z-header-menu);
}

/* ── 行動版頁首精簡（≤640px：Logo + Pill + 匯出 + ⋯；v1.1 §2.2） ── */
@media (max-width: 640px) {
  .app[data-state="editing"] .hdr .sumi-head-inner {
    padding-inline: calc(14px + env(safe-area-inset-left)) calc(14px + env(safe-area-inset-right));
    gap: 8px;
  }

  .hdr .filename,
  .hdr .zoom-toolbar,
  .app[data-state="editing"] .theme-toggle-hdr,
  .app[data-state="editing"] .sumi-head-inner .preview-banner,
  .review-pill-label,
  .review-pill-chevron,
  .review-pill-check {
    display: none !important;
  }

  .app[data-state="editing"] .sumi-head-inner .sumi-logo-slot {
    flex: 0 0 auto;
    margin-right: auto;
  }

  .app[data-state="editing"] .sumi-head-inner .sumi-logo-slot img {
    height: 22px;
    width: auto;
    flex: 0 0 auto;
  }

  #btn-review-pill {
    flex: 0 0 auto;
    min-width: 44px;
    height: 32px;
    padding: 0 8px;
    gap: 4px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }

  #btn-review-pill.is-long {
    font-size: 11px;
  }

  #btn-review-pill .pill-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    line-height: 1;
  }

  #btn-review-pill::after {
    content: "";
    position: absolute;
    inset: -7px 0;
  }

  #btn-download {
    flex: 0 0 auto;
    min-width: 63px;
    height: 36px;
    padding: 0 10px;
    font-size: 12px;
    position: relative;
    white-space: nowrap;
  }

  #btn-download::after {
    content: "";
    position: absolute;
    inset: -5px 0;
  }

  #btn-header-menu {
    flex: 0 0 auto;
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    position: relative;
  }

  #btn-header-menu::after {
    content: "";
    position: absolute;
    inset: -5px;
  }

  .app[data-state="editing"] .sumi-head-inner > * {
    text-overflow: clip;
  }
}

@media (max-width: 339px) {
  .app[data-state="editing"] .hdr .sumi-head-inner {
    gap: 6px;
  }

  .app[data-state="editing"] .sumi-head-inner .sumi-logo-slot img {
    height: 20px;
  }

  #btn-review-pill .pill-icon {
    display: none;
  }
}

/* ── 共用按鈕與卡片 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rl);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.tag.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.tag.fail {
  background: var(--dantint);
  color: var(--dantext);
}

.tag.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.tag.info {
  background: var(--acctint);
  color: var(--acc);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface2);
  border-color: var(--acc);
}

.btn.pri {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--onprimary);
}

.btn.pri:hover:not(:disabled) {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--onprimary);
  opacity: 0.92;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink2);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--surface2);
}

.btn.sm {
  min-height: 36px;
  padding: 0 11px;
  font-size: 12.5px;
}

.btn.xs {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: var(--rs);
}

.btn.full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  background: var(--surface2);
  border-color: var(--line);
  color: var(--ink3);
}

/* ── 未匯入首頁：家族預設主欄 1584 / 72·32·18（.sumi-container）；落地內容單欄仍 ≤640px 置中 ── */
.empty-stage {
  flex: 1;
  width: 100%;
  padding-block: 32px 40px;
}

.landing-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
}

.dropzone {
  padding: 40px 24px;
  text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: var(--rl);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-dragover {
  border-style: solid;
  border-color: var(--acc);
  background: var(--acctint);
}

.landing-title {
  font-size: 24px;
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: 8px;
}

.dropzone-hint {
  font-size: 14px;
  color: var(--ink2);
  margin-bottom: 20px;
}

.dropzone-cta {
  display: flex;
  justify-content: center;
}

.landing-secondary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.privacy-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--acc);
  font-weight: 700;
  font-size: 14px;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--rm);
  font-size: 13.5px;
}

.alert-fail {
  background: var(--dantint);
  border: 1px solid var(--dan);
  color: var(--dantext);
}

.limit-card {
  padding: 14px 16px;
}

.limit-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink3);
  margin-bottom: 4px;
}

.limit-text {
  font-size: 13px;
  color: var(--ink2);
}

.landing-disclaimer {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink3);
  padding: 10px 12px;
  border-left: 3px solid var(--frame);
  background: var(--surface);
  border-radius: 0 var(--rm) var(--rm) 0;
}

/* ── 容量提示／超過上限 ── */
.panel-notice {
  width: 100%;
}

.notice-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notice-warn {
  border-left: 4px solid var(--warn);
}

.notice-fail {
  border-left: 4px solid var(--dan);
}

.file-meta {
  font-size: 13px;
  color: var(--ink3);
}

.notice-body {
  color: var(--ink2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.split-suggest {
  font-weight: 700;
  color: var(--ink);
  background: var(--surface2);
  padding: 10px 12px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
}

.split-steps {
  margin: 0;
  padding-left: 20px;
}

.privacy-warn {
  background: var(--dantint);
  color: var(--dantext);
  padding: 10px 12px;
  border-radius: var(--rm);
  font-weight: 700;
}

.cap-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cap-seg {
  padding: 8px 10px;
  border-radius: var(--rm);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  border: 1.5px solid transparent;
}

.cap-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.cap-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.cap-fail {
  background: var(--dantint);
  color: var(--dantext);
}

.cap-active {
  border-color: var(--ink);
}

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

.footnote {
  font-size: 12.5px;
  color: var(--ink3);
}

@media (max-width: 640px) {
  .cap-bar {
    grid-template-columns: 1fr;
  }
}

/* ── 滿版編輯工作區與畫布（1440×900 >=82%、390×844 滿寬高=100dvh-44） ── */
.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viewer-col {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.canvas.viewer-scroll {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background: var(--mount);
  overscroll-behavior: contain;
  padding: 20px 24px 96px;
}

@media (max-width: 640px) {
  .canvas.viewer-scroll {
    padding: max(24px, var(--banner-inset)) 0 calc(var(--dock-bottom) + var(--dock-h) + 18px);
  }
}

.viewer-scroll.is-pan-ready .page-overlay-canvas {
  cursor: grab;
}

.viewer-scroll.is-panning .page-overlay-canvas {
  cursor: grabbing;
}

.pages-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  min-width: min-content;
}

.pages-container.is-pinching {
  will-change: transform;
}

.page-card {
  background: transparent;
  padding: 0;
}

.page-header {
  position: relative;
  z-index: var(--z-page-label);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding: 0 4px;
  padding-left: 80px;
  font-size: 11.5px;
  color: var(--ink3);
}

@media (max-width: 640px) {
  .page-header {
    padding-left: 12px;
  }
}

.page-canvas-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.24);
  background: #ffffff;
}

.page-pdf-canvas {
  display: block;
}

.page-render-error {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background: var(--surface, #1e2128);
  color: var(--ink, #e8eaed);
  text-align: center;
  line-height: 1.5;
}

.page-render-error-msg {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.page-render-retry {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 18px;
}

.page-overlay-canvas {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
}

.page-overlay-canvas.is-pan-tool {
  cursor: grab;
  /* Keep none so the browser cannot steal a one-finger pan and cancel the
     pointers used by the app pinch / two-finger pan state machine. */
  touch-action: none;
}

/* 建議框點擊彈出迷你操作條 */
.pii-popover {
  position: absolute;
  z-index: var(--z-pii-popover);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--surface);
  border: 1.5px solid var(--acc);
  border-radius: var(--rm);
  box-shadow: var(--shadow-lg);
  line-height: 1.2;
  white-space: nowrap;
}

.pii-popover button,
.pii-popover .btn.xs {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
}

.pan-hint-anchor {
  position: absolute;
  left: 68px;
  bottom: 42px;
  z-index: var(--z-hint);
  pointer-events: none;
}

.pan-hint {
  pointer-events: none;
  user-select: none;
  background: rgba(25, 31, 34, 0.9);
  color: #f2eee6;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  opacity: 1;
  transition: opacity 0.32s ease;
}

.pan-hint.is-fading {
  opacity: 0;
  pointer-events: none;
}

.canvas-toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--rm);
  box-shadow: var(--shadow-sm);
  padding: 6px 12px;
  font-size: 12.5px;
  max-width: min(520px, calc(100% - 32px));
}

@media (max-width: 640px) {
  .pan-hint-anchor {
    left: 50%;
    bottom: var(--toast-bottom);
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
  }

  .pan-hint {
    text-align: center;
    line-height: 1.35;
    max-width: calc(100vw - 24px);
  }

  .canvas-toast {
    top: auto;
    bottom: var(--toast-bottom);
    max-width: calc(100vw - 24px);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .canvas-toast.has-action {
    display: inline-flex;
    overflow: visible;
  }
}

.canvas-toast.has-action {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.canvas-toast-msg {
  min-width: 0;
}

.canvas-toast-action {
  position: relative;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--acc);
  border-radius: var(--rs);
  background: var(--acctint);
  color: var(--acc);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.canvas-toast-action::after {
  content: "";
  position: absolute;
  inset: -8px -4px;
}

.canvas-toast-action:hover {
  background: var(--acc);
  color: var(--onacc);
}

/* ── 重疊個資建議群組代理按鈕與 Bottom Sheet / Popover（v1.1 §5.5–5.7） ── */
.pii-badge-proxy-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.pii-badge-proxy {
  position: absolute;
  left: 0;
  top: 0;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  color: transparent;
  pointer-events: none;
  border-radius: var(--rs);
}

.pii-badge-proxy:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

.pii-group-sheet[hidden] {
  display: none !important;
}

.pii-group-sheet {
  position: fixed;
  z-index: var(--z-sheet);
  width: 320px;
  max-width: calc(100vw - 16px);
  max-height: min(60dvh, 420px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--rl);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
}

.pii-group-sheet .sheet-handle {
  display: none;
}

.pii-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pii-group-sheet .sheet-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  color: var(--ink);
}

.pii-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.pii-group-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  min-height: 44px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface2);
  cursor: pointer;
}

.pii-group-row:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
}

.pii-group-row.is-selected {
  border-color: var(--acc);
  background: var(--acctint);
}

.pii-group-row .pii-kind {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--rs);
  background: var(--acctint);
  color: var(--acc);
  white-space: nowrap;
}

.pii-group-row .pii-masked {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--ink);
}

.pii-group-row .btn-sm {
  position: relative;
  flex: 0 0 auto;
  min-height: 32px;
  min-width: 44px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pii-group-row .btn-sm::after {
  content: "";
  position: absolute;
  inset: -6px 0;
}

.pii-group-sheet .sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.pii-group-sheet .btn-block {
  width: 100%;
  min-height: 44px;
  justify-content: center;
}

@media (max-width: 640px) {
  .pii-popover {
    min-width: 180px;
    justify-content: space-between;
    box-sizing: border-box;
  }

  .pii-group-sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: 60dvh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 6px 14px calc(16px + env(safe-area-inset-bottom));
  }

  .pii-group-sheet .sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    margin: 0 auto 2px;
    width: 88px;
    touch-action: none;
    cursor: grab;
    position: relative;
  }

  .pii-group-sheet .sheet-handle::before {
    content: "";
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
  }

  .pii-group-sheet .sheet-handle::after {
    content: "";
    position: absolute;
    inset: -10px -20px;
  }

  .workspace.has-sheet .canvas.viewer-scroll {
    padding-bottom: max(62dvh, calc(var(--dock-bottom) + var(--dock-h) + 18px));
  }
}

/* ── 浮動工具列（三斷點；≤640px 固定 7 欄 grid，v1.1 §2.1） ── */
.floating-toolbar {
  position: absolute;
  z-index: var(--z-toolbar);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rl);
  box-shadow: var(--shadow-sm);
}

#tool-focus {
  display: none;
}

.toolbar-items {
  display: flex;
  gap: 4px;
}

.floating-toolbar.is-collapsed .toolbar-items {
  display: none;
}

.tool-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: var(--rm);
  background: transparent;
  color: var(--ink2);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.1;
}

.tool-btn:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--ink);
}

.tool-btn.is-active,
.tool-btn[aria-expanded="true"] {
  background: var(--acctint);
  border-color: var(--frame);
  color: var(--acc);
}

.tool-btn-apply.is-ready {
  background: var(--primary);
  color: var(--onprimary);
}

.tool-btn:disabled {
  opacity: 0.4;
}

.tool-icon {
  font-size: 15px;
  line-height: 1;
}

.tool-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--acc);
  color: var(--onacc);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

/* Desktop >=1024px：左側縱向浮動 */
@media (min-width: 1024px) {
  .floating-toolbar {
    left: 12px;
    top: 12px;
    flex-direction: column;
    width: 54px;
  }

  .toolbar-items {
    flex-direction: column;
  }
}

/* Tablet 641–1023px：底部置中橫向浮動膠囊 */
@media (min-width: 641px) and (max-width: 1023px) {
  .floating-toolbar {
    left: 50%;
    bottom: 64px;
    transform: translateX(-50%);
    flex-direction: row;
  }

  .toolbar-items {
    flex-direction: row;
  }
}

/* Mobile <=640px：底部 7 欄等寬 grid（v1.1 §2.1） */
@media (max-width: 640px) {
  .floating-toolbar,
  .floating-toolbar.is-collapsed {
    position: absolute;
    left: calc(var(--tb-edge) + env(safe-area-inset-left));
    right: auto;
    width: calc(100vw - 2 * var(--tb-edge) - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-width: 100%;
    bottom: var(--tb-bottom);
    height: var(--tb-h);
    box-sizing: border-box;
    display: block;
    padding: var(--tb-pad);
    border: 1px solid var(--line);
    border-radius: var(--rl);
    overflow: visible;
    z-index: var(--z-toolbar);
  }

  #btn-toolbar-toggle {
    display: none;
  }

  #toolbar-items,
  .floating-toolbar.is-collapsed #toolbar-items {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--tb-gap);
    min-width: 0;
    height: 100%;
  }

  .floating-toolbar .tool-btn,
  #tool-focus {
    min-width: 0;
    width: auto;
    min-height: 44px;
    height: 44px;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }

  .floating-toolbar .tool-icon {
    font-size: 18px;
    line-height: 18px;
  }

  .floating-toolbar .tool-label {
    font-size: 10px;
    line-height: 12px;
    white-space: nowrap;
  }

  .floating-toolbar .tool-btn .tool-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
    border-radius: 8px;
    box-sizing: border-box;
  }

  .floating-toolbar .tool-btn-apply.is-ready {
    background: var(--acc);
    color: var(--surface);
  }
}

@media (min-width: 481px) and (max-width: 640px) {
  .floating-toolbar,
  .floating-toolbar.is-collapsed {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ── 底部浮動翻頁導覽 ── */
.page-dock {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-dock);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.dock-btn {
  min-width: 32px;
  height: 30px;
  border: 0;
  border-radius: var(--rs);
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.dock-btn:hover:not(:disabled) {
  background: var(--surface2);
}

.dock-btn:disabled {
  opacity: 0.35;
}

.page-readout {
  padding: 0 8px;
  font-weight: 700;
  color: var(--ink);
}

.dock-mark-btn {
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--frame);
  border-radius: var(--rs);
  background: var(--acctint);
  color: var(--acc);
  font-size: 12px;
  font-weight: 700;
}

.dock-mark-btn.is-done {
  background: var(--acc);
  border-color: var(--acc);
  color: var(--onacc);
}

@media (max-width: 1023px), (pointer: coarse) {
  .dock-btn {
    min-width: 44px;
    min-height: 44px;
    height: 44px;
  }

  .dock-mark-btn {
    min-height: 44px;
  }
}

@media (min-width: 641px) and (max-width: 1023px) {
  .page-dock {
    bottom: 10px;
  }
}

@media (max-width: 640px) {
  .page-dock {
    bottom: var(--dock-bottom);
    height: var(--dock-h);
    transition: opacity 150ms ease;
  }

  .workspace.has-coachmark .page-dock {
    opacity: 0;
    pointer-events: none;
  }

  .workspace.has-sheet .page-dock {
    display: none;
  }
}

/* ── 共用 Popover / Mobile Bottom Sheet 容器 ── */
.scrim {
  display: none;
}

.floating-popover {
  position: absolute;
  z-index: 25;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rl);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}

.tool-popover {
  top: 12px;
  left: 74px;
  width: 340px;
  max-width: calc(100vw - 92px);
  max-height: calc(100% - 24px);
}

.review-popover {
  top: 10px;
  right: 12px;
  width: 376px;
  max-width: calc(100vw - 24px);
  max-height: calc(100% - 24px);
}

.header-menu-popover {
  top: 10px;
  right: 12px;
  width: 288px;
  max-width: calc(100vw - 24px);
  max-height: calc(100% - 24px);
}

/* 個資建議面板：桌機疊在畫布右側（寬 <=280px，不擠壓畫布） */
.pii-panel {
  top: 12px;
  right: 12px;
  width: 280px;
  max-height: calc(100% - 24px);
  z-index: 22;
}

@media (min-width: 641px) and (max-width: 1023px) {
  .tool-popover {
    left: 50%;
    top: auto;
    bottom: 120px;
    transform: translateX(-50%);
    max-height: calc(100% - 136px);
  }

  .workspace.has-edit-dock .tool-popover {
    bottom: calc(126px + var(--edit-dock-h, 64px) + 12px);
    max-height: max(160px, calc(100% - 126px - var(--edit-dock-h, 64px) - 24px));
  }
}

@media (max-width: 640px) {
  .scrim:not(.hidden) {
    display: block;
    position: fixed;
    z-index: var(--z-sheet-backdrop);
    inset: var(--hdr) 0 0;
    background: rgba(15, 20, 22, 0.56);
  }

  .tool-popover,
  .review-popover,
  .header-menu-popover,
  .pii-panel {
    position: fixed;
    z-index: var(--z-sheet);
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: 80dvh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
    transform: none;
  }

  /* Keep export-block as a centered viewport popover (not a bottom sheet); do not align to 匯出. */
  .floating-popover.export-block-popover {
    position: fixed;
    top: calc(var(--hdr) + 8px);
    left: 8px;
    right: 8px;
    bottom: auto;
    width: min(360px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - var(--hdr) - 24px);
    margin-inline: auto;
    box-sizing: border-box;
    padding: 16px;
    border-radius: var(--rl);
    border: 1px solid var(--line);
    transform: none;
    z-index: var(--z-header-menu);
  }

  .export-block-popover .rs-pop-headline,
  .export-block-popover .rs-pop-body,
  .export-block-popover .rs-reasons,
  .export-block-popover .rs-reason {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .header-menu-popover {
    z-index: var(--z-header-menu);
  }

  .tool-popover::before,
  .review-popover::before,
  .header-menu-popover::before,
  .pii-panel::before {
    content: "";
    display: block;
    margin: 0 auto 4px;
    width: 34px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    flex-shrink: 0;
  }
}

.popover-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.popover-head h2 {
  font-size: 16px;
  line-height: 1.3;
  color: var(--ink);
}

.close-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.close-btn:hover {
  background: var(--surface2);
}

/* ── 頁面檢視閘門內容 ── */
.review-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--ink2);
}

.review-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-sym {
  font-style: normal;
  font-weight: 700;
}

.legend-done {
  color: var(--acc);
}

.legend-exc {
  color: var(--dantext);
}

.review-chips {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.review-chip {
  position: relative;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.review-chip::after {
  content: "";
  position: absolute;
  inset: -5px;
}

.review-chip[data-chip-state="done"] {
  background: var(--acc);
  border-color: var(--acc);
  color: var(--onacc);
}

.review-chip[data-chip-state="exception"] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.review-chip[aria-current="page"] {
  box-shadow: inset 0 0 0 1.5px var(--acc);
  border-color: var(--acc);
}

.chip-sym {
  font-size: 11px;
}

.chip-dan-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--dan);
}

@media (max-width: 640px) {
  .review-chip {
    min-height: 38px;
  }
}

.review-current-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface2);
}

.review-bulk-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.review-range-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-range-form input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--page);
  color: var(--ink);
  font-size: 13px;
}

.review-range-form input[aria-invalid="true"] {
  border-color: var(--dan);
}

.review-action-row {
  display: flex;
  gap: 6px;
}

.review-mark-all-btn {
  flex: 1;
  color: var(--acc);
  border-color: var(--frame);
}

.review-feedback {
  font-size: 12px;
  color: var(--acc);
}

.review-feedback.is-error {
  color: var(--dantext);
}

.review-feedback:empty {
  display: none;
}

.review-section-title {
  font-size: 12.5px;
  color: var(--ink2);
  margin-bottom: 6px;
}

.review-exceptions-wrap,
.review-blocking-wrap {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.review-exceptions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-exc-card {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

.review-exc-card.is-flash {
  box-shadow: 0 0 0 2px var(--acc);
  background: var(--acctint);
}

.review-exc-desc {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
}

.review-exc-dot {
  width: 6px;
  height: 6px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--dan);
  flex-shrink: 0;
}

.review-exc-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.review-exc-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  min-height: 30px;
}

.review-exc-check.is-locked {
  color: var(--ink3);
  cursor: not-allowed;
}

.review-exc-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--acc);
  flex-shrink: 0;
}

.block-reason-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.block-reason-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--rs);
  background: var(--surface2);
  font-size: 12px;
  color: var(--ink2);
}

.block-reason-text {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.block-reason-icon {
  color: var(--dantext);
  font-weight: 700;
  flex-shrink: 0;
}

.review-gate-status {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink2);
}

/* ── 搜尋與手動框面板 ── */
.search-row {
  display: flex;
  gap: 6px;
}

.search-row input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--page);
  color: var(--ink);
  font-size: 13px;
}

.chips-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

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

.chip-btn {
  min-height: 30px;
  border: 1px solid var(--frame);
  background: var(--acctint);
  color: var(--acc);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}

.chip-btn:hover {
  background: var(--acc);
  color: var(--onacc);
}

.feedback {
  min-height: 18px;
  line-height: 1.45;
}

.terms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.term-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--rm);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.term-jump {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  text-align: left;
}

.term-jump:hover:not(:disabled) {
  color: var(--acc);
}

.term-remove {
  border: 0;
  background: transparent;
  color: var(--dantext);
  font-weight: 700;
  padding: 0 3px;
}

@media (max-width: 1023px), (pointer: coarse) {
  .term-pill {
    padding: 0 4px 0 10px;
  }
  .term-jump,
  .term-remove {
    min-height: 44px;
    min-width: 44px;
  }
}

.manual-section {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manual-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.manual-actions {
  display: flex;
  gap: 6px;
}

.manual-box-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.manual-box-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--rm);
  background: var(--surface2);
  border: 1px solid var(--line);
  font-size: 12px;
}

.manual-box-label {
  color: var(--ink2);
  font-weight: 700;
}

.manual-box-remove {
  border: 1px solid var(--line);
  background: var(--dantint);
  color: var(--dantext);
  border-radius: var(--rs);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

/* ── 四種遮罩樣式 ── */
.fill-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fill-label {
  font-weight: 700;
  margin-bottom: 4px;
}

.fill-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.fill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 8px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink2);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.fill-btn:hover:not(:disabled) {
  border-color: var(--acc);
}

.fill-btn.is-active {
  border-color: var(--acc);
  background: var(--acctint);
  color: var(--acc);
}

.fill-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(128, 138, 142, 0.5);
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
}

.swatch-black {
  background: #000000;
}

.swatch-white {
  background: #ffffff;
}

.swatch-mosaic {
  border: 0;
  background:
    linear-gradient(90deg, #20272a 0 33%, #aeb6b8 33% 66%, #5c676b 66% 100%),
    linear-gradient(180deg, #5c676b 0 50%, #20272a 50% 100%);
  background-size: 6px 6px;
}

.swatch-custom {
  background: conic-gradient(#b64d3b, #d97706, #2e6b4a, #3e6473, #1f2937, #b64d3b);
}

.sub-option-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.sub-chip {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--rs);
  background: var(--surface2);
  color: var(--ink2);
  font-size: 11.5px;
  font-weight: 700;
}

.sub-chip.is-active {
  border-color: var(--acc);
  background: var(--acctint);
  color: var(--acc);
}

.style-note,
.fill-mosaic-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink2);
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--rm);
  padding: 7px 9px;
}

.style-note-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

/* 8 色預設色票（無 inline style） */
.custom-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-swatches,
.recent-colors-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.swatch-preset {
  width: 28px;
  height: 28px;
  border-radius: var(--rs);
  border: 1px solid var(--line);
  padding: 0;
}

.swatch-preset[aria-pressed="true"] {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

.sw-000000 { background: #000000; }
.sw-191f22 { background: #191f22; }
.sw-20272a { background: #20272a; }
.sw-3e6473 { background: #3e6473; }
.sw-6e8e99 { background: #6e8e99; }
.sw-b64d3b { background: #b64d3b; }
.sw-5c676b { background: #5c676b; }
.sw-ffffff { background: #ffffff; border-color: var(--ink3); }

.recent-colors-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fill-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fill-picker {
  width: 38px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--page);
  cursor: pointer;
  flex-shrink: 0;
}

.fill-hex-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
  background: var(--page);
}

.fill-hex-input.is-invalid {
  border-color: var(--dan);
  background: var(--dantint);
  color: var(--dantext);
}

.fill-error {
  font-size: 12px;
  font-weight: 700;
  color: var(--dantext);
}

/* ── 三檔輸出壓縮與驗證報告 ── */
.compression-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comp-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comp-opt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  background: var(--surface2);
  cursor: pointer;
}

.comp-opt:hover {
  border-color: var(--acc);
}

.comp-opt.is-active {
  border-color: var(--acc);
  background: var(--acctint);
}

.comp-opt input[type="radio"] {
  margin: 3px 0 0;
  accent-color: var(--acc);
  flex-shrink: 0;
}

.comp-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.comp-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.comp-rec {
  font-size: 11px;
  color: var(--acc);
}

.comp-desc {
  font-size: 11.5px;
  color: var(--ink3);
}

.comp-estimate {
  font-size: 12px;
  color: var(--ink2);
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.pii-pending-notice {
  font-size: 12px;
  line-height: 1.45;
  color: var(--warn);
  background: var(--warn-bg);
  border-radius: var(--rm);
  padding: 6px 8px;
}

.progress-box {
  padding: 9px 11px;
  border-radius: var(--rm);
  background: var(--acctint);
  color: var(--acc);
  font-size: 12.5px;
  font-weight: 700;
}

.apply-result {
  padding: 9px 11px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.apply-result.is-error {
  border-color: var(--line);
  background: var(--surface2);
  color: var(--ink);
}

.apply-error-reason {
  line-height: 1.5;
}

.compression-downgrade-notice {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--ink2);
}

.tech-details {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink2);
}

.tech-details > summary {
  cursor: pointer;
  font-weight: 700;
}

.tech-details > pre {
  margin: 6px 0 0;
  padding: 8px;
  border-radius: var(--rs);
  background: var(--page);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  max-height: 160px;
  overflow: auto;
}

.fill-only-note {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: var(--rs);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
}

.verify-section {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.verify-section h3 {
  font-size: 13.5px;
}

.verify-summary {
  padding: 8px 10px;
  border-radius: var(--rm);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 8px;
}

.verify-summary.pass {
  background: var(--ok-bg);
  color: var(--ok);
}

.verify-summary.fail {
  background: var(--dantint);
  color: var(--dantext);
}

.verify-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.verify-item {
  border: 1px solid var(--line);
  border-radius: var(--rm);
  padding: 7px 9px;
  background: var(--surface2);
}

.verify-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}

.verify-item-desc {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--ink3);
}

.verify-note {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink3);
}

/* ── 個資建議面板（W13 規格對齊） ── */
.pii-disclaimer {
  border-left: 3px solid var(--acc);
  background: var(--surface2);
  padding: 8px 10px;
  border-radius: 0 var(--rm) var(--rm) 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink2);
}

.pii-scan-status {
  padding: 6px 8px;
  background: var(--acctint);
  color: var(--acc);
  border-radius: var(--rm);
  font-weight: 700;
}

.pii-empty-scan {
  padding: 10px;
  border-radius: var(--rm);
  background: var(--surface2);
  border: 1px solid var(--line);
}

.pii-empty-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.pii-empty-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink2);
}

.pii-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pii-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pii-chip {
  min-height: 28px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink2);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 700;
}

.pii-chip:hover {
  border-color: var(--acc);
}

.pii-chip.is-active {
  border-color: var(--acc);
  background: var(--acc);
  color: var(--onacc);
}

.pii-batch-row {
  display: flex;
  gap: 6px;
}

.pii-batch-btn {
  flex: 1;
}

.pii-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pii-empty-list {
  font-size: 12px;
  color: var(--ink3);
  padding: 10px;
  background: var(--surface2);
  border-radius: var(--rm);
  text-align: center;
}

.pii-page-group {
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface2);
  overflow: hidden;
}

.pii-page-group > summary {
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink2);
  cursor: pointer;
}

.pii-group-items {
  list-style: none;
  margin: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pii-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rm);
  padding: 7px 8px;
  cursor: pointer;
}

.pii-item-select {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: left;
  color: inherit;
  border-radius: var(--rs);
}

.pii-item:hover,
.pii-item.is-selected {
  border-color: var(--acc);
}

.pii-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.pii-cat-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--acc);
  background: var(--acctint);
  padding: 1px 6px;
  border-radius: var(--rs);
}

.pii-page-tag {
  font-size: 11px;
  color: var(--ink3);
}

.pii-preview-text {
  font: 700 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
  word-break: break-all;
  margin-bottom: 6px;
}

.pii-item-actions {
  display: flex;
  gap: 6px;
}

.pii-restore-wrap {
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  text-align: center;
}

.pii-restore-btn {
  border: 0;
  background: transparent;
  color: var(--acc);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
}

/* ── 頁首選單內容 ── */
.menu-disclaimer-note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink2);
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--rm);
  padding: 7px 10px;
}

.menu-focus-btn {
  display: none;
}

@media (max-width: 640px) {
  .menu-focus-btn {
    display: inline-flex;
  }
}

.menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.menu-section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.menu-filename {
  font-weight: 700;
  font-size: 13px;
  word-break: break-all;
}

.menu-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.mobile-zoom-section {
  display: none;
}

@media (max-width: 640px) {
  .mobile-zoom-section {
    display: flex;
  }
}

.mobile-zoom-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.menu-diag-section {
  gap: 4px;
}

.diag-log-btn {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--ink3);
  font-size: 12px;
  padding: 4px 0;
  min-height: 36px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.diag-log-btn:hover {
  color: var(--ink);
}

.diag-log-feedback {
  font-size: 11.5px;
  color: var(--ink3);
}

/* ── 放行狀態橫幅（v1.1 §1.5）與單一事實來源區塊（§1.6 / §1.7） ── */
.safety-strip.release-banner {
  position: absolute;
  z-index: var(--z-banner);
  top: 12px;
  left: 74px;
  width: min(360px, calc(100% - 472px));
  max-height: 210px;
  overflow-y: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rl);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  line-height: 17px;
  color: var(--ink);
}

.release-banner[hidden] {
  display: none !important;
}

.release-banner.is-resurfaced {
  border-color: var(--acc);
  box-shadow: 0 0 0 2px var(--acctint), var(--shadow-lg);
}

.release-banner[data-tone="alert"] {
  background: var(--surface2);
  --rs-dot: var(--dan);
}

.release-banner[data-tone="pending"] {
  background: var(--acctint);
  --rs-dot: var(--acc);
}

.release-banner[data-tone="ok"] {
  background: var(--ok-bg);
  --rs-dot: var(--ok);
}

.release-banner[data-tone="neutral"] {
  background: var(--surface);
  --rs-dot: var(--ink3);
}

.release-banner .rs-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.release-banner .rs-icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  display: inline-block;
  background-color: var(--ink3);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 16px 16px;
  mask-size: 16px 16px;
}

.release-banner[data-tone="alert"] .rs-icon {
  background-color: var(--dan);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm0 3a.9.9 0 0 1 .9.9v3.7a.9.9 0 0 1-1.8 0V4.9A.9.9 0 0 1 8 4zm0 7.9a1.05 1.05 0 1 1 0-2.1 1.05 1.05 0 0 1 0 2.1z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm0 3a.9.9 0 0 1 .9.9v3.7a.9.9 0 0 1-1.8 0V4.9A.9.9 0 0 1 8 4zm0 7.9a1.05 1.05 0 1 1 0-2.1 1.05 1.05 0 0 1 0 2.1z'/%3E%3C/svg%3E");
}

.release-banner[data-tone="pending"] .rs-icon {
  background-color: var(--acc);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm0 3.1a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm1 7.4H7V7.3h2v4.2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm0 3.1a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm1 7.4H7V7.3h2v4.2z'/%3E%3C/svg%3E");
}

.release-banner[data-tone="ok"] .rs-icon {
  background-color: var(--ok);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm3.4 5.3-4.1 4.2a.8.8 0 0 1-1.15 0L4.6 8.95a.8.8 0 1 1 1.13-1.13l1 1 3.54-3.64a.8.8 0 1 1 1.13 1.12z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm3.4 5.3-4.1 4.2a.8.8 0 0 1-1.15 0L4.6 8.95a.8.8 0 1 1 1.13-1.13l1 1 3.54-3.64a.8.8 0 1 1 1.13 1.12z'/%3E%3C/svg%3E");
}

@keyframes rs-spin {
  to {
    transform: rotate(360deg);
  }
}

.release-banner[data-tone="neutral"] .rs-icon {
  background-color: transparent;
  border: 2px solid var(--line);
  border-top-color: var(--ink3);
  border-radius: 50%;
  box-sizing: border-box;
  animation: rs-spin 0.9s linear infinite;
}

.release-banner .rs-text {
  flex: 1 1 auto;
  min-width: 0;
  text-align: start;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
}

.release-banner .rs-headline {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
}

.release-banner .rs-headline-inner {
  display: block;
  text-wrap: balance;
}

.release-banner .rs-chip {
  display: none;
}

.release-banner .rs-compact {
  display: none;
}

.release-banner .rs-cta {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--rs);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  position: relative;
  background: var(--acc);
  color: var(--surface);
  border: 0;
}

.release-banner .rs-cta::after {
  content: "";
  position: absolute;
  inset: -6px 0;
}

.release-banner .rs-cta[hidden],
.release-banner .rs-toggle[hidden] {
  display: none;
}

.release-banner .rs-toggle {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--rs);
  background: transparent;
  color: var(--ink2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.release-banner .rs-toggle::before {
  content: "";
  width: 12px;
  height: 12px;
  display: block;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 7.5 6 4l3.5 3.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 7.5 6 4l3.5 3.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  -webkit-mask-size: 12px 12px;
  mask-size: 12px 12px;
}

.release-banner[data-collapsed="true"] .rs-toggle::before {
  transform: rotate(180deg);
}

.release-banner .rs-toggle::after {
  content: "";
  position: absolute;
  inset: -10px;
}

/* 收合成 chip（桌面與手機共用） */
.release-banner[data-collapsed="true"] {
  width: auto;
  right: auto;
  min-height: 28px;
  height: 28px;
  max-height: 28px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  overflow: hidden;
  justify-content: center;
}

.release-banner[data-collapsed="true"] .rs-headline,
.release-banner[data-collapsed="true"] .rs-cta,
.release-banner[data-collapsed="true"] .rs-icon,
.release-banner[data-collapsed="true"] .rs-desktop-body {
  display: none;
}

.release-banner[data-collapsed="true"] .rs-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.release-banner .rs-row:lang(en) .rs-cta {
  max-width: 45%;
  height: auto;
  min-height: 32px;
  white-space: normal;
}

.release-banner[data-collapsed="true"] .rs-row:lang(en) .rs-chip {
  white-space: normal;
  line-height: 1.1;
}

.release-banner[data-collapsed="true"] .rs-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rs-dot);
  flex-shrink: 0;
}

.safety-strip-body,
.review-disclosures-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.disclosure-item {
  margin: 0;
  padding: 6px 8px;
  border-radius: var(--rs);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink2);
  font-size: 12px;
  line-height: 1.45;
}

.disclosure-item.is-pass {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: transparent;
  font-weight: 700;
}

.disclosure-item.is-fail {
  background: var(--surface2);
  color: var(--ink);
  border-color: var(--line);
  font-weight: 700;
}

.disclosure-item.is-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: transparent;
}

.review-disclosures-wrap {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── 套用面板與匯出 popover 的 .rs-block / .rs-notes / .rs-details（§1.6 / §1.7） ── */
.rs-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
}

.rs-block[data-tone="alert"] {
  background: var(--surface2);
  border-color: var(--line);
  --rs-dot: var(--dan);
}

.rs-block[data-tone="pending"] {
  background: var(--acctint);
  border-color: var(--frame);
  --rs-dot: var(--acc);
}

.rs-block[data-tone="ok"] {
  background: var(--ok-bg);
  border-color: transparent;
  color: var(--ok);
  --rs-dot: var(--ok);
}

.rs-block[data-tone="neutral"] {
  background: var(--surface2);
  --rs-dot: var(--ink3);
}

.export-block-popover .rs-block {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.rs-pop-headline {
  font-family: var(--head);
  font-weight: var(--headw);
  font-size: 13.5px;
  line-height: 1.45;
  color: inherit;
}

.rs-pop-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink2);
}

.rs-block[data-tone="ok"] .rs-pop-body {
  color: var(--ok);
}

.rs-reasons {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rs-reason {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: start;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--rs);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
}

.rs-reason:hover {
  border-color: var(--acc);
  background: var(--acctint);
}

.rs-reason-chev {
  color: var(--ink3);
  font-size: 15px;
  flex-shrink: 0;
}

.rs-reason-static {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--rs);
  background: var(--surface);
  color: var(--ink2);
  font-size: 12px;
  line-height: 1.45;
}

.rs-cta-block {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--rm);
  background: var(--acc);
  color: var(--surface);
  font-size: 13px;
  font-weight: 700;
}

.rs-cta-secondary {
  width: 100%;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface);
  color: var(--ink2);
  font-size: 12.5px;
  font-weight: 700;
}

.rs-cta-secondary:hover {
  background: var(--surface2);
  color: var(--ink);
}

.rs-cta-block[hidden],
.rs-cta-secondary[hidden],
.rs-pop-body[hidden],
.rs-reasons[hidden] {
  display: none;
}

.rs-notes {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rs-note-item {
  padding: 7px 9px;
  border-radius: var(--rs);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink2);
  font-size: 12px;
  line-height: 1.45;
}

.rs-note-item.is-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: transparent;
}

.rs-note-item.is-fail {
  background: var(--surface2);
  color: var(--ink);
  font-weight: 700;
}

.rs-details {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface2);
  padding: 7px 9px;
  font-size: 12px;
  color: var(--ink2);
}

.rs-details > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.rs-check-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
}

.rs-check-table th,
.rs-check-table td {
  text-align: start;
  padding: 4px 5px;
  border-bottom: 1px solid var(--line);
}

.rs-check-table th {
  color: var(--ink3);
  font-weight: 700;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--ink2);
}

.mono.is-warn {
  color: var(--warn);
}

.mono.is-fail {
  color: var(--dantext);
}

.rs-details-h {
  margin: 8px 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.rs-codes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  word-break: break-all;
}

.rs-details-note {
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink3);
}

.rs-details-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.rs-copied {
  font-size: 12px;
  font-weight: 700;
  color: var(--acc);
}

.rs-debug-manual {
  width: 100%;
  min-height: 110px;
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--rs);
  background: var(--page);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  resize: vertical;
}

.rs-disclaimer {
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink3);
}

@media (min-width: 641px) and (max-width: 1023px) {
  .safety-strip.release-banner {
    left: 12px;
    width: min(360px, calc(100% - 24px));
    max-height: 200px;
  }
}

@media (max-width: 640px) {
  .safety-strip.release-banner {
    position: absolute;
    top: 6px;
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    width: auto;
    min-height: 44px;
    max-height: 56px;
    overflow: hidden;
    padding: 6px 6px 6px 8px;
    border-radius: var(--rm);
  }

  .safety-strip.release-banner[data-collapsed="true"] {
    right: auto;
    min-height: 28px;
    height: 28px;
    max-height: 28px;
    padding: 0 10px 0 8px;
    border-radius: 999px;
  }

  .safety-strip.release-banner .rs-desktop-body {
    display: none !important;
  }
}

@media (max-width: 389px) {
  .release-banner .rs-full {
    display: none;
  }

  .release-banner .rs-compact {
    display: -webkit-box;
  }
}

/* ── 首次操作引導氣泡（v1.1 §4） ── */
.coachmark {
  position: absolute;
  z-index: var(--z-coach);
  bottom: calc(var(--tb-bottom) + var(--tb-h) + 8px);
  left: var(--coach-left, 12px);
  max-width: min(320px, calc(100vw - 24px));
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 4px 8px 12px;
  border-radius: var(--rm);
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  line-height: 18px;
  box-shadow: var(--shadow-sm);
  opacity: 1;
  transition: opacity 300ms ease;
}

.coachmark[hidden] {
  display: none !important;
}

.coachmark.is-fading {
  opacity: 0;
  pointer-events: none;
}

.coachmark::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: var(--coach-arrow-x, 20px);
  border: 6px solid transparent;
  border-bottom: 0;
  border-top-color: var(--ink);
  transform: translateX(-50%);
}

.coachmark-text {
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.coachmark-close {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  position: relative;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.coachmark-close::after {
  content: "";
  position: absolute;
  inset: -10px;
}

#tool-draw.is-coached {
  animation: coach-pulse 1.2s ease-out 2;
}

@keyframes coach-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--acctint);
  }
  70% {
    box-shadow: 0 0 0 6px var(--acctint);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@media (min-width: 641px) {
  .coachmark {
    display: none !important;
  }
}

/* ── 手機專注（全螢幕）編輯模式（v1.1 §3） ── */
.focus-chrome {
  display: none;
}

@keyframes focus-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.focus-exit {
  position: fixed;
  z-index: var(--z-focus-chrome);
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  height: 36px;
  padding: 0 12px;
  gap: 4px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-sm);
}

.focus-exit::after {
  content: "";
  position: absolute;
  inset: -4px;
}

.focus-mini-bar {
  position: fixed;
  z-index: var(--z-focus-chrome);
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(8px + env(safe-area-inset-bottom));
  height: 48px;
  padding: 2px 8px 2px 2px;
  gap: 4px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--rl);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-sm);
  --rs-dot: var(--ink3);
}

.focus-mini-bar[data-tone="ok"],
.focus-mini-bar[data-status="READY"] {
  --rs-dot: var(--ok);
}

.focus-mini-bar[data-tone="alert"] {
  --rs-dot: var(--dan);
}

.focus-mini-bar[data-tone="pending"] {
  --rs-dot: var(--acc);
}

.focus-mini-bar .mini-btn {
  width: 56px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--rm);
  background: transparent;
  color: var(--ink2);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 700;
}

.focus-mini-bar .mini-btn:disabled {
  opacity: 0.4;
}

.focus-mini-bar .mini-btn .tool-icon {
  font-size: 16px;
  line-height: 16px;
}

.focus-mini-bar .mini-btn .tool-label {
  font-size: 10px;
  line-height: 12px;
  white-space: nowrap;
}

.focus-mini-bar .mini-btn[aria-pressed="true"] {
  background: var(--acctint);
  border-color: var(--frame);
  color: var(--acc);
}

.focus-mini-bar .mini-apply.is-ready {
  background: var(--acc);
  color: var(--surface);
}

.focus-mini-bar .mini-dot {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 8px;
  height: 8px;
  display: grid;
  place-items: center;
}

.focus-mini-bar .mini-dot[hidden] {
  display: none !important;
}

.focus-mini-bar .mini-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rs-dot);
}

.focus-mini-bar .mini-page {
  font-size: 11px;
  color: var(--ink2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-inline: 2px;
}

@media (max-width: 640px) {
  :root[data-focus="true"] {
    --toast-bottom: calc(8px + env(safe-area-inset-bottom) + 48px + 12px);
  }

  :root[data-focus="true"] .app[data-state="editing"] {
    grid-template-rows: 1fr;
  }

  :root[data-focus="true"] .hdr.sumi-site-head,
  :root[data-focus="true"] #safety-disclosure-strip,
  :root[data-focus="true"] #page-dock,
  :root[data-focus="true"] #floating-toolbar,
  :root[data-focus="true"] .pan-hint-anchor,
  :root[data-focus="true"] .coachmark,
  :root[data-focus="true"] .page-header {
    display: none !important;
  }

  :root[data-focus="true"] .canvas.viewer-scroll {
    padding: 8px 0 calc(64px + env(safe-area-inset-bottom));
  }

  :root[data-focus="true"] .scrim:not(.hidden) {
    inset: 0;
  }

  :root[data-focus="true"] .app[data-state="editing"] .focus-chrome {
    display: flex;
    animation: focus-fade-in 150ms ease;
  }

  :root[data-focus="true"] .workspace.has-sheet .focus-mini-bar {
    opacity: 0;
    pointer-events: none;
  }
}

/* ── CDO Phase 2：桌機版面（方案 1）與共用匯出確認（方案 2） ── */
:root {
  --desk-rail-w: 64px;
  --desk-panel-w: 296px;
  --overview-cols: 2;
  --dp-ok-bg: #234234;
  --dp-ok-ink: #d7f2e4;
}

:root[data-theme="light"] {
  --dp-ok-bg: #1e5638;
  --dp-ok-ink: #ffffff;
}

@media (min-width: 1024px) {
  :root {
    --hdr: 56px;
    --desk-rail-w: 64px;
    --desk-panel-w: 296px;
    --overview-cols: 2;
  }
}

@media (min-width: 1280px) {
  :root {
    --desk-rail-w: 72px;
    --desk-panel-w: 336px;
    --overview-cols: 3;
  }
}

@media (min-width: 1440px) {
  :root {
    --desk-rail-w: 72px;
    --desk-panel-w: 360px;
    --overview-cols: 3;
  }
}

@media (min-width: 1920px) {
  :root {
    --desk-rail-w: 72px;
    --desk-panel-w: 400px;
    --overview-cols: 4;
  }
}

.hdr-svg,
.rail-svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
  flex: none;
}

.hdr-svg.theme-icon-moon {
  display: none;
}

:root[data-theme="light"] .hdr-svg.theme-icon-sun {
  display: none;
}

:root[data-theme="light"] .hdr-svg.theme-icon-moon {
  display: block;
}

@media (max-width: 640px) {
  .floating-toolbar .rail-svg {
    width: 18px;
    height: 18px;
  }

  .hdr-icon-btn .hdr-svg {
    width: 20px;
    height: 20px;
  }
}

.desk-only-inline {
  display: none;
}

.non-desk-inline {
  display: inline;
}

.rail-sep {
  display: none;
}

.panel-reparent-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.desk-panel {
  display: none;
}

.desk-focus-exit {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: var(--z-focus-chrome);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* ── 頁內狀態列與總覽格線 ── */
.canvas-topbar {
  flex: none;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  font-size: 15px;
  z-index: 6;
}

.canvas-topbar-title {
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
}

.canvas-topbar-pill {
  font-size: 14px;
  line-height: 1.3;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--acctint);
  color: var(--acc);
  font-weight: 700;
}

.canvas-topbar-pill.is-exc {
  background: var(--dantint);
  color: var(--dantext);
}

.canvas-topbar-sp {
  flex: 1;
}

.canvas-view-seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  overflow: hidden;
  flex-shrink: 0;
}

.canvas-seg-btn {
  min-width: 56px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink2);
  font-size: 14px;
  font-weight: 700;
}

.canvas-seg-btn:last-child {
  border-right: 0;
}

.canvas-seg-btn.is-active {
  background: var(--acctint);
  color: var(--acc);
}

.confirm-overview-scroll {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--mount);
  padding: 20px 24px 36px;
}

.confirm-overview-grid {
  display: grid;
  grid-template-columns: repeat(var(--overview-cols, 3), minmax(0, 1fr));
  gap: 24px;
  align-content: start;
}

.ov-thumb-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.ov-thumb-card:focus-visible .ov-thumb-frame {
  outline: 2px solid var(--acc);
  outline-offset: 3px;
}

.ov-thumb-frame {
  position: relative;
  width: 100%;
  background: #ffffff;
  border-radius: 2px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  line-height: 0;
}

.ov-thumb-card.is-exception .ov-thumb-frame {
  outline: 3px solid var(--dan);
  outline-offset: 2px;
}

.ov-thumb-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.ov-thumb-cta {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--rm);
  background: var(--dan);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.ov-thumb-cap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink2);
  min-height: 24px;
}

.ov-thumb-card.is-exception .ov-thumb-cap {
  color: var(--dantext);
  font-weight: 700;
}

.ov-thumb-card.is-seen .ov-thumb-cap-state {
  color: var(--acc);
  font-weight: 700;
}

.ov-thumb-card.is-confirmed .ov-thumb-cap-state {
  color: var(--ok);
  font-weight: 700;
}

.confirm-nav-dock {
  gap: 6px;
  padding: 4px;
}

.dock-nav-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--rm);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.dock-nav-btn:hover:not(:disabled) {
  background: var(--surface2);
}

.dock-nav-btn:disabled {
  opacity: 0.4;
}

/* ── 共用確認卡片、狀態卡與摘要樣式（桌機右欄 & 手機確認共用） ── */
.dp-head {
  flex: none;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line2);
}

.dp-head h2 {
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
}

.dp-subtitle {
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink3);
}

.dp-steps {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.dp-steps i {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

.dp-steps i.is-on {
  background: var(--acc);
}

.dp-steps-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink3);
}

.dp-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dp-body > * {
  flex-shrink: 0;
}

.dp-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dp-slot {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dp-subview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line2);
}

.dp-back-btn {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: var(--surface2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.dp-back-btn:hover {
  border-color: var(--acc);
}

.dp-subview-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink2);
}

.dp-foot {
  flex: none;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dp-foot-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dp-status {
  border-radius: var(--rl);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface2);
  border: 1px solid var(--line);
}

.dp-status-ok {
  border-color: var(--ok);
}

.dp-status-bad {
  border-color: var(--dan);
  background: var(--dantint);
}

.dp-status-dot {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  background: var(--acctint);
  color: var(--acc);
}

.dp-status-ok .dp-status-dot {
  background: var(--dp-ok-bg);
  color: var(--dp-ok-ink);
}

.dp-status-bad .dp-status-dot {
  background: var(--dan);
  color: #ffffff;
}

.dp-status-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dp-status-text strong {
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
}

.dp-status-bad .dp-status-text strong {
  color: var(--dantext);
}

.dp-status-text span {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink2);
}

@keyframes dp-spin {
  to {
    transform: rotate(360deg);
  }
}

.dp-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--acc);
  animation: dp-spin 0.9s linear infinite;
}

.dp-sec-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink3);
}

.dp-card-list,
.dp-normal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dp-todo {
  border: 1px solid var(--line);
  border-radius: var(--rl);
  padding: 12px 14px;
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dp-todo-acc {
  border-color: var(--acc);
}

.dp-todo-cur {
  border-color: var(--dan);
  box-shadow: 0 0 0 1px var(--dan);
}

.dp-todo-done {
  opacity: 0.86;
}

.dp-todo-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.dp-pg-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--dantint);
  color: var(--dantext);
}

.dp-todo-done .dp-pg-pill {
  background: var(--dp-ok-bg);
  color: var(--dp-ok-ink);
}

.dp-todo-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink2);
}

.dp-check-list {
  margin: 0;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}

.dp-check-sub {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink2);
}

.dp-todo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dp-btn {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

.dp-big-btn {
  min-height: 48px;
  width: 100%;
  font-size: 16px;
}

.dp-sec-btn {
  min-height: 40px;
  width: 100%;
  font-size: 14px;
}

.dp-ok-btn {
  min-height: 40px;
  background: var(--dp-ok-bg);
  color: var(--dp-ok-ink);
  border-color: transparent;
  font-weight: 700;
}

.dp-ok-btn:hover:not(:disabled) {
  opacity: 0.92;
  background: var(--dp-ok-bg);
  border-color: var(--ok);
}

.dp-ok-btn:disabled {
  opacity: 0.45;
  background: var(--surface);
  color: var(--ink3);
  border-color: var(--line);
}

.dp-inline-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink2);
}

.dp-note-icon {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--acctint);
  color: var(--acc);
}

.dp-note-text {
  flex: 1;
  min-width: 0;
}

.dp-inline-btn {
  min-height: 40px;
  padding: 0 12px;
  font-size: 14px;
}

.dp-hint {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink3);
}

.dp-batch-hint {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink2);
}

.dp-confirm-reminder {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink2);
}

.dp-confirm-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
}

.dp-confirm-check input[type='checkbox'] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--acc);
  flex: none;
  cursor: pointer;
}

.dp-big-btn:disabled {
  opacity: 0.45;
}

.dp-batch-details summary {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  color: var(--acc);
  font-weight: 700;
  font-size: 14px;
}

.dp-normal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  background: var(--surface2);
}

.dp-normal-jump {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
}

.dp-normal-state {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink3);
  white-space: nowrap;
}

.dp-normal-state.is-seen {
  color: var(--acc);
}

.dp-normal-state.is-confirmed {
  color: var(--ok);
}

.dp-normal-revoke {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: transparent;
  color: var(--ink2);
  font-size: 13px;
  font-weight: 700;
}

.dp-fail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dp-fail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
  background: var(--surface2);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}

.dp-fail-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dp-done-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── 下載前常駐摘要 ── */
.confirm-summary {
  border: 1px solid var(--line);
  border-radius: var(--rm);
  padding: 10px 12px;
  background: var(--surface2);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.confirm-summary.is-attention {
  border-color: var(--dan);
  box-shadow: 0 0 0 2px var(--dantint);
}

.cs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.cs-head strong {
  font-size: 14px;
  color: var(--ink);
}

.cs-pass {
  font-size: 14px;
  font-weight: 700;
  color: var(--ok);
}

.cs-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cs-item {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink2);
}

.cs-item.is-warn {
  color: var(--warn);
  font-weight: 700;
}

.cs-tech {
  font-size: 14px;
  color: var(--ink2);
}

.cs-tech > summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--acc);
  font-weight: 700;
  font-size: 14px;
  list-style: none;
}

.cs-tech > summary::-webkit-details-marker {
  display: none;
}

.cs-tech > summary::before {
  content: "▸";
  margin-inline-end: 8px;
}

.cs-tech[open] > summary::before {
  content: "▾";
}

.cs-tech-body {
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.cs-tech-list {
  margin: 0;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── 編輯模式已標出清單（跳頁 + 獨立刪除按鈕 ≥40px） ── */
.manual-box-jump {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 4px 6px;
  border: 0;
  border-radius: var(--rs);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.manual-box-jump:hover {
  background: var(--acctint);
  color: var(--acc);
}

/* ── 桌機 ≥1024px 三欄工作區（方案 1） ── */
@media (min-width: 1024px) {
  .desk-only-inline {
    display: inline;
  }

  .non-desk-inline {
    display: none;
  }

  .rail-sep {
    display: block;
    width: 40px;
    border: 0;
    border-top: 1px solid var(--line);
    margin: 6px 0;
  }

  .app[data-state="editing"] .hdr .sumi-head-inner {
    padding-inline: 20px;
    gap: 14px;
  }

  .app[data-state="editing"] #btn-review-pill,
  .app[data-state="editing"] .export-wrap {
    display: none !important;
  }

  .app[data-state="editing"] .filename {
    font-size: 14px;
  }

  .app[data-state="editing"] .zoom-toolbar {
    height: 46px;
  }

  .app[data-state="editing"] .zoom-btn {
    height: 100%;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    font-size: 14px;
  }

  .app[data-state="editing"] .hdr-icon-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
  }

  .workspace {
    display: grid;
    grid-template-columns: var(--desk-rail-w) minmax(0, 1fr) var(--desk-panel-w);
    grid-template-rows: minmax(0, 1fr);
    flex-direction: row;
  }

  #floating-toolbar,
  #floating-toolbar.is-collapsed {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    left: auto;
    top: auto;
    right: auto;
    bottom: auto;
    width: var(--desk-rail-w);
    height: 100%;
    padding: 10px 0;
    gap: 4px;
    flex-direction: column;
    align-items: center;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
  }

  #floating-toolbar.is-collapsed .toolbar-items {
    display: flex;
  }

  #btn-toolbar-toggle,
  #tool-apply,
  #btn-mark-current-page {
    display: none !important;
  }

  #tool-focus {
    display: inline-flex;
  }

  #floating-toolbar .toolbar-items {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
  }

  #floating-toolbar .tool-btn {
    width: 60px;
    min-width: 60px;
    min-height: 60px;
    padding: 2px;
    gap: 1px;
    font-size: 13px;
    line-height: 1.2;
  }

  #floating-toolbar .tool-icon {
    height: 36px;
    display: grid;
    align-content: center;
  }

  #floating-toolbar .tool-icon .rail-svg {
    width: 40px;
    height: 40px;
  }

  #floating-toolbar .tool-label {
    font-size: 13px;
    line-height: 1.2;
  }

  #floating-toolbar .tool-btn.is-dimmed {
    opacity: 0.42;
  }

  #viewer-col {
    grid-column: 2;
    grid-row: 1;
  }

  .canvas.viewer-scroll {
    padding: 20px 12px 96px;
  }

  .page-header {
    padding-left: 4px;
  }

  .page-dock {
    padding: 4px;
    gap: 4px;
    font-size: 14px;
  }

  .dock-btn {
    min-width: 40px;
    min-height: 40px;
    height: 40px;
    font-size: 18px;
  }

  #safety-disclosure-strip {
    display: none !important;
  }

  .desk-panel {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    width: var(--desk-panel-w);
    border-left: 1px solid var(--line);
    background: var(--surface);
  }

  .desk-panel button {
    min-width: 44px;
    min-height: 44px;
  }

  .desk-panel .floating-popover {
    position: static;
    width: auto;
    max-width: none;
    max-height: none;
    flex-shrink: 0;
  }

  .desk-panel .review-chips {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .desk-panel .dp-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .desk-panel .dp-back-btn .rail-svg {
    width: 36px;
    height: 36px;
  }

  .desk-panel .dp-note-icon,
  .desk-panel .dp-status-dot {
    width: 28px;
    height: 28px;
    font-size: 24px;
    line-height: 1;
  }

  .desk-panel .dp-spinner {
    width: 24px;
    height: 24px;
  }

  .dp-feedback {
    padding: 8px 10px;
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: var(--rm);
    font-size: 14px;
    line-height: 1.5;
  }

  .desk-panel .search-row input {
    height: 44px;
    font-size: 14px;
  }

  .desk-panel .search-row .btn,
  .desk-panel .manual-actions .btn {
    min-height: 44px;
    font-size: 14px;
  }

  .desk-panel .manual-box-list {
    max-height: none;
    overflow-y: visible;
  }

  .desk-panel .manual-box-item {
    padding: 4px 8px;
    font-size: 14px;
  }

  .desk-panel .manual-box-jump {
    min-height: 44px;
    font-size: 14px;
  }

  .desk-panel .manual-box-remove {
    min-height: 44px;
    min-width: 48px;
    padding: 0 12px;
    font-size: 14px;
  }

  .desk-panel #btn-apply {
    min-height: 48px;
    font-size: 16px;
  }

  .desk-panel .fill-btn {
    min-height: 44px;
    font-size: 14px;
  }

  .desk-panel .sub-chip {
    min-height: 44px;
    font-size: 13px;
  }

  .desk-panel .pii-chip {
    min-height: 44px;
    font-size: 13px;
  }

  .desk-panel .pii-item-actions .btn {
    min-height: 44px;
    font-size: 14px;
  }

  .desk-panel .pii-batch-btn {
    min-height: 44px;
    font-size: 14px;
  }

  /* 桌機專注模式：隱藏右欄，擴大中央畫布 */
  :root[data-desk-focus="true"] .workspace {
    grid-template-columns: var(--desk-rail-w) minmax(0, 1fr);
  }

  :root[data-desk-focus="true"] .desk-panel {
    display: none;
  }
}

/* 桌機短視窗（如 600px 高）防擠壓：改為整欄垂直捲動，確保最後一項與 CTA 可到達 */
@media (min-width: 1024px) and (max-height: 680px) {
  .desk-panel {
    overflow-y: auto;
  }

  .desk-panel .dp-body {
    flex: 0 0 auto;
    overflow-y: visible;
  }
}

@media (max-width: 1023px) {
  #canvas-topbar,
  #confirm-overview-scroll,
  #confirm-nav-dock,
  #btn-desk-focus-exit {
    display: none !important;
  }
}

/* ── 手機與平板全螢幕確認流程（方案 2；≤1023px） ── */
.mc-screen {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: var(--page);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .mc-screen {
    display: none !important;
  }
}

.mc-top {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--page);
}

.mc-back-btn,
.mc-nav-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--rm);
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}

.mc-title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  line-height: 1.3;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mc-chip {
  font-size: 13px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink2);
  font-weight: 700;
  white-space: nowrap;
}

.mc-inspect-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mc-toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  pointer-events: auto;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--rm);
  box-shadow: var(--shadow-sm);
  padding: 6px 12px;
  font-size: 13px;
  max-width: calc(100% - 24px);
  width: max-content;
  text-align: center;
}

.mc-toast.has-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.mc-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mc-body > * {
  flex-shrink: 0;
}

.mc-thumbs {
  display: flex;
  flex: none;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 -16px;
  padding: 6px 16px;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

.mc-thumbs .ov-thumb-card {
  flex: none;
  width: 150px;
}

@media (min-width: 641px) and (max-width: 1023px) {
  .mc-thumbs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin: 0;
    padding: 4px 0;
    overflow-x: visible;
  }

  .mc-thumbs .ov-thumb-card {
    width: auto;
  }
}

.mc-inspect-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mc-tip {
  flex: none;
  margin: 8px 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--rl);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}

.mc-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--mount);
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mc-canvas-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  background: #ffffff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.3);
}

.mc-inspect-pdf-canvas {
  display: block;
}

.mc-inspect-overlay-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mc-foot {
  flex: none;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mc-inspect-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mc-inspect-bar .dp-big-btn {
  flex: 1;
}

@media (max-width: 1023px) and (max-height: 580px) {
  .mc-screen {
    overflow-y: auto;
  }

  .mc-body {
    flex: 0 0 auto;
    overflow-y: visible;
  }
}

/* ── 無障礙：reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  #tool-draw.is-coached {
    animation: none !important;
    box-shadow: 0 0 0 2px var(--acc);
  }

  .focus-chrome {
    animation: none !important;
    transition: none !important;
  }
}

/* ── 落地頁頁尾與選單法律連結 ── */
.landing-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line2);
  font-size: 12px;
  color: var(--ink3);
}

.landing-footer a,
.menu-legal-link {
  color: var(--acc);
  text-decoration: none;
}

.landing-footer a:hover,
.landing-footer a:focus-visible,
.menu-legal-link:hover,
.menu-legal-link:focus-visible {
  color: var(--acchover);
  text-decoration: underline;
}

.menu-legal-link {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 2px 0;
}

/* ── 隱私與免責聲明靜態頁（privacy.html） ── */
.privacy-body {
  min-height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.privacy-header-back {
  color: var(--acc);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--rm);
  border: 1px solid var(--line);
}

.privacy-header-back:hover,
.privacy-header-back:focus-visible {
  background: var(--surface2);
  color: var(--acchover);
  text-decoration: none;
}

.privacy-main {
  flex: 1 0 auto;
  padding-block: 36px 56px;
}

.privacy-lead {
  color: var(--ink2);
  margin: 12px 0 28px;
}

.privacy-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rl);
  padding: 20px 24px;
  margin-bottom: 18px;
}

.privacy-section h2 {
  font-size: 18px;
  line-height: 1.4;
  margin: 0 0 10px;
}

.privacy-section p {
  margin: 0 0 10px;
  color: var(--ink2);
}

.privacy-section p:last-child {
  margin-bottom: 0;
}

.privacy-list {
  margin: 8px 0 10px;
  padding-left: 20px;
  color: var(--ink2);
}

.privacy-list li {
  margin-bottom: 6px;
}

.privacy-list code,
.privacy-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  background: var(--surface2);
  color: var(--ink);
  padding: 1px 6px;
  border-radius: var(--rs);
  border: 1px solid var(--line2);
}

.privacy-todo {
  background: var(--dantint);
  border: 1px solid var(--dan);
  color: var(--ink);
  border-radius: var(--rm);
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 14px;
}

.privacy-link {
  color: var(--acc);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.privacy-link:hover,
.privacy-link:focus-visible {
  color: var(--acchover);
}

.privacy-footer {
  border-top: 1px solid var(--line);
  padding-block: 20px 32px;
  font-size: 13px;
  color: var(--ink3);
}

.privacy-footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.not-found-actions .privacy-header-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
}

/* ── 編輯停靠列（一側完成）：樣式、壓縮、套用都貼著文件，只在步驟 1 顯示 ── */
.edit-dock {
  position: absolute;
  z-index: var(--z-dock);
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rl);
  box-shadow: var(--shadow-lg);
}

.edit-dock-row {
  display: grid;
  grid-template-columns: auto auto auto;
  grid-template-areas:
    "notice notice notice"
    "style comp apply";
  align-items: center;
  gap: 0 8px;
}

.edit-dock-row > [data-testid="dp-style-summary"] {
  grid-area: style;
}

.edit-dock-row > [data-testid="dp-comp-summary"] {
  grid-area: comp;
}

.edit-dock-chip-wrap {
  display: flex;
  min-width: 0;
  max-width: 100%;
}

.dock-chip {
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  max-width: 100%;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--ink2);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-chip-v {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-chip:hover:not(:disabled) {
  border-color: var(--frame);
}

.dock-chip[aria-expanded="true"] {
  border-color: var(--frame);
  background: var(--acctint);
  color: var(--acc);
}

.dock-chip[aria-expanded="true"] .dock-chip-v {
  color: var(--acc);
}

/* 套用按鈕與「建議未採用」提示是同一組既有元素（#apply-action-slot），在停靠列裡攤平成格線的兩格 */
.edit-dock-apply-slot,
.edit-dock #apply-action-slot {
  display: contents;
}

.edit-dock #btn-apply {
  grid-area: apply;
}

.edit-dock #pii-apply-pending-notice {
  grid-area: notice;
  margin-bottom: 8px;
}

.edit-dock #btn-apply {
  width: auto;
  min-height: 48px;
  padding: 0 22px;
  font-size: 16px;
}

.edit-dock .pii-pending-notice {
  font-size: 13px;
}

@media (min-width: 1024px) {
  .workspace.has-edit-dock .canvas.viewer-scroll {
    padding-bottom: calc(74px + var(--edit-dock-h, 72px) + 24px);
  }
}

/* 平板 641–1023：在置中工具列上方 */
@media (min-width: 641px) and (max-width: 1023px) {
  .edit-dock {
    bottom: 126px;
    padding: 4px;
    box-shadow: var(--shadow-sm);
  }

  .workspace.has-edit-dock .canvas.viewer-scroll {
    padding-bottom: calc(126px + var(--edit-dock-h, 54px) + 24px);
  }
}

/* 手機 ≤640：工具列正上方的一條，與工具列等寬；翻頁膠囊往上讓位 */
@media (max-width: 640px) {
  .edit-dock {
    left: calc(var(--tb-edge) + env(safe-area-inset-left));
    right: calc(var(--tb-edge) + env(safe-area-inset-right));
    bottom: calc(var(--tb-bottom) + var(--tb-h) + 6px);
    transform: none;
    width: auto;
    max-width: none;
    padding: var(--tb-pad);
    box-shadow: var(--shadow-sm);
  }

  .edit-dock-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "style comp";
    align-items: stretch;
    gap: var(--tb-gap);
  }

  .dock-chip {
    width: 100%;
    justify-content: center;
    padding: 0 8px;
    border-radius: var(--rm);
    font-size: 13px;
  }

  :root:not([data-focus="true"]) .workspace.has-edit-dock {
    --dock-bottom: calc(var(--tb-bottom) + var(--tb-h) + 6px + var(--edit-dock-h, 52px) + 8px);
    --toast-bottom: calc(var(--dock-bottom) + var(--dock-h) + 8px);
  }

  .workspace.has-sheet .edit-dock,
  :root[data-focus="true"] .edit-dock {
    display: none;
  }

  /* 首次引導氣泡指向工具列的「框選」，期間停靠條像翻頁膠囊一樣讓位，關掉氣泡即回來 */
  .workspace.has-coachmark .edit-dock {
    visibility: hidden;
  }
}

@media (min-width: 481px) and (max-width: 640px) {
  .edit-dock {
    left: calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2);
    right: auto;
    width: min(480px, calc(100vw - 2 * var(--tb-edge) - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-width: calc(100vw - 2 * var(--tb-edge) - env(safe-area-inset-left) - env(safe-area-inset-right));
    transform: translateX(-50%);
  }
}

/* ── 頁面上的框旁操作（只在編輯步驟；只是 DOM 控制，不畫進任何 PDF） ── */
.box-action-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.box-action-layer[hidden] {
  display: none;
}

.box-inline-btn {
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  line-height: 1;
}

.box-inline-btn::after {
  content: "";
  position: absolute;
  inset: -10px;
}

/* Pending ✓/✕ sit 2px apart on desktop: expand outward to 44x44 without stealing clicks from the neighbour's glyph. */
.box-inline-btn.is-adopt::after {
  inset: -10px -1px -10px -19px;
}

.box-inline-btn.is-dismiss::after {
  inset: -10px -19px -10px -1px;
}

.box-action-layer.is-touch-size .box-inline-btn {
  width: 44px;
  height: 44px;
}

.box-action-layer.is-touch-size .box-inline-btn::after {
  content: none;
}

.box-inline-glyph {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface);
  color: var(--ink2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.box-action-layer.is-touch-size .box-inline-glyph {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.box-inline-btn.is-delete .box-inline-glyph {
  background: var(--dan);
  border-color: var(--dan);
  color: var(--onprimary);
}

.box-inline-btn.is-adopt .box-inline-glyph {
  background: #3e6473;
  border-color: #3e6473;
  color: #ffffff;
}

.box-inline-btn:hover .box-inline-glyph,
.box-inline-btn.is-linked .box-inline-glyph {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
}

.box-inline-btn:focus-visible {
  outline: none;
}

.box-inline-btn:focus-visible .box-inline-glyph {
  outline: 3px solid var(--acc);
  outline-offset: 2px;
}

/* ── 依類型分組的已標出清單 ── */
.manual-box-list {
  max-height: min(50vh, 420px);
  gap: 8px;
}

.box-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--rl);
  background: var(--surface);
}

.box-group-head {
  display: flex;
  align-items: center;
}

.box-group-toggle {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 4px 6px;
  border: 0;
  border-radius: var(--rm);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.box-group-toggle:hover {
  background: var(--surface2);
}

.box-group-caret {
  display: inline-block;
  transition: transform 120ms ease;
}

.box-group.is-collapsed .box-group-caret {
  transform: rotate(-90deg);
}

.box-group-pending {
  font-size: 12px;
  font-weight: 700;
  color: var(--warn);
}

.box-group-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
}

.box-group-actions.is-manual {
  grid-template-columns: minmax(0, 1fr);
}

.btn.box-group-btn {
  min-height: 44px;
  padding: 0 8px;
  font-size: 13px;
  white-space: nowrap;
}

.box-group-keep {
  grid-column: 1;
}

.box-group-remove {
  grid-column: 2;
  color: var(--dantext);
}

.box-group-actions.is-manual .box-group-remove {
  grid-column: 1;
}

.box-group-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.box-group-items[hidden] {
  display: none;
}

.box-group-pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border: 1px dashed var(--line);
  border-radius: var(--rm);
  background: var(--surface2);
}

.box-group-pending-item.is-linked {
  border-color: var(--acc);
}

.box-group-pending-adopt {
  flex: none;
  border: 1px solid var(--frame);
  border-radius: var(--rs);
  background: var(--acctint);
  color: var(--acc);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.manual-box-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.manual-box-page {
  flex: none;
}

.manual-box-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  color: var(--ink2);
}

.manual-box-item.is-linked {
  border-color: var(--dan);
  box-shadow: inset 0 0 0 1px var(--dan);
}

@media (max-width: 1023px) {
  .manual-box-jump,
  .manual-box-remove,
  .box-group-pending-adopt {
    min-height: 44px;
  }

  .manual-box-remove,
  .box-group-pending-adopt {
    min-width: 48px;
  }
}

@media (min-width: 1024px) {
  .desk-panel .manual-box-list {
    max-height: none;
  }
}


/* qe28b L3: search-panel buttons and close control are >=44px on every viewport. */
#popover-search .btn.sm,
#search-form .btn,
.manual-actions .btn {
  min-height: 44px;
}
#popover-search .close-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}
.mobile-zoom-row .btn {
  min-width: 44px;
  min-height: 44px;
}
