* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Yu Gothic UI", sans-serif;
  background: #14181f; color: #dde3ea;
  height: 100vh; display: flex; flex-direction: column;
}
header { padding: 10px 16px; border-bottom: 1px solid #2a3140; }
header h1 { font-size: 18px; display: inline-block; margin-right: 12px; }
.tagline { display: inline-block; font-size: 12px; color: #8a94a6; }
main { flex: 1; display: flex; min-height: 0; }
#preview-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#canvas-wrap { flex: 1; overflow: auto; padding: 16px; background: #0d1015; }
#preview { display: block; margin: 0 auto; box-shadow: 0 0 24px rgba(0,0,0,.6); }
#zoom-bar { padding: 6px 16px; border-top: 1px solid #2a3140; font-size: 12px; display: flex; align-items: center; gap: 10px; }
#zoom { vertical-align: middle; width: 160px; }
#zoom-fit {
  padding: 4px 10px; font-size: 12px; background: #1c222d; color: #dde3ea;
  border: 1px solid #3a4356; border-radius: 4px; cursor: pointer;
}
#zoom-fit:hover { background: #26304082; border-color: #8b7cf6; }
#panel-resizer {
  width: 6px; flex-shrink: 0; cursor: col-resize; position: relative; background: transparent;
}
#panel-resizer::after {
  content: ""; position: absolute; left: 2px; top: 0; bottom: 0; width: 2px; background: #2a3140;
}
#panel-resizer:hover::after, #panel-resizer.dragging::after { background: #8b7cf6; }
#panel { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0; }
/* scrollbar-gutter: overflowの有無でスクロールバー分(~15px)の幅が増減し、
   ステップ間でパネル幅が変わって見出しの折り返しがズレるのを防ぐ */
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding: 12px; }
.step { margin-bottom: 18px; }
.step h2 { font-size: 14px; color: #8b7cf6; margin-bottom: 8px; }
.step label { display: block; font-size: 12px; margin: 6px 0 2px; color: #a8b2c2; }
.step input, .step select, .step button {
  width: 100%; padding: 5px 8px; font-size: 13px;
  background: #1c222d; color: #dde3ea; border: 1px solid #3a4356; border-radius: 4px;
}
.step input[type="range"] { padding: 0; }
.step button { cursor: pointer; margin-top: 8px; }
.step button:hover { background: #26304082; border-color: #8b7cf6; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hint { font-size: 11px; color: #8a94a6; margin-top: 4px; line-height: 1.5; }
.footer-link { flex-shrink: 0; margin: 8px 0 10px; text-align: center; font-size: 11px; }
.footer-link a { color: #6a7688; }
.footer-link a:hover { color: #8b7cf6; }
.step h3.sub { font-size: 12px; color: #a8b2c2; margin: 12px 0 4px; }
.calib-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.calib-actions .calib-reset { width: auto; padding: 5px 12px; font-size: 12px; }
.zone-item-row { display: flex; gap: 4px; margin-top: 4px; }
.zone-item-row .zone-item {
  flex: 1; height: 28px; box-sizing: border-box; text-align: left; margin-top: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.zone-item.selected { border-color: #8b7cf6; background: #223046; }
.zone-item-row .zone-item-delete,
.file-picker-row .zone-item-delete {
  flex-shrink: 0; flex-grow: 0; width: 32px; height: 28px; box-sizing: border-box;
  padding: 0; margin-top: 0; line-height: 26px; color: #f2a6a6;
}
.zone-item-delete:hover { background: #402626; border-color: #f26d6d; }
.file-picker-row { display: flex; align-items: center; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.file-picker-row .hint { flex: 1; min-width: 60px; }
/* 選択中のゾーン編集: アクセント色の枠+背景で「全体の枠デフォルト」とはっきり区別する */
.zone-editor {
  margin-top: 10px; padding: 10px; border-radius: 6px;
  border: 1px solid #6a4fd1; background: #201c33; box-shadow: 0 0 0 1px #6a4fd155;
}
.zone-editor > h3.sub { color: #b3a4ff; }
/* 全体の枠デフォルト: ニュートラル色の実線枠で「個別ゾーンではない」ことを示す */
.default-editor {
  margin-top: 20px; padding: 10px; border: 1px solid #3a4356; border-radius: 6px;
}
/* ステップ1の各グループ枠(自動検出可能な項目/アイコンサイズ/キャリブレーション)、
   ステップ2の枠スタイル入れ子枠・全体の枠デフォルトでも共用 */
.step1-group {
  margin-top: 14px; padding: 10px; border: 1px solid #3a4356; border-radius: 6px;
}
.step1-group:first-child { margin-top: 0; }
.step1-group > h3.sub { margin-top: 0; }
.step1-group > summary, .default-editor > summary {
  cursor: pointer; font-weight: bold; color: #b3a4ff; font-size: 13px;
  list-style: none;
}
.step1-group > summary::-webkit-details-marker,
.default-editor > summary::-webkit-details-marker { display: none; }
.step1-group > summary::before, .default-editor > summary::before { content: "▸ "; }
.step1-group[open] > summary, .default-editor[open] > summary { margin-bottom: 10px; }
.step1-group[open] > summary::before, .default-editor[open] > summary::before { content: "▾ "; }
.step .field-gap-top { margin-top: 24px; }
button.primary { border-color: #2e6db3; background: #1d3a5c; font-weight: bold; }
button.primary:hover { background: #24507e; }
/* ガイドボタンを上、設定入出力ボタン(書き出す/読み込む/リセット)を下に縦積みし、
   両者の幅を揃える(設定ボタン側が増えてもガイドボタンとずれないように) */
.panel-toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.guide-open-btn {
  width: 100%; margin-top: 0; text-align: left;
  padding: 6px 10px; font-size: 12px; background: #1c222d; color: #8b7cf6;
  border: 1px solid #3a4356; border-radius: 4px; cursor: pointer;
}
.guide-open-btn:hover { background: #26304082; border-color: #8b7cf6; }
.guide-content ol { margin: 4px 0 16px 20px; }
.guide-content li { margin-bottom: 12px; line-height: 1.7; }
.guide-content li:last-child { margin-bottom: 0; }
.guide-step-title { font-weight: bold; color: #b3a4ff; margin-bottom: 4px; }
.guide-tip {
  margin: 16px 0; padding: 10px 12px; background: #1c222d;
  border-left: 3px solid #8b7cf6; border-radius: 4px;
}
.guide-tip-title { font-weight: bold; margin-bottom: 4px; }
.settings-io { display: flex; gap: 6px; }
.settings-io button {
  flex: 1; padding: 6px 10px; font-size: 11px; white-space: nowrap;
  background: #1c222d; color: #dde3ea; border: 1px solid #3a4356; border-radius: 4px; cursor: pointer;
}
.settings-io button:hover { background: #26304082; border-color: #8b7cf6; }
.settings-io .reset-btn:hover { background: #402626; border-color: #f26d6d; color: #f2a6a6; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid #2a3140; }
.tab-btn {
  flex: 1; background: none; border: none; border-bottom: 2px solid transparent;
  color: #8a94a6; font-size: 13px; padding: 8px 4px; cursor: pointer; border-radius: 0;
}
.tab-btn:hover { color: #dde3ea; background: #1c222d82; }
.tab-btn.active { color: #8b7cf6; border-bottom-color: #8b7cf6; }
.step { display: none; }
.step.active { display: block; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  position: relative; max-width: 480px; width: 90%; max-height: 80vh; overflow-y: auto;
  background: #1c222d; border: 1px solid #3a4356; border-radius: 8px; padding: 24px;
}
.modal-close {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px;
  background: none; border: none; color: #8a94a6; font-size: 18px; line-height: 1; cursor: pointer;
}
.modal-close:hover { color: #dde3ea; }
.modal-box h2 { font-size: 16px; color: #8b7cf6; margin-bottom: 12px; padding-right: 24px; }
.modal-box ol { margin: 8px 0 8px 18px; line-height: 1.7; font-size: 13px; }
.modal-box p { margin: 8px 0; line-height: 1.6; font-size: 13px; color: #a8b2c2; }
.guide-hide-option {
  display: flex; align-items: center; gap: 6px; margin-top: 16px;
  font-size: 12px; color: #8a94a6; cursor: pointer;
}
