/* キャラ図鑑 CZ-01 — オリジナルの図鑑デバイス風UI（公式資産は未使用） */

@font-face {
  font-family: "DotGothic16";
  src: url("./fonts/DotGothic16-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --shell: #c43632;
  --shell-dark: #8e1f1c;
  --shell-deep: #5e1210;
  --shell-light: #e0564f;
  --shell-hi: #ef7a72;
  --lens: #2f8cff;
  --lens-hi: #b9e3ff;
  --bezel: #1c1c20;
  --bezel-hi: #3a3a42;
  --screen: #e4edd0;
  --screen-2: #d3ddba;
  --ink: #1c2a1e;
  --ink-dim: #4e5d4c;
  --line: #8b9a72;
  --flavor: #cfd9b4;
  --sel: #3d6b4a;
  --sel-bg: #1c2a1e;
  --led-r: #ff3b3b;
  --led-y: #ffd23a;
  --led-g: #3de06a;
  --chip-ink: #1a1a1a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(ellipse at 50% 0%, #2a2426 0%, #141314 55%, #0c0b0c 100%);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  overflow: hidden;
}

.desk {
  height: 100dvh;
  padding: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l));
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* ===== デバイスシェル ===== */
.dex {
  --r: 28px;
  width: 100%;
  max-width: 520px;
  display: grid;
  grid-template-columns: 1fr;
  background: linear-gradient(165deg, var(--shell-light) 0%, var(--shell) 38%, var(--shell-dark) 100%);
  border-radius: var(--r);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.28),
    inset 0 -6px 10px rgba(0,0,0,.28),
    0 18px 40px rgba(0,0,0,.45),
    0 2px 0 var(--shell-deep);
  padding: 10px 10px 12px;
  position: relative;
  min-height: 0;
}
.dex::before {
  /* ヒンジ線（閉じた状態の溝） */
  content: "";
  display: none;
}

.panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  min-width: 0;
}

.panel-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px 10px 6px;
}

.lens {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, var(--lens-hi) 0%, #5ab0ff 28%, var(--lens) 55%, #0a4aa0 100%);
  box-shadow:
    0 0 0 4px #d8dde8,
    0 0 0 7px #6a6e78,
    0 0 0 9px #2c2e33,
    0 0 18px 2px rgba(80,170,255,.55),
    inset 0 -6px 10px rgba(0,20,60,.35);
  position: relative;
  animation: lensPulse 3.6s ease-in-out infinite;
}
.lens::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,.75);
  top: 12px;
  left: 14px;
  transform: rotate(-20deg);
  filter: blur(0.3px);
}
@keyframes lensPulse {
  0%, 100% { box-shadow: 0 0 0 4px #d8dde8, 0 0 0 7px #6a6e78, 0 0 0 9px #2c2e33, 0 0 14px 1px rgba(80,170,255,.4), inset 0 -6px 10px rgba(0,20,60,.35); }
  50% { box-shadow: 0 0 0 4px #d8dde8, 0 0 0 7px #6a6e78, 0 0 0 9px #2c2e33, 0 0 26px 4px rgba(80,190,255,.75), inset 0 -6px 10px rgba(0,20,60,.35); }
}

.leds { display: flex; gap: 7px; align-self: start; padding-top: 6px; }
.led {
  width: 12px; height: 12px; border-radius: 50%;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.7), 0 0 0 2px #2a2a2e, 0 0 6px currentColor;
}
.led-r { background: var(--led-r); color: var(--led-r); animation: ledBlink 2.8s ease-in-out infinite; }
.led-y { background: var(--led-y); color: var(--led-y); animation: ledBlink 4.2s ease-in-out infinite 0.4s; }
.led-g { background: var(--led-g); color: var(--led-g); }
@keyframes ledBlink {
  0%, 72%, 100% { filter: brightness(1); opacity: 1; }
  80% { filter: brightness(.55); opacity: .7; }
  88% { filter: brightness(1.2); opacity: 1; }
}

.brand { text-align: right; }
.brand-title {
  font-family: "DotGothic16", monospace;
  font-size: 22px;
  letter-spacing: .08em;
  color: #fff8f0;
  text-shadow: 0 2px 0 rgba(80,0,0,.35);
  line-height: 1.1;
}
.brand-sub {
  font-family: "DotGothic16", monospace;
  font-size: 10px;
  letter-spacing: .16em;
  color: rgba(255,236,220,.72);
  margin-top: 2px;
}

.bezel {
  background: linear-gradient(180deg, #2a2a30, var(--bezel));
  border-radius: 16px;
  padding: 12px 12px 16px;
  box-shadow: inset 0 0 0 2px #0b0b0d, 0 1px 0 rgba(255,255,255,.12);
  min-height: 0;
  display: flex;
  position: relative;
}
.bezel::after {
  /* 装飾ネジ */
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 12px;
  pointer-events: none;
  box-shadow:
    8px 8px 0 -6px #5a5a62,
    calc(100% - 8px) 8px 0 -6px #5a5a62,
    8px calc(100% - 8px) 0 -6px #5a5a62,
    calc(100% - 8px) calc(100% - 8px) 0 -6px #5a5a62;
}

.screen {
  flex: 1;
  min-height: 0;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.18), transparent 28%),
    repeating-linear-gradient(180deg, rgba(20,40,20,.03) 0 2px, transparent 2px 4px),
    var(--screen);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px #9aa680, inset 0 8px 18px rgba(0,0,0,.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  color: var(--ink);
}

/* ===== 下部コントロール ===== */
.controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 4px;
}
.dpad {
  width: 86px; height: 86px;
  position: relative;
  filter: drop-shadow(0 3px 0 var(--shell-deep));
}
.dpad button {
  position: absolute;
  background: #2c2c32;
  border: 0;
  color: #c8c8d0;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 2px 0 #111;
  font-size: 11px;
  padding: 0;
}
.dpad button:active { transform: translateY(1px); box-shadow: inset 0 1px 2px #000; }
.dpad .u { left: 29px; top: 2px; border-radius: 5px 5px 0 0; }
.dpad .d { left: 29px; bottom: 2px; border-radius: 0 0 5px 5px; }
.dpad .l { left: 2px; top: 29px; border-radius: 5px 0 0 5px; }
.dpad .r { right: 2px; top: 29px; border-radius: 0 5px 5px 0; }
.dpad .c {
  left: 29px; top: 29px; width: 28px; height: 28px;
  border-radius: 2px; background: #242428;
}

.oval-btns { display: flex; gap: 14px; justify-content: flex-end; align-items: center; }
.oval-btns button {
  width: 42px; height: 42px; border-radius: 50%;
  border: 0; cursor: pointer;
  font-family: "DotGothic16", monospace;
  font-size: 14px;
  color: #2a1010;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.35), 0 3px 0 #5a1010;
}
.oval-btns button:active { transform: translateY(2px); box-shadow: inset 0 2px 3px rgba(0,0,0,.3); }
#btn-a { background: #5da8e8; }
#btn-b { background: #e8a05d; }

.pills { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.pills button, .linkish {
  font-family: "DotGothic16", monospace;
  font-size: 10px;
  letter-spacing: .08em;
  background: #8a1e1c;
  color: #ffd8d0;
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 2px 0 var(--shell-deep);
}
.pills button:active { transform: translateY(1px); }

.speaker {
  height: 36px;
  background: repeating-linear-gradient(180deg, #6a1614 0 3px, #c43632 3px 6px);
  border-radius: 4px;
  opacity: .7;
  margin: 0 8px;
}

.panel-right, .hinge { display: none; }

/* ===== ワイド：二つ折り図鑑 ===== */
@media (min-width: 1100px) {
  .desk { padding: 18px 24px; }
  .dex {
    max-width: 1680px;
    width: 100%;
    grid-template-columns: 1fr 28px 1fr;
    padding: 14px;
    border-radius: 36px;
  }
  .panel-right, .hinge { display: grid; }
  .hinge {
    display: flex;
    align-items: stretch;
    justify-content: center;
    position: relative;
    margin: -6px 0;
  }
  .hinge-bar {
    width: 18px;
    border-radius: 10px;
    background:
      repeating-linear-gradient(180deg, #5a1210 0 8px, #8a2420 8px 10px),
      linear-gradient(90deg, #4a0e0c, #9a3030 40%, #4a0e0c);
    box-shadow: inset 3px 0 0 rgba(255,255,255,.08), inset -3px 0 0 rgba(0,0,0,.35);
    position: relative;
  }
  .hinge-pin {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 26px; height: 70px;
    border-radius: 13px;
    background: linear-gradient(90deg, #3a0c0a, #7a2826 45%, #2a0808);
    box-shadow: 0 0 0 2px #1a0606, inset 0 1px 0 rgba(255,255,255,.15);
  }
  .panel-right .panel-head { min-height: 74px; }
  .right-deco {
    font-family: "DotGothic16", monospace;
    color: rgba(255,236,220,.7);
    font-size: 11px;
    letter-spacing: .2em;
    text-align: center;
    width: 100%;
  }
  .right-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 6px;
  }
  .slider-deco {
    flex: 1;
    height: 10px;
    border-radius: 6px;
    background: #2a2a30;
    box-shadow: inset 0 2px 3px #000, 0 1px 0 rgba(255,255,255,.15);
  }
}

@media (max-width: 1099px) {
  .wide-only { display: none !important; }
}

/* ===== 画面の中身 ===== */
.screen-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 2px solid var(--ink);
  background: rgba(255,255,255,.2);
  flex-shrink: 0;
}
.screen-bar h1, .screen-bar .ttl {
  font-family: "DotGothic16", monospace;
  font-size: 14px;
  letter-spacing: .12em;
  flex: 1;
}
.icon-btn, .text-btn, button.chip-btn {
  font-family: "DotGothic16", monospace;
  background: var(--ink);
  color: var(--screen);
  border: 0;
  border-radius: 4px;
  padding: 5px 8px;
  min-height: 32px;
  cursor: pointer;
  font-size: 12px;
}
.text-btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.search {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.search input[type="search"], .search select, .field input, .field textarea, .field select {
  width: 100%;
  font: inherit;
  background: #f4f7e8;
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 7px 8px;
  color: var(--ink);
  min-height: 36px;
}
.search-row { display: flex; gap: 6px; }
.search-row input { flex: 1; }
.search-row select { max-width: 46%; }

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 8px 8px;
  flex-shrink: 0;
}
.tag, .type-chip {
  font-family: "DotGothic16", monospace;
  font-size: 11px;
  letter-spacing: .04em;
  border: 0;
  border-radius: 999px;
  padding: 3px 8px;
  cursor: pointer;
  line-height: 1.4;
  color: #fff;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.2);
}
.tag.on, .type-chip.on { outline: 2px solid var(--ink); outline-offset: 1px; }
.tag.sm { font-size: 10px; padding: 2px 6px; cursor: pointer; }
.tag .x { margin-left: 4px; opacity: .8; }

.list {
  flex: 1;
  overflow: auto;
  padding: 6px;
  min-height: 0;
}
.dex-row {
  display: grid;
  grid-template-columns: auto 54px 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 6px;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
  border-radius: 2px;
}
.dex-row:hover { background: rgba(28,42,30,.06); }
.dex-row.sel, .dex-row:active {
  background: var(--sel-bg);
  color: var(--screen);
}
.dex-row.sel .no, .dex-row:active .no { color: #f0e070; }
.no {
  font-family: "DotGothic16", monospace;
  font-size: 13px;
  letter-spacing: .06em;
  color: #9a2a28;
  min-width: 3.6em;
}
.thumb {
  width: 54px; height: 54px;
  object-fit: cover;
  border-radius: 4px;
  background: #c5d0a8;
  box-shadow: inset 0 0 0 2px var(--ink);
  display: block;
}
.thumb.ph { display: grid; place-items: center; font-size: 10px; color: var(--ink-dim); }
.row-name {
  font-family: "DotGothic16", monospace;
  font-size: 15px;
  letter-spacing: .06em;
}
.row-cat { font-size: 11px; color: var(--ink-dim); margin-top: 1px; }
.dex-row.sel .row-cat { color: #c5d0a8; }
.row-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--ink-dim);
  font-family: "DotGothic16", monospace;
  line-height: 1.7;
}

/* ===== 詳細 ===== */
.detail {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.detail > * { flex-shrink: 0; }
.photo-screen {
  background: #0e140f;
  border: 3px solid var(--ink);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 240px;
  min-height: 160px;
  margin: 0 auto;
  width: 100%;
  flex-shrink: 0;
}
.photo-screen img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  background: #0e140f;
}
.photo-thumbs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0;
}
.photo-thumbs img, .photo-thumbs .add-ph {
  width: 48px; height: 48px;
  object-fit: cover;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  background: #c5d0a8;
}
.photo-thumbs img.on { border-color: var(--ink); }
.identity .name {
  font-family: "DotGothic16", monospace;
  font-size: 22px;
  letter-spacing: .1em;
  line-height: 1.2;
}
.identity .cat {
  font-family: "DotGothic16", monospace;
  font-size: 13px;
  color: var(--ink-dim);
  margin-top: 2px;
}
.identity .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.stats {
  display: grid;
  grid-template-columns: 1fr;
  border: 2px solid var(--ink);
  background: #f3f6e6;
}
.stat {
  display: grid;
  grid-template-columns: 7em 1fr;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.stat:first-child { border-top: 0; }
.stat dt {
  font-family: "DotGothic16", monospace;
  background: #1c2a1e;
  color: var(--screen);
  padding: 5px 8px;
  letter-spacing: .12em;
}
.stat dd { padding: 5px 8px; }
.stat.quiet dt { background: #5a6754; letter-spacing: .08em; font-size: 12px; }
.prov { font-size: 10px; color: var(--ink-dim); margin-left: 6px; }

.flavor {
  border: 2px solid var(--ink);
  background: var(--flavor);
  padding: 8px 10px;
  font-family: "DotGothic16", monospace;
  font-size: 13px;
  line-height: 1.75;
  letter-spacing: .04em;
  min-height: 4.5em;
  position: relative;
}
.flavor::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, transparent 0 22px, rgba(28,42,30,.05) 22px 23px);
}

.scan-panel {
  border: 3px solid var(--ink);
  background: #0e140f;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.scan-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 6px;
  background: #1c2a1e;
  color: var(--screen);
  font-family: "DotGothic16", monospace;
  font-size: 11px;
  letter-spacing: .06em;
}
.scan-top button {
  font-family: inherit;
  font-size: 11px;
  border: 0;
  background: #3d6b4a;
  color: #f4f7e8;
  padding: 4px 8px;
  border-radius: 2px;
  cursor: pointer;
  min-height: 28px;
}
.scan-top button.on { background: #e4edd0; color: #1c2a1e; }
.scan-view {
  height: 260px;
  min-height: 260px;
  flex-shrink: 0;
  position: relative;
  background:
    linear-gradient(rgba(80,220,120,.05), rgba(80,220,120,.05)),
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(80,255,140,.07) 7px 8px),
    #152018;
}
.scan-view .scanline {
  position: absolute;
  left: 0; right: 0; height: 18%;
  background: linear-gradient(180deg, transparent, rgba(120,255,180,.10), transparent);
  animation: scanMove 3.2s linear infinite;
  pointer-events: none;
  z-index: 2;
}
@keyframes scanMove {
  0% { top: -18%; }
  100% { top: 100%; }
}

.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.video-link {
  font-family: "DotGothic16", monospace;
  color: #1a4a9a;
  word-break: break-all;
}

/* フォーム */
.form { display: flex; flex-direction: column; gap: 8px; padding: 8px; overflow: auto; flex: 1; min-height: 0; }
.field label {
  display: block;
  font-family: "DotGothic16", monospace;
  font-size: 11px;
  letter-spacing: .1em;
  margin-bottom: 3px;
}
.field textarea { min-height: 90px; resize: vertical; }
.bwh { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.help { font-size: 11px; color: var(--ink-dim); }

.tag-input { position: relative; }
.tag-edit { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag-edit input { flex: 1; min-width: 8em; }
.suggest {
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: #fff;
  border: 2px solid var(--ink);
  z-index: 5;
  max-height: 160px;
  overflow: auto;
}
.suggest button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; padding: 6px 8px; cursor: pointer;
  font-family: "DotGothic16", monospace;
}
.suggest button:hover, .suggest button.hi { background: #1c2a1e; color: var(--screen); }

.photo-edit { display: flex; flex-wrap: wrap; gap: 6px; }
.photo-edit .pe {
  width: 72px; position: relative;
}
.photo-edit .pe img { width: 72px; height: 72px; object-fit: cover; border: 2px solid var(--ink); }
.photo-edit .pe button {
  position: absolute; top: 2px; right: 2px;
  background: #9a2a28; color: #fff; border: 0; border-radius: 2px;
  width: 22px; height: 22px; cursor: pointer;
}

/* メニュー・モーダル */
.menu, .modal-back {
  position: absolute;
  inset: 0;
  background: rgba(14,20,15,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 8;
  padding: 10px;
}
.menu-card, .modal {
  background: var(--screen);
  border: 3px solid var(--ink);
  width: 100%;
  max-width: 420px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.menu-card button, .modal .row-btn {
  font-family: "DotGothic16", monospace;
  text-align: left;
  background: #f3f6e6;
  border: 2px solid var(--ink);
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
}
.danger { color: #9a2a28 !important; }

/* 合わせパネル */
.align-wrap {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: var(--screen);
  display: flex;
  flex-direction: column;
}
.aligner-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, #c5d0a8 0 8px, #d3ddba 8px 16px),
    #d3ddba;
  touch-action: none;
  cursor: grab;
}
.aligner-man {
  position: absolute;
  inset: 6% 28%;
  pointer-events: none;
  opacity: .85;
  z-index: 1;
}
.aligner-man svg { width: 100%; height: 100%; }
.aligner-img {
  position: absolute;
  left: 50%; top: 50%;
  width: 70%;
  height: auto;
  opacity: .62;
  z-index: 2;
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
}
.align-tools {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px;
  border-top: 2px solid var(--ink);
  background: #f3f6e6;
}

/* ワイド詳細の internally 2-col */
@media (min-width: 1100px) {
  .detail.wide-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: min-content;
    gap: 10px;
  }
  .detail.wide-split .photo-screen { max-height: 360px; }
  .detail.wide-split .scan-panel { grid-column: 2; grid-row: 1 / span 4; align-self: start; }
  .detail.wide-split .scan-view { height: 400px; min-height: 300px; max-height: 48vh; }
}

.hidden { display: none !important; }
.toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--screen);
  font-family: "DotGothic16", monospace;
  padding: 8px 12px;
  z-index: 20;
  border-radius: 2px;
  font-size: 12px;
}

/* ===== 詳細タブ ===== */
.dex-tabs {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  border-bottom: 2px solid var(--ink);
  background: rgba(255,255,255,.15);
}
.dex-tabs button {
  flex: 1;
  font-family: "DotGothic16", monospace;
  font-size: 13px;
  letter-spacing: .12em;
  background: transparent;
  border: 0;
  border-bottom: 4px solid transparent;
  padding: 8px 6px 6px;
  cursor: pointer;
  color: var(--ink-dim);
  min-height: 40px;
}
.dex-tabs button.on {
  color: var(--ink);
  border-bottom-color: var(--ink);
  background: rgba(255,255,255,.25);
}

/* ===== 設定資料 ===== */
.sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px;
}
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 0 8px 12px;
}
.sheet-card { display: flex; flex-direction: column; gap: 4px; }
.sheet-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid var(--ink);
  background: #0e140f;
  cursor: pointer;
  overflow: hidden;
}
.sheet-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-type {
  position: absolute;
  left: 4px; top: 4px;
  font-family: "DotGothic16", monospace;
  font-size: 10px;
  letter-spacing: .08em;
  background: #1c2a1e;
  color: var(--screen);
  padding: 2px 6px;
}
.sheet-cap { font-size: 11px; color: var(--ink-dim); line-height: 1.4; min-height: 2.6em; }
.sheet-ops { display: flex; flex-wrap: wrap; gap: 3px; }
.sheet-ops button { min-height: 28px; padding: 3px 6px; font-size: 10px; }

@media (min-width: 1100px) {
  .sheet-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* フルスクリーン資料ビューア */
.sheet-viewer, .crop-editor {
  position: absolute;
  inset: 0;
  z-index: 12;
  background: #0e140f;
  color: var(--screen);
  display: flex;
  flex-direction: column;
}
.sheet-viewer .sv-bar, .crop-editor .sv-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #1c2a1e;
  flex-shrink: 0;
}
.sv-ttl { flex: 1; font-family: "DotGothic16", monospace; font-size: 12px; letter-spacing: .08em; }
.sv-idx { font-family: "DotGothic16", monospace; font-size: 11px; opacity: .8; }
.sv-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  background: #0e140f;
}
.sv-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}
.sv-cap {
  font-size: 12px;
  padding: 6px 10px;
  color: #c5d0a8;
  min-height: 2em;
  background: #152018;
}
.sv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px; height: 56px;
  border: 0;
  background: rgba(28,42,30,.7);
  color: var(--screen);
  font-size: 18px;
  cursor: pointer;
  z-index: 2;
}
.sv-nav:disabled { opacity: .25; }
.sv-prev { left: 4px; }
.sv-next { right: 4px; }

/* 切り出し */
.crop-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #0e140f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.crop-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}
.crop-boxes { position: absolute; pointer-events: auto; }
.cbox {
  position: absolute;
  border: 2px solid #3a7ab5;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.4);
  background: rgba(58,122,181,.12);
  cursor: move;
  touch-action: none;
}
.cbox-lab {
  position: absolute;
  left: 0; top: 0;
  font-family: "DotGothic16", monospace;
  font-size: 10px;
  color: #fff;
  padding: 1px 5px;
  pointer-events: none;
}
.cbox-h {
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border: 2px solid #1c2a1e;
  border-radius: 2px;
}
.cbox-h[data-h=nw] { left: -7px; top: -7px; cursor: nwse-resize; }
.cbox-h[data-h=ne] { right: -7px; top: -7px; cursor: nesw-resize; }
.cbox-h[data-h=sw] { left: -7px; bottom: -7px; cursor: nesw-resize; }
.cbox-h[data-h=se] { right: -7px; bottom: -7px; cursor: nwse-resize; }

.aligner-ref {
  position: absolute;
  right: 4%;
  top: 8%;
  width: 28%;
  opacity: .55;
  pointer-events: none;
  z-index: 3;
  border: 2px solid #1c2a1e;
  background: #c5d0a8;
}
.aligner-ref img { width: 100%; display: block; }
.aligner-ref .lab {
  font-family: "DotGothic16", monospace;
  font-size: 9px;
  background: #1c2a1e;
  color: var(--screen);
  padding: 2px 4px;
}

/* 三面図3Dウィザード */
.hull-wizard {
  position: absolute;
  inset: 0;
  z-index: 13;
  background: var(--screen);
  display: flex;
  flex-direction: column;
  color: var(--ink);
}
.hull-views { display: flex; gap: 4px; padding: 6px 8px; flex-shrink: 0; }
.hull-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #0e140f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.hull-stage canvas { touch-action: none; display: block; }
.lm-head, .lm-feet {
  position: absolute;
  height: 20px;
  border-top: 2px dashed #f0e070;
  color: #f0e070;
  font-family: "DotGothic16", monospace;
  font-size: 10px;
  cursor: ns-resize;
  z-index: 3;
  line-height: 18px;
  padding-left: 4px;
  touch-action: none;
}
.lm-feet { border-top: 0; border-bottom: 2px dashed #f0e070; }
.hull-progress {
  width: 100%;
  background: #1c2a1e;
  color: var(--screen);
  padding: 4px;
  font-family: "DotGothic16", monospace;
  font-size: 11px;
}
.hull-progress .hull-bar {
  height: 8px;
  width: 0;
  background: #3de06a;
  transition: width .15s linear;
}
.scan-top button.warn { background: #8a5a1a; }

.sv-bar .text-btn { background: #e4edd0; color: #1c2a1e; }
.sv-bar .text-btn.ghost { background: transparent; color: #e4edd0; box-shadow: inset 0 0 0 1px #e4edd0; }

/* ===== キャラメイク ===== */
.make-wrap {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--screen);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.make-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.make-stage {
  flex: 0 0 46%;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  padding: 4px 8px 0;
}
.make-stage .scan-view {
  flex: 1;
  min-height: 0;
  border: 3px solid var(--ink);
  border-radius: 4px;
  position: relative;
  background: #152018;
}
.make-cam {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
.make-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 2px solid var(--ink);
  background: #f3f6e6;
}
.make-body, .make-pose {
  flex: 1;
  overflow: auto;
  padding: 6px 8px 16px;
  -webkit-overflow-scrolling: touch;
}
.preset-row, .color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  align-items: center;
}
.swatch {
  width: 26px; height: 26px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}
.swatch.on { outline: 2px solid #c43632; outline-offset: 1px; }
.acc {
  border: 2px solid var(--ink);
  background: #eef3dc;
  margin-bottom: 6px;
}
.acc summary {
  font-family: "DotGothic16", monospace;
  font-size: 12px;
  letter-spacing: .1em;
  padding: 6px 8px;
  cursor: pointer;
  background: #1c2a1e;
  color: var(--screen);
  list-style: none;
}
.acc summary::-webkit-details-marker { display: none; }
.acc-body { padding: 6px 8px 8px; }
.sl-row { margin: 6px 0 8px; }
.sl-lab {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 2px;
}
.sl-reset {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  min-width: 24px;
  min-height: 24px;
  color: var(--ink-dim);
}
.sl-ctl { display: flex; align-items: center; gap: 8px; }
.sl-ctl input[type=range] {
  flex: 1;
  accent-color: #3d6b4a;
  min-width: 0;
}
.sl-num {
  font-family: "DotGothic16", monospace;
  font-size: 11px;
  min-width: 4.6em;
  text-align: right;
}
.sl-hint { font-size: 10px; color: var(--ink-dim); }
.mirror-tog, .ref-tog { margin-left: 6px; }

@media (min-width: 1100px) {
  .make-layout {
    flex-direction: row;
  }
  .make-stage {
    flex: 1 1 52%;
    padding: 8px;
  }
  .make-panel {
    flex: 0 0 42%;
    max-width: 520px;
    border-top: 0;
    border-left: 2px solid var(--ink);
  }
  .make-stage .scan-view { min-height: 420px; }
}


#make-host {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: block;
}
#make-host .make-wrap {
  position: absolute;
  inset: 8px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

/* ===== キャラメイク v4: 部位パッド / チップ ===== */
.part-block { margin: 8px 0 6px; }
.part-lab { font-size: 12px; margin-bottom: 4px; display: flex; gap: 8px; align-items: baseline; }
.part-chips, .part-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.chip {
  font-family: "DotGothic16", monospace;
  font-size: 11px;
  letter-spacing: .06em;
  border: 2px solid var(--ink);
  background: #eef3dc;
  color: var(--ink);
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 28px;
}
.chip.sub { background: #e4edd0; font-size: 11px; }
.chip.on { background: #1c2a1e; color: var(--screen); }
.pad-block { margin: 4px 0 10px; }
.pad-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}
.pad {
  position: relative;
  width: min(220px, 70vw);
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  background:
    linear-gradient(#e8edcf, #e8edcf),
    repeating-linear-gradient(90deg, #d5dec0 0 1px, transparent 1px 25%),
    repeating-linear-gradient(0deg, #d5dec0 0 1px, transparent 1px 25%),
    #eef3dc;
  background-blend-mode: multiply;
  border-radius: 4px;
  touch-action: none;
  margin: 0 auto;
}
.pad-axis-x, .pad-axis-y {
  position: absolute;
  background: rgba(28,42,30,.25);
  pointer-events: none;
}
.pad-axis-x { left: 0; right: 0; top: 50%; height: 1px; }
.pad-axis-y { top: 0; bottom: 0; left: 50%; width: 1px; }
.pad-handle {
  position: absolute;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--ink);
  background: #3d6b4a;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 2px #eef3dc;
}
.pad-nums {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
}
.pad-nums input[type=number] {
  width: 4.5em;
  border: 1px solid var(--ink);
  background: #fff;
  padding: 2px 4px;
}
.height-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin: 6px 0;
  font-size: 12px;
}
.height-row input[type=number] {
  width: 5em;
  border: 1px solid var(--ink);
  padding: 2px 4px;
}
.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 8px;
}
.mode-lab { font-size: 12px; margin-right: 4px; }
.vrm-note { margin: 0 0 8px; font-size: 11px; }
.my-body { margin: 6px 0 8px; padding: 6px; border: 1px dashed var(--ink); background: #f7f9ee; }
.my-head { font-family: "DotGothic16", monospace; font-size: 11px; letter-spacing: .1em; margin-bottom: 4px; }
.mine-name {
  flex: 1;
  min-width: 8em;
  border: 1px solid var(--ink);
  padding: 4px 6px;
}
.acc-sub { margin-bottom: 8px; }
.acc-sub-t { font-size: 11px; font-weight: 700; margin: 4px 0; color: #1c2a1e; }

@media (min-width: 1100px) {
  .pad { width: 200px; }
}

/* ===== 2D シルエット ===== */
.sil-root {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 1;
}
.sil-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  padding: 6px 6px 0;
}
.sil-fig {
  flex: 1;
  min-width: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}
.sil-fig .sil-svg {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: visible;
}
.sil-fig figcaption {
  flex: 0 0 auto;
  font-family: "DotGothic16", monospace;
  font-size: 11px;
  letter-spacing: .12em;
  color: #cfe8d2;
  padding: 2px 0 4px;
}
.sil-single .sil-fig { cursor: default; }
.sil-cam {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 4px 6px 6px;
}
.sil-cam .text-btn {
  background: #3d6b4a;
  color: #f4f7e8;
  box-shadow: none;
  min-height: 28px;
  padding: 3px 10px;
}
.sil-cam .text-btn.on { background: #e4edd0; color: #1c2a1e; }
.scan-view { height: 280px; min-height: 280px; }
