:root {
  --bg: #0f0f12; --card: #18181c; --red: #8b0000;
  --text: #e0e0e0; --border: #3a3a42; --input: #222228; --header-bg: #1a1a20;
}
* { box-sizing: border-box; }
body { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Georgia", serif; background: var(--bg); color: var(--text); margin: 0; padding: 12px; font-size: 13px; }
h1 { text-align: center; color: #f0a0a0; font-size: 1.4rem; margin: 0 0 12px 0; font-weight: bold; letter-spacing: 3px; border-bottom: 1px solid var(--red); padding-bottom: 6px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 4px; padding: 10px; margin-bottom: 12px; }
.sticky-top-bar { position: sticky; top: 0; z-index: 1000; background: rgba(24, 24, 28, 0.95); backdrop-filter: blur(4px); border: 1px solid var(--red); box-shadow: 0 4px 12px rgba(0,0,0,0.6); margin-bottom: 12px; }
.title { font-size: .95rem; font-weight: bold; color: #f0a0a0; border-bottom: 2px solid var(--red); padding-bottom: 4px; margin-bottom: 8px; font-family: serif; }
.part-header { background: #2a0808; border: 1px solid var(--red); color: #ffffff; padding: 4px 8px; font-weight: bold; font-size: .9rem; margin-top: 12px; display: flex; justify-content: space-between; align-items: center; letter-spacing: 1px; }
.part-header .val { font-size: .75rem; color: #ddd; font-weight: normal; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
label { display: block; font-size: .75rem; color: #aaa; margin-bottom: 2px; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea { width: 100%; padding: 5px; border: 1px solid var(--border); border-radius: 3px; background: var(--input); color: #fff; font-size: .85rem; font-family: sans-serif; text-align: center; }
input[type="text"] { text-align: left; }
textarea { text-align: left; resize: vertical; }
/* チェックボックスは背景色の指定を受けないようにし、見やすい色をはっきり指定する */
input[type="checkbox"] { width: auto; accent-color: #f0a0a0; background: #fff; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 4px; min-width: 100%; }
th, td { border: 1px solid var(--border); padding: 4px 2px; text-align: center; font-size: .8rem; }
th { background: var(--header-bg); color: #eee; font-weight: normal; letter-spacing: 1px; }
.calc-table { background: #121215; margin-bottom: 8px; }
.calc-table th { background: #22222a; color: #ccc; font-weight: bold; }
.calc-table td.label-cell { background: #1e1e24; text-align: right; padding-right: 8px; font-weight: bold; color: #ddd; }
.calc-table input[type="number"] { width: 100%; background: #18181c; border: 1px solid #444; color: #fff; font-weight: bold; }
.calc-table input[type="radio"] { width: 18px; height: 18px; accent-color: var(--red); cursor: pointer; margin: 0 auto; }
.calc-table .total-row td { background: #2a0808; color: #fff; font-size: 1rem; font-weight: bold; }
.limit-table { font-size: 0.75rem; margin-top: 8px; background: #15151a; }
.limit-table th { background: #22222c; color: #f0a0a0; }
.limit-table td { padding: 3px; }
.limit-table input[type="number"] { width: 45px; background: #18181c; border: 1px solid #444; color: #ff8888; font-weight: bold; padding: 2px; }
.limit-ok, .limit-selected { color: #8ff; font-weight: bold; }
.limit-ng { color: #ff8888; font-weight: bold; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
button { padding: 8px; border: none; border-radius: 4px; background: var(--red); color: #fff; font-weight: bold; cursor: pointer; font-size: .85rem; font-family: sans-serif; }
button:hover { opacity: 0.9; }
button.sec { background: #4a4a52; }
button.del { background: #522; color: #f88; padding: 2px 6px; }
.add-part-select { width: 100%; margin-top: 6px; padding: 6px; background: #25252d; color: #f0a0a0; border: 1px dashed var(--border); border-radius: 3px; font-size: .85rem; cursor: pointer; }
tr.broken input, tr.broken textarea { text-decoration: line-through; opacity: 0.5; }
tr.used td { background: rgba(255, 220, 100, 0.07); }
tr.used input:not([type="checkbox"]), tr.used textarea, tr.used select { opacity: 0.65; }

/* --- キャラクター管理（複数保存）--- */
.slot-select-row { margin-bottom: 8px; }
.action-btn-row { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 2px 10px 2px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.action-btn { flex: 0 0 auto; min-width: 132px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #14161a; border: 1.5px solid #444; font-weight: bold; font-size: .82rem; cursor: pointer; text-align: left; line-height: 1.3; font-family: sans-serif; }
.action-btn:active { opacity: 0.75; }
.action-btn .icon { font-size: 1.5rem; flex-shrink: 0; }
.action-btn.c-green  { border-color: #2f6b4f; background: #14211a; color: #7fe3a8; }
.action-btn.c-blue   { border-color: #4b4bcf; background: #17182c; color: #9aa4ff; }
.action-btn.c-orange { border-color: #8a5a2e; background: #271b10; color: #ffbb80; }
.action-btn.c-red    { border-color: #7a3232; background: #241313; color: #ff9a9a; }
.action-btn.c-purple { border-color: #6a3e9e; background: #1e1626; color: #cba3ff; }
.action-btn.c-teal   { border-color: #2e7a72; background: #102420; color: #7ae8da; }
.action-btn.c-yellow { border-color: #8a7a2e; background: #26230f; color: #f0d878; }
.action-btn.c-cyan   { border-color: #2e6a8a; background: #0f1f26; color: #7ac4f0; }
.action-btn.c-pink   { border-color: #9e3e6a; background: #26101c; color: #ff9ac4; }

/* --- 保存キャラクターのカード表示 --- */
.save-cards-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px 2px; -webkit-overflow-scrolling: touch; }
.save-card { flex: 0 0 auto; width: 92px; background: #16161c; border: 2px solid #3a3a42; border-radius: 10px; padding: 6px; text-align: center; cursor: pointer; }
.save-card.selected { border-color: #f0a0a0; background: #241416; box-shadow: 0 0 0 1px #f0a0a0 inset; }
.save-card-thumb { width: 78px; height: 78px; object-fit: cover; object-position: 50% 8%; border-radius: 6px; display: block; margin: 0 auto 4px auto; background: #222228; }
.save-card-thumb-placeholder { display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: #555; }
.save-card-name { font-size: .72rem; font-weight: bold; color: #eee; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-card-date { font-size: .58rem; color: #777; margin-top: 1px; }
.save-card-sub { font-size: .62rem; color: #999; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- 自動保存ステータス・元に戻すボタン --- */
#autosave-status { font-size: .68rem; color: #7fe3a8; }
.undo-btn { background: #2a2a32; color: #f0d878; border: 1px solid #555; border-radius: 6px; padding: 3px 8px; font-size: .72rem; font-weight: bold; cursor: pointer; font-family: sans-serif; }
.undo-btn:disabled { opacity: 0.4; cursor: default; }

/* --- 表示モード（編集画面と分離） --- */
body.view-mode .edit-only { display: none !important; }

/* 表示モードの時だけ見せたい要素（例: 表示画面からの共有ボタン） */
.view-only { display: none; }
body.view-mode .view-only { display: block; }
body:not(.view-mode) #view-mode-image-container { display: none !important; }
#view-mode-image-container img { max-width: 100%; max-height: 280px; display: block; margin: 0 auto 10px auto; border-radius: 8px; border: 1.5px solid var(--red); object-fit: cover; object-position: 50% 0; background: var(--img-bg, transparent); }
body.view-mode .del { display: none !important; }
body.view-mode .color-col { display: none !important; }
body.view-mode .col-op { display: none !important; }

/* --- マニューバ表をコンパクトに（縦幅を詰めて1画面でより多く見えるように） --- */
.maneuver-table th, .maneuver-table td { padding: 2px 2px; font-size: .72rem; }
.maneuver-table input, .maneuver-table select { font-size: .72rem; padding: 2px; }
/* スマホのプルダウン矢印アイコンが幅を圧迫して文字が見えなくなるのを防ぐ（矢印を消して文字表示分の幅を確保） */
.maneuver-table select { appearance: none; -webkit-appearance: none; -moz-appearance: none; padding: 2px 1px; text-align: center; }
.maneuver-table textarea { font-size: .72rem; padding: 1px 2px; min-height: 30px; line-height: 1.25; }

body.view-mode input:not([type="checkbox"]),
body.view-mode select,
body.view-mode textarea {
  pointer-events: none !important;
  background: transparent !important;
  border-color: transparent !important;
}

/* 効果メモ欄も、表示モードではパーツ名・分類などと同じく透明にして、行の色と一体化させる */
body.view-mode input[type="radio"] { opacity: 0.85; }

/* 損傷チェックだけはセッション中も操作できるよう残す */
body.view-mode input[type="checkbox"] { pointer-events: auto !important; }

body.view-mode .part-header .val,
body.view-mode th { color: #ddd; }

/* --- キャラクター切替オーバーレイ --- */
.char-switch-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.char-switch-btn {
  width: 100%; margin-bottom: 8px; padding: 9px; background: #1c1c22; color: #8ff;
  border: 1.5px solid #2e6a8a; border-radius: 8px; font-weight: bold; font-size: 0.85rem;
  cursor: pointer; font-family: sans-serif;
}

/* --- カテゴリ選択（色だけのコンパクトな枠。押すと選択肢名が見える） --- */
.p-tag, .skill-tag {
  width: 100%;
  min-width: 22px;
  padding: 3px 0;
  color: transparent;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  text-align: center;
  text-align-last: center;
}

/* パソコンでは、選択肢の一覧にも欄の「透明な文字色」が引き継がれて、白い一覧に字が見えなくなるので、一覧の中の文字は読める色にする */
.p-tag option, .skill-tag option { color: #111; background: #fff; }

/* --- 左下固定：小さいアイコンボタン群（キャラ切替・表示/編集モード切替） --- */
.corner-btn {
  position: fixed;
  left: 20px;
  z-index: 9999;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: bold;
  font-family: sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.6);
  white-space: nowrap;
}

/* --- パーツ表：1段目（本体）と2段目（効果メモ）の区切り線は、他の罫線と同じように表示する --- */
.maneuver-table tr.part-memo-row td,
.maneuver-table tr.skill-memo-row td { text-align: left; padding: 1px 3px 2px 3px; }
/* 効果メモは内容に合わせて高さを自動調整するので、最低高さの指定を外し、余分な余白や手動リサイズも不要にする */
.maneuver-table tr.part-memo-row textarea,
.maneuver-table tr.skill-memo-row textarea {
  min-height: 0;
  resize: none;
  overflow-y: hidden;
  /* 対応ブラウザでは、JSの計算タイミングに頼らずブラウザ自身が内容の高さに自動追従してくれる */
  field-sizing: content;
}

/* --- 効果メモが元々空のパーツ用：追加ボタン --- */
.add-memo-btn {
  display: block;
  width: 100%;
  padding: 3px 6px;
  background: transparent;
  color: #aaa;
  border: 1px dashed rgba(255,255,255,0.3);
  border-radius: 3px;
  font-size: 0.68rem;
  cursor: pointer;
  text-align: left;
}
/* 表示モードでは、まだメモが追加されていない（ボタンが残ったままの）2段目は場所を取らないようにする */
body.view-mode tr.part-memo-row:has(.add-memo-btn) { display: none; }

/* 基本情報：ラベルが黒い小さなセルで、入力欄と横並びの格子 */
.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 6px; }
.kv { display: flex; align-items: stretch; min-width: 0; border-radius: 4px; overflow: hidden; border: 1px solid #444; background: #18181c; }
.kv.kv-wide { grid-column: 1 / -1; }
.kv > label { flex: 0 0 auto; display: flex; align-items: center; margin: 0; padding: 0 8px; background: #0e0e12; color: #ddd; font-size: .75rem; white-space: nowrap; }
.kv > input, .kv > select { flex: 1 1 auto; min-width: 0; width: 100%; border: none; border-radius: 0; margin: 0; background: #2a2a30; color: #fff; }
@media (min-width: 640px) { .kv-grid { grid-template-columns: repeat(3, 1fr); } }

/* 折りたたみできるカード（見出しを押すと開閉） */
.fold-card > summary.title { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.fold-card > summary.title::-webkit-details-marker { display: none; }
.fold-card > summary.title::after { content: "▾"; color: #aaa; font-size: 1rem; transition: transform .15s; }
.fold-card:not([open]) > summary.title::after { transform: rotate(-90deg); }
.fold-card:not([open]) > summary.title { margin-bottom: 0; border-bottom: none; }

/* 戦闘用表示（表示モードのときだけ）：パーツ・スキル・未練・行動値だけに絞る */
body.view-mode.battle-view .non-battle { display: none !important; }

/* 損傷したパーツ：行全体を灰色にして、名前に取り消し線を付ける */
tr.broken td { background: rgba(140, 140, 140, 0.16); }
tr.broken .p-name { text-decoration: line-through; }
tr.broken input, tr.broken textarea, tr.broken select { color: #999; }

/* 部位見出しの残りパーツ数 */
.part-count { font-size: .72rem; font-weight: normal; color: #ffd0d0; margin-left: 6px; letter-spacing: 0; }
.part-count.low { color: #ff8888; font-weight: bold; }

/* 表示モードの固定バー：2つのボタンを横に並べて、縦幅を取らない */
body.view-mode .view-btn-row { display: flex; gap: 6px; }
.view-btn-row .char-switch-btn { flex: 1; width: auto; margin: 0; padding: 5px 4px; font-size: .75rem; }

/* 未練：2行目の「発狂」欄（発狂名＋効果） */
.miren-mad-row td { padding: 0 2px 6px; border-top: none; }
.miren-mad-box { display: flex; align-items: flex-start; gap: 4px; }
.miren-mad-label { flex: 0 0 auto; min-width: 2.8em; text-align: center; box-sizing: border-box; background: #0e0e12; color: #f0a0a0; font-size: .72rem; padding: 5px 6px; border-radius: 3px; white-space: nowrap; }
.miren-mad-box .miren-madname { flex: 0 0 30%; min-width: 0; text-align: left; }
.miren-mad-box .miren-madeffect { flex: 1 1 auto; min-width: 0; text-align: left; resize: none; overflow-y: hidden; font-size: .78rem; line-height: 1.3; min-height: 30px; }
body.view-mode .miren-mad-row.empty { display: none; }

/* --- 印刷：白地に黒文字、編集用の部品や固定ボタンは出さない --- */
@media print {
  :root { --bg: #fff; --card: #fff; --text: #000; --border: #999; --input: #fff; --header-bg: #eee; }
  body { background: #fff !important; color: #000 !important; padding: 0; font-size: 11px; }
  h1 { color: #000; border-bottom: 1px solid #000; }
  .title { color: #000 !important; border-bottom: 1px solid #000 !important; }
  .card { background: #fff !important; border: 1px solid #999 !important; box-shadow: none !important; break-inside: auto; }
  .sticky-top-bar { position: static !important; background: #fff !important; backdrop-filter: none !important; box-shadow: none !important; border: 1px solid #000 !important; }
  .sticky-top-bar * { color: #000 !important; }
  .corner-btn, .edit-only, .view-only, .col-op, .color-col, .del, .undo-btn, #autosave-status,
  button, #hokansho-overlay, #help-overlay, #char-switch-overlay { display: none !important; }
  .view-btn-row { display: none !important; }
  input, select, textarea { background: transparent !important; color: #000 !important; border-color: #bbb !important; -webkit-appearance: none; appearance: none; }
  table, th, td { color: #000 !important; border-color: #999 !important; }
  th { background: #eee !important; }
  tr.part-row td, tr.part-memo-row td, tr.skill-row td, tr.skill-memo-row td { background: #fff !important; }
  tr.broken td { background: #ddd !important; }
  .kv { border-color: #999; background: #fff; }
  .kv > label { background: #eee; color: #000; }
  .kv > input, .kv > select { background: #fff; color: #000; }
  .part-header { background: #eee !important; color: #000 !important; border-color: #999 !important; }
  .part-count, .part-header .val { color: #000 !important; }
  .miren-mad-label { background: #eee; color: #000; }
  .fold-card > summary.title::after { display: none; }
  tr { break-inside: avoid; }
  textarea { overflow: visible !important; }
}

/* 印刷のとき、はみ出す1行入力欄を折り返し表示に差し替えるための部品（画面では出さない） */
.print-clone { display: none; }
@media print {
  .print-clone { display: block; flex: 1 1 auto; min-width: 0; white-space: pre-wrap; word-break: break-all; text-align: left; padding: 2px 4px; color: #000; }
  input.print-hidden { display: none !important; }
}

/* サイト名の下のサブタイトル */
.site-subtitle { text-align: center; text-wrap: balance; font-size: .66rem; color: #999; margin: -4px 0 10px; line-height: 1.4; }
@media print { .site-subtitle { color: #000 !important; } }

/* --- 固定バーのツール行・目次・折りたたみ --- */
.bar-tools { display: flex; gap: 6px; justify-content: flex-end; }
.bar-tools button, .toc-row button { background: #22222a; color: #ddd; border: 1px solid #555; border-radius: 12px; padding: 2px 10px; font-size: .7rem; cursor: pointer; font-family: sans-serif; }
.toc-row { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 2px; }
.sticky-top-bar.bar-collapsed .bar-detail { display: none; }
body.view-mode .bar-tools { justify-content: space-between; }
@media print { .bar-tools, .toc-row { display: none !important; } .sticky-top-bar.bar-collapsed .bar-detail { display: block !important; } }

/* --- 文字サイズ（小・中・大）：rem で書かれた大きさがまとめて変わる --- */
html.fs-small { font-size: 14px; }
html.fs-large { font-size: 18px; }

/* --- iPhone：入力欄が16px未満だと、タップした時に画面が勝手に拡大されるので、編集中だけ16pxにする --- */
/* マニューバ・スキル表の1行目の欄は、16pxにすると列が窮屈で名前が読めなくなるので、今の大きさのままにする */
@media (pointer: coarse) {
  body:not(.view-mode) input:not([type="checkbox"]):not([type="radio"]):not(.maneuver-table input),
  body:not(.view-mode) select:not(.maneuver-table select),
  body:not(.view-mode) textarea { font-size: 16px !important; }
  /* 表の欄は、押して入力している間だけ16pxにして、拡大されないようにする */
  body:not(.view-mode) .maneuver-table input:focus,
  body:not(.view-mode) .maneuver-table select:focus { font-size: 16px !important; }
}

/* --- データ未登録のパーツ（効果メモを足せる印） --- */
.add-memo-btn.unregistered { border-style: dashed; color: #c9a8a8; }

.emergency-fold { margin: 6px 0; }
.emergency-fold > summary { cursor: pointer; font-size: 0.78rem; color: #aaa; padding: 4px 2px; }

/* 記憶のカケラ：数字・名前・詳細 */
.memory-entry { margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dashed #3a2a2a; }
.memory-head { display: flex; gap: 6px; align-items: center; margin-bottom: 3px; }
.memory-entry .memory-head input.memory-num { width: 3.6em; flex: none; text-align: center; }
.memory-entry .memory-head input.memory-name { width: auto; flex: 1; min-width: 0; text-align: left; }
.memory-entry .memory-detail { width: 100%; box-sizing: border-box; min-height: 34px; resize: none; overflow: hidden; }

.memory-head .memory-toggle { flex: none; width: 2em; padding: 4px 0; background: #2a1e1e; border: 1px solid var(--border); color: #ccc; border-radius: 3px; cursor: pointer; }
.memory-entry.collapsed .memory-detail { display: none; }
body.print-mode .memory-entry.collapsed .memory-detail { display: block; }
body.print-mode .memory-toggle, body.print-mode #memory-all-toggle { display: none; }
/* 記憶のカケラの詳細：長い文章でも枠が伸びすぎないように、4行ぶんで止めて中でスクロールする */
.memory-entry .memory-detail { max-height: 6.2em; overflow-y: auto; resize: vertical; }
body.print-mode .memory-entry .memory-detail { max-height: none; overflow: visible; }
/* 記憶のカケラの名前欄：行いっぱいに伸ばさず、短めにする（削除ボタンは右端） */
.memory-entry .memory-head input.memory-name { flex: 0 1 12em; }
.memory-entry .memory-head .del { margin-left: auto; }
/* 記憶のカケラ：複数あるときは、体重・髪の色のように横に並べる（幅に合わせて2列〜） */
#memory-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(165px, 47%), 1fr)); gap: 6px 8px; }
#memory-list .memory-entry { margin: 0; min-width: 0; }
#memory-list .memory-entry .memory-head input.memory-name { flex: 1 1 0; width: auto; min-width: 0; }
#memory-list .memory-head { gap: 3px; }
#memory-list .memory-head input.memory-num { width: 2.8em; padding-left: 2px; padding-right: 2px; }
#memory-list .memory-head .memory-toggle { width: 1.8em; }
#memory-list .memory-head .del { padding: 5px 7px !important; margin-left: 0; }

/* 折りたたんでいる間は、詳細の書き出しを1行だけ薄く見せる（押すと開く） */
.memory-entry .memory-preview { display: none; font-size: .72rem; color: #9a8a8a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; cursor: pointer; }
.memory-entry.collapsed .memory-preview:not(:empty) { display: block; }
body.print-mode .memory-preview { display: none !important; }

/* --- 設計図風の印刷（A4縦2枚） --- */
#sheet-print { display: none; }
@page { size: A4 portrait; margin: 6mm; }
@media print {
  body.sheet-print-mode > *:not(#sheet-print) { display: none !important; }
  body.sheet-print-mode { background: #fff !important; padding: 0 !important; }
  body.sheet-print-mode #sheet-print { display: block; color: #000; font-family: sans-serif; font-size: 8.5pt; }
  .sp-page { page-break-after: always; break-after: page; }
  .sp-page:last-child { page-break-after: auto; break-after: auto; }
  .sp-top { display: flex; gap: 6mm; margin-bottom: 3mm; }
  .sp-left { flex: 1; } .sp-right { width: 52mm; }
  .sp-title { font-size: 15pt; font-weight: bold; letter-spacing: .1em; border-bottom: 2px solid #000; margin-bottom: 2mm; }
  .sp-line { display: flex; gap: 2mm; align-items: baseline; border-bottom: 1px solid #000; min-height: 7mm; padding: 1mm 0 0; }
  .sp-line span { font-size: 6.5pt; color: #333; flex: none; }
  .sp-line b { font-weight: normal; font-size: 10pt; flex: 1; }
  .sp-half b { flex: 1 1 0; }
  .sp-t { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 0; }
  .sp-t th, .sp-t td { border: 1px solid #000 !important; padding: 0.8mm 1.2mm; vertical-align: middle; word-break: break-all; line-height: 1.25; background: #fff !important; color: #000 !important; }
  .sp-t thead th { background: #e8e8e8 !important; font-size: 6.5pt; font-weight: bold; }
  .sp-t tbody tr { height: 6.4mm; break-inside: avoid; }
  .sp-c { text-align: center; }
  .sp-class { margin-top: 2mm; } .sp-class th { width: 28mm; background: #222 !important; color: #fff !important; font-size: 8pt; }
  .sp-stat th { background: #222 !important; color: #fff !important; width: 14mm; } .sp-stat td { text-align: center; font-size: 11pt; font-weight: bold; }
  .sp-chouai { border: 1px solid #000; text-align: center; margin-top: 2mm; padding: 1mm; font-size: 7pt; } .sp-chouai b { font-size: 11pt; }
  .sp-body { font-size: 7pt; margin-top: 1.5mm; color: #222; }
  .sp-sec { margin-top: 3mm; }
  .sp-bar { background: #222; color: #fff; font-weight: bold; font-size: 10pt; padding: 0.6mm 2mm; display: flex; justify-content: space-between; align-items: baseline; }
  .sp-bar span { font-size: 7.5pt; font-weight: normal; }
  .sp-skills th:nth-child(1), .sp-parts th:nth-child(1), .sp-parts th:nth-child(2) { width: 5mm; }
  .sp-skills th:nth-child(2) { width: 24%; } .sp-skills th:nth-child(3) { width: 12mm; } .sp-skills th:nth-child(4), .sp-skills th:nth-child(5) { width: 10mm; }
  .sp-parts th:nth-child(3) { width: 26%; } .sp-parts th:nth-child(4) { width: 13mm; } .sp-parts th:nth-child(5), .sp-parts th:nth-child(6) { width: 10mm; }
  .sp-miren th:nth-child(1), .sp-miren th:nth-child(2) { width: 22%; } .sp-miren th:nth-child(3) { width: 17mm; }
  .sp-t td { font-size: 8pt; } .sp-parts td:last-child, .sp-skills td:last-child, .sp-t td:last-child { font-size: 7.5pt; }
  tr.sp-broken td { background: #ddd !important; text-decoration: line-through; }
  .sp-act { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2mm; }
  .sp-actbox { background: #222; color: #fff; padding: 2mm 4mm; font-size: 10pt; } .sp-actbox span { font-weight: bold; margin-right: 3mm; } .sp-actbox b { background: #fff; color: #000; padding: 0 3mm; margin: 0 1mm; font-weight: normal; } .sp-big { font-size: 14pt; font-weight: bold !important; }
  .sp-ps { border: 1px solid #000; padding: 1.5mm 3mm; display: flex; gap: 3mm; align-items: center; font-size: 8pt; } .sp-ps span { font-weight: bold; } .sp-ps i { font-style: normal; }
}
@media print {
  .sp-t td { text-align: left; } .sp-t td.sp-c { text-align: center; }
  .sp-t tbody tr { height: 6.1mm; }
  .sp-t th, .sp-t td { padding: 0.5mm 1mm; }
  .sp-skills th:nth-child(3), .sp-parts th:nth-child(4) { width: 17mm; }
  .sp-skills th:nth-child(4), .sp-skills th:nth-child(5), .sp-parts th:nth-child(5), .sp-parts th:nth-child(6) { width: 11mm; }
  .sp-parts th:nth-child(3) { width: 30%; } .sp-skills th:nth-child(2) { width: 22%; }
  .sp-sec { margin-top: 2.2mm; }
  .sp-bar { padding: 0.3mm 2mm; font-size: 9pt; }
}

@media print {
  /* 1枚目は、記憶のカケラと未練を用紙の一番下に寄せる */
  .sp-page:first-child .sp-bottom { margin-top: 4mm; }
}

@media print {
  /* 2枚目はスキルも入るので、行を少し低くする */
  .sp-page:nth-child(2) .sp-t tbody tr { height: 4.6mm; }
  .sp-page:nth-child(2) .sp-t td { font-size: 7.5pt; padding-top: 0.2mm; padding-bottom: 0.2mm; }
  .sp-page:nth-child(2) .sp-t td:last-child { font-size: 7pt; }
  .sp-page:nth-child(2) .sp-sec { margin-top: 1.8mm; }
}
@media print { .sp-page:first-child .sp-t tbody tr { height: 6.6mm; } }

.print-credit { display: none; }
@media print {
  .sp-foot, body.print-mode .print-credit { display: block; text-align: right; font-size: 7pt; color: #333; margin-top: 2mm; }
}

/* === 見やすさ（損傷/使用済みの強調・戦闘用表示・凡例・配色・表の余白） === */
/* 損傷：灰色に落とし、左端に赤い印、名前に取り消し線。種別の色より優先する */
tr.broken td { background: #2c2c2c !important; }
tr.broken td:first-child { box-shadow: inset 4px 0 0 #c0392b; }
tr.broken .p-name, tr.broken .skill-name-select { text-decoration: line-through; }
tr.broken input, tr.broken textarea, tr.broken select { opacity: .55; }
/* 使用済み：少し暗くして、左端に黄色の印 */
tr.used td:first-child { box-shadow: inset 4px 0 0 #e0b040; }
tr.used input:not([type="checkbox"]), tr.used textarea, tr.used select { opacity: .5; }

/* 戦闘用表示：部位の見出しを太く区切り、行動値を大きく */
body.battle-view .part-header { border-left: 6px solid #e05050; }
body.battle-view #bar-act { font-size: 1.5rem; }

/* 種別の色の凡例 */
.cat-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: .68rem; color: #aaa; margin: -2px 0 6px; }
.cat-legend .cat-chip { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.cat-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; border: 1px solid #777; }
@media print { .cat-legend { display: none !important; } }

/* 表のゆったり表示 */
html.table-roomy .maneuver-table th, html.table-roomy .maneuver-table td { padding: 5px 3px; font-size: .8rem; }
html.table-roomy .maneuver-table input, html.table-roomy .maneuver-table select { font-size: .8rem; padding: 4px 2px; }
html.table-roomy .maneuver-table textarea { font-size: .8rem; line-height: 1.4; }

/* 配色：明（画面全体の明暗を反転し、写真だけ元に戻す） */
html.theme-light { filter: invert(1) hue-rotate(180deg); background: #fff; }
html.theme-light img, html.theme-light video, html.theme-light canvas { filter: invert(1) hue-rotate(180deg); }
html.theme-light input[type="color"] { filter: hue-rotate(180deg) invert(1); }
html.theme-light { --red: #5c4a4a; }
html.theme-light .part-header, html.theme-light .calc-table .total-row td { background: #2e2a2a; }
@media print { html.theme-light { filter: none; } }
.bar-tools { flex-wrap: wrap; }

/* 戦闘用表示：スキルを1画面にたくさん見られるよう、凡例・区分の列を省き、行を詰める */
body.battle-view .cat-legend { display: none; }
body.battle-view #sec-skill .maneuver-table th:nth-child(2),
body.battle-view #sec-skill .maneuver-table tr.skill-row > td:nth-child(2) { display: none; }
body.battle-view #sec-skill .maneuver-table th { padding: 2px 1px; font-size: .68rem; }
body.battle-view #sec-skill .maneuver-table td { padding: 1px 2px; }
body.battle-view #sec-skill .maneuver-table input,
body.battle-view #sec-skill .maneuver-table select { padding: 1px; font-size: .74rem; }
body.battle-view #sec-skill .maneuver-table tr.skill-memo-row td { padding: 0 3px 2px; }
body.battle-view #sec-skill .maneuver-table tr.skill-memo-row textarea { font-size: .7rem; line-height: 1.25; min-height: 0; padding: 0 2px; }
body.battle-view #sec-skill .title { margin-bottom: 4px; }

/* 記憶のカケラの開閉ボタン：枠なしの細い矢じるし（▾/▸ の文字はやめた） */
#memory-list .memory-head .memory-toggle { background: transparent; border: none; width: 1.8em; height: 1.8em; padding: 0; position: relative; color: #9a8a8a; }
#memory-list .memory-head .memory-toggle::before { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translate(-50%, -70%) rotate(45deg); transition: transform .15s; }
#memory-list .memory-entry.collapsed .memory-toggle::before { transform: translate(-70%, -50%) rotate(-45deg); }

/* 閲覧用URLで開いたとき：保存・切替・編集切替のボタンと、編集用の部品を出さない */
body.view-locked .corner-btn, body.view-locked .edit-only, body.view-locked #view-mode-toggle { display: none !important; }
.view-btn-row { flex-wrap: wrap; }
.view-btn-row .char-switch-btn { flex: 1 1 28%; }

/* 狂気点：0/4 の形（4/4で赤く） */
.mad-pt { display: flex; align-items: center; justify-content: center; gap: 2px; min-width: 0; }
.mad-pt .mad-input { width: 2.4em; min-width: 0; flex: none; text-align: center; padding: 4px 1px; }
.mad-pt .mad-max { color: #aaa; font-size: .85rem; white-space: nowrap; }
.mad-pt .mad-step { flex: none; width: 1.7em; height: 1.7em; padding: 0; font-size: .8rem; background: #2a2a32; color: #ddd; border: 1px solid #555; border-radius: 6px; cursor: pointer; line-height: 1; }
.mad-pt.full .mad-input, .mad-pt.full .mad-max { color: #ff6b6b; font-weight: bold; }
.mad-pt.full .mad-input { border-color: #c0392b; }
@media print { .mad-step { display: none !important; } }
.mad-pt input.mad-input { width: 2.6em !important; min-width: 0; flex: none; text-align: center; padding: 4px 1px; }
@media (pointer: coarse) { body:not(.view-mode) .mad-pt input.mad-input { font-size: 16px !important; } }

.share-row { display:flex; gap:8px; align-items:center; justify-content:space-between; padding:6px 4px; border-bottom:1px solid #333; }
.share-info { display:flex; flex-direction:column; min-width:0; }
.share-info b { font-size:.86rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.share-info span { font-size:.7rem; color:#999; }
.share-btns { display:flex; gap:6px; flex:none; }
.share-btns button { padding:4px 8px; font-size:.74rem; white-space:nowrap; }

/* 固定バーの行動値・損傷は、表示画面だけに出す（編集画面では隠す） */
body:not(.view-mode) .edit-hide { display: none !important; }

/* 戦闘用ON：未練の表もスキルの表と同じように詰める */
body.battle-view #sec-miren .title { margin-bottom: 4px; }
body.battle-view #sec-miren table th { padding: 2px 1px; font-size: .68rem; }
body.battle-view #sec-miren table td { padding: 1px 2px; }
body.battle-view #sec-miren table input,
body.battle-view #sec-miren table select { padding: 1px; font-size: .74rem; }
body.battle-view #sec-miren table textarea { font-size: .7rem; line-height: 1.25; min-height: 0; padding: 0 2px; }
/* 戦闘用ON：発狂の効果文は、スキルの効果文と同じように、表の幅いっぱいに1行下げて出す */
body.battle-view .miren-mad-box { flex-wrap: wrap; row-gap: 0; }
body.battle-view .miren-mad-box .miren-madname { flex: 1 1 0; }
body.battle-view .miren-mad-box .miren-madeffect { flex: 1 0 100%; padding: 0 3px; }
body.battle-view .miren-mad-row td { padding: 0 2px 3px; }

/* キャラクター画像（複数枚）の管理欄 */
#image-panel { margin: 4px 0 12px 0; padding: 8px; border: 1px dashed #666; border-radius: 8px; }
.img-panel-head { font-size: .9rem; font-weight: bold; margin-bottom: 6px; }
.img-panel-head span { font-weight: normal; font-size: .78rem; color: #999; }
.img-panel-list { display: flex; flex-wrap: wrap; gap: 8px; }
.img-thumb { position: relative; width: 72px; height: 72px; padding: 0; border: 2px solid #555; border-radius: 8px; background: var(--img-bg, #222228); overflow: hidden; cursor: pointer; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 8%; display: block; }
.img-thumb.main { border-color: #e0a040; }
.img-badge { position: absolute; left: 0; bottom: 0; right: 0; font-size: .62rem; line-height: 1.4; background: rgba(0,0,0,.65); color: #fff; text-align: center; }
.img-thumb.main .img-badge { background: rgba(200,130,20,.85); }
.img-add { display: flex; flex-direction: column; align-items: center; justify-content: center; border-style: dashed; color: #bbb; gap: 2px; }
.img-add-plus { font-size: 1.5rem; line-height: 1; }
.img-add-text { font-size: .62rem; }
.img-panel-note { font-size: .72rem; color: #999; margin-top: 6px; line-height: 1.5; }
/* 表示モードの画像：複数枚のとき、下に小さな一覧 */
.vm-thumbs { display: flex; gap: 6px; justify-content: center; margin: -4px 0 10px 0; flex-wrap: wrap; }
.vm-thumbs img { width: 44px; height: 44px; object-fit: cover; object-position: 50% 8%; border-radius: 6px; border: 1.5px solid #555; opacity: .65; cursor: pointer; }
.vm-thumbs img.on { border-color: #e0a040; opacity: 1; }
@media print { #image-panel, .vm-thumbs { display: none !important; } }

.img-bg-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: .8rem; }
.img-bg-row input[type=color] { width: 44px; height: 28px; padding: 0; }

/* パソコン幅：左下の固定ボタン（保存・切替・表示）が内容に重ならないよう、左右に専用の余白をあける（右はREADMEボタン用） */
@media screen and (min-width: 900px) {
  body { padding-left: 124px; padding-right: 138px; }
}

/* 戦闘用ボタン：ON（絞り込み中）は赤く塗りつぶし、OFFは灰色の枠だけにして、状態が一目で分かるようにする */
#battle-toggle.on { background: #7a1f1f; color: #fff; border: 2px solid #ff6a6a; font-weight: bold; }
#battle-toggle.off { background: transparent; color: #999; border: 1px dashed #666; font-weight: normal; }

/* チャパレ編集画面は、表示モードでも文字を編集できるようにする */
body.view-mode #cp-text { pointer-events: auto !important; background: #fff !important; border-color: #999 !important; }

/* ココフォリアコマの編集画面も、表示モードで入力できるようにする */
body.view-mode #ccf-modal input, body.view-mode #ccf-modal textarea { pointer-events: auto !important; background: #fff !important; border-color: #999 !important; }

/* iPhone：表示モードでも編集できるチャパレ・ココフォリアコマの編集画面は、16pxにして勝手に拡大されないようにする */
@media (pointer: coarse) {
  body.view-mode #cp-text, body.view-mode #ccf-modal input, body.view-mode #ccf-modal textarea { font-size: 16px !important; }
}

/* 戦闘メモは、表示モードでも書けるようにする（閲覧用URLでは書き込み不可のまま） */
body.view-mode #battle-memo { pointer-events: auto !important; background: #1d1d24 !important; border: 1px solid #555 !important; }
body.view-mode.view-locked #battle-memo { pointer-events: auto !important; }
@media (pointer: coarse) { body #battle-memo { font-size: 16px !important; } }
@media print { #sec-battle-memo { display: none !important; } }

/* リンクの色：標準の青は、暗い背景でも、配色を「明」にして反転したときでも読みにくいので、見出しと同じ色にする */
a, a:visited { color: #8ff; text-decoration: underline; }
a:hover { color: #cff; }

/* --- スマホ：左下・右下の固定ボタン（保存・切替・表示・README）を小さくして、内容に重なりにくくする --- */
@media screen and (max-width: 899px) {
  .fixed-save, .corner-btn, .fixed-readme { opacity: .9; box-shadow: 0 2px 6px rgba(0,0,0,.6) !important; }
  .fixed-save { left: 8px !important; bottom: 10px !important; padding: 5px 11px !important; font-size: .72rem !important; }
  .corner-btn { left: 8px !important; padding: 4px 10px !important; font-size: .68rem !important; }
  .corner-switch { bottom: 44px !important; }
  #view-mode-toggle { bottom: 76px !important; }
  .fixed-readme { right: 8px !important; bottom: 10px !important; padding: 5px 11px !important; font-size: .72rem !important; }
  /* いちばん下まで読んだとき、固定ボタンの下に内容が隠れないよう、余白をあける */
  body { padding-bottom: 64px; }
}
}

/* スマホ：マニューバ表の入力欄の左右の余白を小さくして、「アクション」などが切れずに見えるようにする */
@media screen and (max-width: 899px) {
  .p-name, .p-timing, .p-cost, .p-range, .p-level, select.range-sel { padding-left: 1px !important; padding-right: 1px !important; }
  .p-type, .p-location { padding-left: 1px !important; padding-right: 1px !important; }
  .p-timing, .p-cost, .p-range { text-align: center !important; }
}
@media screen and (min-width: 385px) and (max-width: 899px) {
  /* 文字が切れやすい列に、最低限の幅をとる（名前の列がそのぶん細くなる。幅の狭い小型のスマホでは、名前が潰れるので行わない） */
  .maneuver-table td:has(> .p-cost), .maneuver-table td:has(> .skill-cost) { min-width: 30px; }
  .maneuver-table td:has(> .p-range), .maneuver-table td:has(> .skill-range) { min-width: 34px; }
  .maneuver-table td:has(> .p-timing), .maneuver-table td:has(> .skill-timing) { min-width: 62px; }
}

#editing-name { font-weight: bold; color: #ffd0d0; font-size: .9rem; line-height: 1.3; padding: 1px 2px 3px; border-bottom: 1px dashed var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* マニューバ表のタイミング(選択式)：固定のパーツ(無効化している行)も、同じ大きさ・色で見せる */
.maneuver-table select.p-timing, .maneuver-table select.skill-timing { font-size: .86rem; }
@media screen and (max-width: 384px) { .maneuver-table select.p-timing, .maneuver-table select.skill-timing { font-size: .72rem; } } /* 幅の狭い小型のスマホは、これまでの大きさ */
.maneuver-table select.p-timing:disabled { opacity: 1; color: #fff; -webkit-text-fill-color: #fff; }
html.table-roomy .maneuver-table select.p-timing, html.table-roomy .maneuver-table select.skill-timing { font-size: .95rem; }
/* 戦闘用の表示(battle-view)のスキル表は、select の文字を一括で小さくしているので、タイミングだけ上書きする */
body.battle-view #sec-skill .maneuver-table select.skill-timing { font-size: .86rem; }
@media screen and (max-width: 384px) { body.battle-view #sec-skill .maneuver-table select.skill-timing { font-size: .74rem; } }
html.table-roomy body.battle-view #sec-skill .maneuver-table select.skill-timing { font-size: .95rem; }

.maneuver-table select.p-level { font-size: .8rem; }

/* 射程(選択式＋自由枠) */
.maneuver-table select.range-sel { font-size: .72rem; }
html.table-roomy .maneuver-table select.range-sel { font-size: .8rem; }

/* 固定のパーツ(基本パーツ・一覧から選んだパーツ)の、無効にしているレベル・射程の選択欄も、同じ色で見せる */
.maneuver-table select.p-level:disabled, .maneuver-table select.range-sel:disabled { opacity: 1; color: #fff; -webkit-text-fill-color: #fff; }

/* 固定バーの「スキル」行：名前が多いときは折り返す */

/* 寵愛点で取得したスキル・パーツ：「寵」ボタンと、行の左端の金色の印 */
.op-stack { display: inline-flex; flex-direction: column; align-items: stretch; gap: 2px; }
/* パーツの並べ替え(▲▼)：2つを横に並べる */
.move-btns { display: flex; gap: 2px; }
.move-btn { flex: 1 1 0; min-width: 0; background: #23304a; color: #cfe0ff; border: 1px solid #5a74a8; border-radius: 3px; font-size: .7rem; padding: 2px 0; line-height: 1.2; cursor: pointer; }
.move-btn:hover, .move-btn:focus-visible { background: #34466c; }
.move-btn:active { filter: brightness(1.3); }
html.theme-light .move-btn { background: #e3eaf8; color: #28406e; border-color: #8aa0cc; }
@keyframes movedflash { from { background-color: rgba(120,180,255,.55); } to { background-color: transparent; } }
tr.moved-flash > td { animation: movedflash 1.1s ease-out; }
@media print { .move-btns { display: none !important; } }
.chouai-btn { background: #2a2418; color: #d9b44a; border: 1px solid #8a6d1e; border-radius: 3px; font-size: .68rem; padding: 1px 3px; cursor: pointer; line-height: 1.2; }
tr.chouai-acq .chouai-btn { background: #b8860b; color: #fff; border-color: #ffd24a; font-weight: bold; }
tr.chouai-acq > td:first-child { box-shadow: inset 4px 0 0 #ffd24a; }
html.theme-light tr.chouai-acq > td:first-child { box-shadow: inset 4px 0 0 #a07000; }
@media print {  }

.bar-chouai { color: #ffd24a; white-space: nowrap; }
html.theme-light .bar-chouai { color: #ffd24a; }

/* 「寵」ボタンは、印が付いた行にだけ出す(印は「寵愛点の使い道」の記載から自動で付く。ボタンは外すとき用) */





/* キャラクター画像の横に置く「保管所から読み込む」ボタン(画像の枠と同じ大きさ) */
/* 「保管所テキストからキャラクターを読み込む」：キャラクター画像の枠の外に置く、横いっぱいのボタン */
.hokansho-bar { display: block; width: 100%; margin: 0 0 12px 0; padding: 10px 12px; background: #8a4a10; color: #fff; border: 2px solid #ffb060; border-radius: 8px; font-size: .95rem; font-weight: bold; font-family: inherit; cursor: pointer; box-shadow: 0 0 8px rgba(255,160,70,.45); }
.hokansho-bar:active { filter: brightness(1.15); }
/* 印の付いていない行の「寵」ボタンは、目立たないよう薄くする(押せば印が付く)。印の付いた行は、これまでどおり金色で目立たせる */
tr:not(.chouai-acq) .chouai-btn { opacity: .85; background: transparent; border: 1px dashed #c9a43a; color: #e6c766; }
tr:not(.chouai-acq) .chouai-btn:hover, tr:not(.chouai-acq) .chouai-btn:focus-visible { opacity: 1; background: #3a3018; }
.chouai-btn { white-space: nowrap; }
.chouai-note { font-size: .72rem; color: #c9b27a; margin: 4px 2px 0; line-height: 1.5; }
.chouai-note b { color: #ffd24a; }
tr.no-chouai .chouai-btn { display: none !important; }

/* 「獲得」＝シナリオ中に獲得したもの(寵愛点は使わず、上限だけ1増える) */
@keyframes savePendingBlink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(127,227,168,0); filter: none; }
  50% { box-shadow: 0 0 14px 4px rgba(127,227,168,.95); filter: brightness(1.5); }
}
.save-pending { animation: savePendingBlink 1.1s ease-in-out infinite; border-color: #7fe3a8 !important; }
@media (prefers-reduced-motion: reduce) { .save-pending { animation: none; box-shadow: 0 0 10px 3px rgba(127,227,168,.9); } }
.other-btn { display: none !important; }
tr.other-acq .other-btn { display: inline-block !important; }
.other-btn { background: transparent; color: #5fd0c0; border: 1px dashed #3e9d90; border-radius: 3px; font-size: .68rem; padding: 1px 3px; cursor: pointer; line-height: 1.2; white-space: nowrap; opacity: .85; }
.other-btn:hover, .other-btn:focus-visible { opacity: 1; background: #12302c; }
tr.other-acq .other-btn { background: #1f8f80; color: #fff; border: 1px solid #5fd0c0; font-weight: bold; opacity: 1; }
tr.other-acq > td:first-child { box-shadow: inset 4px 0 0 #5fd0c0; }
html.theme-light tr.other-acq > td:first-child { box-shadow: inset 4px 0 0 #0f7a6c; }
tr.no-chouai .other-btn { display: none !important; }
tr.no-chouai.other-acq .other-btn { display: none !important; }

/* 上限を超えているマニューバ(パーツ・スキル)の行 */
tr.over-row > td:first-child { box-shadow: inset 4px 0 0 #ff5555; }
tr.over-row .p-name, tr.over-row .skill-name-select { color: #ff9a9a; }

/* 「寵」ボタンは出さない(寵の印は、使い道に名前を書くと自動で付く。コードは互換のために残す) */
.chouai-btn { display: none !important; }

/* 「シナリオ中に獲得」の追加欄 */
.add-part-select.acq-select { margin-top: 4px; border-color: #3e9d90; color: #5fd0c0; }

/* --- スマホ(編集時)：パーツ表は1行が細くなりすぎるので、2段に折り返す（1段目：損/使/色/部位/名前/操作、2段目：分類/Lv/タイミング/コスト/射程） --- */
@media screen and (max-width: 560px) {
  html:not(.parts-oneline) body:not(.view-mode) .parts-table, html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody { display: block; width: 100%; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table thead { display: none; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tr.part-memo-row { display: block; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tr.part-memo-row > td { display: block; width: auto; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) {
    display: grid; align-items: end; column-gap: 3px; row-gap: 2px; padding: 3px 2px 2px;
    grid-template-columns: 28px 28px 40px minmax(48px,.8fr) 1fr 1fr 64px;
    grid-template-areas: "b u c loc name name op" "type type lv tim tim cost rng";
  }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td { display: block; width: auto; min-width: 0 !important; padding: 0; border: 0; text-align: center; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(1) { grid-area: b; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(2) { grid-area: u; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(3) { grid-area: c; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(4) { grid-area: loc; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(5) { grid-area: name; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(6) { grid-area: type; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(7) { grid-area: lv; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(8) { grid-area: tim; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(9) { grid-area: cost; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(10) { grid-area: rng; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(11) { grid-area: op; }
  /* 2段目の小さな見出し */
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(n+6):nth-child(-n+10)::before { display: block; font-size: .6rem; line-height: 1.1; color: #bbb; text-align: left; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(6)::before { content: "分類"; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(7)::before { content: "Lv"; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(8)::before { content: "タイミング"; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(9)::before { content: "コスト"; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(10)::before { content: "射程"; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table td > input, html:not(.parts-oneline) body:not(.view-mode) .parts-table td > select { width: 100%; box-sizing: border-box; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table td input[type=checkbox] { width: auto; }
}
@media screen and (max-width: 360px) {
  /* 幅の狭い小型のスマホは、名前が潰れて長い名前が読めないので、名前を独立した段にして全幅で見せる(3段) */
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) {
    grid-template-columns: 24px 24px 36px 44px 1fr minmax(34px,.7fr) 56px;
    grid-template-areas: "b u c loc . . op" "name name name name name name name" "type type lv tim tim cost rng";
  }
}
@media screen and (max-width: 560px) {
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(-n+2)::before { display: block; font-size: .6rem; line-height: 1.1; color: #bbb; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(1)::before { content: "損"; }
  html:not(.parts-oneline) body:not(.view-mode) .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(2)::before { content: "使"; }
}
/* スマホ：スクロール中・入力中は、左下/右下の固定ボタンを薄くして、表の内容が読めるようにする（触れば使える。保存の警告点滅中は薄くしない） */
@media screen and (max-width: 899px) {
  body.fab-dim .fixed-save:not(.save-pending), body.fab-dim .corner-btn, body.fab-dim .fixed-readme { opacity: .25 !important; transition: opacity .2s; }
}

/* スマホ：文字・表・配色の3ボタンは「⚙ 表示設定」にまとめ、固定バーを低くする（PCは今まで通り並べる） */
.look-tools { display: contents; }
#look-toggle { display: none; }
@media screen and (max-width: 560px) {
  #look-toggle { display: inline-block; }
  .look-tools { display: none; }
  .bar-tools.look-open .look-tools { display: contents; }
}
@media print { #look-toggle { display: none !important; } }

/* 固定バーを畳んでいる間だけ、武装・変異・改造・スキルの残数を1行で見せる */
.bar-summary { display: none; font-size: .78rem; line-height: 1.3; padding: 1px 2px; flex-wrap: wrap; gap: 2px 10px; }
.sticky-top-bar.bar-collapsed .bar-summary { display: flex; }
.bar-summary { cursor: pointer; }
.bar-summary b { font-weight: bold; }
.bar-summary .over { color: #ff8a8a; }
@media print { .bar-summary { display: none !important; } }

/* 表示モード：パーツ表も、文字と枠の間の縦の余白をなくして、行を詰める（スキル表の戦闘用表示と同じ考え方） */
body.view-mode .parts-table td { padding-top: 0; padding-bottom: 0; }
body.view-mode .parts-table td input, body.view-mode .parts-table td select { padding-top: 0; padding-bottom: 0; line-height: 1.25; min-height: 0; }
body.view-mode .parts-table tr.part-memo-row > td { padding-top: 0; padding-bottom: 0; }
body.view-mode .parts-table tr.part-memo-row textarea { padding-top: 0; padding-bottom: 0; line-height: 1.25; }

/* --- 小型スマホ(表示モード)：パーツ表は1行が細くなりすぎるので、2段に折り返す（1段目：損/使/色/部位/名前/操作、2段目：分類/Lv/タイミング/コスト/射程） --- */
@media screen and (max-width: 380px) {
  html:not(.parts-oneline) body.view-mode .parts-table, html:not(.parts-oneline) body.view-mode .parts-table tbody { display: block; width: 100%; }
  html:not(.parts-oneline) body.view-mode .parts-table thead { display: none; }
  html:not(.parts-oneline) body.view-mode .parts-table tr.part-memo-row { display: block; }
  html:not(.parts-oneline) body.view-mode .parts-table tr.part-memo-row > td { display: block; width: auto; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) {
    display: grid; align-items: end; column-gap: 3px; row-gap: 2px; padding: 3px 2px 2px;
    grid-template-columns: 28px 28px 40px minmax(48px,.8fr) 1fr 1fr 64px;
    grid-template-areas: "b u c loc name name op" "type type lv tim tim cost rng";
  }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td { display: block; width: auto; min-width: 0 !important; padding: 0; border: 0; text-align: center; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(1) { grid-area: b; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(2) { grid-area: u; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(3) { grid-area: c; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(4) { grid-area: loc; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(5) { grid-area: name; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(6) { grid-area: type; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(7) { grid-area: lv; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(8) { grid-area: tim; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(9) { grid-area: cost; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(10) { grid-area: rng; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(11) { grid-area: op; }
  /* 2段目の小さな見出し */
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(n+6):nth-child(-n+10)::before { display: block; font-size: .6rem; line-height: 1.1; color: #bbb; text-align: left; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(6)::before { content: "分類"; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(7)::before { content: "Lv"; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(8)::before { content: "タイミング"; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(9)::before { content: "コスト"; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(10)::before { content: "射程"; }
  html:not(.parts-oneline) body.view-mode .parts-table td > input, html:not(.parts-oneline) body.view-mode .parts-table td > select { width: 100%; box-sizing: border-box; }
  html:not(.parts-oneline) body.view-mode .parts-table td input[type=checkbox] { width: auto; }
}
@media screen and (max-width: 360px) {
  /* 幅の狭い小型のスマホは、名前が潰れて長い名前が読めないので、名前を独立した段にして全幅で見せる(3段) */
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) {
    grid-template-columns: 24px 24px 36px 44px 1fr minmax(34px,.7fr) 56px;
    grid-template-areas: "b u c loc . . op" "name name name name name name name" "type type lv tim tim cost rng";
  }
}
@media screen and (max-width: 380px) {
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(-n+2)::before { display: block; font-size: .6rem; line-height: 1.1; color: #bbb; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(1)::before { content: "損"; }
  html:not(.parts-oneline) body.view-mode .parts-table tbody > tr:not(.part-memo-row) > td:nth-child(2)::before { content: "使"; }
}
/* 「パーツ：1行」を選んだとき(スマホ)は、2段にせず、これまで通り1行の表にする。このボタンはスマホだけに出す */
#parts-oneline-btn { display: none; }
@media screen and (max-width: 560px) { #parts-oneline-btn { display: inline-block; } }
@media print { #parts-oneline-btn { display: none !important; } }

/* スマホ(2段)のパーツは、行の間に薄い区切り線を入れて見分けやすくする */
@media screen and (max-width: 560px) {
  html:not(.parts-oneline) .parts-table tbody > tr:not(.part-memo-row) { border-top: 1px solid rgba(255,255,255,.14); }
  html:not(.parts-oneline) .parts-table tbody > tr:not(.part-memo-row):first-child { border-top: 0; }
}
