/* ============================================================
   scp.css — Stellia Color Palette（SCP）
   ------------------------------------------------------------
   base.css（header,.panel のカード見た目・.app の flex 骨格）と
   components.css（.icon / .ghost / .hdr-ic / .pane-head / .hdr-menu /
   .theme-dot 等）をそのまま使い、SME と同じ見た目に揃える。
   ここには SCP 固有のレイアウトだけを定義する。
   ============================================================ */

/* ---- ヘッダー ---- */
.scp .title p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.scp-hdr-mount { display: inline-flex; gap: 6px; align-items: center; }
/* 「ワークスペースを開く」はサンプルどおり主ボタン（紫）にする */
.scp-primary {
  background: var(--button-primary-bg);
  border-color: var(--brand);
  color: #fff;
}
.scp-primary:hover { background: var(--button-primary-bg-hover); border-color: var(--brand-strong); color: #fff; }
.scp .actions button[hidden] { display: none; }

/* ---- 3ペイン（.workspace は base.css で flex:1） ---- */
.scp-main {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 312px;
  gap: 8px;
  min-height: 0;
}
.scp-left, .scp-right, .scp-center { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

/* ---- 左：パレット一覧 ---- */
.scp-left-body { flex: 1 1 auto; overflow: auto; padding: 10px; }
.scp-ws-label { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .02em; }
.scp-ws-name { font-size: 13px; font-weight: 700; color: var(--text); margin: 2px 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scp-dir-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 4px 2px; margin-bottom: 2px;
}
.scp-mini-ic { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.scp-palette-list { display: flex; flex-direction: column; gap: 2px; }
.scp-pal-item {
  display: flex; align-items: center; gap: 8px;
  border: 0; background: transparent; box-shadow: none;
  border-radius: 8px; padding: 7px 8px; cursor: pointer; width: 100%;
  color: var(--text); font-size: 13px; font-weight: 600; text-align: left;
}
.scp-pal-item:hover { background: var(--brand-tint-1); color: var(--brand-ink); }
.scp-pal-item.active { background: var(--brand-tint-2); color: var(--brand-ink); font-weight: 800; }
.scp-pal-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.15); }
.scp-pal-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scp-pal-count { flex: none; font-size: 11px; color: var(--muted); font-weight: 700; }
.scp-add-row {
  display: block; width: 100%; margin-top: 8px;
  border: 1.5px dashed var(--border); background: transparent; box-shadow: none;
  border-radius: 8px; padding: 8px; color: var(--muted); font-size: 12px; font-weight: 700;
}
.scp-add-row:hover { border-color: var(--brand-border); color: var(--brand-ink); background: var(--brand-tint-1); }
.scp-empty-note { color: var(--muted); font-size: 12px; padding: 8px 2px; line-height: 1.7; }

/* ---- 中央 ---- */
.scp-center-body { flex: 1 1 auto; overflow: auto; padding: 12px; min-height: 0; }
.scp-pal-headdot { width: 14px; height: 14px; border-radius: 4px; flex: none; background: var(--brand); border: 1px solid rgba(0,0,0,.12); }
/* 表示切替（パレット / CSS変数 / JSON）：セグメントボタン */
.scp-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.scp-seg-btn {
  border: 0; background: transparent; box-shadow: none; border-radius: 0;
  color: var(--muted); font-size: 12px; font-weight: 700; padding: 5px 12px; cursor: pointer;
}
.scp-seg-btn + .scp-seg-btn { border-left: 1px solid var(--border); }
.scp-seg-btn.on { background: var(--brand-tint-2); color: var(--brand-ink); }
/* パレット表示トグル（グリッド/スペクトラム）の選択状態 */
.scp-block-tools .icon.on { background: var(--brand-tint-2); color: var(--brand-ink); border-radius: 8px; }

/* テーマ行 */
.scp-theme-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.scp-theme-label { font-size: 12px; font-weight: 800; color: var(--muted); }
.scp-theme-tabs { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.scp-theme-tab {
  border: 1px solid var(--border); background: var(--button-bg); color: var(--text);
  border-radius: 999px; padding: 4px 14px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.scp-theme-tab.active { background: var(--button-primary-bg); color: #fff; border-color: var(--brand); }
.scp-theme-add { border-style: dashed; color: var(--muted); padding: 4px 10px; }

/* セクション（トークン / パレット / ライブプレビュー）。セクション間は仕切り線で区切る */
.scp-block { margin-bottom: 16px; }
.scp-block + .scp-block { border-top: 1px solid var(--border); padding-top: 14px; }
.scp-block-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scp-block-head strong { font-size: 13px; color: var(--text); }
.scp-badge {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  background: var(--brand-tint-3); color: var(--brand-ink);
  border-radius: 5px; padding: 2px 7px; flex: none;
}
.scp-block-note { font-size: 11px; color: var(--muted); }
.scp-block-tools { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; }
.scp-block-desc { margin: 4px 0 10px; font-size: 11px; color: var(--muted); }
.scp-block-desc code { background: var(--inline-code-bg); border-radius: 5px; padding: 1px 5px; font-family: Consolas, monospace; font-size: 10px; }

/* ---- トークンカード ---- */
.scp-token-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 10px; margin-top: 8px; }
.scp-token-card {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: var(--surface); cursor: pointer; position: relative;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
  transition: box-shadow .15s ease, border-color .15s ease, transform .1s ease;
}
.scp-token-card:hover { border-color: var(--brand-border); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15,23,42,.1); }
.scp-token-card.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint-3); }
.scp-token-card.dragover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-3); }
.scp-token-band { height: 46px; display: flex; align-items: flex-start; justify-content: space-between; padding: 5px 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.07); }
.scp-token-hex {
  font-size: 9px; font-weight: 800; font-family: Consolas, monospace;
  padding: 1px 6px; border-radius: 4px; background: rgba(15,23,42,.55); color: #fff;
}
.scp-state-minis { display: inline-flex; gap: 3px; }
.scp-state-minis i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(255,255,255,.65); box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.scp-token-body { padding: 7px 9px 8px; display: flex; flex-direction: column; gap: 3px; }
.scp-token-role { font-size: 12.5px; font-weight: 800; color: var(--text); font-family: Consolas, monospace; }
.scp-token-ref { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 13px; }
.scp-token-use {
  font-size: 10px; color: var(--brand-ink); background: var(--brand-tint-1);
  border: 1px solid var(--brand-tint-3); border-radius: 999px; padding: 1px 8px;
  align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scp-token-add, .scp-color-add {
  border: 1.5px dashed var(--border); border-radius: 10px; min-height: 104px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; box-shadow: none;
  color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer;
}
.scp-token-add:hover, .scp-color-add:hover { border-color: var(--brand-border); color: var(--brand-ink); background: var(--brand-tint-1); }
/* 削除（グレーアウト）した標準トークンの欄。クリックで復活できることを示す */
.scp-token-card.scp-token-removed {
  border: 1.5px dashed var(--border); background: var(--soft); box-shadow: none;
  text-align: left; padding: 0; opacity: .85;
}
.scp-token-card.scp-token-removed:hover { opacity: 1; border-color: var(--brand-border); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15,23,42,.1); }
.scp-token-removed .scp-token-band {
  height: 46px; box-shadow: none; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, var(--border) 0 6px, transparent 6px 12px);
  opacity: .5;
}
.scp-token-removed-ic { font-size: 20px; font-weight: 800; color: var(--muted); line-height: 1; }
.scp-token-removed .scp-token-role { color: var(--muted); }
.scp-token-removed-note { font-size: 10px; color: var(--brand-ink); font-weight: 700; }

/* ---- マイパレット ---- */
.scp-color-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 8px; }
.scp-color-card {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface);
  cursor: grab; position: relative;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
  transition: box-shadow .15s ease, border-color .15s ease, transform .1s ease;
}
.scp-color-card:hover { border-color: var(--brand-border); transform: translateY(-1px); }
.scp-color-card.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint-3); }
.scp-color-swatch { height: 52px; }
.scp-color-meta { padding: 5px 8px 7px; }
.scp-color-name { display: block; font-size: 11.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scp-color-hex { display: block; font-size: 10px; color: var(--muted); font-family: Consolas, monospace; }
.scp-color-add { min-height: 88px; }

/* ---- スペクトラム ---- */
.scp-spec-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.scp-spec-head input[type="range"] { vertical-align: middle; width: 180px; }
#scpSpecCanvas { width: 100%; height: 230px; border-radius: 10px; border: 1px solid var(--border); cursor: crosshair; display: block; }

/* ---- 出力（CSS変数 / JSON 表示） ---- */
.scp-output {
  margin: 0; padding: 12px 14px; border-radius: 10px;
  background: var(--code-bg, #0d1117); color: var(--code-fg, #c9d1d9);
  font-family: Consolas, Monaco, "Courier New", monospace; font-size: 12px; line-height: 1.6;
  overflow: auto; white-space: pre;
}

/* ---- 右：詳細・色調整 ---- */
.scp-right-body { flex: 1 1 auto; overflow: auto; padding: 12px; }
.scp-detail-empty { color: var(--muted); font-size: 12px; padding: 8px 2px; line-height: 1.8; }
.scp-d-preview { height: 88px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 10px; position: relative; }
.scp-d-preview .scp-token-hex { position: absolute; top: 6px; left: 6px; }
.scp-d-title { font-size: 14px; font-weight: 800; margin: 0 0 2px; }
.scp-d-sub { font-size: 11px; color: var(--muted); margin: 0 0 12px; }
.scp-d-sec-title { font-size: 11px; color: var(--muted); font-weight: 800; margin: 14px 0 6px; letter-spacing: .02em; }

/* 状態スロット */
.scp-state-slots { display: flex; flex-direction: column; gap: 6px; }
.scp-state-slot {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 8px; background: var(--surface);
}
.scp-state-slot.dragover { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint-3); }
.scp-ss-swatch { width: 28px; height: 28px; border-radius: 7px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.scp-ss-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.scp-ss-name { font-size: 12px; font-weight: 800; }
.scp-ss-hex { font-family: Consolas, monospace; font-size: 10px; color: var(--muted); }
.scp-ss-badge { font-size: 9px; font-weight: 800; border-radius: 999px; padding: 2px 8px; flex: none; }
.scp-ss-badge.auto { background: var(--brand-tint-2); color: var(--brand-ink); }
.scp-ss-badge.manual { background: var(--warn-tint, #fef3c7); color: var(--warn-ink, #92400e); }
.scp-ss-pick { width: 24px; height: 24px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; flex: none; box-shadow: none; }
.scp-ss-reset { border: 0; background: transparent; box-shadow: none; cursor: pointer; color: var(--muted); padding: 2px; flex: none; display: inline-grid; place-items: center; }
.scp-ss-reset:hover { color: var(--brand-ink); background: transparent; }
.scp-ss-reset .scp-mini-ic { width: 13px; height: 13px; }
.scp-states-off { width: 100%; margin-top: 8px; font-size: 12px; }

/* HSL スライダー */
.scp-d-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 12px; }
.scp-d-row label { width: 38px; flex: none; color: var(--muted); font-weight: 800; font-size: 11px; }
.scp-d-row input[type="range"] {
  flex: 1 1 auto; min-width: 0; appearance: none; -webkit-appearance: none;
  height: 10px; border-radius: 5px; outline: none; border: 1px solid rgba(0,0,0,.08);
}
.scp-d-row input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--brand); cursor: pointer;
  box-shadow: 0 1px 3px rgba(15,23,42,.3);
}
.scp-d-val { width: 42px; flex: none; text-align: right; font-family: Consolas, monospace; font-size: 11px; color: var(--text); font-weight: 700; }

/* HEX/RGB/HSL コピー行 */
.scp-codes { display: flex; flex-direction: column; gap: 5px; margin: 12px 0; }
.scp-code-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-family: Consolas, monospace; font-size: 12px;
  cursor: pointer; text-align: left; box-shadow: none;
}
.scp-code-btn:hover { background: var(--brand-tint-1); border-color: var(--brand-border); }
.scp-code-btn .scp-code-label { color: var(--muted); font-size: 10px; font-weight: 800; font-family: var(--ui-font); }

/* コントラスト */
.scp-contrast { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin: 12px 0; background: var(--surface); }
.scp-contrast h4 { margin: 0 0 8px; font-size: 11px; color: var(--muted); font-weight: 800; }
.scp-ct-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 5px 0; }
.scp-ct-sample { width: 56px; height: 26px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; border: 1px solid var(--border); flex: none; }
.scp-ct-pass { color: var(--ok, #15803d); font-weight: 800; margin-left: auto; }
.scp-ct-fail { color: var(--danger, #dc2626); font-weight: 800; margin-left: auto; }

/* スケール生成 */
.scp-scale { display: flex; gap: 3px; margin-top: 4px; }
.scp-scale button { flex: 1 1 auto; height: 30px; border: 1px solid rgba(0,0,0,.12); border-radius: 6px; cursor: pointer; position: relative; padding: 0; box-shadow: none; }
.scp-scale button:hover::after { content: attr(data-step); position: absolute; inset: auto auto 110% 50%; transform: translateX(-50%); font-size: 9px; background: #1e293b; color: #fff; padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.scp-d-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.scp-d-actions button { font-size: 12px; }

/* ---- 下部バー（SME の .bottom-bar と平仄。枠なしのプレーンテキスト・右寄せ） ---- */
.scp-status {
  height: 20px; display: flex; align-items: center; justify-content: flex-end;
  gap: 16px; padding: 0 6px; flex: none;
  color: var(--muted); font-size: 12px; font-weight: 700;
}
.scp-st-sync { color: var(--ok, #16a34a); }
.scp-st-sync.dirty { color: var(--warn, #d97706); }
.scp-st-sync.off { color: var(--muted); }

/* ---- 中央パネル最下部のステータスバー（SME の editor-status-bar と同体裁） ----
   テーマ名・現在のカラーコードを右側に表示する */
.scp-pane-status {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px; border-top: 1px solid var(--border); background: var(--panel);
  flex: none; min-height: 30px;
}
.scp-st-right { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
.scp-chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 9px;
  background: var(--surface); color: var(--text); font-size: 11px; font-weight: 700;
}
.scp-st-hex { font-family: Consolas, monospace; }

/* ---- ライブプレビュー（B-2） ---- */
.scp-live { margin-top: 8px; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.scp-live-stage { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.scp-live-card { border-radius: 10px; padding: 12px 14px; }
.scp-live-h { margin: 0 0 4px; font-size: 14px; font-weight: 800; }
.scp-live-p { margin: 0; font-size: 12px; line-height: 1.6; }
.scp-live-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.scp-live-btn {
  border: 0; border-radius: 8px; padding: 7px 14px;
  font-size: 12px; font-weight: 800; cursor: pointer; box-shadow: none; color: #fff;
}
.scp-live-badge { border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 800; color: #fff; }

/* ---- トークン追加ダイアログ ---- */
.scp-set-field input[type="text"] {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; box-sizing: border-box;
}
.scp-tok-colors { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.scp-tok-swatch {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(0,0,0,.15);
  cursor: pointer; padding: 0; box-shadow: none; position: relative;
}
.scp-tok-swatch.selected { outline: 2px solid var(--brand); outline-offset: 2px; }
.scp-tok-pick-row { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.scp-tok-pick-row input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: transparent; }

/* ---- ドラッグ中のチップ ---- */
.scp-drag-chip {
  position: fixed; z-index: 999; width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid #fff; box-shadow: 0 4px 12px rgba(15,23,42,.35);
  pointer-events: none; transform: translate(-50%, -50%);
}

/* ---- 設定ダイアログ ---- */
.scp-dialog { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-pop); padding: 0; min-width: 380px; max-width: 92vw; }
.scp-dialog::backdrop { background: rgba(15, 23, 42, .38); }
.scp-dialog-body { padding: 18px 20px; }
.scp-dialog-body h2 { margin: 0 0 12px; font-size: 15px; color: var(--brand-ink); }
.scp-set-field { margin-bottom: 14px; }
.scp-set-field > label { display: block; font-size: 12px; font-weight: 800; margin-bottom: 5px; }
.scp-set-field select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px; }
.scp-set-desc { margin: 5px 0 0; font-size: 11px; color: var(--muted); line-height: 1.6; }
.scp-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 700; cursor: pointer; }
.scp-check input { margin-top: 2px; }
.scp-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---- ポップアップモード ---- */
body.scp-popup-mode .app { display: none; }
.scp-popup { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.scp-popup[hidden] { display: none; }
.scp-pop-swatch { height: 110px; border-radius: 12px; border: 1px solid var(--border); }
.scp-pop-codes { display: flex; flex-direction: column; gap: 6px; }
.scp-pop-code {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 12px; font-family: Consolas, monospace; font-size: 13px;
  cursor: pointer; text-align: left; box-shadow: none;
}
.scp-pop-code:hover { background: var(--brand-tint-1); border-color: var(--brand-border); }
.scp-pop-actions { display: flex; gap: 8px; }

@media (max-width: 1080px) {
  .scp-main { grid-template-columns: 200px minmax(0, 1fr) 280px; }
}
@media (max-width: 880px) {
  .scp-main { grid-template-columns: 1fr; overflow: auto; }
  .scp-left, .scp-right, .scp-center { overflow: visible; }
  .scp-left-body, .scp-right-body, .scp-center-body { overflow: visible; }
}

/* ============================================================
   v0.2.0 追加分
   ============================================================ */

/* ---- 全色スペクトラム グリッド（改善001） ---- */
.scp-spec-satval { font-size: 12px; font-weight: 800; color: var(--text); margin-left: 2px; }
.scp-spec-grid {
  display: grid; gap: 3px; margin-top: 8px;
  /* grid-template-columns は scp.js が列数に合わせて設定する */
}
.scp-spec-cell {
  border: 1px solid rgba(255,255,255,.65); border-radius: 5px; box-shadow: none; padding: 0;
  aspect-ratio: 7 / 5; min-height: 18px; cursor: pointer;
}
.scp-spec-cell:hover { transform: scale(1.12); border-color: rgba(0,0,0,.4); z-index: 1; position: relative; }
.scp-spec-cell.selected { outline: 2px solid var(--brand); outline-offset: 1px; border-color: #fff; z-index: 1; position: relative; }
.scp-spec-cell.gray { margin-right: 5px; }

/* ---- 右クリックメニュー（改善002/004） ---- */
.scp-ctx {
  position: fixed; z-index: 300; min-width: 220px; padding: 5px;
  background: var(--panel, var(--surface)); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.22);
}
.scp-ctx-sub { position: absolute; z-index: 301; }
.scp-ctx-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  border: 0; background: transparent; box-shadow: none; border-radius: 7px;
  padding: 7px 10px; font-size: 12.5px; font-weight: 600; color: var(--text); text-align: left; cursor: pointer;
}
.scp-ctx-item:hover:not([disabled]) { background: var(--brand-tint-2); color: var(--brand-ink); }
.scp-ctx-item[disabled] { opacity: .45; cursor: default; }
.scp-ctx-item.danger { color: var(--danger, #dc2626); }
.scp-ctx-item.danger:hover:not([disabled]) { background: var(--danger-tint-2, rgba(220,38,38,.1)); color: var(--danger, #dc2626); }
.scp-ctx-arrow { color: var(--muted); font-size: 11px; }
.scp-ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ---- 未保存インジケータ（改善003） ---- */
.scp-pal-dirty { flex: none; color: var(--brand); font-size: 10px; line-height: 1; }

/* ---- 状態色リセット（改善005: 手動バッジの左。自動時は非活性） ---- */
.scp-ss-reset[disabled] { opacity: .25; cursor: default; pointer-events: none; }

/* ---- 選択ダイアログ（保存して移動 / 破棄して移動 / キャンセル） ---- */
.scp-choice-msg { margin: 0 0 14px; font-size: 13px; line-height: 1.8; color: var(--text); }
.scp-choice-actions { flex-wrap: wrap; }

/* ============================================================
   v0.2.0 フィードバック対応分
   ============================================================ */

/* 表示切替（パレット/CSS変数/JSON）はテーマ行の右端へ */
.scp-theme-row .scp-seg { margin-left: auto; }

/* 編集中バッジ（SMEのタブと同じ点滅ドット。パレット名の横） */
.scp-dirty-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: scpDirtyPulse 1.6s ease-in-out infinite; }
.scp-dirty-dot[hidden] { display: none; }
@keyframes scpDirtyPulse { 0%,100% { opacity: .45; box-shadow: 0 0 0 0 var(--brand-tint-2); } 50% { opacity: 1; box-shadow: 0 0 6px 1px var(--brand); } }

/* アクティブペインの紫線（SME base.css の .panel.pane と同じ動き）。
   中央は .panel.pane なので base.css の規則がそのまま効く。左右パネルにも同じ線を付ける。 */
.scp .panel.scp-left, .scp .panel.scp-right { position: relative; }
.scp .panel.scp-left::before, .scp .panel.scp-right::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--brand); transform: scaleX(0); transform-origin: left;
  transition: transform .25s ease; z-index: 6; pointer-events: none;
}
.scp .panel.scp-left.pane-active::before, .scp .panel.scp-right.pane-active::before {
  transform: scaleX(1); animation: pane-active-glow 2.2s ease-in-out infinite;
}

/* D&D・Shift+クリックで文字が選択状態にならないように */
.scp-token-grid, .scp-color-cards, .scp-spec-grid, .scp-palette-list,
.scp-state-slots, .scp-theme-tabs, .scp-live { user-select: none; }

/* 色追加ダイアログ */
.scp-col-preview { height: 64px; border-radius: 10px; border: 1px solid var(--border); margin: 2px 0 12px; display: flex; align-items: center; justify-content: center; }
.scp-col-inputs { display: flex; gap: 12px; margin: 4px 0 12px; }
.scp-col-inputs label { flex: 1; display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 800; }
.scp-col-inputs input {
  flex: 1; min-width: 0; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
  font-family: Consolas, monospace; font-size: 13px;
}
.scp-col-inputs input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-2); }
.scp-dialog .scp-set-field input[type="text"] {
  width: 100%; padding: 7px 10px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px;
}
.scp-dialog .scp-set-field input[type="text"]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-2); }

/* ============================================================
   v0.3.0 追加分
   ============================================================ */

/* ---- トークン/パレットのスクロール（改善008→FB3-g） ----
   トークンカードが途中で切れて「バッジが隠れる」のを避けるため、トークングリッドの
   固定 max-height（約2段）を廃止。トークンは全カードを丸ごと表示し、トークン＋パレットの
   領域全体（#scpViewPalette）を1つのスクロールにする。 */
.scp-center-body { display: flex; flex-direction: column; overflow: hidden; }
.scp-theme-row { flex: none; }
#scpViewPalette { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
#scpViewPalette[hidden] { display: none; }
#scpViewPalette > .scp-block:nth-of-type(1) { flex: none; display: flex; flex-direction: column; }
.scp-token-grid { align-content: start; } /* カードは縦に伸ばさず、全カードを丸ごと表示（内部スクロールしない） */
#scpViewPalette > .scp-block:nth-of-type(2) { flex: none; display: flex; flex-direction: column; margin-bottom: 0; }
#scpMyPalette, #scpSpectrum { min-height: 0; }
#scpMyPalette[hidden], #scpSpectrum[hidden] { display: none; }
/* 出力（CSS/JSON）ブロック：コード内右上にコピー／保存ボタンを内蔵（SMEのコードブロックと同体裁） */
.scp-output-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.scp-output-wrap[hidden] { display: none; }
.scp-output-wrap > #scpOutput { flex: 1 1 auto; min-height: 0; width: 100%; overflow: auto; }
.scp-output-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; z-index: 2; }
.scp-out-btn {
  width: 28px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 7px; cursor: pointer;
  background: rgba(255,255,255,.08); color: #c9d1d9; box-shadow: none;
  transition: background .14s ease, color .14s ease, transform .1s ease;
}
.scp-out-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.scp-out-btn:active { transform: translateY(1px); }
.scp-out-btn.scp-out-copied { color: #4ade80; }
.scp-out-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ---- ライブプレビュー別ウインドウ（改善008/009） ---- */
.scp-livewin {
  position: fixed; z-index: 250; width: 560px; height: 520px;
  display: flex; flex-direction: column;
  background: var(--panel, var(--surface)); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28); overflow: hidden;
}
.scp-livewin[hidden] { display: none; }
.scp-lw-titlebar { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 12px; cursor: move; user-select: none; background: var(--soft); border-bottom: 1px solid var(--border); }
.scp-lw-title { font-size: 12px; font-weight: 800; color: var(--text); flex: none; }
.scp-lw-seg { margin-left: auto; cursor: default; }
.scp-lw-close { flex: none; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); cursor: pointer; font-size: 12px; line-height: 1; }
.scp-lw-close:hover { background: var(--border); color: var(--text); }
.scp-lw-body { flex: 1; min-height: 0; overflow: auto; }
.scp-lw-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--border) 50%); border-bottom-right-radius: 12px; }

/* ---- ライブプレビュー内容（lp-*。色はすべて scp.js がトークンからインラインで指定） ----
   .lp-stage は縦flexにして、フッター（margin-top:auto）が常に最下部へ来るようにする。
   ウインドウ内では #scpLiveBody も縦flexにし、内容が短いときは stage が全高まで伸びる */
.lp-stage { min-height: 100%; font-size: 12.5px; line-height: 1.6; user-select: none; display: flex; flex-direction: column; }
#scpLiveBody { display: flex; flex-direction: column; }
#scpLiveBody > .lp-stage { flex: 1 0 auto; }
.lp-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.lp-logo { flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-weight: 900; }
.lp-nav { display: flex; gap: 12px; margin-left: 12px; font-weight: 700; font-size: 12px; }
.lp-nav span { padding: 2px 0; }
.lp-header .lp-btn-sm { margin-left: auto; }
.lp-hero { padding: 26px 18px 18px; text-align: center; }
.lp-hero h2 { margin: 0 0 6px; font-size: 19px; }
.lp-hero p { margin: 0 0 14px; font-size: 12.5px; }
.lp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.lp-btn { border: 0; border-radius: 8px; padding: 7px 14px; font-size: 12.5px; font-weight: 800; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.12); display: inline-block; }
.lp-btn-sm { padding: 5px 10px; font-size: 11.5px; }
.lp-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 4px 18px 14px; }
.lp-card { border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.lp-card-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; margin-bottom: 2px; }
.lp-form { margin: 0 18px 14px; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.lp-form .lp-row { justify-content: flex-start; }
.lp-input { display: inline-block; border-radius: 8px; padding: 6px 10px; font-size: 12px; min-width: 110px; }
.lp-alerts { display: flex; gap: 8px; flex-wrap: wrap; }
.lp-alert { border-radius: 8px; padding: 5px 10px; font-size: 11.5px; font-weight: 700; }
.lp-footer { padding: 10px 14px; font-size: 11.5px; margin-top: auto; }
/* アプリ画面 */
.lp-app { display: flex; flex-direction: row; min-height: 100%; }
.lp-side { flex: 0 0 124px; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px; }
.lp-side-item { border-radius: 7px; padding: 6px 9px; font-size: 11.5px; font-weight: 700; opacity: .92; }
.lp-app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lp-app-top { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; }
.lp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px 12px 0; }
.lp-stat { border-radius: 10px; padding: 9px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.lp-stat strong { font-size: 14.5px; }
.lp-chart { margin: 10px 12px 0; border-radius: 10px; padding: 10px 12px; font-size: 11px; }
.lp-bars { display: flex; align-items: flex-end; gap: 8px; height: 64px; margin-top: 6px; }
.lp-bars i { flex: 1; border-radius: 4px 4px 0 0; }
.lp-table { margin: 10px 12px 12px; border-radius: 10px; border-collapse: collapse; overflow: hidden; width: calc(100% - 24px); font-size: 11.5px; }
.lp-table th, .lp-table td { text-align: left; padding: 6px 10px; }
/* 部品一覧 */
.lp-parts { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.lp-sec { display: flex; flex-direction: column; gap: 6px; }
.lp-sec .lp-row { justify-content: flex-start; }
.lp-sec-t { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; }
.lp-badge { border-radius: 999px; padding: 3px 9px; font-size: 10.5px; font-weight: 800; }
.lp-tag { border-radius: 999px; padding: 2px 9px; font-size: 10.5px; font-weight: 700; background: transparent; }
.lp-check { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 4px; font-size: 10px; vertical-align: -2px; }
.lp-radio { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 2px solid; vertical-align: -2px; }
.lp-radio i { width: 7px; height: 7px; border-radius: 50%; }
.lp-toggle { display: inline-block; width: 30px; height: 16px; border-radius: 999px; position: relative; }
.lp-toggle i { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.lp-toggle.on i { left: auto; right: 2px; }
.lp-progress { display: inline-block; width: 130px; height: 8px; border-radius: 999px; overflow: hidden; }
.lp-progress i { display: block; height: 100%; border-radius: 999px; }
.lp-skel { display: inline-block; width: 130px; height: 12px; border-radius: 6px; background-size: 200% 100% !important; animation: lpSkel 1.4s linear infinite; }
@keyframes lpSkel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- ワークスペース選択ダイアログ（改善007） ---- */
.scp-ws-recent { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 12px; max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 5px; background: var(--surface); }
.scp-ws-item { display: flex; align-items: center; gap: 9px; border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); }
.scp-ws-item:hover { background: var(--brand-tint-2); color: var(--brand-ink); }
.scp-ws-ic { flex: none; color: var(--muted); }
.scp-ws-item-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scp-ws-del { flex: none; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); cursor: pointer; font-size: 11px; opacity: 0; transition: opacity .12s ease; }
.scp-ws-item:hover .scp-ws-del { opacity: .8; }
.scp-ws-del:hover { background: var(--border); color: var(--text); opacity: 1 !important; }

/* ---- RGB 分割入力（改善011） ---- */
.scp-rgb-group { display: inline-flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.scp-rgb-group span { color: var(--muted); font-weight: 800; }
.scp-rgb-group input {
  width: 46px; min-width: 0; padding: 7px 4px; text-align: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
  font-family: Consolas, monospace; font-size: 13px;
}
.scp-rgb-group input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-2); }

/* ============================================================
   v0.3.0 フィードバック対応分
   ============================================================ */

/* ---- ワークスペース選択ダイアログ（SMEと同構成。改善007 FB） ---- */
.scp-ws-dialog .scp-dialog-body { min-width: min(560px, calc(100vw - 64px)); }
.scp-ws-divider { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.scp-ws-row { display: flex; align-items: center; gap: 10px; }
.scp-ws-row > label { flex: none; font-size: 13px; font-weight: 700; color: var(--text); }
.scp-ws-row .ss-wrap { flex: 1 1 auto; min-width: 0; width: auto; }
/* 履歴項目：フォルダ名のすぐ右に日時を控えめに置く（名前と日時の間を詰める） */
.scp-ws-when { color: var(--muted); font-weight: 500; margin-left: 6px; font-size: 12px; }
.scp-ws-browse {
  flex: none; padding: 7px 14px; border: 1px solid var(--brand); border-radius: 8px;
  background: var(--surface); color: var(--brand-ink, var(--brand)); font-size: 13px; font-weight: 800; cursor: pointer;
}
.scp-ws-browse:hover { background: var(--brand-tint-2); }
.scp-ghost { border: 0; background: transparent; box-shadow: none; color: var(--muted); font-weight: 700; cursor: pointer; }
.scp-ghost:hover { color: var(--text); background: transparent; }

/* ---- パレット追加：テンプレート選択ダイアログ ---- */
.scp-tpl-dialog .scp-dialog-body { min-width: min(520px, calc(100vw - 64px)); }
.scp-tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0 14px; }
.scp-tpl-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
  text-align: left; padding: 14px; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface); cursor: pointer; box-shadow: none; transition: border-color .12s ease, box-shadow .12s ease;
}
.scp-tpl-card:hover { border-color: var(--brand-border); }
.scp-tpl-card.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-2); }
.scp-tpl-ic { font-size: 22px; line-height: 1; }
.scp-tpl-card strong { font-size: 13.5px; color: var(--text); }
.scp-tpl-desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* ---- ライブプレビュー: 外部ウインドウボタン・カスタムトークン ---- */
.scp-lw-ext { flex: none; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.scp-lw-ext:hover { background: var(--border); color: var(--text); }
.scp-lw-ext .hdr-ic { width: 14px; height: 14px; }
.lp-custom { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
/* カスタムトークンのカード（FB3: 色帯＋HEX / 役割名 / 用途 / 見え方サンプル） */
.lp-ct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.lp-ct-card { border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.lp-ct-band { height: 42px; display: flex; align-items: flex-end; justify-content: flex-end; padding: 5px 8px; }
.lp-ct-band span { font-size: 10px; font-weight: 800; letter-spacing: .05em; opacity: .92; font-family: Consolas, ui-monospace, monospace; }
.lp-ct-meta { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 2px; }
.lp-ct-meta strong { font-size: 12px; line-height: 1.3; word-break: break-all; }
.lp-ct-meta span { font-size: 10.5px; line-height: 1.4; }
.lp-ct-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 7px 10px 10px; }
.lp-ct-mini { display: inline-flex; align-items: center; border-radius: 6px; padding: 3px 8px; font-size: 10.5px; font-weight: 700; line-height: 1.4; }

/* ---- パレットの別ウインドウ（FB。ライブプレビューと同スタイル） ---- */
.scp-palwin-body { display: flex; flex-direction: column; }
.scp-palwin .scp-block { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; padding: 10px 12px; }
.scp-palwin #scpMyPalette, .scp-palwin #scpSpectrum { flex: 1 1 auto; min-height: 0; overflow: auto; }
/* ✕ は右端に赤で表示する（FB3。タイトルバーにはタイトルと✕しかないため auto マージンで右へ寄せる） */
.scp-palwin .scp-lw-close { margin-left: auto; color: var(--danger, #dc2626); }
.scp-palwin .scp-lw-close:hover { background: var(--danger, #dc2626); color: #fff; }
