/* ==========================================================================
   Kamishibai エディタの UI スタイル
   スライド自体の見た目は runtime.css（.ks-deck 以下）。ここはツールの外枠だけ。
   ========================================================================== */
:root {
  color-scheme: dark;
  --bg: #0d0f14;
  --panel: #14171f;
  --panel-2: #1a1e29;
  --raise: #222735;
  --line: #262b39;
  --line-strong: #353c4f;
  --text: #e8ebf3;
  --muted: #8a92a8;
  --text-soft: #c3c8d6;
  --accent: #7c8cff;
  --accent-2: #5eead4;
  --accent-ink: #0b0d18;
  --danger: #ff6b81;
  --ok: #5eead4;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.7);
  --radius: 10px;
  --font: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
  --mono: 'Cascadia Code', 'SF Mono', 'Consolas', 'BIZ UDGothic', 'MS Gothic', monospace;
}
:root[data-scheme='light'] {
  color-scheme: light;
  --bg: #eef0f5;
  --panel: #ffffff;
  --panel-2: #f5f6fa;
  --raise: #eceef4;
  --line: #e2e5ed;
  --line-strong: #cfd4e0;
  --text: #1b1e27;
  --muted: #687086;
  --text-soft: #3d4352;
  --accent: #4f5dff;
  --accent-2: #12b5a0;
  --accent-ink: #ffffff;
  --danger: #e03a55;
  --ok: #0f9d8a;
  --shadow: 0 18px 40px -20px rgba(30, 40, 80, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:hover { background: var(--raise); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .tabs button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 1px;
}
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--raise); color: var(--text); }
.btn.icon { width: 32px; padding: 0; }
.btn.primary {
  border: 0;
  background: linear-gradient(100deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-2)));
  color: var(--accent-ink);
  font-weight: 650;
  box-shadow: 0 6px 20px -8px var(--accent);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- 上部バー ---------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 9px; margin-right: 6px; font-size: 15px; font-weight: 700; letter-spacing: 0.01em; }
.brand svg { width: 24px; height: 24px; stroke: none; }
/* プロジェクト名（押すとファイルメニュー） */
.project-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  max-width: 340px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-2);
  font-weight: 650;
  cursor: pointer;
}
.project-btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
.project-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-kind { flex: none; padding: 1px 7px; border-radius: 999px; background: var(--raise); color: var(--muted); font-size: 11px; font-weight: 600; }
.project-kind:empty { display: none; }
.project-kind[data-kind='temp'] { background: color-mix(in srgb, #f5c451 22%, transparent); color: #e3b23c; }
.project-btn .caret { width: 14px; height: 14px; opacity: 0.7; }
body.is-start .project-btn { cursor: default; }
body.is-start .project-btn .caret,
body.is-start #btnExportMenu,
body.is-start #btnPresent,
body.is-start #status { visibility: hidden; }
#fileMenu { left: 0; right: auto; width: 330px; }

.status { display: inline-flex; align-items: center; gap: 7px; margin-left: 6px; color: var(--muted); font-size: 12px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); transition: background 0.2s; }
.status[data-state='saving'] i { background: #f5c451; animation: pulse 1s infinite; }
.status[data-state='error'] { color: var(--danger); }
.status[data-state='error'] i { background: var(--danger); }
.status[data-state='temp'] { color: #e3b23c; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.status[data-state='temp'] i { background: #e3b23c; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- 2 ペイン（プレビュー / 編集パネル）。data-side で左右を入れ替える ---------- */
.panes {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5px var(--side-w, 520px);
  grid-template-areas: 'preview split side';
}
.panes[data-side='left'] {
  grid-template-columns: var(--side-w, 520px) 5px minmax(0, 1fr);
  grid-template-areas: 'side split preview';
}
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-preview { grid-area: preview; }
.splitter { grid-area: split; cursor: col-resize; background: var(--line); transition: background 0.15s; }
.splitter:hover, .splitter.is-dragging { background: var(--accent); }
.pane-side { grid-area: side; background: var(--panel); container-type: inline-size; }

/* 編集パネルのタブ（原稿 / デザイン） */
.side-tabs {
  flex: none;
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--line);
}
.side-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: none;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}
.side-tabs button:hover { color: var(--text); }
.side-tabs button.is-active { border-color: var(--line); background: var(--panel); color: var(--text); box-shadow: 0 -2px 0 var(--accent) inset; }
.side-tabs button.is-active { box-shadow: inset 0 2px 0 var(--accent); }
.side-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-page[hidden] { display: none; }

/* ---------- 原稿: ツールバー ---------- */
.toolbar {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.toolbar button:hover { background: var(--raise); color: var(--text); }
/* 書式ボタンの列 */
.format-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.format-bar button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: 600 14px/1 var(--font, inherit);
  cursor: pointer;
}
.format-bar button:hover { background: var(--raise); color: var(--text); }
.format-bar button b, .format-bar button i, .format-bar button s { font-family: Georgia, 'Times New Roman', serif; font-size: 15px; }
.format-bar svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.format-bar select {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
}
.format-bar .sep { width: 1px; height: 16px; margin: 0 5px; background: var(--line-strong); }
.format-bar .spacer { flex: 1; }
/* 編集パネルが狭いときは、ツールバーのボタンを絵だけにする */
@container (max-width: 600px) {
  .toolbar [data-insert] span { display: none; }
  .toolbar [data-insert] { padding: 0 7px; }
}
.editor-host { position: relative; flex: 1; min-height: 0; }

/* ---------- プレビュー ---------- */
.pane-preview { background: var(--bg); }
.stage-host { position: relative; flex: 1; min-height: 120px; margin: 22px 26px 6px; }
.stage-host .ks-stage { box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--line); border-radius: calc(8px / var(--ks-scale, 1)); }
.preview-bar { flex: none; display: flex; align-items: center; gap: 4px; padding: 4px 22px 8px; }
.preview-bar .count { min-width: 62px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.notes-view {
  flex: none;
  height: 62px;
  overflow: auto;
  margin: 0 26px 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}
.notes-view.is-empty { opacity: 0.6; }
.notes-view .label { float: left; margin-right: 10px; padding: 0 7px; border-radius: 5px; background: var(--raise); font-size: 11px; }
.notes-view p, .notes-view ul, .notes-view ol { margin: 0 0 4px; }
.notes-view ul, .notes-view ol { padding-left: 1.4em; overflow: hidden; }

.film {
  flex: none;
  display: flex;
  gap: 12px;
  padding: 12px 22px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.thumb {
  position: relative;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: none;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s, transform 0.15s;
}
.thumb:hover { transform: translateY(-2px); outline-color: var(--line-strong); }
.thumb.is-current { outline-color: var(--accent); }
.thumb .ks-deck { border-radius: 6px; pointer-events: none; }
.thumb .num {
  position: absolute;
  left: 5px;
  bottom: 5px;
  z-index: 4;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 10.5px;
  line-height: 17px;
  text-align: center;
}
.thumb .pin { position: absolute; right: 5px; top: 5px; z-index: 4; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4); }

/* ---------- デザインパネル ---------- */
.tabs { flex: none; display: flex; gap: 2px; margin: 10px 12px 0; padding: 3px; border-radius: 10px; background: var(--bg); }
.tabs button {
  flex: 1;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.tabs button.is-active { background: var(--raise); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.panel { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 12px 40px; }

.group { border-bottom: 1px solid var(--line); }
.group > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 13px 2px 11px;
  list-style: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: ''; margin-left: auto; width: 6px; height: 6px; border-right: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(-45deg); transition: transform 0.15s; }
.group[open] > summary::after { transform: rotate(45deg); }
.group > summary .badge { padding: 0 6px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); letter-spacing: 0; }
.group-body { padding: 0 2px 14px; display: flex; flex-direction: column; gap: 9px; }

.field { display: grid; grid-template-columns: 96px minmax(0, 1fr) 20px; align-items: center; gap: 8px; min-height: 28px; }
.field > label { color: var(--muted); font-size: 12px; line-height: 1.3; }
.field.is-overridden > label { color: var(--text); }
.field.is-overridden > label::before { content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.field .reset {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  visibility: hidden;
}
.field .reset svg { width: 13px; height: 13px; }
.field.is-overridden .reset { visibility: visible; }
.field .reset:hover { background: var(--raise); color: var(--text); }
.field.wide { grid-template-columns: minmax(0, 1fr) 20px; }
.field.wide > label { grid-column: 1 / -1; }

.field input[type='text'], .field select, .form-row input, .form-row select, .panel textarea {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-2);
  outline: 0;
}
.field select, .form-row select { padding-right: 4px; cursor: pointer; }
.field input[type='text']:focus, .form-row input:focus, .panel textarea:focus { border-color: var(--accent); }

.color { display: flex; gap: 6px; }
.color .swatch {
  position: relative;
  flex: none;
  width: 28px;
  height: 28px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  cursor: pointer;
}
.color .swatch.is-empty { background: repeating-conic-gradient(var(--raise) 0 25%, transparent 0 50%) 0 0 / 10px 10px; }
.color input[type='color'] { position: absolute; inset: -6px; width: 44px; height: 44px; padding: 0; border: 0; cursor: pointer; opacity: 0; }
.color input[type='text'] { font-family: var(--mono); font-size: 12px; }

.range { display: flex; align-items: center; gap: 8px; }
.range input[type='range'] { flex: 1; min-width: 0; height: 4px; margin: 0; border-radius: 4px; background: var(--line-strong); appearance: none; cursor: pointer; }
.range input[type='range']::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border: 2px solid var(--panel); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.range input[type='range']::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid var(--panel); border-radius: 50%; background: var(--accent); }
.range output { width: 38px; color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

.seg { display: flex; padding: 2px; border-radius: 8px; background: var(--bg); }
.seg button { flex: 1; height: 24px; padding: 0 6px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 12px; cursor: pointer; white-space: nowrap; }
.seg button.is-active { background: var(--raise); color: var(--text); }

.switch { position: relative; width: 34px; height: 20px; border: 0; border-radius: 999px; background: var(--line-strong); cursor: pointer; transition: background 0.15s; justify-self: start; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch[aria-checked='true'] { background: var(--accent); }
.switch[aria-checked='true']::after { transform: translateX(14px); }

/* テーマ選択カード */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-card {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel-2);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.theme-card:hover { transform: translateY(-1px); border-color: var(--accent); }
.theme-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-card .sample { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 5px; height: 62px; padding: 0 12px; }
.theme-card .sample b { font-size: 15px; line-height: 1; }
.theme-card .sample i { display: block; width: 26px; height: 3px; border-radius: 3px; }
.theme-card .sample span { display: block; width: 62%; height: 3px; border-radius: 3px; opacity: 0.45; }
.theme-card .name { padding: 6px 10px 7px; border-top: 1px solid var(--line); font-size: 12px; font-weight: 600; }

/* レイアウト選択 */
.layout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.layout-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 4px 5px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.layout-btn svg { width: 56px; height: 34px; border-radius: 4px; background: var(--bg); stroke: none; }
.layout-btn svg .a { fill: var(--accent); }
.layout-btn svg .m { fill: var(--muted); opacity: 0.55; }
.layout-btn svg .i { fill: color-mix(in srgb, var(--accent-2) 55%, var(--bg)); }
.layout-btn svg text { fill: var(--muted); font: 700 8px var(--font); }
.layout-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.layout-btn.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--text); }
.layout-btn.is-detected:not(.is-active) { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); }
.layout-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.hint { margin: 2px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.hint code, .dialog code { padding: 1px 5px; border-radius: 4px; background: var(--raise); font-family: var(--mono); font-size: 11px; }
.id-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-top: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.id-chip code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.id-chip span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.panel textarea { height: 180px; padding: 8px; font: 12px/1.6 var(--mono); resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.char-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.char-grid button { height: 26px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--text); font-size: 13px; cursor: pointer; }
.char-grid button:hover { border-color: var(--line-strong); }
.char-grid button.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.stack > input[type='text'] { width: 100%; height: 28px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel-2); outline: 0; }
.stack > input[type='text']:focus { border-color: var(--accent); }

/* ---------- ダイアログ・トースト ---------- */
.dialog {
  width: min(460px, calc(100vw - 40px));
  padding: 22px 24px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(6, 8, 14, 0.55); backdrop-filter: blur(3px); }
.dialog h2 { margin: 0 0 16px; font-size: 16px; }
.dialog p { margin: 0 0 10px; line-height: 1.7; }
.dialog .path { display: block; margin: 8px 0 12px; padding: 9px 11px; border-radius: 8px; background: var(--panel-2); font-family: var(--mono); font-size: 12px; word-break: break-all; }
.dialog ul { margin: 0 0 12px; padding-left: 1.3em; color: var(--danger); }
.form-row { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 10px; margin-bottom: 10px; }
.form-row span { color: var(--muted); }
.form-row input, .form-row select { height: 32px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-actions a.btn { text-decoration: none; }

/* 設定（settings.js） */
.settings-dialog { width: min(600px, calc(100vw - 40px)); max-height: calc(100vh - 40px); padding: 0; display: none; flex-direction: column; overflow: hidden; }
.settings-dialog[open] { display: flex; }
.set-head { padding: 20px 24px 12px; border-bottom: 1px solid var(--line); }
.set-head h2 { margin: 0 0 2px; }
.set-head small { color: var(--muted); }
.set-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 24px 8px; }
.settings-dialog .dialog-actions { align-items: center; margin: 0; padding: 12px 24px 16px; border-top: 1px solid var(--line); }
.set-version { color: var(--muted); font-size: 12px; }
.set-section { padding: 14px 0 6px; }
.set-section + .set-section { border-top: 1px solid var(--line); }
.set-section h3 { margin: 0 0 10px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; }
.set-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 14px; margin-bottom: 12px; }
.set-label b { display: block; font-weight: 500; }
.set-label small { display: block; color: var(--muted); font-size: 11px; line-height: 1.45; }
.set-ctl { display: flex; align-items: center; gap: 10px; }
.set-ctl .seg { flex: 1; }
.set-val { min-width: 42px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.set-note { margin: 0 !important; color: var(--muted); }
.set-check { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; cursor: pointer; }
.set-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.license-dialog { width: min(820px, calc(100vw - 40px)); }
.license-text { height: min(62vh, 640px); margin: 0; padding: 12px 14px; overflow: auto; border-radius: 8px; background: var(--panel-2); font: 11.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; }

.toasts { position: fixed; left: 50%; bottom: 26px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast {
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--raise);
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease both;
}
.toast.is-error { border-color: var(--danger); color: var(--danger); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 書き出しメニュー ---------- */
.btn .caret { width: 14px; height: 14px; margin-left: -2px; opacity: 0.7; }
.menu-anchor { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  width: 290px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: menu-in 0.16s ease both;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu-label { padding: 8px 10px 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.menu button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.menu button:hover { background: var(--raise); }
.menu button svg { width: 18px; height: 18px; color: var(--accent); }
.menu button span { display: flex; flex-direction: column; line-height: 1.35; }
.menu button small { color: var(--muted); font-size: 11.5px; }
.menu-check { display: flex; align-items: center; gap: 8px; margin: 4px 10px 6px; color: var(--muted); font-size: 12px; cursor: pointer; }
.menu-check input { accent-color: var(--accent); }

/* ---------- 左ペイン: 表示の切り替え ---------- */
.toolbar .spacer { flex: 1; }
.mode-seg { display: flex; padding: 2px; border-radius: 8px; background: var(--bg); }
.mode-seg button {
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.mode-seg button.is-active { background: var(--raise); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }

/* ---------- ドロップ先（画像ファイルをドラッグ中） ---------- */
.is-dropping { position: relative; }
.editor-host.is-dropping::after,
.stage-host.is-dropping::after {
  content: attr(data-drop-label);
  position: absolute;
  inset: 8px;
  z-index: 30;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
  backdrop-filter: blur(2px);
}
.thumb.is-dropping { outline-color: var(--accent-2); transform: translateY(-3px) scale(1.03); }

/* ---------- プレビュー上の画像操作（editor-canvas.js） ---------- */
.cv-layer { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.stage-host.is-over-image { cursor: pointer; }
.cv-hover {
  position: absolute;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 80%, #fff);
  border-radius: 3px;
  pointer-events: none;
}
.cv-sel {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 0 9999px rgba(8, 10, 18, 0.12);
  pointer-events: none;
}
.cv-sel > * { pointer-events: auto; }
.cv-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.cv-corner.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.cv-corner.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.cv-corner.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.cv-corner.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.cv-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  cursor: ew-resize;
}
.cv-edge::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 46px;
  margin: -23px 0 0 -3px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0, 0, 0, 0.4);
}
.cv-edge.left { left: -9px; }
.cv-edge.right { right: -9px; }
.cv-pan { position: absolute; inset: 0; cursor: grab; }
.cv-pan:active, body.is-dragging-canvas { cursor: grabbing; }
body.is-dragging-canvas, body.is-dragging-canvas * { user-select: none; }
.cv-toolbar {
  position: absolute;
  z-index: 12;
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  white-space: nowrap;
  animation: menu-in 0.14s ease both;
}
.cv-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.cv-tool:hover { background: var(--raise); }
.cv-tool.is-active { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.cv-tool svg { width: 15px; height: 15px; }
.cv-badge {
  position: absolute;
  z-index: 13;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ---------- 原稿エディタ（editor-live.js / CodeMirror 6） ---------- */
.editor-host .cm-editor { height: 100%; background: var(--panel); color: var(--text); font-size: var(--editor-fs, 15px); }
.editor-host .cm-editor.cm-focused { outline: none; }
.editor-host .cm-scroller { font-family: var(--font); line-height: 1.75; overflow: auto; }
.editor-host .cm-content { max-width: 760px; margin: 0 auto; padding: 22px 26px 45vh; caret-color: var(--accent); }
.editor-host .cm-line { padding: 0 2px; }
.editor-host .cm-cursor { border-left: 2px solid var(--accent); }
.editor-host .cm-selectionBackground, .editor-host .cm-editor.cm-focused .cm-selectionBackground { background: color-mix(in srgb, var(--accent) 30%, transparent) !important; }
.editor-host .cm-placeholder { color: var(--muted); font-style: normal; }
.editor-host .cm-gutters { display: none; }

/* 見出し */
.editor-host .cm-line.cm-h { font-weight: 700; line-height: 1.4; }
.editor-host .cm-line.cm-h1 { font-size: 1.85em; padding-top: 0.25em; }
.editor-host .cm-line.cm-h2 { font-size: 1.45em; padding-top: 0.2em; }
.editor-host .cm-line.cm-h3 { font-size: 1.2em; color: color-mix(in srgb, var(--accent) 55%, var(--text)); }
.editor-host .cm-line.cm-h4, .editor-host .cm-line.cm-h5, .editor-host .cm-line.cm-h6 { font-size: 1.05em; }

/* 行内 */
.editor-host .cm-icode { font-family: var(--mono); font-size: 0.88em; padding: 0.1em 0.35em; border-radius: 5px; background: var(--raise); }
.editor-host .cm-link { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.editor-host .cm-bullet { display: inline-block; width: 0.8em; color: var(--accent); font-weight: 700; }
.editor-host .cm-olmark { color: var(--accent); font-weight: 700; }
.editor-host .cm-inline-img { height: 1.6em; max-width: 6em; vertical-align: middle; border-radius: 4px; object-fit: cover; }
.editor-host .cm-line.cm-quote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-soft); }
.editor-host .cm-line.cm-hr { color: var(--muted); }

/* コード */
.editor-host .cm-line.cm-code { font-family: var(--mono); font-size: 13px; line-height: 1.65; background: var(--panel-2); padding: 0 12px; }
.editor-host .cm-line.cm-code-first { border-radius: 8px 8px 0 0; padding-top: 6px; color: var(--muted); }
.editor-host .cm-line.cm-code-last { border-radius: 0 0 8px 8px; padding-bottom: 6px; color: var(--muted); }
.editor-host .cm-line.cm-table-src { font-family: var(--mono); font-size: 13px; }

/* デッキ情報（front matter）・記号の行（カーソルがあるとき） */
.editor-host .cm-line.cm-fm, .editor-host .cm-line.cm-fm * { font: 13px/1.7 var(--mono) !important; color: var(--muted) !important; }
.editor-host .cm-line.cm-mark-line { font-family: var(--mono); color: var(--accent); }

/* 発表者ノート */
.editor-host .cm-line.cm-note { background: color-mix(in srgb, #e9c46a 12%, transparent); border-left: 3px solid #d8b24e; padding-left: 12px; font-size: 0.95em; }

/* スライドの区切り */
.cm-slide-sep {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 0 10px;
  color: var(--muted);
  font: 600 12px/1.4 var(--font);
  cursor: pointer;
  user-select: none;
}
.cm-slide-sep::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); order: 2; }
.cm-slide-sep .n {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--raise);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.cm-slide-sep .t { max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-slide-sep .l { order: 3; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 999px; font-weight: 500; font-size: 11px; }
.cm-slide-sep:hover { color: var(--text); }
.cm-slide-sep.is-current .n { background: var(--accent); color: var(--accent-ink); }
.cm-slide-sep.is-current { color: var(--text); }
.cm-content > .cm-slide-sep:first-child { padding-top: 0; }

.cm-front {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 13px;
  cursor: text;
}
.cm-front .label { grid-column: 1 / -1; color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; }
.cm-front .row { display: contents; }
.cm-front .row span { color: var(--muted); }
.cm-front .row b { font-weight: 600; }

.cm-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
  font: 700 11px/1.4 var(--font);
  letter-spacing: 0.08em;
  cursor: text;
}
.cm-label::after { content: ''; flex: 1; height: 1px; background: currentColor; opacity: 0.3; }
.cm-label small { font-weight: 500; letter-spacing: 0; opacity: 0.75; }
.cm-label.is-notes { color: #c9a227; }
.cm-label.is-col,
.cm-label.is-cols-open,
.cm-label.is-cols-close { color: var(--accent-2); }

/* ブロックの外側の余白。CodeMirror は margin を高さに数えないので、外側の要素の padding で空ける（margin を使うと ↑↓ のカーソル移動がずれる） */
.cm-block { padding: 4px 0 10px; }
.cm-block.is-front { padding: 0 0 6px; }

/* 図・表のカード（エディタの配色に合わせて描く） */
.cm-card {
  --ks-bg: var(--panel-2);
  --ks-text: var(--text);
  --ks-muted: var(--muted);
  --ks-surface: var(--raise);
  --ks-base-size: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: text;
}
.cm-card:hover { border-color: var(--line-strong); }
.cm-mermaid .ks-mermaid-src { display: none; }
.cm-mermaid .ks-mermaid-out { display: flex; justify-content: center; }
.cm-mermaid .ks-mermaid-out svg { max-width: 100%; height: auto; }
.cm-mermaid .cm-wait { color: var(--muted); font-size: 12px; }
.cm-mermaid .ks-mermaid-error { margin: 0; font: 12px/1.5 var(--mono); white-space: pre-wrap; color: var(--muted); }
.cm-table table { width: 100%; border-collapse: collapse; font-size: 13.5px; line-height: 1.6; }
.cm-table th { padding: 6px 10px; text-align: left; border-bottom: 2px solid var(--accent); }
.cm-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); }
/* 表エディタ（セルに直接入力する） */
.cm-table-edit { padding-top: 6px; }
.cm-table-edit table { table-layout: auto; }
.cm-table-edit :is(th, td) { padding: 0; border-right: 1px solid var(--line); }
.cm-table-edit :is(th, td):last-child { border-right: 0; }
.cm-table-edit :is(th, td).is-col { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.cm-table-edit input {
  display: block;
  width: 100%;
  min-width: 4em;
  field-sizing: content;
  padding: 6px 10px;
  border: 0;
  outline: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
}
.cm-table-edit th input { font-weight: 700; }
.cm-table-edit input:focus { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent); border-radius: 3px; }
.cm-table-edit .is-center { text-align: center; }
.cm-table-edit .is-right { text-align: right; }
.cm-table-tools { display: flex; align-items: center; gap: 1px; margin-bottom: 4px; opacity: 0.35; transition: opacity 0.15s; }
.cm-table-edit:hover .cm-table-tools,
.cm-table-edit.is-active .cm-table-tools { opacity: 1; }
.cm-table-tools button { display: grid; place-items: center; width: 26px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.cm-table-tools button:hover { background: var(--raise); color: var(--text); }
.cm-table-tools svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cm-table-tools .sep { width: 1px; height: 14px; margin: 0 4px; background: var(--line-strong); }
.cm-table-tools .spacer { flex: 1; }

/* 画像 */
.cm-images { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 10px; }
.cm-images.is-row { flex-direction: row; align-items: flex-start; }
.cm-images.is-row .cm-img { flex: 1 1 0; min-width: 0; }
.cm-img { position: relative; align-self: stretch; display: flex; flex-direction: column; align-items: center; }
.cm-img img { display: block; max-width: 100%; max-height: 340px; border-radius: 8px; object-fit: contain; }
.cm-img img[style*='width'] { max-height: none; }
.cm-img img.shadow { box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.6); }
.cm-img img.round { border-radius: 999px; }
.cm-img img.plain { border-radius: 0; }
.cm-img:hover img, .cm-img.is-resizing img { outline: 2px solid var(--accent); outline-offset: 2px; }
.cm-img-tools { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity 0.15s; animation: none; }
.cm-img:hover .cm-img-tools { opacity: 1; pointer-events: auto; }
.cm-img.is-resizing .cm-img-tools { opacity: 0; }
.cm-img-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  cursor: nwse-resize;
  opacity: 0;
}
.cm-img:hover .cm-img-handle, .cm-img.is-resizing .cm-img-handle { opacity: 1; }
.cm-img-size {
  position: absolute;
  right: 0;
  bottom: -28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 12px var(--font);
  opacity: 0;
}
.cm-img.is-resizing .cm-img-size { opacity: 1; }

/* ソース表示: 装飾なし・等幅 */
.editor-host.is-source .cm-scroller { font-family: var(--mono); font-size: calc(var(--editor-fs, 15px) - 1px); }

/* ---------- 「このスライド」タブ: カラム・画像 ---------- */
.layout-grid.cols5 { grid-template-columns: repeat(5, 1fr); gap: 5px; }
.layout-grid.cols5 .layout-btn svg { width: 40px; height: 24px; }
.layout-btn svg .o { fill: none; stroke: var(--accent); stroke-width: 1.4; }
.layout-btn svg .o2 { fill: none; stroke: var(--accent-2); stroke-width: 1.4; }
.layout-btn svg .c { fill: var(--raise); stroke: var(--line-strong); stroke-width: 0.6; }
.img-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
}
.img-row.is-selected { border-color: var(--accent); }
.img-row-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.img-thumb { width: 42px; height: 30px; flex: none; border-radius: 5px; object-fit: cover; background: var(--bg); }
.img-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.img-row .range output { width: 36px; }
.img-row .seg button.is-active { color: var(--accent); }
.btn.icon.small { width: 26px; height: 26px; }
.btn.icon.small svg { width: 14px; height: 14px; }

@media (max-width: 1100px) {
  .topbar .btn:not(.icon):not(.primary) { padding: 0 9px; }
  .preview-bar #btnReplay { font-size: 0; gap: 0; }
}

/* テーマの分類（シンプル / 装飾あり） */
.theme-section + .theme-section { margin-top: 10px; }
.theme-cat { margin: 2px 0 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; }
/* 保存先フォルダのメニュー（デスクトップアプリのみ） */
.menu-path { margin: 0 10px 6px; padding: 6px 8px; border-radius: 7px; background: var(--panel-2); color: var(--muted); font: 11.5px/1.5 var(--mono); word-break: break-all; }

/* ---------- スタート画面（何も開いていないとき） ---------- */
.start {
  position: fixed;
  inset: 52px 0 0;
  z-index: 50;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background: radial-gradient(900px 500px at 70% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%), var(--bg);
}
.start[hidden] { display: none; }
.start-card { width: min(720px, 100%); }
.start-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.start-brand svg { width: 52px; height: 52px; stroke: none; }
.start-brand h1 { margin: 0; font-size: 26px; }
.start-brand p { margin: 2px 0 0; color: var(--muted); }
.start-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.start-action {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.start-action:hover { border-color: var(--accent); transform: translateY(-1px); }
.start-action svg { grid-row: 1 / 3; width: 26px; height: 26px; color: var(--accent); }
.start-action b { font-size: 14px; }
.start-action small { color: var(--muted); font-size: 12px; }
.start-action.is-primary { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.start-path { margin-top: 14px; }
.start-path-row { display: flex; gap: 8px; }
.start-path-row input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-2); outline: 0; font-family: var(--mono); font-size: 12.5px; }
.start-path-row input:focus { border-color: var(--accent); }
.start-label { margin: 26px 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; }
.start-recent-item {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.start-recent-item:hover { background: var(--panel); }
.start-recent-item .kind { grid-row: 1 / 3; padding: 2px 8px; border-radius: 999px; background: var(--raise); color: var(--muted); font-size: 11px; }
.start-recent-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: var(--mono); font-size: 11.5px; }

/* ==========================================================================
   図形エディタ（diagram-editor.js）
   ========================================================================== */
.dg-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}
.dg-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.dg-header > b { font-size: 14px; }
.dg-header .spacer { flex: 1; }
.dg-header .sep { width: 1px; height: 20px; margin: 0 6px; background: var(--line-strong); }
.dg-title { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-btn { display: inline-grid; place-items: center; width: 32px; height: 30px; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.dg-btn:hover { background: var(--raise); color: var(--text); }
.dg-btn span { display: none; }
.dg-zoom { min-width: 52px; height: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); color: var(--text-soft); font-size: 12px; cursor: pointer; }
.dg-btn svg, .dg-shape svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dg-canvas { fill: none; stroke: none; }
.dg-btn svg, .dg-shape svg { width: 19px; height: 19px; }
.dg-body { flex: 1; min-height: 0; display: flex; }
.dg-palette {
  flex: none;
  width: 132px;
  padding: 10px 8px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.dg-label { margin: 6px 4px 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; }
.dg-shape {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-soft);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.dg-shape:hover { background: var(--raise); color: var(--text); }
.dg-shape.is-active { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
.dg-hint { margin: 10px 4px; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.dg-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background-color: var(--panel-2);
  background-image:
    linear-gradient(color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 1px),
    linear-gradient(color-mix(in srgb, var(--text) 4%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--text) 4%, transparent) 1px, transparent 1px);
}
.dg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: default; user-select: none; touch-action: none; }
.dg-canvas.is-drawing { cursor: crosshair; }
/* キャンバスの中の図形は、テーマの線（stroke）設定を引き継がない */
.dg-canvas g[data-id] * { stroke-linecap: butt; }
.dg-canvas .dg-hit { fill: transparent; stroke: none; }
.dg-canvas .dg-hit-line { fill: none; stroke: transparent; stroke-width: 14; }
.dg-canvas g[data-id] { cursor: move; }
.dg-sel { fill: none; stroke: var(--accent); stroke-dasharray: 5 4; pointer-events: none; }
.dg-sel-line { fill: none; stroke: color-mix(in srgb, var(--accent) 45%, transparent); pointer-events: none; }
.dg-handle { fill: #fff; stroke: var(--accent); }
.dg-handle.is-end { cursor: grab; }
.dg-port { fill: var(--accent); stroke: #fff; cursor: crosshair; opacity: 0.85; }
.dg-port:hover { opacity: 1; }
.dg-target { fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--accent); pointer-events: none; }
.dg-band { fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--accent); pointer-events: none; }
.dg-text {
  position: absolute;
  z-index: 2;
  padding: 2px 4px;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  background: color-mix(in srgb, #fff 92%, transparent);
  outline: 0;
  resize: none;
  line-height: 1.3;
  overflow: hidden;
}
.dg-props {
  flex: none;
  width: 268px;
  padding: 6px 12px 20px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
}
.dg-section { padding: 6px 0 10px; border-bottom: 1px solid var(--line); }
.dg-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; font-size: 12px; color: var(--text-soft); }
.dg-row.is-col { flex-direction: column; align-items: stretch; gap: 4px; padding: 4px 0; }
.dg-row > span { flex: none; }
.dg-row .seg { flex: 1; max-width: 170px; }
.dg-row .range { flex: 1; max-width: 170px; display: flex; align-items: center; gap: 6px; }
.dg-row .range input { flex: 1; min-width: 0; }
.dg-row .range output { width: 28px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.dg-row select { height: 26px; max-width: 170px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--text); font-size: 12px; }
.dg-swatches { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; }
.dg-sw { position: relative; aspect-ratio: 1; padding: 0; border: 1px solid var(--line-strong); border-radius: 5px; cursor: pointer; }
.dg-sw.is-active { outline: 2px solid var(--accent); outline-offset: 1px; }
.dg-sw.is-none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), var(--panel-2); }
.dg-sw.is-pick { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; }
.dg-sw.is-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dg-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dg-num { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.dg-num input { width: 100%; height: 26px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--text); }
.dg-arrange { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 6px; }
.dg-keys { margin: 4px 0; padding-left: 18px; color: var(--muted); font-size: 11.5px; line-height: 1.8; }
