/* 介面樣式。桌面版以單屏剪輯工具為主，避免主要控制區捲動。
   視覺世界：碑帖墨拓——墨是地，拓紙白是字，朱砂只是一方印和幾個圈點。
   （方向合約在 .impeccable/surfaces/web-index-html.md） */

/* 標題用的楷書：全字庫正楷體，只取介面標題用到的字（字表在 web/fonts/display-text.txt，
   產生方式見 scripts/subset-display-font.py）。缺字時退回系統楷書。 */
@font-face {
  font-family: "TW-Kai Display";
  src: url("/web/fonts/tw-kai-display.woff2") format("woff2");
  font-display: swap;
}

:root {
  /* 瀏覽器自己畫的部分（勾選框、下拉選單展開的清單、數字欄的上下鈕、捲軸）也走暗色，
     不然在墨地上會冒出一塊塊白色 */
  color-scheme: dark;

  /* ── 墨：烏金拓的暖黑，用蟬翼拓的灰階分層 ── */
  --ink-ground: #0d0c0b;      /* 整張拓紙的墨地 */
  --ink-panel: #12110f;       /* 面板 */
  --ink-raised: #1b1917;      /* 凸起的控制項：按鈕、下拉、輸入框 */
  --ink-sunken: #090807;      /* 凹刻：清單底、軌道 */
  /* ── 紙：拓出來的字 ── */
  --paper: #e9e3d6;           /* 主要文字、選中、強調（對墨地 15:1） */
  --paper-2: #c9c2b4;         /* 次一級的強調：數值、目前值 */
  --paper-dim: #9b9488;       /* 淡墨：次要文字、說明（6.3:1） */
  --paper-faint: #857e74;     /* 最淡的字，只用在墨地與面板上（4.7:1） */
  --rule: rgb(233 227 214 / .1);          /* 界格細線 */
  --rule-strong: rgb(233 227 214 / .2);   /* 控制項外框 */
  --paper-wash: rgb(233 227 214 / .06);   /* 選中／滑過的淡紙色 */
  /* ── 朱砂：只給三件事——出片印、選中的朱筆圈點、朱批錯誤 ── */
  --cinnabar: #b0301f;        /* 印面（配紙白字 5.6:1） */
  --cinnabar-bright: #e0563f; /* 圈點、錯誤字（對墨地 5.2:1） */
  --seal-paper: #f6efe3;      /* 印面上的字 */
  /* ── 赭石：只給警告 ── */
  --ochre: #c8964a;
  /* ── 月光：月兔的月盤，和「現在走到哪、正在調的值」——播放與出片進度、滑桿把手與數值。
        選中與焦點仍是紙白，月光不拿來當強調色 ── */
  --moon: #eedb9a;            /* 月盤、滑桿把手（對墨地 14:1） */
  --moon-2: #d5c287;          /* 進度線、滑桿數值：跟次紙白同一階亮度 */
  --mr-moon: var(--moon);     /* 月兔拓片（index.html 的 #moon-rabbit）吃這個變數上色 */

  --font-ui: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-display: "TW-Kai Display", "DFKai-SB", "BiauKai", "Kaiti TC", "STKaiti", serif;

  /* 拓包墨點：墨地上極淡的紙色斑駁＋零星白點。feTurbulence 開 stitchTiles，貼起來沒有接縫。 */
  --tex-rubbing: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='s' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='1' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.91 0 0 0 0 0.89 0 0 0 0 0.84 0.62 0 0 0 -0.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
  /* 拓出來的墨線：大致是實的，夾著拓包沒壓到的淡塊——給出片進度條當遮罩 */
  --tex-dab: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='8'%3E%3Cfilter id='d' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.3 0.8' numOctaves='2' seed='8' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 -2.6 2.1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23d)'/%3E%3C/svg%3E");

  /* ── 舊名稱沿用：既有樣式都吃這幾個變數，改指向墨拓世界 ──
     「accent」系列不再是顏色，而是紙白的強調；朱砂另外用 --cinnabar 指名。 */
  --bg: var(--ink-ground);
  --panel: var(--ink-panel);
  --panel-2: var(--ink-raised);
  --sunken: var(--ink-sunken);      /* 凹陷面：分頁列、進度條軌、樣式格、片段列、收合面板底 */
  --ink: var(--paper);              /* 主要文字（舊名「ink」指的是字色） */
  --muted: var(--paper-dim);
  --line: var(--rule);
  --accent: var(--paper);           /* 強調＝紙白：選中框、焦點 */
  --accent-2: var(--paper-2);       /* 數值、目前值 */
  --accent-ink: var(--ink-ground);  /* 紙白底上的墨字 */
  --accent-soft: var(--paper-wash); /* 選中／滑過的底 */
  --accent-glow: rgb(233 227 214 / .28); /* 焦點環 */
  --warn: var(--ochre);

  --rail: 34px;
  --spine: 28px;              /* 頻譜面板收起時剩下的書脊寬 */
  --left-panel: 300px;
  --right-panel: 320px;
  --chrome-gap: 10px;
  --top-dock-height: 44px;
  --stage-actions-height: 38px;
  /* 出片片段那一列只有載入音源後才在，沒有它時要還給預覽框，所以獨立成一個變數，
     由下面的 :has() 在它出現時翻成實際高度。 */
  --export-range-reserve: 0px;
  /* 24px＝外框上下內距（12＋12），40px＝播放列 */
  --stage-height-reserve: calc(24px + var(--top-dock-height) + var(--chrome-gap) + 8px + var(--stage-actions-height) + 10px + 40px + var(--export-range-reserve));
  /* 預覽框的比例，跟著「畫面比例」切換（見 web/frame.js）。
     --stage-aspect 給 aspect-ratio 用，--stage-aspect-num 是同一個值的純數字版，
     算「這麼高的話能有多寬」時要用它。 */
  --stage-aspect: 16 / 9;
  --stage-aspect-num: 1.7778;
  /* 預覽框自己的寬度。工具列不吃這個值——直式時預覽只有兩百多 px 寬，
     上面那條放不下出片按鈕和元件標籤，所以它們改吃整個舞台欄的寬度。 */
  --preview-width: min(100%, calc((100vh - var(--stage-height-reserve)) * var(--stage-aspect-num)));
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--tex-rubbing), var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
}

/* 楷書標題：品牌字、區塊標題、對話框標題、側欄分頁、出片印 */
.kai {
  font-family: var(--font-display);
  font-weight: 400;
}

/* 反白選取：紙白的淡底。朱砂只給印、圈點與朱批，選取不算在內 */
::selection {
  background: rgb(233 227 214 / .3);
  color: var(--paper);
}

/* 輸入框裡的提示字：淡墨，在凸起的墨底上仍有 5.8:1，看得清又不會被當成已填的值 */
::placeholder {
  color: var(--paper-dim);
  opacity: 1;
}

/* 說明文字換行時，不要只留一兩個字孤零零掛在最後一行 */
p,
li,
.subtitle-chain-hint {
  text-wrap: pretty;
}

/* 展開的內容淡入、從上面落下 4px：只動 opacity 與 transform，高度一次到位，不拉動版面 */
@keyframes reveal-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .collapsible-extra,
  .focus-detail,
  .visual-layer-body-inner {
    animation: none !important;
  }
}

/* 只給 <use> 參照的圖形庫，本身不佔位 */
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

button, input, select {
  font: inherit;
}

/* 全站下拉只有兩款外觀：這個中性款，以及高一號的 .style-select（每個面板的「主要選擇」）。
   原生的下拉箭頭在各家瀏覽器長得都不一樣，所以一律關掉 appearance、自己畫一個。
   各處只調尺寸（高度、字級、寬度），底色、邊框、箭頭都從這裡來——
   要換底色請用 background-color，用 background 簡寫會把箭頭一起洗掉。 */
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--panel-2);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239b9488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px 12px;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0 26px 0 9px;
  cursor: pointer;
}

select:hover {
  border-color: rgb(233 227 214 / .42);
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

select option {
  background: var(--panel-2);
  color: var(--ink);
}

button {
  color: inherit;
}

/* 勾選框、單選鈕：勾起來是紙白底、墨色勾（瀏覽器會自動配對比色） */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--paper);
}

.app-shell {
  --left-panel-current: var(--left-panel);
  --right-panel-current: var(--right-panel);
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--rail) var(--left-panel-current) minmax(520px, 1fr) var(--right-panel-current);
  grid-template-rows: var(--top-dock-height) minmax(0, 1fr);
  grid-template-areas:
    "header header header header"
    "rail layers stage visual";
  gap: var(--chrome-gap);
  padding: 12px;
}

.app-shell.is-left-collapsed {
  --left-panel-current: 0px;
}

/* 頻譜面板收起時不是消失，而是剩一條書脊 */
.app-shell.is-right-collapsed {
  --right-panel-current: var(--spine);
}

/* 預覽靠上：空出來的高度全部留在下方，不在預覽上下各空一截 */
.stage {
  grid-area: stage;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-items: start;
  justify-items: center;
  position: relative;
}

/* 預覽 + 播放列：上下排。整組佔滿舞台欄，預覽與播放列自己再收到 --preview-width
   並置中——上方的工具列才有整欄可用，不會被直式那個窄預覽框綁死。 */
.stage-wrap {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-height: 100%;
}

/* 碑額：窄窄一條，左邊月兔拓印記＋楷書「夜兔譜」，右邊是小型刻線按鈕。
   不做底色和光暈，只用底下一條界格線跟工作區分開。 */
.app-header {
  grid-area: header;
  position: relative;
  isolation: isolate;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 0;
  overflow: hidden;
  padding: 0 2px;
  border-bottom: 1px solid var(--rule);
}

.top-dock-brand,
.top-dock-content {
  min-width: 0;
  display: flex;
  align-items: center;
}

.top-dock-brand {
  flex: 0 1 auto;
  gap: 10px;
}

.top-dock-content {
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 6px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: none;
}

.app-header h1 {
  margin: 0;
  color: var(--paper);
  font-size: 22px;
  line-height: 1;
  letter-spacing: .12em;
}

.header-shortcut {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--paper-dim);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
}

.header-shortcut:hover,
.header-shortcut:focus-visible {
  color: var(--paper);
  border-color: rgb(233 227 214 / .42);
  background: var(--paper-wash);
}

.header-shortcut:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

.header-shortcut svg {
  flex: 0 0 auto;
}

/* 單色 YouTube 標記：播放三角挖成墨色 */
.youtube-mark .youtube-play {
  fill: var(--ink-ground);
}

/* 頂列的「更新公告」按鈕：有沒看過的新版本時，右上角點一個朱點 */
button.header-shortcut {
  position: relative;
  cursor: pointer;
}

.header-shortcut.whatsnew-link.has-news::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--paper);
}

.hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

main {
  position: relative;
  z-index: 2;
  isolation: isolate;
  width: var(--preview-width);
  margin-inline: auto;
  aspect-ratio: var(--stage-aspect);
  border-radius: 2px;
  overflow: hidden;
  /* 預覽就是成品：底色是影片的純黑，外面一條界格線像裱在冊頁上 */
  background: #000;
  outline: 1px solid var(--rule);
}

/* 畫面特效層：背景+可視化+文字一起被變形/模糊；從中心縮放，超出的部分被 main 的 overflow 裁掉 */
/* isolation：舞台特效限制在舞台內；main 的 isolation 則避免最上層 Logo 的融合穿透到頁面底色 */
#stage-fx { position: absolute; inset: 0; z-index: 0; transform-origin: center center; will-change: transform, filter; isolation: isolate; }

#tile-fx {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#tile-fx[hidden] { display: none; }

.bg-slot {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: none;
  opacity: 1;
  transition: opacity .8s linear;
  overflow: hidden;
  pointer-events: none;
}
.bg-slot.on { display: block; }
.bg-slot:not(.is-visible) { opacity: 0; }
.bg-slot.is-visible { opacity: 1; }
.bg-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.bg-media.on { display: block; }

#day-night-period-row[hidden] { display: none; }

/* 素材填滿方式（由 background.js 依素材與媒體框的比例決定，出片走同一套判斷）：
   is-contain  完整顯示——整張塞進框裡，空的地方留黑
   is-blurfill 模糊填滿——同一張素材放大模糊當底，蓋掉那圈黑邊 */
.bg-slot.is-contain { background: #000; }
.bg-slot.is-contain .bg-media { object-fit: contain; }
.bg-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.bg-slot.is-blurfill .bg-blur { display: block; }
#introvideo, #outrovideo { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; z-index: 0; }

/* 環境微光位在可視化之上、文字之下；柔光已畫進貼圖，不另加 CSS filter，
   才能讓預覽與輸出影片保持相同亮度。 */
#ambient-glow {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#ambient-glow[hidden] { display: none; }

/* Logo 是成品畫面的最上層；編輯框仍保留在它上方，方便拖曳調整。 */
#logolayer { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; pointer-events: none; }

/* 可視化方框：預設滿框，編輯模式會用 inline 樣式改 left/top/width/height（%） */
#viz { position: absolute; left: 0; top: 0; z-index: 1; width: 100%; height: 100%; }
#viz.is-hidden { opacity: 0; pointer-events: none; }

#visual-layers-viz {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#particle-viz,
#inverted-bars-viz,
#glass-ring-viz,
#neon-player-viz,
#sequin-viz,
#kinetic-viz {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 0 4px #ffffff55) drop-shadow(0 0 12px #ffffff22);
}

#particle-viz[hidden] { display: none; }
#inverted-bars-viz[hidden] { display: none; }

/* 霓虹播放器的光暈是自己畫進畫布裡的（出片才會有），
   這裡不能再加 CSS 光暈，否則預覽會比成品亮一層。 */
/* 玻璃環的光暈同樣是自己畫進畫布裡的，這裡不能再加一層 CSS 光暈。 */
#glass-ring-viz { filter: none; }
#glass-ring-viz[hidden] { display: none; }

#neon-player-viz { filter: none; }
#neon-player-viz[hidden] { display: none; }

#sequin-viz {
  filter: drop-shadow(0 0 6px #ffd58a55) drop-shadow(0 0 16px #a8744333);
}

#sequin-viz[hidden] { display: none; }

#kinetic-viz {
  filter: drop-shadow(0 0 5px #e67e2844) drop-shadow(0 0 14px #ffdc9622);
}

#kinetic-viz[hidden] { display: none; }

/* 文字 overlay：透明層，蓋在可視化上面；不吃滑鼠事件 */
#overlay { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }

/* 編輯模式的拖拉層：平時隱藏，開啟時才浮在最上面 */
#editlayer { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#editlayer[hidden] { display: none; }

.edit-guide {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgb(13 12 11 / .7);
}

.edit-guide[hidden] { display: none; }

.edit-guide-x {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-.5px);
}

.edit-guide-y {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-.5px);
}

/* 編輯版面按鈕：浮在預覽畫面右上角（出片時錄的是另一張 canvas，不會被錄進去） */
.stage-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  display: flex;
  gap: 8px;
  align-items: center;
}

.lh {
  position: absolute;
  border: 1.5px dashed var(--paper);
  border-radius: 2px;
  background: rgb(233 227 214 / .08);
  pointer-events: auto;
  cursor: move;
  box-sizing: border-box;
}

.lh:hover { background: rgb(233 227 214 / .14); }

.lh-head {
  position: absolute;
  top: -9px;
  left: 6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.lh-label {
  padding: 1px 6px;
  background: var(--paper);
  color: var(--ink-ground);
  font-size: 12px;
  border-radius: 2px;
  pointer-events: none;
}

.lh[data-name="viz"] .lh-label {
  max-width: calc(100% - 18px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 右下角縮放把手 */
.lh-grip {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: 1px;
  background: var(--paper);
  border: 1.5px solid var(--ink-ground);
  cursor: nwse-resize;
}

.stage-action-row {
  min-height: var(--stage-actions-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* 元件標籤的底端藏在預覽框後方，開啟編輯時逐一往上長出來。
   置中對齊預覽框；八個標籤加起來比直式的預覽框寬一點，左右各露出一小截，
   落在直式時本來就空著的兩側留白裡。 */
/* 沒在編的那幾層：淡虛線輪廓，純參考，不吃滑鼠。
   疊圖層時最想知道的就是「這層跟那層有沒有對齊」。 */
.lh-ghost {
  position: absolute;
  border: 1.5px dashed rgb(233 227 214 / .32);
  border-radius: 2px;
  pointer-events: none;
  box-sizing: border-box;
}
.lh-ghost.is-hidden-layer { border-style: dotted; opacity: .45; }
.lh-ghost-badge {
  position: absolute;
  top: -8px;
  left: 6px;
  padding: 0 5px;
  border-radius: 2px;
  background: rgb(233 227 214 / .2);
  color: var(--ink);
  font-size: 11px;
  line-height: 16px;
}

/* 頻譜圖層選擇列：掛在元件標籤列正下方，只有選「頻譜」時才出現 */
.edit-viz-layer-picker {
  position: absolute;
  top: 56px;
  /* left 由 editmode.js 算出來，對齊「頻譜」那一格正下方 */
  left: 50%;
  transform: translateX(-50%);
  /* 浮在預覽畫面上緣，跟「完成編輯」那組同一層，否則會被 #stage-fx 蓋掉 */
  z-index: 6;
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: rgb(13 12 11 / .92);
  box-shadow: 0 6px 16px rgb(0 0 0 / .45);
}
.edit-viz-layer-picker[hidden] { display: none; }
.edit-viz-layer-tab {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 1px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.edit-viz-layer-tab:hover { color: var(--ink); background: var(--paper-wash); }
.edit-viz-layer-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
/* 隱藏中的圖層照樣編得動，只是標示出來 */
.edit-viz-layer-tab.is-hidden-layer:not(.is-active) { opacity: .45; text-decoration: line-through; }

.edit-component-picker {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  align-items: stretch;
  gap: 4px;
  max-width: 100%;
  height: 54px;
  pointer-events: none;
}

.lh-reset {
  width: 16px;
  min-width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(233 227 214 / .6);
  border-radius: 1px;
  background: rgb(13 12 11 / .92);
  color: var(--paper);
  font: 700 11px/1 system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 1px 4px rgb(0 0 0 / .5);
}

.lh-reset:hover,
.lh-reset:focus-visible {
  border-color: var(--paper);
  background: var(--paper);
  color: var(--ink-ground);
  outline: none;
}

.edit-component-picker[hidden] {
  display: none;
}

.edit-component-tab {
  --tab-index: 0;
  --tab-reverse-index: 7;
  flex: 0 0 34px;
  width: 34px;
  height: 54px;
  display: grid;
  place-items: center;
  padding: 4px 0;
  border: 1px solid var(--rule-strong);
  border-bottom-color: transparent;
  border-radius: 2px 2px 0 0;
  background: var(--ink-raised);
  color: var(--paper-dim);
  box-shadow: 0 8px 20px rgb(0 0 0 / .45);
  /* 楷書直書：三個字（標題一）在 54px 高的籤條裡要排得下，字級與字距跟著收 */
  font-size: 13px;
  line-height: 1;
  letter-spacing: .02em;
  writing-mode: vertical-rl;
  text-orientation: upright;
  cursor: pointer;
  pointer-events: none;
  opacity: 0;
  transform: translateY(48px) scaleY(.12);
  transform-origin: bottom center;
  transition:
    transform .3s cubic-bezier(.16, 1, .3, 1),
    opacity .2s ease;
  will-change: transform, opacity;
}

/* 籤條上的拉丁字（Logo）：照直書排版的慣例側躺著排，用介面黑體，不硬塞進楷書 */
.edit-tab-latin {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: .04em;
  text-orientation: mixed;
}

.edit-component-picker.is-opening .edit-component-tab,
.edit-component-picker.is-open .edit-component-tab {
  opacity: 1;
  transform: translateY(0) scaleY(1);
}

.edit-component-picker.is-opening .edit-component-tab {
  transition-delay: calc(var(--tab-index) * 28ms);
}

.edit-component-picker.is-closing .edit-component-tab {
  transition-duration: .24s, .16s;
  transition-delay: calc(var(--tab-reverse-index) * 24ms);
}

.edit-component-picker.is-open {
  pointer-events: auto;
}

.edit-component-picker.is-open .edit-component-tab:hover:not(:disabled),
.edit-component-picker.is-open .edit-component-tab:focus-visible {
  border-color: rgb(233 227 214 / .42);
  color: var(--paper);
  background: #23201d;
  outline: none;
}

.edit-component-picker.is-open .edit-component-tab {
  pointer-events: auto;
}

/* 正在編的那一個：翻成一張紙籤（紙白底、墨字），跟預覽上的編輯框標籤同一種 */
.edit-component-picker.is-open .edit-component-tab.is-active {
  border-color: var(--paper);
  background: var(--paper);
  color: var(--ink-ground);
}

.edit-component-picker.is-open .edit-component-tab:disabled {
  opacity: .32;
  cursor: not-allowed;
}

.edit-component-tab:nth-child(1) { --tab-index: 0; --tab-reverse-index: 7; }
.edit-component-tab:nth-child(2) { --tab-index: 1; --tab-reverse-index: 6; }
.edit-component-tab:nth-child(3) { --tab-index: 2; --tab-reverse-index: 5; }
.edit-component-tab:nth-child(4) { --tab-index: 3; --tab-reverse-index: 4; }
.edit-component-tab:nth-child(5) { --tab-index: 4; --tab-reverse-index: 3; }
.edit-component-tab:nth-child(6) { --tab-index: 5; --tab-reverse-index: 2; }
.edit-component-tab:nth-child(7) { --tab-index: 6; --tab-reverse-index: 1; }
.edit-component-tab:nth-child(8) { --tab-index: 7; --tab-reverse-index: 0; }

.edit-actions {
  position: relative;
  z-index: 7;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

/* 工具列分兩組：左邊是跟出片無關的工具，右邊是「比例 → 幀率 → 兩顆出片按鈕 → 停止」。
   一條細線把兩組隔開，眼睛才不會把靜音也讀成出片流程的一部分。 */
.action-group {
  display: flex;
  gap: 8px;
  align-items: center;
}
.action-group + .action-group {
  margin-left: 6px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

/* 工具列擠不下時，按鈕要保持原本大小，不要被壓扁——按鈕文字一換行，
   整條工具列就會從 38px 撐到 82px，把預覽往下推。 */
.action-group-export {
  white-space: nowrap;
}

.action-group-export > * {
  flex: 0 0 auto;
}

/* 排版和出片是互斥的兩件事，所以編輯版面時整組收起來，上面那條全部讓給元件標籤；
   不這麼做的話，兩組並排要 663px，但舞台欄最窄只有 520px，一定會疊在一起。
   出片進行中例外——停止鍵就在這組裡，收起來就沒得按了。 */
.stage-wrap.is-editing .action-group-export:not(:has(#export-stop:not([hidden]))) {
  display: none;
}

#edittoggle[aria-pressed="true"] {
  border-color: var(--paper);
  background: var(--paper);
  color: var(--ink-ground);
}

@media (prefers-reduced-motion: reduce) {
  .edit-component-tab {
    transition-duration: .001ms !important;
    transition-delay: 0ms !important;
  }
}

/* 還沒放音樂時的起手提示。底下的示範畫面（假字幕、頻譜）壓暗但不蓋死，
   讓人先看到「放了歌會長這樣」，視線再落到中間的月兔拓片與那一句話。 */
#dropzone {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 16px;
  container-type: size;
  background: radial-gradient(ellipse 58% 72% at 50% 50%, rgb(9 8 7 / .95) 35%, rgb(9 8 7 / .72) 68%, rgb(9 8 7 / .42));
  color: var(--paper);
  text-align: center;
  cursor: pointer;
  outline: none;
  transition: background .3s cubic-bezier(.16, 1, .3, 1);
}

#dropzone.hidden,
#dropzone.editing-hidden { display: none; }

.drop-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 2.4cqmin, 12px);
  /* 拖檔經過裡面的字時不要觸發 dragleave，否則高亮會一閃一閃 */
  pointer-events: none;
}

.drop-moon {
  width: clamp(52px, 26cqmin, 112px);
  height: auto;
  margin-bottom: clamp(2px, 1.4cqmin, 10px);
  transition: transform .4s cubic-bezier(.16, 1, .3, 1);
}

.drop-title {
  font-size: clamp(20px, 7.6cqmin, 32px);
  letter-spacing: .16em;
  line-height: 1.3;
  /* 字距會在最後一個字後面多留一截，補回來才會真的置中 */
  margin-right: -.16em;
}

.drop-title-over { display: none; }

.drop-pick {
  padding: 6px 18px;
  border: 1px solid rgb(233 227 214 / .42);
  border-radius: 2px;
  font-size: 14px;
  letter-spacing: .04em;
  transition: background .2s, border-color .2s;
}

.drop-hint {
  max-width: 30em;
  color: var(--paper-dim);
  font-size: 12px;
  line-height: 1.5;
}

#dropzone:hover .drop-pick {
  border-color: rgb(233 227 214 / .72);
  background: rgb(233 227 214 / .08);
}

#dropzone:focus-visible .drop-pick {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

/* 檔案拖到預覽上：拓片微微浮起、換成「放開就載入」，框出可以放的範圍 */
#dropzone.dragover {
  background: radial-gradient(ellipse 58% 72% at 50% 50%, rgb(9 8 7 / .86), rgb(233 227 214 / .06));
}
#dropzone.dragover::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1.5px dashed rgb(233 227 214 / .45);
  border-radius: 2px;
  pointer-events: none;
}
#dropzone.dragover .drop-moon { transform: scale(1.06); }
#dropzone.dragover .drop-title-idle { display: none; }
#dropzone.dragover .drop-title-over { display: inline; }

/* 預覽很小（直式比例、窄螢幕）時先收掉說明，再收掉拓片，留下最要緊的那句話和按鈕 */
@container (max-height: 260px) {
  .drop-hint { display: none; }
}
@container (max-height: 170px) {
  .drop-moon { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #dropzone,
  .drop-moon { transition: none; }
  #dropzone.dragover .drop-moon { transform: none; }
}

/* 原生播放器整個藏起來，改用下面的 .player（web/player.js）。
   靜音只留工具列那顆喇叭：原生那顆是把音訊元素本身關掉，頻譜分析接在元素後面，
   一按下去可視化會整個停擺；工具列那顆改的是「分析之後、送到喇叭之前」的音量。 */
#audio {
  display: none;
}

/* 播放列：跟預覽同寬、貼在預覽正下方。一顆播放鍵、時間（等寬數字）、時間軸。
   「只出片段」打開時，時間軸上用一段淡紙色框出要出片的範圍。 */
.player {
  width: var(--preview-width);
  margin-inline: auto;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 32px max-content minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 2px;
}

.player-toggle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--ink-raised);
  color: var(--paper);
  cursor: pointer;
}

.player-toggle:hover:not(:disabled) {
  border-color: rgb(233 227 214 / .45);
  background: #23201d;
}

.player-toggle:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

.player-toggle:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.player-icon-pause { display: none; }
.player.is-playing .player-icon-play { display: none; }
.player.is-playing .player-icon-pause { display: block; }

.player-time {
  color: var(--paper-dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.player-sep {
  margin: 0 5px;
  color: var(--paper-faint);
}

.player-track {
  position: relative;
  height: 30px;
  display: grid;
  align-items: center;
}

/* 出片範圍：一段淡紙色＋兩條起訖細線，畫在軌道後面 */
.player-range {
  position: absolute;
  top: 50%;
  height: 12px;
  transform: translateY(-50%);
  border-inline: 1px solid var(--paper-2);
  background: rgb(233 227 214 / .12);
  pointer-events: none;
}

.player-range[hidden] { display: none; }

#player-seek {
  position: relative;
  width: 100%;
  margin: 0;
  background: linear-gradient(to right, var(--moon-2) var(--played, 0%), rgb(233 227 214 / .16) var(--played, 0%));
}

#player-seek:disabled {
  cursor: not-allowed;
  opacity: .5;
}

/* 出片片段列。
   刻意不吃 --preview-width：直式時預覽只有兩百多 px 寬，這一整列會被擠成三、四行。
   跟上方工具列同樣的取捨——吃整個舞台欄的寬度，內容置中對齊播放器。 */
.export-range-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 30px;
  flex-shrink: 0;
}

/* 這條的優先權要蓋得過上面那個 display: flex，不然瀏覽器預設的
   [hidden] { display: none } 會被壓過去，還沒選歌就先看到這一列。 */
.export-range-row[hidden] {
  display: none;
}

/* --export-range-reserve 由 main.js 量了這一列的實際高度再寫進來。
   不能寫死：視窗窄或切成直式時這一列會折行，寫死的話預覽框佔掉的高度就不夠，
   整列會被擠出視窗底下按不到。 */

/* 編輯版面時整組收起來（比照 .action-group-export 的既有規則）：
   那個模式在調構圖，出片相關的控制項全部讓位。 */
.stage-wrap.is-editing .export-range-row {
  display: none;
}

.export-range-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}

/* 未勾「只出片段」時整組變淡、不可點，但保持在版面上——
   使用者才看得到自己上次設的區間還在。 */
.export-range-fields.is-disabled {
  opacity: .45;
  pointer-events: none;
}

.export-range-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.export-range-field input {
  width: 68px;
  min-height: 30px;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.export-range-field input:focus {
  outline: none;
  border-color: var(--accent);
}

/* 長度是使用者確認自己沒設錯的唯一依據，用亮一階的紙白讓它跳出來。 */
.export-range-length {
  color: var(--accent-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.export-range-length.is-warn {
  color: var(--warn);
}

.panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  /* 同一張拓紙：墨色略淺於地。拓包墨點用 fixed 跟整頁對齊，選中分頁接上面板時看不出接縫 */
  background-color: var(--panel);
  background-image: var(--tex-rubbing);
  background-attachment: fixed;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 12px;
  overflow: hidden;
}

.layer-panel {
  grid-area: layers;
  grid-template-rows: minmax(0, 1fr);
  /* 往左貼齊 rail，消掉中間的間隙，讓 active 分頁能跟面板無縫接合 */
  margin-left: calc(-1 * var(--chrome-gap));
}

/* 頻譜面板：標頭（楷書「頻譜」＋收起鈕）＋一欄到底的設定，沒有分頁 */
.visual-panel {
  grid-area: visual;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.visual-panel .tab-content {
  flex: 1;
  min-height: 0;
}

/* 頻譜圖層、畫面動態兩區之間跟左側面板各區一樣空 20px */
.visual-panel .tab-content.active {
  gap: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.panel-title {
  margin: 0;
  color: var(--paper);
  font-size: 18px;
  line-height: 1;
  letter-spacing: .24em;
}

.panel-collapse {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
}

.panel-collapse:hover,
.panel-collapse:focus-visible {
  color: var(--paper);
  border-color: rgb(233 227 214 / .42);
  background: var(--paper-wash);
}

.panel-collapse:focus-visible,
.panel-spine:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: -2px;
}

.panel-collapse svg,
.panel-spine svg,
.rail-collapse svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 書脊：頻譜面板收起時只剩這一條直書「頻譜」，整條都能點 */
.panel-spine {
  display: none;
}

.app-shell.is-right-collapsed .visual-panel {
  padding: 0;
}

.app-shell.is-right-collapsed .visual-panel > :not(.panel-spine) {
  display: none;
}

.app-shell.is-right-collapsed .panel-spine {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
}

.panel-spine span {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 16px;
  letter-spacing: .3em;
}

.panel-spine:hover {
  color: var(--paper);
  background-color: var(--paper-wash);
}

.app-shell.is-left-collapsed .layer-panel {
  opacity: 0;
  pointer-events: none;
  padding-left: 0;
  padding-right: 0;
  border-color: transparent;
}

.tool-rail {
  grid-area: rail;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  /* 上緣讓開面板的邊，active 分頁才接得到面板的直邊 */
  padding: 10px 0 2px;
  position: relative;
  z-index: 1;
}

.rail-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0 14px;
  border: 1px solid transparent;
  border-right: 0;
  border-radius: 2px 0 0 2px;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
}

/* 直書楷字分頁，像碑上的一行字 */
.rail-item span {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 15px;
  letter-spacing: .28em;
  line-height: 1;
}

.rail-item:hover {
  color: var(--paper);
}

.rail-item:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: -3px;
}

/* 選中的分頁：跟面板同一張紙、疊住 1px 接縫，頂上點一個朱筆圈點 */
.rail-item.active {
  z-index: 2;
  width: calc(100% + 1px);  /* 多 1px 疊過面板左邊框，接縫完全消失 */
  color: var(--paper);
  background-color: var(--panel);
  background-image: var(--tex-rubbing);
  background-attachment: fixed;
  border-color: var(--rule);
}

.rail-item.active::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--cinnabar-bright);
}

.rail-collapse {
  width: 100%;
  min-height: 28px;
  margin: 0 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--paper-dim);
  border: 1px solid var(--rule);
  border-right: 0;
  border-radius: 2px 0 0 2px;
  background: transparent;
  cursor: pointer;
}

.rail-collapse:hover {
  color: var(--paper);
  border-color: rgb(233 227 214 / .42);
  background: var(--paper-wash);
}

/* 鍵盤焦點跟下面的分頁同一種紙白框，不只是滑過的淡底 */
.rail-collapse:focus-visible {
  color: var(--paper);
  outline: 2px solid var(--paper);
  outline-offset: -3px;
}

.app-shell.is-left-collapsed .rail-collapse[data-collapse-side="left"] svg {
  transform: rotate(180deg);
}

.ghost-action {
  opacity: .45;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 78px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--sunken);
}

.tab {
  min-height: 32px;
  border: 0;
  border-radius: 1px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.tab.active {
  background: var(--paper-wash);
  color: var(--paper);
  box-shadow: inset 0 0 0 1px rgb(233 227 214 / .28);
}

/* 出片：一方朱印。主按鈕＋右邊黏著的小箭頭（備用的即時錄製選單），看起來是同一方印 */
.export-split {
  display: inline-flex;
  align-items: stretch;
}

#export,
#export-more {
  min-height: 38px;
  background: var(--cinnabar);
  color: var(--seal-paper);
  border: 0;
  cursor: pointer;
}

#export {
  min-width: 72px;
  padding: 0 16px;
  border-radius: 2px 0 0 2px;
  font-size: 19px;
  letter-spacing: .14em;
  line-height: 1;
}

#export .kai {
  /* 字距會在最後一個字後面多留一截，補回來才會真的置中 */
  margin-right: -.14em;
}

#export-more {
  display: inline-grid;
  place-items: center;
  width: 28px;
  padding: 0;
  border-left: 1px solid rgb(246 239 227 / .35);
  border-radius: 0 2px 2px 0;
}

#export:hover:not(:disabled),
#export-more:hover:not(:disabled),
#export-more[aria-expanded="true"] { background: #c23a26; }
#export:focus-visible,
#export-more:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}
#export:disabled,
#export-more:disabled { opacity: .55; cursor: progress; }

/* 蓋印：按下去印面往下一壓，朱色往外暈開一圈（main.js 在按下時加 .is-stamping） */
#export.is-stamping {
  animation: seal-press .3s cubic-bezier(.16, 1, .3, 1);
}

@keyframes seal-press {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgb(176 48 31 / .6); }
  35% { transform: scale(.93); }
  100% { transform: scale(1); box-shadow: 0 0 0 12px rgb(176 48 31 / 0); }
}

/* 還沒放音樂：出片是一方還沒蓋墨的印——朱色細框、朱字，照樣看得出是主要動作，只是還不能按 */
.action-group-export.is-waiting #export:disabled,
.action-group-export.is-waiting #export-more:disabled {
  opacity: 1;
  background: transparent;
  color: var(--cinnabar-bright);
  cursor: not-allowed;
}

/* 兩顆合起來只描一圈外框，中間留一條淡淡的分隔線，看起來還是同一方印 */
.action-group-export.is-waiting #export:disabled {
  box-shadow:
    inset 1.5px 0 0 var(--cinnabar-bright),
    inset 0 1.5px 0 var(--cinnabar-bright),
    inset 0 -1.5px 0 var(--cinnabar-bright);
}

.action-group-export.is-waiting #export-more:disabled {
  border-left-color: rgb(224 86 63 / .4);
  box-shadow:
    inset -1.5px 0 0 var(--cinnabar-bright),
    inset 0 1.5px 0 var(--cinnabar-bright),
    inset 0 -1.5px 0 var(--cinnabar-bright);
}

/* 備用選單（popover 會被放到最上層，不受面板裁切）。位置由 main.js 打開前寫進 top / right。 */
.export-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  width: 264px;
  padding: 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: var(--ink-raised);
  color: var(--ink);
  box-shadow: 0 14px 36px rgb(0 0 0 / .55);
}

.export-menu-title {
  margin: 0;
  font-size: 16px;
  letter-spacing: .08em;
}

.export-menu-note {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.export-menu-options {
  display: grid;
  gap: 6px;
}

.export-menu-options button {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--sunken);
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.export-menu-options button span {
  color: var(--muted);
  font-size: 12px;
}

.export-menu-options button:hover,
.export-menu-options button:focus-visible {
  border-color: rgb(233 227 214 / .42);
  background: var(--paper-wash);
  outline: none;
}

/* 成品比例：外觀吃全站那條 select 規則，這裡只放工具列的尺寸與焦點環 */
.toolbar-select {
  min-height: 38px;
  border-radius: 2px;
  padding-left: 10px;
  font-size: 13px;
}

.toolbar-select:focus {
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* 出片進度：在工具列左側、出片印旁邊。一張月兔拓片被拓出來（寬度跟著進度走）、
   一行訊息、一條細線；完成時右邊落款一方朱印。閒置時完全收起，工具列高度不變。 */
.export-status {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 14px;
}

.export-status:not(.is-active) {
  display: none;
}

.export-rubbing {
  width: 30px;
  height: 30px;
  flex: none;
}

/* 還沒拓到的石面：淡淡一層月光 */
.export-rubbing .rubbing-stone {
  --mr-moon: rgb(238 219 154 / .13);
  --mr-rabbit: rgb(238 219 154 / .04);
}

.export-status-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.export-status .exmsg {
  min-height: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-seal {
  display: none;
  width: 26px;
  height: 26px;
  flex: none;
  place-items: center;
  border-radius: 2px;
  background: var(--cinnabar);
  color: var(--seal-paper);
  font-size: 17px;
  line-height: 1;
}

.export-status[data-state="done"] .export-seal {
  display: grid;
  animation: seal-stamp .32s cubic-bezier(.16, 1, .3, 1) both;
}

.export-status[data-state="error"] .exmsg {
  color: var(--cinnabar-bright);
}

.export-status[data-state="error"] .export-rubbing,
.export-status[data-state="stopped"] .export-rubbing {
  opacity: .45;
}

@keyframes seal-stamp {
  from { opacity: 0; transform: scale(1.4) rotate(-8deg); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  #export.is-stamping,
  .export-status[data-state="done"] .export-seal { animation: none; }
}

/* 編輯版面時上面那條讓給元件標籤（比照出片按鈕那組）；出片進行中例外 */
.stage-wrap.is-editing .stage-action-row:not(:has(#export-stop:not([hidden]))) .export-status {
  display: none;
}

.progress {
  height: 4px;
  background: rgb(233 227 214 / .07);
  overflow: hidden;
}

#exfill {
  width: 0;
  height: 100%;
  background: var(--moon-2);
  -webkit-mask: var(--tex-dab) repeat;
  mask: var(--tex-dab) repeat;
}

/* 工具列的小方鈕：設定檔、靜音、停止 */
.iconbtn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--ink-raised);
  color: var(--paper-dim);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  cursor: pointer;
}

.iconbtn:hover {
  color: var(--paper);
  border-color: rgb(233 227 214 / .42);
  background: #23201d;
}

.iconbtn:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

.iconbtn svg { display: block; }

#export-stop[hidden] { display: none; }

/* 停止：朱批色的細框，不搶出片印的戲 */
#export-stop {
  color: var(--cinnabar-bright);
  border-color: rgb(224 86 63 / .5);
  background: transparent;
}

#export-stop:hover {
  color: #f07a63;
  border-color: var(--cinnabar-bright);
  background: rgb(176 48 31 / .16);
}

#export-stop:disabled {
  opacity: .55;
  cursor: progress;
}

#record-mute[aria-pressed="false"] .sound-off,
#record-mute[aria-pressed="true"] .sound-on {
  display: none;
}

/* 已靜音：赭石，提醒喇叭沒聲音（成品不受影響） */
#record-mute[aria-pressed="true"] {
  color: var(--ochre);
  border-color: rgb(200 150 74 / .5);
  background: rgb(200 150 74 / .1);
}

#record-mute[aria-pressed="true"]:hover {
  border-color: var(--ochre);
}

/* 設定檔彈出視窗 */
.settings-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 20px;
  background-color: var(--panel);
  background-image: var(--tex-rubbing);
  color: var(--ink);
  box-shadow: 0 24px 60px rgb(0 0 0 / .66);
}

.settings-dialog::backdrop {
  background: rgb(9 8 7 / .74);
}

.settings-dialog .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-dialog h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: .1em;
}

.dialog-x {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.dialog-x:hover { color: var(--ink); border-color: rgb(233 227 214 / .42); }
.dialog-x svg { width: 16px; height: 16px; }
.dialog-x:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

.dialog-desc {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.dialog-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.dialog-row label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
}

.settings-dialog #pf-select {
  min-height: 36px;
  border-radius: 2px;
  padding-left: 10px;
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.dialog-actions .filebtn,
.dialog-actions .linkbtn {
  min-height: 36px;
}

.dialog-actions #pf-apply { flex: 1; }
.dialog-actions #pf-save { flex: 1; }

.dialog-io {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.dialog-io-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
  margin-right: auto;
}

/* <label> 做成的按鈕（例：匯入檔案）：<button> 會自己把字垂直置中，label 不會，要明講，
   不然跟旁邊的按鈕放在一起時字會往上偏 */
label.linkbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-dialog button:disabled,
.settings-dialog label.linkbtn[aria-disabled='true'] {
  opacity: .4;
  cursor: not-allowed;
}

.settings-dialog button:disabled:hover {
  border-color: rgb(233 227 214 / .12);
  background: var(--panel-2);
  color: var(--ink);
}

/* 更新公告視窗（內容寫在 web/releaseNotes.js） */
.whatsnew-dialog {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 20px;
  background-color: var(--panel);
  background-image: var(--tex-rubbing);
  color: var(--ink);
  box-shadow: 0 24px 60px rgb(0 0 0 / .66);
}

.whatsnew-dialog::backdrop {
  background: rgb(9 8 7 / .74);
}

.whatsnew-dialog .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.whatsnew-dialog h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: .1em;
}

.whatsnew-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  max-height: min(54vh, 430px);
  overflow-y: auto;
  padding-right: 4px;
}

.whatsnew-item {
  padding: 14px 2px;
  border-top: 1px solid var(--rule);
}

.whatsnew-item:first-child {
  padding-top: 2px;
  border-top: 0;
}

.whatsnew-item-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.whatsnew-title {
  margin: 0;
  color: var(--paper);
  font-size: 15px;
  font-weight: 600;
}

/* 版本號・日期：跟在標題後面的小字，不搶標題 */
.whatsnew-meta {
  color: var(--paper-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

/* 「最新」：一張紙白細框的小籤 */
.whatsnew-badge {
  margin-left: auto;
  padding: 1px 7px;
  border: 1px solid rgb(233 227 214 / .45);
  border-radius: 2px;
  color: var(--paper);
  font-size: 12px;
  letter-spacing: 1px;
}

.whatsnew-points {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.whatsnew-points li + li { margin-top: 4px; }

.whatsnew-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.whatsnew-actions .linkbtn,
.whatsnew-actions .filebtn {
  min-height: 36px;
}

/* 確認小視窗（防誤觸：重設版面 / 恢復造型預設…） */
.confirm-dialog {
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 20px;
  background-color: var(--panel);
  background-image: var(--tex-rubbing);
  color: var(--ink);
  box-shadow: 0 24px 60px rgb(0 0 0 / .66);
}

.confirm-dialog::backdrop {
  background: rgb(9 8 7 / .74);
}

.confirm-dialog h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: .1em;
}

.confirm-dialog #confirm-msg {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-line; /* 通知裡的換行（例：被略過的檔名一行一個）照原樣排 */
  overflow-wrap: anywhere;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-actions .linkbtn,
.confirm-actions .filebtn {
  min-height: 36px;
  padding: 0 16px;
}

/* 字型展開裡的授權提醒（本機字型的保存說明在「載入本機字型」視窗裡） */
.font-local-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.font-local-note a,
.font-license-links a {
  color: var(--paper);
  text-underline-offset: 3px;
  white-space: nowrap;
}

.font-local-note a:hover,
.font-license-links a:hover {
  color: var(--seal-paper);
}

.font-license-dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 20px;
  background-color: var(--panel);
  background-image: var(--tex-rubbing);
  color: var(--ink);
  box-shadow: 0 24px 60px rgb(0 0 0 / .66);
}

.font-license-dialog::backdrop {
  background: rgb(9 8 7 / .74);
}

.font-license-dialog .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.font-license-dialog h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: .1em;
}

.font-license-filename {
  margin: -6px 0 14px;
  padding: 8px 10px;
  border-radius: 2px;
  background: var(--paper-wash);
  color: var(--paper-2);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.font-license-check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--sunken);
  color: var(--paper-2);
  font-size: 13px;
  line-height: 1.7;
  cursor: pointer;
}

.font-license-check:focus-within {
  border-color: var(--paper);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.font-license-check input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.font-license-links {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.font-license-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.font-license-actions .linkbtn,
.font-license-actions .filebtn {
  min-height: 36px;
  padding: 0 16px;
}

.font-license-actions .filebtn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* 系統字型：字型展開裡「瀏覽 / 手動輸入字型名稱」那一列 */
.sysfont-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
}

.sysfont-row input {
  flex: 1 1 120px;
  min-width: 120px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--sunken);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.sysfont-row input:focus {
  outline: none;
  border-color: var(--paper);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.sysfont-row .linkbtn { flex: 0 0 auto; white-space: nowrap; }

.sysfont-msg {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.sysfont-msg.is-error { color: var(--cinnabar-bright); }

/* 系統字型挑選視窗 */
.sysfont-search {
  width: 100%;
  min-height: 34px;
  margin: 0 0 10px;
  padding: 0 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--sunken);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.sysfont-search:focus {
  outline: none;
  border-color: var(--paper);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.sysfont-list {
  max-height: min(46vh, 340px);
  overflow-y: auto;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--sunken);
}

.sysfont-list label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--rule);
  color: var(--paper-2);
  cursor: pointer;
}

.sysfont-list label:last-child { border-bottom: 0; }
.sysfont-list label:hover { background: rgb(233 227 214 / .04); }

.sysfont-list input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* 每個字型用它自己的樣子顯示，方便直接看出是哪一款 */
.sysfont-list .sysfont-sample {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.5;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sysfont-empty {
  padding: 18px 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* 破壞性動作：朱批色的細框，不做實心，避免跟出片印搶 */
.filebtn.danger {
  border-color: rgb(224 86 63 / .45);
  color: var(--cinnabar-bright);
}

.filebtn.danger:hover {
  border-color: var(--cinnabar-bright);
  background: rgb(176 48 31 / .16);
  color: #f07a63;
}

.exmsg {
  min-height: 16px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tab-content {
  min-height: 0;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding-right: 6px; /* 數值不要貼著捲軸，留一點空 */
  scrollbar-width: thin;
  scrollbar-color: rgb(233 227 214 / .12) transparent;
}

/* 細一點、配色一致的捲軸（取代瀏覽器預設的醜捲軸） */
.tab-content.active::-webkit-scrollbar {
  width: 8px;
}
.tab-content.active::-webkit-scrollbar-track {
  background: transparent;
}
.tab-content.active::-webkit-scrollbar-thumb {
  background: rgb(233 227 214 / .12);
  border-radius: 0;
}
.tab-content.active::-webkit-scrollbar-thumb:hover {
  background: rgb(233 227 214 / .2);
}

.group {
  min-height: 0;
  flex-shrink: 0; /* 不讓 group 被 flex 壓縮，讓容器去 scroll */
}

.group h2 {
  margin: 0 0 9px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent-2);
}

/* 面板內的次分區（樣式參數 / 顏色）：靠 .list-section 小標 + 細線分段，
   跟左側面板同一套語言（不再用大 h2 或邊框） */
.panel-section {
  margin-top: 6px;
}

.style-picker-section {
  margin-top: 0;
}

.style-picker-section .style-select {
  margin-top: 8px;
}

/* 跟著上面的選擇出現／收起的一塊（例：畫面動態的效果參數）。
   收起就直接不排版；出現時高度一次到位，內容淡入。 */
.collapsible-extra {
  /* 在可捲動的 flex 面板內保留完整內容高度，不讓 flex 把這塊壓矮 */
  flex-shrink: 0;
  animation: reveal-in .24s cubic-bezier(.2, .8, .2, 1);
}

.collapsible-extra.is-collapsed {
  display: none;
}

/* 素材模式切換：「分開素材」＝音樂+底景各自上傳；「已有成片」＝一支已經做好
   背景與音樂的影片，這時音樂／片頭／片尾整組收起來（成片裡本來就有了）。 */
.asset-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--sunken);
}

.asset-mode-opt {
  min-height: 30px;
  border: 0;
  border-radius: 1px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.asset-mode-opt:hover {
  color: var(--ink);
}

.asset-mode-opt.is-on {
  background: var(--paper-wash);
  color: var(--paper);
  box-shadow: inset 0 0 0 1px rgb(233 227 214 / .28);
}

/* 朱筆圈點：分頁、模式這類「現在在哪一個」的選擇，在字前點一個朱點 */
.asset-mode-opt.is-on::before,
.subtitle-tab.active::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--cinnabar-bright);
  vertical-align: middle;
  transform: translateY(-1px);
}

.asset-mode-note {
  margin: 6px 2px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* 兩種模式只顯示自己那一組列 */
#asset-item-list[data-mode="parts"] [data-mode-only="film"],
#asset-item-list[data-mode="film"] [data-mode-only="parts"] {
  display: none;
}

.layer-list-group {
  flex-shrink: 0;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-section-title {
  margin-top: 16px;
}

/* 區塊題名：一條界格線把同類項目框成一組，掃一眼就分得出段落 */
.list-section {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 2px 0;
}

.list-section:first-of-type {
  margin-top: 0;
}

/* 新的一區上方留得比下方寬（上 20px、下 8px），題名才讀得出是「下面這組」的開頭 */
.layer-list > .list-group + .list-section {
  margin-top: 14px;
}

/* 「分開素材」時成片那組整個收起，「聲音」其實是第一區，不用再空一段 */
#asset-item-list[data-mode="parts"] > .list-group[data-mode-only="film"] + .list-section {
  margin-top: 6px;
}

/* 區塊題名是楷書，像碑上分段的小題，用紙白、比列名大一號；
   右邊拉一道文武線（古籍邊欄的一粗一細）到底，跟列與列之間的單根細線分得開 */
.list-section-title {
  color: var(--paper);
  font-size: 16px;
  letter-spacing: .24em;
  white-space: nowrap;
}

.list-section-line {
  flex: 1;
  box-sizing: border-box;
  height: 4px;
  border-top: 2px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
}

/* 次一層的分段（頻譜圖層裡的樣式參數／顏色、畫面動態的效果參數）：小一號、次紙白、單根細線 */
.list-section.is-sub .list-section-title {
  color: var(--paper-2);
  font-size: 14px;
  letter-spacing: .2em;
}

.list-section.is-sub .list-section-line {
  height: 1px;
  border: 0;
  background: var(--rule);
}

/* 同一區塊的項目直接排在標題下面，用列與列之間的界格線分開 */
.list-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}

/* 右側面板的群組（滑桿 / 色票）：列本身已有 padding 與底線分隔，不需要再加間距。
   只歸零直向間距——橫向那個是 .inline-controls 用來排欄的，清掉欄線就會黏在一起。 */
.visual-panel .list-group {
  row-gap: 0;
}

/* 區塊小標那一行裡的操作鈕（例如「重設」）：縮小、不撐高整行 */
.list-section .linkbtn {
  min-height: 22px;
  padding: 0 8px;
  font-size: 12px;
}

/* 一列設定＝一行界格：不做卡片框，只在下緣一條細線 */
.layer-item {
  border: 1px solid transparent;
  border-bottom-color: var(--rule);
  border-radius: 2px;
  background: transparent;
  outline: none;
  transition:
    background .16s ease,
    border-color .16s ease,
    box-shadow .16s ease,
    transform .16s ease;
}

/* 一組的最後一列不畫底線：下一區的文武線已經把段落隔開，兩條線疊在一起反而分不出層級 */
.list-group > .layer-item:last-child {
  border-bottom-color: transparent;
}

.layer-item:hover {
  background: rgb(233 227 214 / .03);
}

.layer-item:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.layer-item .asset-row {
  border-bottom: 0;
}

/* 列首的線條圖示（index.html 共用圖形庫裡的 #i-*） */
.layer-icon {
  width: 16px;
  height: 16px;
  color: var(--paper-dim);
  justify-self: center;
  align-self: center;
}

.layer-item .content-control-row {
  display: grid;
  grid-template-columns: 18px 62px minmax(0, 1fr);
}

.layer-item .content-control-row .inline-check {
  justify-self: start;
}

.inline-text-input {
  min-width: 0;
  width: 100%;
  min-height: 36px;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0 10px;
  font-size: 14px;
}

.inline-text-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* 字型列：「預設字型」右邊直接就是下拉，最常用的這一步不用展開；
   載入本機字型、系統字型收在展開裡（.font-advanced） */
#font-row > .asset-name {
  flex: 0 0 auto;
}

#font-row > select {
  flex: 1 1 0;
  min-width: 0;
  min-height: 30px;
  color: var(--ink);
  font-size: 13px;
}

.font-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 文字設定裡字幕那一列：一句「在哪裡設定」對齊上面各列的欄位起點，前往鈕靠右 */
.content-link {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.content-link .asset-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 片頭：秒數輸入 + 「秒」單位，跟「片頭」同一行 */
.intro-secs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.intro-secs .numin {
  width: 52px;
  padding: 0 6px;
  min-height: 30px;
}

/* 片尾勾了「使用片頭」時：片尾那列還看得到，但秒數/檔案改了也沒作用，先淡掉並停用 */
.asset-row.is-muted {
  opacity: .55;
}

.filebtn.is-disabled {
  pointer-events: none;
  opacity: .5;
}

/* 片頭/片尾進階設定：開關那一列沒有左邊的標籤欄，說明就直接跟在勾選下面；完成鈕靠右 */
.intro-advanced .intro-solid-field,
.outro-advanced .outro-use-intro-field {
  padding: 5px 0;
}

.intro-advanced .focus-foot,
.outro-advanced .focus-foot {
  justify-content: flex-end;
}

/* 「數字＋單位」欄（例：停留秒數 3 秒）：窄面板下單位也要跟數字同一行，
   所以不換行、間距收窄，空間不夠時讓數字欄自己縮，而不是把「秒」擠到下一行。 */
.checkrow.numrow {
  flex-wrap: nowrap;
  gap: 7px;
}

.numrow .numin {
  width: 90px;
  min-width: 0;
  flex: 0 1 auto;
}

/* ── 聚焦模式：點一列 → 升到頂端展開細項，其餘被深色遮罩蓋住，一次只專注一個元素 ── */
.focus-list {
  position: relative;
}

/* 遮罩：蓋住整個清單（含展開後變高的範圍），點它就收合 */
.focus-scrim {
  position: absolute;
  inset: -6px;
  z-index: 5;
  border-radius: 3px;
  background: rgb(9 8 7 / .84);
  opacity: 0;
  cursor: pointer;
  transition: opacity .3s ease;
}
.focus-scrim[hidden] { display: none; }
.focus-list.is-open .focus-scrim { opacity: 1; }

.focus-item {
  position: relative;
  transition:
    transform .42s cubic-bezier(.2, .8, .2, 1),
    box-shadow .28s ease,
    border-color .28s ease;
  will-change: transform;
}

/* 被選中的那張：浮到遮罩之上、往上滑到頂端（--rise 由 JS 量出）、描邊加亮 */
.focus-list.is-open .focus-item.is-active {
  z-index: 6;
  transform: translateY(var(--rise, 0px));
  border-color: rgb(233 227 214 / .45);
  background: var(--panel);
  box-shadow: 0 16px 36px rgb(0 0 0 / .65);
}

/* 標頭是開關：沒展開點了展開、展開中再點收合，所以永遠是 pointer */
.focus-head {
  cursor: pointer;
}

/* ── 「還有進階設定」記號 ──
   展開卡片收起來時跟一般欄位長得一樣，使用者不會知道能點。
   registerDisclosure() 會幫每張卡片掛上 .has-more：名稱後面畫一個小箭頭（往下＝還有東西），
   展開後翻向上。用細線畫的，不用字元，跟其他圖示同一種筆畫。 */
.has-more {
  position: relative;
}

.has-more > .focus-head .asset-name::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: var(--paper-dim);
  transform: translateY(-3px) rotate(45deg);
  transition: transform .2s ease;
}

.has-more:hover > .focus-head .asset-name::after {
  color: var(--paper);
}

.has-more.is-active > .focus-head .asset-name::after {
  transform: translateY(1px) rotate(-135deg);
}

/* 名稱本身就是開關（main.js 的 markDisclosure 掛上 role="button"），鍵盤停在上面時要看得到 */
.focus-head .asset-name[role="button"] {
  border-radius: 1px;
  cursor: pointer;
}

.focus-head .asset-name[role="button"]:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

/* 字幕樣式卡的標頭只有一顆下拉，「進階設定」開關是下拉右邊的一顆小鈕（markDisclosure 補上的）。
   下拉本身已經有往下的箭頭，所以這裡用調整鈕的圖示，不再並排兩個一樣的箭頭。 */
.subtitle-style-item.has-more > .subtitle-style-head {
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
}

.disclosure-toggle {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
}

.disclosure-toggle::before {
  content: '';
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 7h9M17 7h3M4 17h3M11 17h9'/%3E%3Ccircle cx='15' cy='7' r='2'/%3E%3Ccircle cx='9' cy='17' r='2'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 7h9M17 7h3M4 17h3M11 17h9'/%3E%3Ccircle cx='15' cy='7' r='2'/%3E%3Ccircle cx='9' cy='17' r='2'/%3E%3C/svg%3E") center / 16px no-repeat;
}

.has-more:hover .disclosure-toggle,
.has-more.is-active .disclosure-toggle {
  color: var(--paper);
}

.disclosure-toggle:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .has-more > .focus-head .asset-name::after { transition: none; }
}

/* 細項面板：平時不排版；選中時直接展開成完整高度（不設上限，項目再多也不會被裁掉），
   內容淡入。卡片往上滑到頂端的那段由 .focus-item 的 transform 負責。 */
.focus-detail {
  padding: 2px 10px 12px 34px;
}
.focus-item:not(.is-active) .focus-detail {
  display: none;
}
.focus-item.is-active .focus-detail {
  animation: reveal-in .26s cubic-bezier(.2, .8, .2, 1);
}

/* 細項面板底部：套用到全部 / 完成 */
.focus-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgb(233 227 214 / .05);
}
.focus-foot .fx-applyall {
  margin-right: auto;
}

.asset-row {
  min-height: 42px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 7px 6px;
  border-bottom: 1px solid var(--rule);
  border-radius: 2px;
  transition: background .16s, box-shadow .16s, border-color .16s;
}

/* 名稱占滿中間、狀態緊接其後；操作鈕成組靠右，空間不足時整組換到下一行而不擠成一團 */
.asset-row > .layer-icon { flex: 0 0 18px; }
.asset-row > .asset-name { flex: 1 1 auto; min-width: 0; }
.asset-row > .asset-status { flex: 0 1 auto; min-width: 0; }
.asset-row > .intro-secs { flex: 0 0 auto; }

.row-actions {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.asset-row.drop-hover {
  background: var(--paper-wash);
  border-bottom-color: rgb(233 227 214 / .4);
  box-shadow: inset 0 0 0 1px var(--paper);
}

.asset-name {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-status {
  min-width: 0;
  justify-self: start;
  max-width: 100%;
  color: var(--paper-faint);
  background: transparent;
  border-radius: 2px;
  padding: 3px 6px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 已載入：字亮成紙白；未載入維持最淡的字。不用綠色，墨拓世界只有墨、紙、朱、赭 */
.asset-status.ok {
  color: var(--paper);
}

.asset-status.warn {
  color: var(--warn);
  background: rgb(200 150 74 / .1);
}

.logo-controls {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px 38px;
}

.logo-position-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.logo-position-tools .linkbtn {
  min-width: 0;
  padding-inline: 8px;
}

.logo-position-tools .linkbtn.active {
  color: var(--paper);
  border-color: rgb(233 227 214 / .45);
  background: var(--paper-wash);
}

/* 還沒上傳 Logo：透明度與位置先鎖住（main.js 的 lockLogoControls），
   跟片頭／片尾的秒數欄同一種淡法，看得出「現在不能改」 */
.logo-controls.is-locked {
  opacity: .35;
}

.logo-controls.is-locked :is(input, button) {
  cursor: not-allowed;
}

.logo-advanced .focus-foot {
  justify-content: flex-end;
}

.filebtn {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0 10px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.filebtn:hover,
.filebtn.drop-hover {
  border-color: rgb(233 227 214 / .42);
  background: #23201d;
}

.filebtn:focus-visible,
.linkbtn:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

.linkbtn {
  min-height: 30px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  color: var(--muted);
  padding: 0 9px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.linkbtn:hover {
  color: var(--ink);
  border-color: rgb(233 227 214 / .42);
}

/* 停用的按鈕：滑過去不要有反應，游標也說明「現在不能按」，免得看起來還能按 */
.linkbtn:disabled,
.filebtn:disabled {
  cursor: not-allowed;
}

.linkbtn:disabled:hover {
  color: var(--muted);
  border-color: var(--rule-strong);
}

.filebtn:disabled:hover {
  border-color: var(--rule-strong);
  background: var(--panel-2);
}

.cliplist {
  max-height: 148px;
  margin: 7px 0 4px;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
}

.cliplist:empty { display: none; }

/* 跟右側面板一致的細捲軸（取代瀏覽器預設的亮色醜捲軸） */
.cliplist {
  scrollbar-width: thin;
  scrollbar-color: rgb(233 227 214 / .12) transparent;
}
.cliplist::-webkit-scrollbar { width: 8px; }
.cliplist::-webkit-scrollbar-track { background: transparent; }
.cliplist::-webkit-scrollbar-thumb { background: rgb(233 227 214 / .12); border-radius: 0; }
.cliplist::-webkit-scrollbar-thumb:hover { background: rgb(233 227 214 / .2); }

.clip {
  min-height: 34px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--sunken);
  color: var(--muted);
  font-size: 12px;
}

.clip.dragging {
  opacity: .55;
}

.clip-over {
  border-color: var(--accent);
}

.drag-handle {
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: grab;
  user-select: none;
}

.drag-handle .icon {
  width: 14px;
  height: 14px;
}

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

.clip .clip-actions {
  display: flex;
  gap: 4px;
}

.clip .linkbtn {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.subtitle-workbench {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 8px 10px;
}

/* 展開時的描邊/陰影沿用 .focus-list.is-open .focus-item.is-active 的統一樣式，這裡不另外定義 */

/* 標頭只剩模式下拉，佔滿整列。外觀走 .style-select，
   跟頻譜造型、效果選擇那兩顆「主要選擇」同一款。 */
.subtitle-style-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.subtitle-style-basic {
  display: grid;
  gap: 2px;
  padding: 2px 10px 10px 34px;
  border-top: 1px solid rgb(233 227 214 / .05);
}

.subtitle-style-basic[hidden],
.subtitle-normal-advanced[hidden],
.subtitle-sequence-advanced[hidden] {
  display: none !important;
}

/* 模式專屬欄位會由 JS 切換 hidden；.inline-field 的 display:grid 會蓋過瀏覽器預設隱藏，
   所以在字幕樣式面板內明確恢復 hidden 的優先權。 */
.subtitle-style-basic [hidden],
.subtitle-normal-advanced [hidden],
.subtitle-sequence-advanced [hidden] {
  display: none !important;
}

.subtitle-normal-advanced .focus-foot,
.subtitle-sequence-advanced .focus-foot {
  justify-content: flex-end;
}

.subtitle-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.subtitle-tab {
  min-height: 30px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--sunken);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.subtitle-tab.active {
  border-color: rgb(233 227 214 / .45);
  background: var(--paper-wash);
  color: var(--paper);
}

.subtitle-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subtitle-panel[hidden] {
  display: none !important;
}

.subtitle-cue-list-wrap {
  min-height: 92px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--sunken);
  scrollbar-width: thin;
  scrollbar-color: rgb(233 227 214 / .12) transparent;
}

.subtitle-cue-list-wrap::-webkit-scrollbar { width: 8px; }
.subtitle-cue-list-wrap::-webkit-scrollbar-track { background: transparent; }
.subtitle-cue-list-wrap::-webkit-scrollbar-thumb { background: rgb(233 227 214 / .12); border-radius: 0; }
.subtitle-cue-list-wrap::-webkit-scrollbar-thumb:hover { background: rgb(233 227 214 / .2); }

.subtitle-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

/* display:flex 會蓋掉 [hidden]，補回來（有字幕時要藏起空狀態） */
.subtitle-empty[hidden] {
  display: none;
}

.subtitle-cue-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
}

.subtitle-cue {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  width: 100%;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: rgb(233 227 214 / .03);
  color: var(--ink);
  padding: 7px;
  text-align: left;
  cursor: pointer;
}

.subtitle-cue:hover {
  border-color: rgb(233 227 214 / .13);
  background: rgb(233 227 214 / .05);
}

.subtitle-cue.active {
  border-color: rgb(233 227 214 / .45);
  background: var(--paper-wash);
}

.subtitle-cue.has-issue {
  border-color: rgb(200 150 74 / .45);
}

.subtitle-cue-index {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.subtitle-cue-main {
  min-width: 0;
  overflow: hidden;
}

.subtitle-cue-time {
  display: block;
  min-width: 0;
  color: var(--paper-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtitle-cue-text {
  display: block;
  min-width: 0;
  margin-top: 3px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtitle-cue-issue {
  margin-top: 4px;
  color: var(--warn);
  font-size: 12px;
}

.subtitle-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgb(233 227 214 / .05);
  padding-top: 10px;
}

/* class 設了 display:flex，會蓋掉 hidden 屬性的 [hidden]{display:none}；
   補一條同名覆蓋，讓 subtitleEditor.hidden = true 真的能藏起來（未選字幕時） */
.subtitle-editor[hidden] {
  display: none;
}

.subtitle-time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.subtitle-time-grid label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.subtitle-time-grid input,
#subtitle-text,
#subtitle-raw-text {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 13px;
}

.subtitle-time-grid input {
  min-height: 34px;
  padding: 0 9px;
  font-variant-numeric: tabular-nums;
}

#subtitle-text,
#subtitle-raw-text {
  resize: vertical;
  padding: 9px;
  line-height: 1.5;
}

.subtitle-time-grid input:focus,
#subtitle-text:focus,
#subtitle-raw-text:focus {
  outline: none;
  border-color: var(--accent);
}

.subtitle-actions,
.subtitle-tools,
.subtitle-offset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.subtitle-actions .linkbtn,
.subtitle-tools .linkbtn {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.subtitle-chain-option {
  position: relative;
  display: grid;
  width: 100%;
  box-sizing: border-box;
  grid-template-columns: 17px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: rgb(233 227 214 / .02);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.subtitle-chain-option:hover {
  border-color: rgb(233 227 214 / .14);
  background: rgb(233 227 214 / .03);
}

.subtitle-chain-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.subtitle-chain-box {
  display: grid;
  width: 17px;
  height: 17px;
  box-sizing: border-box;
  place-items: center;
  margin-top: 1px;
  border: 1px solid rgb(233 227 214 / .32);
  border-radius: 1px;
  background: var(--panel-2);
  transition: border-color 160ms ease, background 160ms ease;
}

/* 勾號用兩條細線畫出來 */
.subtitle-chain-box::after {
  content: '';
  width: 8px;
  height: 4px;
  border-left: 2px solid var(--ink-ground);
  border-bottom: 2px solid var(--ink-ground);
  opacity: 0;
  transform: translateY(-1px) rotate(-45deg) scale(.7);
  transition: opacity 120ms ease, transform 120ms ease;
}

.subtitle-chain-option input:checked + .subtitle-chain-box {
  border-color: var(--paper);
  background: var(--paper);
}

.subtitle-chain-option input:checked + .subtitle-chain-box::after {
  opacity: 1;
  transform: translateY(-1px) rotate(-45deg) scale(1);
}

.subtitle-chain-option input:focus-visible + .subtitle-chain-box {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

.subtitle-chain-copy {
  min-width: 0;
}

.subtitle-chain-title,
.subtitle-chain-hint {
  display: block;
}

.subtitle-chain-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.subtitle-chain-hint {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.fx-mode-section {
  flex-shrink: 0;
  margin-top: 0;
}

/* 「效果參數」跟上面的效果下拉隔開：16px，比面板各區之間（20px）略窄，讀得出是「畫面動態」底下的一段。
   間距放在可收合區裡面，選「關閉」收起參數區時這段空白也一起收掉。 */
#fx-tweaks > .list-section:first-child {
  margin-top: 16px;
}

.danger-link {
  border-color: rgb(224 86 63 / .4);
  color: var(--cinnabar-bright);
}

.danger-link:hover {
  border-color: var(--cinnabar-bright);
  color: #f07a63;
}

.subtitle-editor-msg {
  min-height: 16px;
  color: var(--warn);
  font-size: 12px;
  line-height: 1.35;
}

/* AI 字幕對齊面板 */
.ai-align-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ai-align-field a {
  color: var(--paper);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ai-align-field a:hover {
  color: var(--seal-paper);
}

.ai-align-field input,
#ai-align-lyrics {
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--panel-2);
}

.ai-align-field input,
.ai-align-field select,
#ai-align-lyrics {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
}

.ai-align-field input,
.ai-align-field select {
  min-height: 34px;
}

.ai-align-field input {
  padding: 0 9px;
}

#ai-align-lyrics {
  resize: vertical;
  padding: 9px;
  line-height: 1.5;
}

.ai-align-field input:focus,
.ai-align-field select:focus,
#ai-align-lyrics:focus {
  outline: none;
  border-color: var(--accent);
}

/* 套用歌詞：對齊完成後才能按，做成整排的紙白主要按鈕（墨字）。朱印只留給出片。 */
.ai-align-apply {
  width: 100%;
  min-height: 40px;
  justify-content: center;
  border-color: var(--paper);
  background: var(--paper);
  color: var(--ink-ground);
  font-size: 14px;
  font-weight: 600;
}

.ai-align-apply:hover:not(:disabled) {
  border-color: var(--seal-paper);
  background: var(--seal-paper);
}

/* 沒有 AI 對齊輸出時：常駐但變暗、不可按 */
.ai-align-apply:disabled {
  border-color: var(--rule-strong);
  background: rgb(233 227 214 / .05);
  color: var(--muted);
  cursor: not-allowed;
  filter: none;
}

.subtitle-tools {
  border-top: 1px solid rgb(233 227 214 / .05);
  padding-top: 10px;
}

.subtitle-offset-row {
  color: var(--muted);
  font-size: 12px;
}

.subtitle-offset-row .numin {
  width: 70px;
  min-height: 28px;
  font-size: 12px;
}

/* 粗體 / 陰影 勾選列 */
.checkrow {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

/* 顏色選項：文字標籤 + 色塊，一組一組排在 checkrow 裡 */
.coloropt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

/* checkrow 裡的色塊 / 下拉，不要被上面那條控制項規則撐成滿版 */
.checkrow input[type="color"] { width: 32px; height: 26px; min-height: 0; }
.checkrow select { width: auto; min-height: 30px; }
.checkrow input:disabled { opacity: 0.35; cursor: not-allowed; }

/* 停用的數字欄（例：還沒上傳素材的片頭秒數）：連旁邊的單位一起淡掉，看得出「現在不能改」 */
.numin:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.numin:disabled + .unit {
  opacity: 0.35;
}

/* 一行式欄位裡的下拉／輸入框：高度跟同一組的滑桿對得上，所以比全站其他輸入框小一號 */
.inline-field > select,
.inline-field > input[type="text"],
.inline-field > input[type="number"] {
  min-width: 0;
  width: 100%;
  min-height: 30px;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  font-size: 13px;
}

.inline-field > input[type="text"],
.inline-field > input[type="number"] {
  background: var(--panel-2);
  padding: 0 8px;
}

/* 下拉的右邊要留給箭頭，不能跟輸入框一樣用對稱的 padding */
.inline-field > select {
  padding-left: 8px;
}

.inline-field > select:focus,
.inline-field > input:focus {
  outline: none;
  border-color: var(--accent);
}

.numin {
  width: 64px;
  min-height: 34px;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0 9px;
  font-size: 14px;
}

.numin:focus {
  outline: none;
  border-color: var(--accent);
}

.unit {
  color: var(--muted);
  font-size: 13px;
}

.slider-row {
  padding: 9px 0;
  border-bottom: 1px solid rgb(233 227 214 / .05);
}

.slider-row:last-child {
  border-bottom: 0;
}

/* 群組內的次層小標（主要控制 / 音樂反應…）：淡墨黑體、比楷書區塊標題再低一階，
   形成「楷書區塊標題 → 次層標題 → 項目」的層次 */
.slider-subgroup-title {
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
}

.slider-subgroup-title:first-child {
  margin-top: 2px;
}

.slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 7px;
}

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

.slider-val {
  color: var(--moon-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.slider-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

/* 滑桿：軌道是一條界格線，把手是一枚小小的方印（月光面、墨框） */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 0;
  background: rgb(233 227 214 / .16);
  cursor: pointer;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 1px;
  background: var(--moon);
  border: 2px solid var(--ink-ground);
  box-shadow: 0 0 0 1px rgb(238 219 154 / .4);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid var(--ink-ground);
  border-radius: 1px;
  background: var(--moon);
  box-shadow: 0 0 0 1px rgb(238 219 154 / .4);
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px var(--paper);
}

input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 2px var(--paper);
}

.color-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgb(233 227 214 / .05);
}

.color-row:last-child {
  border-bottom: 0;
}

.color-label {
  color: var(--ink);
  font-size: 14px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-mode-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.color-mode-row .segmented-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.color-mode-row .style-option {
  min-height: 26px;
}

.primary-copy-button {
  min-height: 28px;
  margin-left: auto;
  font-size: 12px;
}

.gradient-reverse-button {
  min-height: 22px;
  padding-inline: 6px;
  font-size: 12px;
}

.gradient-reverse-button[aria-pressed="true"] {
  color: var(--paper);
  border-color: rgb(233 227 214 / .45);
}

.palette-summary-row {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding-block: 7px;
}

.palette-part {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.palette-part-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.palette-preview {
  flex-wrap: nowrap;
  gap: 4px;
}

.palette-chip {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1px solid rgb(233 227 214 / .2);
  border-radius: 1px;
  box-shadow: inset 0 0 0 1px #00000024;
}

.custom-palette-row input[type="color"] {
  width: 28px;
  height: 24px;
  border-radius: 2px;
}

.color-row .slider-hint {
  grid-column: 1 / -1;
  margin-top: 2px;
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 28px;
  padding: 0;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 1px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 1px; }

/* 頻譜造型選擇器：下拉選單（造型變多也塞得下，不再受按鈕格寬度限制）
   選擇器寫成 select.style-select 是為了跟 .inline-field > select 打平特異性：
   放在一行式的欄位裡時（例如圖層檢視器），那條規則的 background 簡寫
   會把這裡的自訂箭頭連同底色、邊框一起洗掉，下拉就變成沒有箭頭的灰框。 */
select.style-select {
  width: 100%;
  min-height: 40px;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--ink-raised);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c9c2b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0 36px 0 12px;
  font-size: 14px;
  cursor: pointer;
}

.style-select:hover {
  background-color: #23201d;
  border-color: rgb(233 227 214 / .42);
}

.style-select:focus {
  outline: none;
  border-color: var(--paper);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.style-select option {
  background: var(--panel-2);
  color: var(--ink);
}

/* position: relative 給拖曳時的插入線當定位基準 */
.visual-layer-picker { position: relative; display: grid; gap: 8px; }
.visual-layer-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.visual-layer-list { display: grid; gap: 6px; }

/* ── 拖曳排序 ── 被拿起來的那列變淡；插入線畫在要放下去的縫上，兩端加圓點比較好認 */
.visual-layer-item.is-dragging { opacity: .4; }
.visual-layer-drop-line {
  position: absolute;
  z-index: 2;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: var(--paper);
  pointer-events: none;
}
.visual-layer-drop-line::before,
.visual-layer-drop-line::after {
  content: '';
  position: absolute;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.visual-layer-drop-line::before { left: -4px; }
.visual-layer-drop-line::after { right: -4px; }
.visual-layer-drop-line[hidden] { display: none; }

/* ── 刪除復原 ── 從畫面右下角浮出來的小提示，一層一張，由下往上疊。
   容器本身不吃滑鼠，才不會擋到它後面的東西；只有提示本身可以點。 */
.visual-layer-undo-stack {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: min(300px, calc(100vw - 40px));
  pointer-events: none;
}
.visual-layer-undo {
  /* 用 margin 而不是容器的 gap：離場時連間距一起收掉，下面那張才會平順地補上來 */
  margin-top: 8px;
  box-sizing: border-box;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: var(--panel-2);
  box-shadow: 0 12px 32px rgb(0 0 0 / .62);
  font-size: 13px;
  pointer-events: auto;
  transform-origin: right bottom;
  animation: visual-layer-undo-in .32s cubic-bezier(.16, 1, .3, 1) both;
}
.visual-layer-undo.is-leaving {
  overflow: hidden;
  pointer-events: none;
  animation: visual-layer-undo-out .22s cubic-bezier(.4, 0, .6, 1) forwards;
}
/* 配色色帶跟清單上那一列的一模一樣，一眼就對得起來是哪一層 */
.visual-layer-undo-swatch { width: 22px; height: 8px; border-radius: 1px; }
.visual-layer-undo-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
  line-height: 1.3;
}
.visual-layer-undo-text strong,
.visual-layer-undo-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.visual-layer-undo-text strong { color: var(--ink); font-weight: 600; }
.visual-layer-undo-text small { color: var(--muted); font-size: 12px; }
.visual-layer-undo-btn {
  flex: none;
  padding: 3px 10px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: transparent;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.visual-layer-undo-btn:hover,
.visual-layer-undo-btn:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
/* 進場：從右下角滑出來，快到慢收住 */
@keyframes visual-layer-undo-in {
  from { opacity: 0; transform: translate(16px, 14px) scale(.9); }
  to { opacity: 1; transform: none; }
}
/* 離場：往右淡出，同時把高度與間距收掉，上面的那幾張順勢往下補位
   （--toast-h 是 JS 在離場前量好的實際高度） */
@keyframes visual-layer-undo-out {
  from { opacity: 1; transform: none; height: var(--toast-h); margin-top: 8px; }
  to {
    opacity: 0;
    transform: translateX(24px);
    height: 0;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .visual-layer-undo,
  .visual-layer-undo.is-leaving { animation: none; }
}

/* ── 支持夜兔譜 ── 入口在碑額右邊（.support-link），點了在本頁打開 Ko-fi 面板 */

.support-dialog {
  width: min(390px, calc(100vw - 28px));
  max-width: none;
  max-height: calc(100vh - 28px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 28px 90px rgb(0 0 0 / .8);
}

.support-dialog::backdrop {
  background: rgb(9 8 7 / .78);
}

.support-dialog-head {
  min-height: 76px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 14px 12px 18px;
  border-bottom: 1px solid var(--rule);
  background-color: var(--panel);
  background-image: var(--tex-rubbing);
}

.support-dialog-head h2 { margin: 0; color: var(--paper); font-size: 20px; font-weight: 400; letter-spacing: .1em; }
.support-dialog-head p { margin: 5px 0 0; color: var(--paper-dim); font-size: 12px; line-height: 1.4; }
/* 跟碑額「支持」鈕同一個杯子線條圖示，取代原本的表情符號 */
.support-cup { width: 15px; height: 15px; margin-left: 2px; vertical-align: -3px; }

/* 刻意的例外：Ko-fi 面板本身是白底，外框先鋪白，載入時才不會由黑閃成白 */
.support-embed-wrap {
  height: min(640px, calc(100vh - 156px));
  min-height: 350px;
  background: #fff;
}

.support-embed {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.support-external {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--paper-dim);
  text-decoration: none;
  font-size: 12px;
  background: var(--sunken);
}

.support-external:hover,
.support-external:focus-visible { color: var(--paper); outline: none; }

@media (max-width: 550px) {
  .visual-layer-undo-stack {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: min(300px, calc(100vw - 24px));
  }
}

.visual-layer-empty {
  padding: 16px 10px;
  border: 1px dashed var(--line);
  border-radius: 2px;
  color: var(--muted);
  text-align: center;
}
/* 一列圖層 = 標題列 + 展開後的設定區。外框畫在 .visual-layer-item 上，
   展開時整包（含設定）才會一起被框起來，看得出設定屬於哪一層。 */
.visual-layer-item {
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgb(233 227 214 / .02);
  overflow: hidden;
  transition: border-color .16s ease, background .16s ease;
}
.visual-layer-item:hover { border-color: rgb(233 227 214 / .22); background: rgb(233 227 214 / .04); }
/* 兩種狀態各自有記號，因為它們可以不同步：
   is-expanded＝這一列的設定開著；is-target＝編輯版面時方框在拖這一層。
   全部收起來時，方框對著的那一層，編號會變成一枚朱印（見 .visual-layer-index）。 */
.visual-layer-item.is-expanded {
  border-color: rgb(233 227 214 / .4);
  background: rgb(233 227 214 / .04);
}
.visual-layer-item.is-hidden .visual-layer-name { opacity: .48; text-decoration: line-through; }
.visual-layer-row {
  display: grid;
  grid-template-columns: 20px 26px minmax(0, 1fr) 26px 26px;
  align-items: center;
  min-height: 42px;
  cursor: pointer;
}
/* 整列是展開／收合的開關（main.js 給了 tabindex），鍵盤停在上面時框住整列 */
.visual-layer-row:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: -2px;
}
/* 設定區：縮排＋上緣分隔線，讓它讀起來是「屬於上面那一列」而不是新的一段。
   高度一次到位，換了展開對象時內容淡入（.is-entering 由 main.js 加）。 */
.visual-layer-body-inner {
  padding: 2px 10px 12px;
  border-top: 1px solid rgb(233 227 214 / .08);
}
.visual-layer-body.is-entering .visual-layer-body-inner {
  animation: reveal-in .24s cubic-bezier(.2, .8, .2, 1);
}
.visual-layer-body .list-section { margin-top: 14px; }
.visual-layer-body .list-group { margin-top: 2px; }
/* 介面圖示（web/icons.js）：線條圖，顏色跟著 color 走 */
.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon-filled { fill: currentColor; stroke: none; }

.visual-layer-drag {
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: .7;
  cursor: grab;
  user-select: none;
}
.visual-layer-drag .icon { width: 14px; height: 14px; }
.visual-layer-action {
  width: 26px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.visual-layer-action:hover { color: var(--accent-2); }
.visual-layer-remove:hover { color: var(--cinnabar-bright); }
.visual-layer-action:disabled { opacity: .35; cursor: not-allowed; }
.visual-layer-action:focus-visible { outline: 1px solid var(--accent); outline-offset: -3px; border-radius: 1px; }
/* 隱藏中的那層，眼睛圖示也跟著淡下去 */
.visual-layer-item.is-hidden .visual-layer-visible { opacity: .6; }

.visual-layer-name { min-width: 0; padding: 0 4px; }
.visual-layer-title,
.visual-layer-name small {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}
.visual-layer-name strong,
.visual-layer-detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* 圖層名稱跟左側面板的列名（.asset-name）同一級，不要比上面的區塊題名還大 */
.visual-layer-name strong { font-size: 14px; font-weight: 500; }
.visual-layer-name small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.visual-layer-item.is-hidden .visual-layer-name strong { text-decoration: line-through; }
/* 編號：跟編輯版面的 1234 同一組 */
.visual-layer-index {
  flex: none;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 1px;
  background: rgb(233 227 214 / .1);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
/* 編輯版面時方框對著的那一層：編號是一枚小朱印 */
.visual-layer-item.is-target .visual-layer-index { background: var(--cinnabar); color: var(--seal-paper); }
/* 這層的配色；寬度跟編號一樣，上下兩個剛好對成一欄 */
.visual-layer-swatch {
  flex: none;
  width: 16px;
  height: 6px;
  border-radius: 1px;
  box-shadow: inset 0 0 0 1px rgb(233 227 214 / .16);
}

/* ── 展開後的設定區：每個參數壓成一行 ─────────────────────
   只套在明確掛了 .slider-inline 的列上。.slider-row 全站共用（字幕面板、
   配色模式那列都是），用範圍去框很容易誤中，所以反過來由要壓的列自己宣告。
   一行由左到右：名稱｜ⓘ｜滑桿｜數值；說明收在下一行，點 ⓘ 才出現。 */
.slider-inline {
  display: grid;
  /* 名稱欄只要跟最長的名稱一樣寬就好，剩下的全部讓給滑桿；
     ⓘ 那欄固定寬，沒有說明的列（例如圖層透明度）滑桿才會跟別列對齊。 */
  grid-template-columns: max-content 16px minmax(0, 1fr) max-content;
  align-items: center;
  column-gap: 6px;
  padding: 7px 0;
  font-size: 13px;
}
/* 一整組控制項共用同一套欄寬（subgrid）：名稱欄＝這一組裡最長的那個名稱，
   每一列的滑桿／下拉起點都對齊。整組換掉（例如換頻譜造型、換字幕樣式）時，
   欄寬會跟著新那一組的名稱長短走。
   頻譜的樣式參數、圖層屬性、畫面動態、字幕樣式都掛這個 class。 */
.inline-controls {
  display: grid;
  grid-template-columns: max-content 16px minmax(0, 1fr) max-content;
  column-gap: 6px;
  font-size: 13px;
}
/* 整組一起顯示/隱藏、但裡面的列要排進外層欄線的包裝層（例：字幕的星塵設定）。
   包裝層自己不佔格子（display:contents），所以下面的擺放規則要連它的小孩一起框。 */
.inline-contents { display: contents; }
.inline-contents[hidden] { display: none; }
.inline-controls > *,
.inline-controls > .inline-contents > * { grid-column: 1 / -1; }
.inline-controls > .slider-inline,
.inline-controls > .inline-field,
.inline-controls > .inline-contents > .slider-inline,
.inline-controls > .inline-contents > .inline-field { grid-template-columns: subgrid; }
/* display:grid 會蓋過瀏覽器預設的 hidden，被 JS 收起來的那幾組要明確擋回去 */
.inline-controls[hidden],
.inline-field[hidden] { display: none; }
/* 標籤 + 單一控制項（下拉、勾選、色塊…）的一列，跟滑桿列共用欄線 */
.inline-field {
  display: grid;
  grid-template-columns: max-content 16px minmax(0, 1fr) max-content;
  align-items: center;
  /* 換成 subgrid 時會照自己的 gap 把欄線錯開，所以要跟外層同一個值 */
  column-gap: 6px;
  margin: 0;
  padding: 5px 0;
  font-size: 13px;
}
/* 第 1 欄是名稱、第 2 欄是 ⓘ，控制項一律從第 3 欄開始——跟滑桿列同一條起跑線 */
.inline-field > label,
.inline-field > span:first-child { grid-column: 1; grid-row: 1; color: var(--ink); white-space: nowrap; }
.inline-field > .slider-info { grid-column: 2; grid-row: 1; }
.inline-field > select,
.inline-field > input,
.inline-field > textarea,
.inline-field > .checkrow,
.inline-field > .segmented-options {
  grid-column: 3 / 5;
  grid-row: 1;
  justify-self: stretch;
}
.inline-field > .slider-hint {
  grid-column: 1 / -1;
  grid-row: 2;
  display: none;
  margin: 6px 0 0;
}
.inline-field.show-hint > .slider-hint { display: block; }
/* 右半邊常常塞的是「下拉＋色塊」「數字＋單位」這種小組合，間距要比一般 checkrow 窄才排得下 */
/* 右半欄只剩一欄的寬度，裡面的東西不換行：下拉自己縮，色塊固定。
   這麼窄的下拉要把箭頭跟左右留白再收一點，文字才不會被截成半個字。 */
.inline-field .checkrow {
  gap: 8px;
  flex-wrap: nowrap;
}
.inline-field .checkrow select {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 19px 0 7px;
  background-position: right 5px center;
  background-size: 10px 10px;
}
.inline-field .checkrow input[type="color"] { flex: 0 0 auto; width: 28px; }
.inline-field .check,
.inline-field .coloropt { font-size: 13px; }
.inline-field .check input {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
/* 三個文字樣式選項擠不進右半欄，照分段按鈕那一列的做法：標籤在上、選項獨占第二行 */
.text-style-toggle-field > .checkrow {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: 5px;
}
.slider-inline .slider-head { display: contents; }
.slider-inline .slider-head > :first-child {
  grid-column: 1;
  grid-row: 1;
  color: var(--ink);
  white-space: nowrap;
}
.slider-inline .slider-info { grid-column: 2; grid-row: 1; }
/* 瀏覽器預設給 range 左右各 2px 外距，會讓它跟上面的下拉差一截 */
.slider-inline > input[type="range"] { grid-column: 3; grid-row: 1; margin: 0; }
.slider-inline .slider-val { grid-column: 4; grid-row: 1; justify-self: end; font-size: 12px; }
.slider-inline .slider-hint {
  grid-column: 1 / -1;
  grid-row: 3;
  display: none;
  margin: 6px 0 0;
}
.slider-inline.show-hint .slider-hint { display: block; }
/* 選項型（分段按鈕）塞不進一行，按鈕放到第二行 */
.slider-inline.is-choice .segmented-options { grid-column: 1 / -1; grid-row: 2; margin-top: 7px; }
.slider-inline.is-choice .slider-val { grid-column: 3 / 5; }

.slider-info {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  opacity: .55;
  cursor: help;
}
.slider-info .icon { width: 13px; height: 13px; }
.slider-info:hover,
.slider-info:focus-visible,
.slider-row.show-hint .slider-info { opacity: 1; color: var(--accent-2); }

/* 這一層本身的屬性：造型、透明度、混合模式三列（.inline-controls 負責對齊欄線） */
.visual-layer-props {
  row-gap: 4px;
  margin-top: 10px;
}
.visual-layer-props > .slider-inline {
  margin: 0;
  padding: 5px 0;
}

.style-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--sunken);
}

.segmented-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--sunken);
}

.style-option {
  min-height: 30px;
  border: 0;
  border-radius: 1px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0 8px;
  font-size: 13px;
}

.style-option.active {
  background: var(--paper-wash);
  color: var(--paper);
  box-shadow: inset 0 0 0 1px rgb(233 227 214 / .32);
}

/* 側欄＋兩個面板（頻譜面板展開時）＋舞台 520 的大 token 下限約 1342；窄於此先換較緊的 token */
@media (max-width: 1342px) {
  .app-shell {
    --rail: 32px;
    --left-panel: 300px;
    --right-panel: 300px;
    --chrome-gap: 8px;
    grid-template-columns: var(--rail) var(--left-panel-current) minmax(520px, 1fr) var(--right-panel-current);
  }

  /* 窄版左側面板更擠，三個選項再收窄一點才排得完（標籤/選項分兩列是預設就有的） */
  .focus-detail .text-style-toggle-field .checkrow {
    gap: 7px;
    flex-wrap: nowrap;
  }

  .focus-detail .text-style-toggle-field .check {
    gap: 4px;
    font-size: 13px;
  }

  .focus-detail .text-style-toggle-field .check input {
    width: 15px;
    height: 15px;
  }
}

/* 小 token 下限約 1214；再窄就固定寬度 + 水平捲動，避免頻譜面板被裁掉 */
@media (max-width: 1214px) {
  body {
    overflow-x: auto;
  }

  .app-shell {
    width: 1214px;
  }
}
