/* 5eキャラシ工房 — 画面用スタイル
   レイアウト：左に目次、中央にフォーム、右に概要と出力の固定パネル（狭い画面では縦積み） */
:root {
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --line: #d8dbe2;
  --ink: #1d2230;
  --muted: #646b7b;
  --accent: #9e2a2f;        /* 封蝋の赤 */
  --accent-ink: #ffffff;
  --accent-soft: #f6e5e5;
  --brass: #8a6a1f;         /* 真鍮 */
  --brass-soft: #f3ecd9;
  --ok: #2f7d4f;
  --warn: #b5562a;
  --focus: #2f5fb3;
  --shadow: 0 1px 2px rgba(20, 24, 36, .06), 0 4px 16px rgba(20, 24, 36, .05);
  --font-display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-body: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --font-label: "Cinzel", "Times New Roman", serif;
  --radius: 10px;
  color-scheme: light;
}
/* テーマ（キャラクターごとに保存）：ライト／ダーク／パステル8色。html の data-theme で切り替える */
:root[data-theme="dark"] {
  --bg: #14161b; --surface: #1c1f26; --surface-2: #23272f; --line: #323743; --ink: #eceef3; --muted: #9aa1b0;
  --accent: #e0666c; --accent-ink: #14161b; --accent-soft: #3a2224; --brass: #d3b265; --brass-soft: #332c1b;
  --ok: #63c08a; --warn: #e48a5c; --focus: #7aa2ff; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
:root[data-theme="pastel-sakura"] { --bg: #f7dfe7; --surface: #fcf2f5; --surface-2: #faeaef; --line: #d4c0c7; }
:root[data-theme="pastel-peach"] { --bg: #fbe5d6; --surface: #fdf5ef; --surface-2: #fceee4; --line: #d8c5b8; }
:root[data-theme="pastel-lemon"] { --bg: #f8f0c8; --surface: #fcf9e9; --surface-2: #faf5db; --line: #d5ceac; }
:root[data-theme="pastel-mint"] { --bg: #d9f0e1; --surface: #f0f9f3; --surface-2: #e6f5ec; --line: #bbcec2; }
:root[data-theme="pastel-sky"] { --bg: #dbeaf8; --surface: #f1f7fc; --surface-2: #e8f1fa; --line: #bcc9d5; }
:root[data-theme="pastel-lavender"] { --bg: #e6def5; --surface: #f5f2fb; --surface-2: #efeaf8; --line: #c6bfd3; }
:root[data-theme="pastel-aqua"] { --bg: #d5efee; --surface: #eef9f8; --surface-2: #e4f5f4; --line: #b7cecd; }
:root[data-theme="pastel-sand"] { --bg: #efe6d6; --surface: #f9f5ef; --surface-2: #f5efe4; --line: #cec6b8; }

/* テーマ切り替え（キャラクターごと） */
.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.theme-grid button { border: 1px solid var(--line); border-radius: 8px; padding: 6px 2px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: #1d2230; line-height: 1.2; min-width: 0; }
.theme-grid button span { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.theme-grid button.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-grid button[data-theme-key="dark"] { color: #eceef3; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.6; }
body.modal-open { overflow: hidden; }
img { max-width: 100%; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- 上部バー ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-family: var(--font-label); font-size: 14px; }
.topbar-chars { display: flex; gap: 6px; align-items: center; flex: 1 1 320px; min-width: 0; }
.topbar-chars select { flex: 1 1 auto; min-width: 0; max-width: 360px; }
.topbar-links { display: flex; gap: 16px; align-items: center; font-size: 13px; }
.topbar-links a { color: var(--muted); text-decoration: none; }
.topbar-links a:hover { color: var(--accent); }
.save-state { color: var(--muted); font-size: 12px; }
.save-state.bad { color: var(--warn); }

/* ---------- レイアウト ---------- */
.layout { display: grid; grid-template-columns: 150px minmax(0, 1fr) 300px; gap: 20px; max-width: 1440px; margin: 0 auto; padding: 20px 16px 80px; }
.toc { position: sticky; top: 72px; align-self: start; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.toc a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--accent); border-left-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.side { min-width: 0; }
.side-inner { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); max-height: calc(100vh - 92px); overflow: auto; }
@media (max-width: 1180px) { .layout { grid-template-columns: minmax(0, 1fr) 280px; } .toc { display: none; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { order: -1; }
  .side-inner { position: static; max-height: none; }
}

/* ---------- カード ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0 0 14px; font-family: var(--font-display); font-weight: 800; font-size: 21px; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; }
.card h2::before { content: ""; width: 10px; height: 10px; transform: rotate(45deg); background: var(--accent); flex: none; }
.card h3 { margin: 18px 0 8px; font-size: 15px; color: var(--brass); font-weight: 700; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
@media (max-width: 520px) { .card { padding: 14px 14px 16px; } }

/* ---------- 入力 ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2);
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); background: var(--surface); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
textarea { resize: vertical; line-height: 1.55; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; }
.f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.f > span { font-size: 12px; color: var(--muted); }
.f-wide { grid-column: 1 / -1; }
.f-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; }
.f .conv { font-size: 11px; color: var(--muted); min-height: 1em; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.f-check { padding-bottom: 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.empty { color: var(--muted); font-size: 13px; margin: 4px 0; }
.mini { width: 64px; text-align: center; padding: 5px 4px; font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 24px; }
.two-col h3:first-child { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 760px) { .two-col { grid-template-columns: minmax(0, 1fr); } }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; text-decoration: none; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-ghost { background: transparent; }
.btn-primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn-primary:hover { opacity: .9; }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.icon-btn { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; line-height: 1; }
.icon-btn.danger:hover { color: var(--accent); border-color: var(--accent); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface-2); padding: 7px 14px; cursor: pointer; font-size: 14px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.badge { font-size: 12px; font-weight: 400; color: var(--muted); }

/* ---------- 基本情報 ---------- */
.basic-grid { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 18px; }
.portrait-box { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.portrait { aspect-ratio: 3 / 4; border-radius: 8px; border: 1px dashed var(--line); background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 13px; max-width: 100%; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 600px) { .basic-grid { grid-template-columns: minmax(0, 1fr); } .portrait-box { flex-direction: row; flex-wrap: wrap; align-items: center; } .portrait { width: 96px; } }

/* ---------- 表 ---------- */
.table-wrap { overflow-x: auto; }
.grid-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grid-table th, .grid-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: center; vertical-align: middle; }
.grid-table thead th { font-size: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.grid-table tbody th { text-align: left; font-weight: 700; white-space: nowrap; }
.grid-table tbody th small { display: block; font-family: var(--font-label); font-size: 10px; color: var(--muted); letter-spacing: .08em; font-weight: 600; }
.grid-table .num { font-variant-numeric: tabular-nums; }
.grid-table .strong { font-weight: 700; font-size: 16px; }
.grid-table .sm { font-size: 12px; color: var(--muted); }
.ab-table select.ab-base, .ab-table input.ab-base { width: 84px; text-align: center; }
.ab-table .cost-col { display: none; color: var(--muted); font-size: 13px; }
.ab-table.mode-point .cost-col { display: table-cell; }
.ab-total { font-size: 20px; font-weight: 700; font-family: var(--font-display); }
.ab-mod .modval { display: inline-block; min-width: 46px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; }
.ab-mod .modval.pos { background: var(--brass-soft); border-color: var(--brass); color: var(--brass); }
.ab-mod .modval.neg { color: var(--muted); }
.warn { color: var(--warn); font-weight: 700; }
.ab-status { margin: 12px 0 8px; display: flex; flex-direction: column; gap: 6px; }
.pb-meter { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; max-width: 420px; }
.pb-bar { height: 100%; background: var(--brass); transition: width .2s; }
.pb-meter.done .pb-bar { background: var(--ok); }
.pb-meter.over .pb-bar { background: var(--warn); }
.pb-text { font-size: 14px; }
.pb-text b { font-size: 18px; font-family: var(--font-display); }
.pb-text.ok { color: var(--ok); }
.pb-text.sub { font-size: 13px; color: var(--muted); }
.pb-left b { color: var(--accent); }
.cost-table { margin-top: 10px; font-size: 13px; color: var(--muted); }
.cost-table summary { cursor: pointer; }
.cost-row { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.skill-table tr.class-skill th::before { content: "■"; color: var(--brass); margin-right: 4px; font-size: 10px; vertical-align: 2px; }
.mark-class { color: var(--brass); }
.prof-sel { width: 76px; padding: 4px 6px; }
.prof-sel.p1 { background: var(--brass-soft); border-color: var(--brass); }
.prof-sel.p2 { background: var(--accent-soft); border-color: var(--accent); }
.passives { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.passives div, .stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.passives b, .stat b { font-size: 20px; font-family: var(--font-display); line-height: 1.2; font-variant-numeric: tabular-nums; }
.passives span, .stat span { font-size: 12px; color: var(--muted); }
.stat small { font-size: 11px; color: var(--muted); }
.stat.warnbox { border-color: var(--warn); }
.stat.warnbox b { color: var(--warn); }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin: 14px 0; }

/* ---------- 行カード（攻撃・装備・リソース） ---------- */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row-card { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); position: relative; }
.row-card input, .row-card select { background: var(--surface); }
.row-card .f-xs { min-width: 0; }
.row-card .check { padding-bottom: 6px; font-size: 13px; }
.row-tools { display: flex; gap: 4px; justify-content: flex-end; grid-column: -2 / -1; }
.atk-row { grid-template-columns: minmax(140px, 1.2fr) minmax(140px, 1.3fr) minmax(120px, 1fr) minmax(120px, 1fr) 90px; }
.atk-row .f-wide { grid-column: 1 / span 3; }
.atk-result { grid-column: span 2; display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; font-size: 13px; padding-bottom: 6px; }
.atk-result b { font-size: 17px; font-family: var(--font-display); color: var(--accent); }
.atk-result .atk-ab { color: var(--muted); font-size: 12px; }
@media (max-width: 1100px) {
  .atk-row { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .atk-row > .f:first-child, .atk-row > .f:nth-child(2) { grid-column: span 2; }
  .atk-row .f-wide { grid-column: 1 / -1; }
  .atk-result { grid-column: 1 / -2; }
}
.eq-row { grid-template-columns: minmax(0, 1fr) 90px 80px auto; }
.eq-row .eq-memo { grid-column: 1 / -1; resize: vertical; min-height: 60px; font-size: 13px; }
.eq-row .f-wide { grid-column: auto; }
.res-row { grid-template-columns: minmax(0, 1fr) 100px auto; }
@media (max-width: 520px) { .eq-row { grid-template-columns: minmax(0, 1fr) 70px 64px; } .eq-row .f-wide { grid-column: 1 / -1; } .eq-row .row-tools { grid-column: 1 / -1; } }
.coins { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.coin span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .coins { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.auto-res { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.auto-res li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 6px; background: var(--brass-soft); font-size: 13.5px; }
.auto-res li.roll { background: var(--surface-2); border: 1px solid var(--line); }
.auto-res li b { font-family: var(--font-display); }
.auto-res li.empty { background: none; color: var(--muted); }

/* ---------- 呪文 ---------- */
.spell-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 12px; }
.spell-lv { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); min-width: 0; }
.spell-lv-empty summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.spell-lv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.spell-lv-head b { font-family: var(--font-display); font-size: 16px; }
.slot { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.slot .mini { width: 54px; background: var(--surface); }
.spell-list { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 4px; }
.spell-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.spell-list li.cantrip { grid-template-columns: minmax(0, 1fr) auto auto; }
.spell-list .sp-desc { grid-column: 1 / -1; resize: vertical; min-height: 60px; font-size: 13px; background: var(--surface); }
.sp-toggle { padding: 3px 8px; font-size: 12px; }
.sp-toggle.has { border-color: var(--brass); color: var(--brass); font-weight: 700; }
.spell-list li input:not([type=checkbox]) { padding: 4px 8px; background: var(--surface); }
.prep { display: inline-flex; gap: 2px; align-items: center; font-size: 11px; color: var(--muted); cursor: pointer; }
.spell-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.spell-add input { background: var(--surface); font-size: 13px; }

/* ---------- 出力 ---------- */
.palette { white-space: pre-wrap; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 320px; overflow: auto; margin: 10px 0 0; }
.share-panel { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.share-url { display: flex; gap: 6px; width: 100%; flex-wrap: wrap; }
.share-url input { flex: 1 1 260px; font-size: 13px; }

/* ---------- サイドパネル ---------- */
.side-head { display: flex; gap: 12px; align-items: center; }
.side-portrait { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); flex: none; }
.side-portrait img { width: 100%; height: 100%; object-fit: cover; }
.side-name { font-family: var(--font-display); font-weight: 800; font-size: 18px; line-height: 1.3; word-break: break-all; }
.side-sub { color: var(--muted); font-size: 12.5px; }
.side-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.side-stats > div:not(.side-abs) { background: var(--surface-2); border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; }
.side-stats b { font-family: var(--font-display); font-size: 18px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.side-stats span { font-size: 11px; color: var(--muted); }
.side-abs { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 2px; }
.side-abs div { text-align: center; border: 1px solid var(--line); border-radius: 6px; padding: 4px 0; display: flex; flex-direction: column; }
.side-abs span { font-size: 11px; color: var(--muted); }
.side-abs b { font-size: 16px; }
.side-abs small { font-size: 11px; color: var(--brass); font-weight: 700; }
.out-group { display: flex; flex-direction: column; gap: 6px; }
.out-title { font-size: 11px; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.howto { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.howto summary { cursor: pointer; color: var(--ink); }
.howto p { margin: 6px 0; }
.side-files { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- モーダル・画面外描画・通知 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 92%, transparent); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); }
.modal-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.modal-body { flex: 1; overflow: auto; padding: 20px 16px 40px; }
.sheet-scaler { width: 794px; max-width: 100%; margin: 0 auto; overflow: hidden; }
.offscreen { position: fixed; left: -10000px; top: 0; width: 794px; pointer-events: none; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; z-index: 60; background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; font-size: 14px; transition: all .2s; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--warn); color: #fff; }

/* ---------- 共通フッター ---------- */
.site-foot { max-width: 1440px; margin: 0 auto; padding: 0 16px 40px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.site-foot a { color: var(--muted); }

/* ---------- スマホ向けの詰め ---------- */
@media (max-width: 600px) {
  .topbar { position: static; }
  html { scroll-padding-top: 8px; }
  .mini { width: 42px; padding: 5px 2px; }
  .ab-table select.ab-base, .ab-table input.ab-base { width: 58px; padding: 5px 2px; }
  .grid-table th, .grid-table td { padding: 4px 2px; }
  .grid-table tbody th small { display: none; }
  .ab-total { font-size: 17px; }
  .ab-mod .modval { min-width: 36px; padding: 2px 4px; }
  .ab-table .ab-name { font-size: 13px; }
  .prof-sel { width: 62px; }
}

/* マルチクラス・画像表示 */
.multi-box { display: flex; flex-direction: column; gap: 6px; }
.multi-row { grid-template-columns: minmax(130px, 1.2fr) 80px minmax(120px, 1.2fr) minmax(130px, 1fr) auto; }
.multi-row .multi-custom { grid-column: 1 / -2; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
@media (max-width: 700px) { .multi-row { grid-template-columns: minmax(0, 1fr) 80px; } .multi-row .row-tools { grid-column: 1 / -1; } .multi-row .multi-custom { grid-column: 1 / -1; } }
.img-pages { display: flex; flex-direction: column; gap: 20px; align-items: center; }
.img-page { display: flex; flex-direction: column; gap: 8px; align-items: center; width: 100%; max-width: 794px; }
.img-page img { width: 100%; height: auto; box-shadow: var(--shadow); background: #fff; }
.img-page .img-cap { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }

/* 確認ダイアログ */
.dlg-back { position: fixed; inset: 0; z-index: 70; background: rgba(10, 12, 18, .45); display: grid; place-items: center; padding: 16px; }
.dlg { width: min(440px, 100%); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dlg h3 { margin: 0 0 8px; font-family: var(--font-display); font-size: 19px; }
.dlg-msg { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.dlg-form { display: flex; flex-direction: column; gap: 10px; }
.dlg-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }
.btn-danger { background: var(--warn); border-color: var(--warn); color: #fff; }
.share-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-end; width: 100%; }
.pw-row .f { flex: 1 1 200px; }
.lock-note { font-size: 12.5px; color: var(--muted); }
.dlg-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.dlg input#dlg-f-0 { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; }

.caster-row { grid-template-columns: minmax(0, 1fr) minmax(140px, 1fr) auto; margin-top: 10px; }
