/* ═══════════════════════════════════════════════════════════════
   chopchop

   配色紀律：介面本身只用灰階明度區分層級，飽和的顏色一律保留給
   資料本身（區塊色帶）。這樣視覺重心永遠落在切分結果上。
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* 區塊配色：三個暖色相 × 兩檔亮度，相鄰區塊同時換色相與明暗。
     全部壓在暖色區（16–104）色相只跨 88 度，光靠色相分不開六塊，
     所以讓亮度也交替 —— 實測相鄰色差 0.20（OKLab，可辨門檻約 0.1）。

     用 OKLCH 而非 HSL：HSL 的 L 不是感知亮度，同樣 42% 的橄欖綠遠比
     梅紫亮，沒有一種文字色能在兩者上都讀得清楚。OKLCH 的 L 就是感知
     亮度，兩檔亮度各自的對比因此一致可控。 */
  --h-0: 16;   /* 粉紅 */
  --h-1: 60;   /* 橙 */
  --h-2: 104;  /* 芥黃 */
  --h-3: 16;
  --h-4: 60;
  --h-5: 104;

  --font-display: 'Bricolage Grotesque', 'IBM Plex Sans', -apple-system, 'PingFang TC', sans-serif;
  --font-ui: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
             'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
               'PingFang TC', 'Noto Sans TC', monospace;

  --t-2: 0.6875rem;
  --t-1: 0.8125rem;
  --t0: 0.9375rem;
  --t1: 1.0625rem;
  --t2: 1.375rem;
  --t3: 2rem;

  --r-sm: 4px;
  --r: 8px;
  --r-lg: 14px;

  --gut: clamp(1rem, 3.5vw, 2.25rem);
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
}

/* ── 暗色：深烘焙咖啡（預設） ──────────────────────────────── */
:root,
:root[data-theme='dark'] {
  --bg: #1b1613;
  --bg-deep: #14100e;
  --surface: #251e19;
  --surface-2: #302620;
  --line: #3f3229;
  --line-soft: #2d241e;
  --text: #f4ebe1;
  --text-2: #c9b6a6;      /* 8.4:1 */
  --text-3: #a18d7c;      /* 5.2:1 —— 11px 小字也要過 4.5 */
  --focus: #ffc98a;

  --chunk-l-a: 0.88;      /* 亮檔 */
  --chunk-l-b: 0.62;      /* 暗檔 */
  --chunk-l: 0.75;        /* 靜態元素（圖例）用的中間值 */
  --chunk-c: 0.17;
  /* 深底上兩檔都夠亮，不需要邊框；--chunk-edge-l 留白讓它回退成填色 */
  --chunk-ink: #14100e;   /* 色帶上的文字，最低對比 4.8:1 */
  --chunk-wash: 0.22;     /* 文字底色濃度 */
  --chunk-wash-2: 0.36;   /* 重疊處 */
  --ribbon-a: 1;
  --density-ink: 255 236 214; /* 覆蓋密度用的暖白 */
  --shadow: 0 1px 2px rgb(12 6 2 / 0.45), 0 8px 24px -12px rgb(12 6 2 / 0.6);
}

/* ── 亮色：暖砂陶土 ─────────────────────────────────────────── */
:root[data-theme='light'] {
  --bg: #eae1d6;
  --bg-deep: #ddd1c1;
  --surface: #fbf7f1;
  --surface-2: #f3ece2;
  --line: #d5c7b5;
  --line-soft: #e6dbcd;
  --text: #241a13;
  --text-2: #55443a;      /* 7.1:1 */
  --text-3: #785c4b;      /* 4.7:1 —— 暖砂底較暗，小字上限就在這 */
  --focus: #a8451a;

  --chunk-l-a: 0.88;
  --chunk-l-b: 0.64;
  --chunk-l: 0.76;
  --chunk-c: 0.17;
  --chunk-edge-l: 0.5;    /* 亮底上靠同色相深邊框界定形狀 */
  --chunk-ink: #241a13;   /* 最低對比 4.7:1 */
  --chunk-wash: 0.18;
  --chunk-wash-2: 0.34;
  --ribbon-a: 1;
  --density-ink: 60 36 20;
  --shadow: 0 1px 2px rgb(74 48 28 / 0.08), 0 8px 24px -14px rgb(74 48 28 / 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* .field 等元件自帶 display，會蓋掉 hidden 屬性 */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:where(button, input, select, textarea) {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* 捲軸融進面板，預設樣式在暗色下太搶眼 */
.doc-view,
.doc-edit,
.chunk-list,
.strip {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.doc-view::-webkit-scrollbar,
.doc-edit::-webkit-scrollbar,
.chunk-list::-webkit-scrollbar,
.strip::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.doc-view::-webkit-scrollbar-thumb,
.doc-edit::-webkit-scrollbar-thumb,
.chunk-list::-webkit-scrollbar-thumb,
.strip::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 6px;
  background: var(--line);
  background-clip: content-box;
}

.doc-view::-webkit-scrollbar-thumb:hover,
.chunk-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
  background-clip: content-box;
}

.doc-view::-webkit-scrollbar-track,
.doc-edit::-webkit-scrollbar-track,
.chunk-list::-webkit-scrollbar-track,
.strip::-webkit-scrollbar-track {
  background: transparent;
}

/* ═══ 頁首 ═══════════════════════════════════════════════════ */

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: clamp(1.25rem, 3vw, 2rem) var(--gut) 1rem;
}

.wordmark {
  margin: 0;
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, var(--t3));
  font-weight: 800;
  font-variation-settings: 'wdth' 88, 'opsz' 40;
  letter-spacing: -0.035em;
  line-height: 1;
}

/* 刀口：wordmark 自己被切成兩半，hover 時兩半錯開 */
.blade {
  width: 2px;
  height: 0.86em;
  margin: 0 0.075em;
  background: repeating-linear-gradient(
    to bottom,
    currentColor 0 3px,
    transparent 3px 7px
  );
  opacity: 0.4;
}

.wordmark span {
  transition: transform 0.28s var(--ease);
}

.wordmark:hover span:first-child {
  transform: translateY(-2px);
}

.wordmark:hover span:last-child {
  transform: translateY(2px);
}

.tagline {
  margin: 0.4rem 0 0;
  color: var(--text-2);
  font-size: var(--t-1);
}

/* ═══ 共用零件 ═══════════════════════════════════════════════ */

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--t-1);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.theme-icon {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(to right, currentColor 50%, transparent 50%);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--t1);
  font-weight: 700;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.015em;
}

.sub-title {
  margin: 0;
  font-size: var(--t-1);
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.select-wrap {
  position: relative;
  display: block;
}

.select-wrap::after {
  content: '';
  position: absolute;
  right: 0.7rem;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select-wrap select {
  appearance: none;
  width: 100%;
  padding: 0.4rem 2rem 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  font-size: var(--t-1);
  cursor: pointer;
}

.select-wrap-sm select {
  padding-block: 0.3rem;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--t-1);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  position: relative;
}

.checkbox input:checked {
  background: var(--text);
  border-color: var(--text);
}

.checkbox input:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border-right: 2px solid var(--surface);
  border-bottom: 2px solid var(--surface);
  transform: rotate(42deg);
}

/* ═══ 控制列 ═════════════════════════════════════════════════ */

.console {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 1.5rem;
  margin: 0 var(--gut);
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: var(--t-2);
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field-value {
  font-family: var(--font-mono);
  font-size: var(--t-1);
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.field-note {
  margin: 0;
  max-width: 22ch;
  font-size: var(--t-2);
  line-height: 1.4;
  color: var(--text-3);
}

.field-preset {
  width: 13rem;
}

.field-slider {
  flex: 1 1 11rem;
  max-width: 20rem;
}

.field-toggle {
  justify-content: center;
  padding-top: 1.1rem;
}

.field-strategy,
.field-measure {
  flex: 0 0 auto;
}

/* 分段選擇器 */
.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-deep);
}

.segmented button {
  padding: 0.28rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--t-1);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-checked='true'] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
}

/* 滑桿 */
input[type='range'] {
  appearance: none;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}

input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--text);
  transition: transform 0.15s var(--ease);
}

input[type='range']:hover::-webkit-slider-thumb,
input[type='range']:focus-visible::-webkit-slider-thumb {
  transform: scale(1.15);
}

input[type='range']::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}

input[type='range']::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--text);
}

/* 進階：自訂切點 */
.advanced {
  margin: 0.6rem var(--gut) 0;
  font-size: var(--t-1);
}

.advanced summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  color: var(--text-3);
  cursor: pointer;
  list-style: none;
  width: fit-content;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.advanced summary::before {
  content: '';
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s var(--ease);
}

.advanced[open] summary::before {
  transform: rotate(45deg);
}

.advanced summary:hover {
  color: var(--text);
}

.advanced-body {
  display: grid;
  gap: 0.6rem;
  max-width: 42rem;
  padding: 0.8rem 0 0.2rem;
}

.advanced-help {
  margin: 0;
  font-size: var(--t-2);
  color: var(--text-3);
}

.advanced-help code {
  padding: 0.05em 0.3em;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.95em;
}

#custom-separators {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--t-1);
  line-height: 1.7;
  resize: vertical;
}

.advanced-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ═══ 主視覺：區塊分佈（pileup） ═════════════════════════════ */

.pileup-panel {
  margin: 1.25rem var(--gut) 0;
}

.legend {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  font-size: var(--t-2);
  color: var(--text-3);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  width: 16px;
  height: 8px;
  border-radius: 2px;
}

/* 三段色示意「相鄰區塊換一個顏色」，不是單一色代表全部 */
.legend-swatch-solid {
  background: linear-gradient(
    to right,
    oklch(var(--chunk-l-a) var(--chunk-c) var(--h-0) / 0.85) 0 34%,
    oklch(var(--chunk-l-b) var(--chunk-c) var(--h-1) / 0.85) 34% 67%,
    oklch(var(--chunk-l-a) var(--chunk-c) var(--h-2) / 0.85) 67% 100%
  );
}

.legend-swatch-density {
  background: linear-gradient(to right, var(--line), var(--text-2));
}

.legend-swatch-overlap {
  background: repeating-linear-gradient(
    -45deg,
    oklch(var(--chunk-l-a) var(--chunk-c) var(--h-0) / 0.85) 0 3px,
    oklch(var(--chunk-l-b) var(--chunk-c) var(--h-1) / 0.85) 3px 6px
  );
}

.legend-swatch-gap {
  border: 1px dashed var(--text-3);
  background: transparent;
}

.pileup {
  padding: 0.9rem 1rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pileup-lanes {
  --lane-h: 14px;
  --lane-gap: 3px;
  position: relative;
  height: calc(var(--lanes, 1) * (var(--lane-h) + var(--lane-gap)) - var(--lane-gap));
  min-height: var(--lane-h);
  transition: height 0.3s var(--ease);
}

.ribbon {
  position: absolute;
  height: var(--lane-h);
  min-width: 2px;
  padding: 0 3px;
  border: 1px solid oklch(var(--chunk-edge-l, var(--cl, var(--chunk-l))) var(--chunk-c) var(--h));
  border-radius: 3px;
  background: oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h) / var(--ribbon-a));
  color: var(--chunk-ink);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  line-height: calc(var(--lane-h) - 2px);
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s, filter 0.18s,
    left 0.3s var(--ease), width 0.3s var(--ease), top 0.3s var(--ease);
}

.ribbon:hover,
.ribbon.is-active {
  transform: scaleY(1.35);
  filter: brightness(1.15);
  box-shadow: 0 0 0 1px var(--surface), 0 2px 8px -2px oklch(0.5 0.12 var(--h) / 0.55);
  z-index: 2;
}

/* 覆蓋密度：每個字元被幾個區塊蓋到 */
.pileup-density {
  display: flex;
  height: 5px;
  margin-top: 0.55rem;
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-deep);
}

.density-cell {
  height: 100%;
  transition: background 0.25s var(--ease);
}

.pileup-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: var(--t-2);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.pileup-caption {
  margin: 0.55rem 0 0;
  max-width: 82ch;
  font-size: var(--t-2);
  line-height: 1.5;
  color: var(--text-3);
}

.pileup-empty {
  padding: 0.5rem 0;
  font-size: var(--t-1);
  color: var(--text-3);
}

/* ═══ 警示 ═══════════════════════════════════════════════════ */

.warnings:not(:empty) {
  display: grid;
  gap: 0.4rem;
  margin: 0.8rem var(--gut) 0;
}

.warn {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-left: 3px solid oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h-2)); /* 琥珀 = 提醒 */
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--t-1);
  color: var(--text-2);
}

/* ═══ 工作區 ═════════════════════════════════════════════════ */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  align-items: start; /* 左右兩欄各自照內容高度，不互相拉伸 */
  gap: 1rem;
  padding: 1.25rem var(--gut) 1.5rem;
}

.doc-panel,
.readout {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── 原文 ──────────────────────────────────────────────────── */

.doc-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-tools .select-wrap {
  width: 9.5rem;
}

/* 固定高度而非撐滿：底下的圖例與統計才不會被推出視窗 */
.doc-body {
  height: clamp(18rem, 50vh, 36rem);
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.doc-view,
.doc-edit {
  height: 100%;
  padding: 1.1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: var(--t-1);
  line-height: 2;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow-y: auto;
}

.doc-view {
  cursor: text;
}

.doc-view:focus-visible {
  outline-offset: -2px;
}

.doc-edit {
  width: 100%;
  border: 0;
  background: var(--surface);
  resize: none;
}

.doc-edit:focus {
  outline: none;
}

/* 文字上的區塊底色 */
.seg {
  border-radius: 2px;
  background: oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h) / var(--chunk-wash));
  box-shadow: inset 0 -1px 0 oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h) / 0.5);
  transition: background 0.18s var(--ease);
}

/* 重疊處用兩色斜紋，一眼看出「這段屬於兩個區塊」 */
.seg-overlap {
  background: repeating-linear-gradient(
    -45deg,
    oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h) / var(--chunk-wash-2)) 0 5px,
    oklch(var(--cl2, var(--chunk-l)) var(--chunk-c) var(--h2) / var(--chunk-wash-2)) 5px 10px
  );
  box-shadow: inset 0 -1px 0 oklch(var(--cl2, var(--chunk-l)) var(--chunk-c) var(--h2) / 0.5);
}

/* 沒被任何區塊涵蓋的字元 */
.seg-gap {
  background: transparent;
  box-shadow: none;
  color: var(--text-3);
  text-decoration: underline dotted var(--text-3) 1px;
  text-underline-offset: 3px;
}

.seg.is-active {
  background: oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h) / 0.42);
}

/* 區塊起點的編號標記 */
.seg[data-mark]::before {
  content: attr(data-mark);
  display: inline-block;
  margin-right: 2px;
  padding: 0 3px;
  border-radius: 3px;
  background: oklch(var(--clm, var(--cl, var(--chunk-l))) var(--chunk-c) var(--hm, var(--h)));
  color: var(--chunk-ink);
  font-size: 9px;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: 0.35em;
  user-select: none;
}

.doc-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 0;
}

.doc-meta {
  margin: 0;
  font-size: var(--t-2);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ── 統計側欄 ──────────────────────────────────────────────── */

.readout {
  gap: 1rem;
}

.tally,
.strip-panel,
.chunk-list-panel {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tally-lead {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding-bottom: 0.7rem;
  margin-bottom: 0.7rem;
  border-bottom: 1px solid var(--line-soft);
}

.tally-number {
  font-family: var(--font-display);
  font-size: var(--t3);
  font-weight: 800;
  font-variation-settings: 'wdth' 85;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.tally-caption {
  font-size: var(--t-1);
  color: var(--text-2);
}

.tally-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.9rem;
  margin: 0;
}

.tally-grid div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.tally-grid dt {
  font-size: var(--t-2);
  color: var(--text-3);
  white-space: nowrap;
}

.tally-grid dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--t-1);
  font-variant-numeric: tabular-nums;
}

/* 每塊實際大小 */
.strip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.strip-target {
  font-family: var(--font-mono);
  font-size: var(--t-2);
  color: var(--text-3);
}

.strip {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 64px;
  overflow-x: auto;
  overflow-y: hidden;
}

.strip-bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  background: oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h) / 0.8);
  cursor: pointer;
  transition: filter 0.15s, height 0.3s var(--ease);
}

.strip-bar:hover,
.strip-bar.is-active {
  filter: brightness(1.3);
}

.strip-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed var(--text-3);
  opacity: 0.75;
  pointer-events: none;
}

.strip-note {
  margin: 0.5rem 0 0;
  font-size: var(--t-2);
  color: var(--text-3);
}

/* 區塊內容清單 */
.chunk-list-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chunk-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  align-content: start; /* 區塊少的時候不要被撐成大空卡片 */
  gap: 0.4rem;
  max-height: 26rem;
  overflow-y: auto;
}

.chunk-item {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line-soft);
  border-left: 3px solid oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h));
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.chunk-item:hover,
.chunk-item.is-active {
  border-color: var(--text-3);
  border-left-color: oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h));
  background: var(--bg-deep);
}

.chunk-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-family: var(--font-mono);
  font-size: var(--t-2);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.chunk-badge {
  color: oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h));
  font-weight: 600;
}

.chunk-text {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--t-2);
  line-height: 1.6;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-more {
  padding: 0.4rem 0.1rem;
  font-size: var(--t-2);
  color: var(--text-3);
}

.empty-note {
  padding: 1rem 0;
  font-size: var(--t-1);
  color: var(--text-3);
}

/* ═══ 頁尾 ═══════════════════════════════════════════════════ */

.colophon {
  padding: 0 var(--gut) 2rem;
  font-size: var(--t-2);
  color: var(--text-3);
}

.colophon p {
  margin: 0 0 0.25rem;
  max-width: 70ch;
}

.colophon-note {
  opacity: 0.8;
}

/* ═══ 浮動提示 ═══════════════════════════════════════════════ */

.tip {
  position: fixed;
  z-index: 50;
  max-width: 20rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--t-2);
  line-height: 1.5;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.13s, transform 0.13s;
}

.tip.is-on {
  opacity: 1;
  transform: translateY(0);
}

.tip b {
  color: oklch(var(--cl, var(--chunk-l)) var(--chunk-c) var(--h));
  font-weight: 600;
}

/* ═══ 響應式 ═════════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .workbench {
    grid-template-columns: minmax(0, 1fr) 18rem;
  }
}

@media (max-width: 900px) {
  body {
    display: block;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .doc-body {
    height: clamp(16rem, 55vh, 30rem);
  }

  .chunk-list {
    max-height: 24rem;
  }

  .field-slider {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .console {
    gap: 0.75rem 1rem;
  }

  .field-preset,
  .field-slider {
    flex: 1 1 100%;
    width: auto;
  }

  .field-toggle {
    padding-top: 0;
  }

  .tally-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
