/* UMA DESIGN REVIEW — 外枠は DESIGN_RULE（3値・角丸0・3px罫・絵文字なし）に従う。
   赤ペン（#e5484d）だけは「描き込み」の意味色として足している。 */
:root {
  --bg: #0f1220;
  --card: #171a2b;
  --border: #2a2f45;
  --text: #e6e8f0;
  --muted: #9aa0b8;
  --accent: #58a6ff;
  --pen: #e5484d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* .empty / figure の display 指定より hidden を優先 */
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.5; display: flex; flex-direction: column; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
button, .btn {
  font: inherit; font-weight: 700; color: var(--text); background: var(--card);
  border: 3px solid var(--border); padding: 8px 12px; cursor: pointer; text-decoration: none;
  border-radius: 0; touch-action: manipulation;
}
button:disabled { opacity: .4; cursor: default; }
button.ok { background: var(--accent); color: #0b1020; border-color: var(--accent); }
button.ng { background: var(--pen); color: #fff; border-color: var(--pen); }
button.sub { color: var(--muted); }
button.on, button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.tags button.last[aria-pressed="false"] { border-style: dashed; border-color: var(--accent); } /* 前回見たジャンル（自動では開かない） */
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 3px solid var(--border); flex-wrap: wrap; }
.bar .title { font-size: .95rem; letter-spacing: .04em; }
.bar button, .bar .btn { padding: 4px 10px; }
.bar .stat { color: var(--muted); font-size: .85rem; }
.bar .stat b { color: var(--text); }
.grow { flex: 1; }
.notice { margin: 0; padding: 6px 12px; font-size: .8rem; color: var(--muted); border-bottom: 3px solid var(--border); }
.tags { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; }
.tags button { padding: 4px 10px; font-size: .85rem; white-space: nowrap; }

main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 12px; min-height: 0; }
.deck { position: relative; width: 100%; max-width: 760px; flex: 1; display: flex; justify-content: center; min-height: 320px; }
.card {
  position: relative; width: 100%; max-width: 760px; background: var(--card); border: 3px solid var(--border);
  touch-action: none; user-select: none; display: flex; flex-direction: column; cursor: grab;
}
.card.fly { transition: transform .25s ease-out, opacity .25s; }
.card.back { transition: transform .2s ease-out; }
.pair { display: flex; gap: 8px; padding: 8px; flex: 1; min-height: 0; justify-content: center; align-items: center; }
.pair figure { margin: 0; flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pair img { width: 100%; height: auto; max-height: 50dvh; object-fit: contain; pointer-events: none; /* 下に日本語1行と id が入るぶん低め */ }
.pair figcaption { font-size: .75rem; color: var(--muted); text-align: center; }
.stamp {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%); font-size: 2.2rem; font-weight: 900;
  padding: 2px 18px; border: 5px solid currentColor; white-space: nowrap; opacity: 0; pointer-events: none; background: rgba(15,18,32,.6);
}
.stamp.ok { color: var(--accent); }
.stamp.ng { color: var(--pen); }
.stamp.hold { color: var(--text); }
/* 何を作ったか（日本語1行） */
.what { padding: 6px 10px 2px; font-size: .95rem; font-weight: 700; overflow-wrap: anywhere; }
.what[hidden] { display: none; }
.hist .v .what { padding: 2px 0 0; font-size: .78rem; font-weight: 400; color: var(--text); }
.ed-side .what { padding: 0 0 6px; }
.meta { padding: 0 10px 8px; font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.hint { font-size: .75rem; color: var(--muted); margin: 6px 0 0; text-align: center; }

.actions {
  display: grid; grid-template-columns: minmax(0, .8fr) repeat(4, minmax(0, 1fr)) minmax(0, .8fr); gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 3px solid var(--border); position: sticky; bottom: 0; background: var(--bg);
}
.actions button { padding: 12px 2px; min-width: 0; white-space: nowrap; overflow: hidden; font-size: .85rem; }

/* シート（書き込み・履歴） */
.sheet { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; }
.sheet[hidden] { display: none; }
#editor { z-index: 25; } /* 履歴から開いたときに履歴の上に出す */
.sheet-bar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 3px solid var(--border); flex-wrap: wrap; }
.tools { display: inline-flex; gap: 4px; align-items: center; }
.tools button { padding: 4px 8px; min-width: 36px; }
.ed-body { flex: 1; display: flex; min-height: 0; }
@media (max-width: 799px) { .ed-body { flex-direction: column; } .ed-side { max-height: 45dvh; border-left: 0 !important; border-top: 3px solid var(--border); } }
.ed-view { flex: 1; overflow: auto; min-height: 0; background: #000; }
.ed-canvas { position: relative; margin: 0 auto; width: 100%; }
.ed-canvas img { display: block; width: 100%; height: auto; user-select: none; pointer-events: none; }
#edSvg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#edSvg.move { pointer-events: none; }
#edSvg * { vector-effect: non-scaling-stroke; fill: none; stroke: var(--pen); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
#edSvg .sel { stroke: var(--accent); }
#edSvg .draft { stroke-dasharray: 6 4; }
.badges { position: absolute; inset: 0; pointer-events: none; }
.badges span {
  position: absolute; transform: translate(-50%, -110%); background: var(--pen); color: #fff; font-size: .75rem;
  font-weight: 900; padding: 0 5px; pointer-events: auto; cursor: pointer;
}
.badges span.sel { background: var(--accent); color: #0b1020; }
.ed-side { width: 360px; max-width: 100%; overflow: auto; padding: 10px 12px; border-left: 3px solid var(--border); }
.ed-side h2 { font-size: .95rem; margin: 0 0 6px; }
.ed-side h2 small { color: var(--muted); font-weight: 400; }
.regions { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.regions li { border: 3px solid var(--border); padding: 6px 8px; }
.regions li.sel { border-color: var(--accent); }
.regions .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.regions .no { font-weight: 900; color: var(--pen); }
.regions select, textarea {
  font: inherit; color: var(--text); background: #10131f; border: 3px solid var(--border); border-radius: 0; padding: 4px 6px;
}
textarea { width: 100%; resize: vertical; }
.regions textarea { margin-top: 6px; }
.refs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.refs img { width: 64px; height: 64px; object-fit: cover; border: 3px solid var(--border); }
.refs label { font-size: .8rem; color: var(--accent); cursor: pointer; border: 3px dashed var(--border); padding: 4px 8px; align-self: center; }
.refs input { display: none; }
.label, .block { display: block; font-size: .85rem; color: var(--muted); margin: 8px 0 4px; }
.verdicts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.verdicts button.current { outline: 3px solid var(--text); outline-offset: -6px; }

#history .tags { flex: none; }
.hist { list-style: none; margin: 0; padding: 8px 12px; overflow: auto; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.hist li { border: 3px solid var(--border); background: var(--card); cursor: pointer; }
.hist img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #000; display: block; }
.hist .v { padding: 4px 6px; font-size: .8rem; }
.hist .v b.ok { color: var(--accent); }
.hist .v b.ng { color: var(--pen); }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 30; background: var(--card);
  border: 3px solid var(--accent); padding: 8px 14px; font-size: .9rem; display: flex; gap: 10px; align-items: center;
}
.toast[hidden] { display: none; }
.toast button { padding: 2px 10px; white-space: nowrap; }
.toast span { white-space: nowrap; }

/* 運用画面 */
.ops { max-width: 760px; margin: 0 auto; padding: 12px; width: 100%; }
.ops section { border: 3px solid var(--border); background: var(--card); padding: 10px 12px; margin-bottom: 12px; }
.ops h2 { font-size: 1rem; margin: 0 0 8px; }
.ops table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ops td, .ops th { border-bottom: 3px solid var(--border); padding: 4px 6px; text-align: left; }
.ops .online { color: var(--accent); font-weight: 700; }
.ops .offline, .ops .stopped { color: var(--pen); font-weight: 700; }
.ops .warn { border-color: var(--pen); }
.ops pre { background: #10131f; border: 3px solid var(--border); padding: 8px; overflow: auto; max-height: 240px; font-size: .75rem; }
.ops .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.ops select, .ops input { font: inherit; color: var(--text); background: #10131f; border: 3px solid var(--border); padding: 4px 6px; }
/* 一覧（グリッド）: タップで選ぶ → 選んだものをいいね */
.grid-view { align-items: stretch; overflow: auto; padding-bottom: 12px; }
.grid-view .hint { margin: 0 0 6px; text-align: left; }
.g-loading { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 0; color: var(--muted); font-size: .95rem; }
.g-loading progress { width: 70%; max-width: 280px; }
.g-note { margin: 4px 0; font-size: .8rem; color: var(--muted); }
.g-head { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; font-size: .85rem; font-weight: 700; }
.g-head span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.g-head button { padding: 2px 8px; font-size: .75rem; }
.g-list { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.g-tile { position: relative; border: 3px solid var(--border); background: var(--card); cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.g-tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; pointer-events: none; }
.g-tile .t { display: block; padding: 2px 4px; font-size: .68rem; line-height: 1.3; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.g-tile.sel { border-color: var(--accent); outline: 3px solid var(--accent); outline-offset: -6px; }
.g-tile.sel::after { content: 'いいね'; position: absolute; top: 4px; right: 4px; background: var(--accent); color: #0b1020; font-size: .7rem; font-weight: 900; padding: 0 6px; }
.grid-actions { grid-template-columns: minmax(0, .7fr) minmax(0, .9fr) minmax(0, 1.1fr) minmax(0, 1.5fr); }
.grid-actions button { font-size: .8rem; }
.login { display: flex; gap: 6px; margin-top: 8px; }
.login input { flex: 1; min-width: 0; font: inherit; padding: 6px 8px; background: var(--card); color: var(--text); border: 3px solid var(--border); border-radius: 0; }
.login-msg { margin: 6px 0 0; color: var(--pen); font-size: .85rem; }
/* 2026-11-05 一覧だけで評価する: 右下の「拡大」ボタン、評価済みの枠の色と印、目立たない表示切り替え */
.g-zoom { position: absolute; right: 4px; bottom: 30px; padding: 1px 4px; font-size: .58rem; font-weight: 900; line-height: 1.2;
  background: rgba(15, 18, 32, .88); color: #fff; border: 1px solid #fff; z-index: 2; }
.g-tile.done { border-color: var(--muted); }
.g-tile.done img { opacity: .75; }
.g-tile.done::before { content: attr(data-verdict); position: absolute; top: 4px; left: 4px; z-index: 2; font-size: .7rem; font-weight: 900; padding: 0 6px; background: var(--muted); color: #0b1020; }
.g-tile.v-ok { border-color: var(--accent); }
.g-tile.v-ok::before { background: var(--accent); }
.g-tile.v-partial { border-color: #f5c84c; }
.g-tile.v-partial::before { background: #f5c84c; }
.g-tile.v-ng { border-color: var(--pen); }
.g-tile.v-ng::before { background: var(--pen); color: #fff; }
.g-tile.v-hold::before { background: var(--muted); }
.view-switch { text-align: center; margin: 18px 0 4px; }
button.link { background: none; border: 0; padding: 4px; font-size: .75rem; font-weight: 400; color: var(--muted); text-decoration: underline; }
.ed-nav { display: inline-flex; gap: 6px; align-items: center; }
.ed-nav span { font-size: .85rem; color: var(--muted); min-width: 3.5em; text-align: center; }
.ed-hint { margin: 0 0 8px; font-size: .78rem; color: var(--muted); text-align: left; }
@media (max-width: 799px) { .ed-side { max-height: 52dvh; } }
