/* カタチのタイムトラベル — 宇宙・時間トンネル：チャコールの地にシアン（A）とバイオレット（B）で比較する */
:root {
  color-scheme: dark;
  --bg: #10131f;
  --surface: #171b2b;
  --surface-2: #1e2335;
  --surface-3: #283048;
  --stage-bg: #0c0f1a;
  --stage-glow: #161b2d;
  --grid-line: #1b2133;
  --text: #e6e9f3;
  --muted: #a7aec4;
  --disabled: #8a92ab;
  --line: #343b55;
  --line-strong: #6e789e;
  --on-accent: #0b0e18;
  /* シアン（A） */
  --a: #52d6e8;
  --a-front: #52d6e8;
  --a-side: #38929e;
  --a-top: #6cdceb;
  --a-edge: #0b4650;
  --a-soft: rgba(82, 214, 232, 0.14);
  /* バイオレット（B） */
  --b: #b49aff;
  --b-front: #b49aff;
  --b-side: #7a69ad;
  --b-top: #c0aaff;
  --b-edge: #33246f;
  --b-soft: rgba(180, 154, 255, 0.14);
  --warn-bg: #2a2416;
  --warn-line: #c9a24a;
  --warn-text: #f0e3c2;
  --ok: #7fd8a6;
  --link: #9cc8ff;
  --focus: #ffc857;
  --radius: 10px;
  --font-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.02em;
}
a { color: var(--link); text-underline-offset: 2px; overflow-wrap: anywhere; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { width: min(1200px, 100%); margin: 0 auto; padding: 0 16px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 8px; top: -48px; background: var(--text); color: var(--bg); padding: 8px 12px; z-index: 10; border-radius: 6px; }
.skip-link:focus { top: 8px; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0; }

/* ヘッダー */
.site-header { border-bottom: 1px solid var(--line); background: linear-gradient(var(--bg), var(--surface)); }
.site-header .wrap { padding-top: 28px; padding-bottom: 18px; }
.site-title { font-family: var(--font-serif); font-weight: 600; font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: 0.12em; margin: 0; }
.site-title::after { content: ""; display: inline-block; width: 0.5em; height: 0.5em; margin-left: 0.4em; border-radius: 50%; background: var(--b); box-shadow: -0.7em 0 0 var(--a); vertical-align: middle; transform: translateX(0.7em); }
.site-lead { margin: 6px 0 0; color: var(--muted); }

.load-status { margin: 16px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); }
.load-status.is-error { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); }

/* タブ */
.tabs { display: flex; gap: 4px; margin: 20px 0 0; border-bottom: 2px solid var(--line-strong); flex-wrap: wrap; }
.tabs [role="tab"] {
  appearance: none; border: 1px solid var(--line); border-bottom: none; background: var(--surface-2);
  padding: 10px 18px; border-radius: 8px 8px 0 0; cursor: pointer; font-weight: 600; color: var(--muted);
}
.tabs [role="tab"][aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.panel { padding: 20px 0 8px; }

/* ボタン類 */
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 8px;
  padding: 6px 12px; min-height: 40px; cursor: pointer; line-height: 1.4;
}
.btn:hover { background: var(--surface-3); }
.btn[disabled] { background: transparent; color: var(--disabled); border-style: dashed; border-color: var(--line); cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary { background: var(--a); color: var(--on-accent); border-color: var(--a); font-weight: 700; min-width: 6.5em; }
.btn-primary:hover { background: var(--a-top); }
.btn-primary[aria-pressed="true"] { background: var(--surface-2); color: var(--a); border-color: var(--a); }
.btn-small { min-height: 32px; padding: 2px 10px; font-size: 0.85rem; margin: 4px 6px 0 0; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.select { width: 100%; padding: 8px 10px; min-height: 42px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); color: var(--text); }
.select-small { width: auto; min-height: 36px; padding: 4px 8px; }

/* バッジ */
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.badge { display: inline-block; font-size: 0.75rem; line-height: 1.5; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge-jp { border-color: var(--muted); }
.badge-overseas { border-style: dotted; border-color: var(--muted); }
.badge-planned { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); font-weight: 700; }
.badge-ref { background: var(--surface-3); }
.badge-missing { border-style: dashed; color: var(--muted); }

/* モード1 */
.compare-layout { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; align-items: start; }
.pickers { display: grid; gap: 14px; }
.picker { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; background: var(--surface); min-width: 0; }
.picker-a { border-top: 5px solid var(--a); }
.picker-b { border-top: 5px dashed var(--b); }
.picker-a input[type="radio"] { accent-color: var(--a); }
.picker-b input[type="radio"] { accent-color: var(--b); }
.picker legend { font-weight: 700; padding: 0 6px; display: flex; align-items: center; gap: 6px; }
.chip { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 2px solid var(--text); }
.chip-a { background: var(--a); }
.chip-b { background: var(--b); border-style: dashed; }
.field-label { display: block; font-size: 0.85rem; color: var(--muted); margin: 8px 0 4px; }
.sku-sub { font-size: 0.82rem; color: var(--muted); margin: 4px 0 0; }
.state-options { display: grid; gap: 4px; }
.state-option { display: flex; align-items: flex-start; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.state-option input { margin-top: 0.45em; width: 18px; height: 18px; }
.state-option label { cursor: pointer; }
.state-option.is-disabled label { color: var(--disabled); cursor: not-allowed; }
.state-option.is-disabled .state-status { color: var(--disabled); }
.state-status { display: block; font-size: 0.78rem; color: var(--muted); }
.state-reason { font-size: 0.8rem; }
.reason-list { margin: 8px 0 0; padding: 8px 10px 8px 26px; background: var(--warn-bg); color: var(--warn-text); border-left: 3px solid var(--warn-line); border-radius: 4px; }

.viewer-col { min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 10px; }
.renderer-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.stage3d {
  position: relative; height: clamp(320px, 52vh, 520px); border: 1px solid var(--line); border-radius: var(--radius);
  background-color: var(--stage-bg);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 45%, var(--stage-glow) 0%, var(--stage-bg) 72%);
  background-size: 24px 24px, 24px 24px, 100% 100%; overflow: hidden; touch-action: none; cursor: grab; user-select: none;
}
.stage3d:active { cursor: grabbing; }
.baseline { position: absolute; left: 12px; right: 12px; height: 0; border-top: 1px dashed var(--muted); pointer-events: none; }
.stage-legend { position: absolute; left: 10px; top: 8px; display: flex; flex-direction: column; gap: 2px; font-size: 0.8rem; pointer-events: none; z-index: 2; }
.legend-item { background: rgba(16, 19, 31, 0.86); padding: 0 6px; border-radius: 4px; display: inline-flex; align-items: center; gap: 6px; }
.legend-item::before { content: ""; width: 10px; height: 10px; border-radius: 2px; border: 2px solid var(--text); flex: none; }
.legend-a { color: var(--a); }
.legend-a::before { background: var(--a); }
.legend-b { color: var(--b); }
.legend-b::before { background: var(--b); border-style: dashed; }
.legend-missing::before { border-style: dotted; border-color: var(--muted); }
.legend-missing { color: var(--muted); font-style: italic; }
.scale-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; font-size: 0.82rem; color: var(--muted); flex-wrap: wrap; }
.scale-bar { display: inline-block; height: 8px; border: 2px solid var(--text); border-top: none; flex: none; }

/* CSS 3D 描画 */
.css3d-root { position: absolute; inset: 0; pointer-events: none; }
.css3d-world { position: absolute; left: 0; top: 0; transform-style: preserve-3d; }
.box { position: absolute; left: 0; top: 0; transform-style: preserve-3d; }
.face { position: absolute; left: 0; top: 0; border: 1px solid var(--edge); backface-visibility: hidden; }
/* 色以外の識別：A は実線の輪郭、B は破線の輪郭、正面に A／B の文字 */
.box-a { --edge: var(--a-edge); }
.box-b { --edge: var(--b-edge); }
.box-b .face { border-style: dashed; }
.box-a .face-front, .box-a .face-back { background: var(--a-front); }
.box-a .face-right, .box-a .face-left { background: var(--a-side); }
.box-a .face-top, .box-a .face-bottom { background: var(--a-top); }
.box-b .face-front, .box-b .face-back { background: var(--b-front); }
.box-b .face-right, .box-b .face-left { background: var(--b-side); }
.box-b .face-top, .box-b .face-bottom { background: var(--b-top); }
.face-label { position: absolute; top: 3px; font: 700 13px/1 var(--font-sans); color: var(--on-accent); }
.box-a .face-label { left: 5px; }
.box-b .face-label { right: 5px; }
.box.is-overlay .face { opacity: 0.55; backface-visibility: visible; }
.canvas-root { position: absolute; inset: 0; pointer-events: none; }

.section-title { font-size: 1rem; margin: 22px 0 8px; padding-left: 10px; border-left: 4px solid var(--line-strong); }
.table-wrap { overflow-x: auto; }
.summary-table, .dims-table, .small-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; background: var(--surface); }
.summary-table th, .summary-table td, .dims-table th, .dims-table td, .small-table th, .small-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.summary-table thead th, .dims-table thead th, .small-table thead th { background: var(--surface-2); }
.col-a { color: var(--a); }
.col-b { color: var(--b); }
.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.dims-table tr.is-active th { box-shadow: inset 4px 0 0 var(--text); }
.ok { color: var(--ok); font-weight: 600; }
.ng { color: var(--muted); }
.small-table { font-size: 0.8rem; }

/* 情報パネル */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px; }
.info-col { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; background: var(--surface); }
.info-col-a { border-top: 5px solid var(--a); }
.info-col-b { border-top: 5px dashed var(--b); }
.info-slot { margin: 0 0 4px; font-size: 0.9rem; }
.info-slot-a { color: var(--a); }
.info-slot-b { color: var(--b); }
.info-title { font-family: var(--font-serif); font-size: 1.3rem; margin: 0; }
.info-sub { margin: 0; color: var(--muted); font-size: 0.88rem; }
.info-sec { margin-top: 14px; }
.info-sec h4 { margin: 0 0 6px; font-size: 0.95rem; border-bottom: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: minmax(7em, 11em) 1fr; gap: 2px 12px; margin: 6px 0; font-size: 0.88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.note { font-size: 0.82rem; color: var(--muted); margin: 6px 0; }
.note-warn { background: var(--warn-bg); border-left: 3px solid var(--warn-line); color: var(--warn-text); padding: 6px 10px 6px 24px; border-radius: 4px; }
div.note-warn { padding-left: 10px; }
div.note-warn ul { padding-left: 18px; margin: 4px 0 0; }
.sources { padding-left: 1.4em; font-size: 0.85rem; margin: 0; }
.sources li { margin-bottom: 6px; }
.src-type { font-size: 0.75rem; background: var(--surface-3); padding: 0 6px; border-radius: 4px; }
.src-fields, .src-notes { color: var(--muted); font-size: 0.8rem; }
.siblings { padding-left: 1.2em; font-size: 0.86rem; }
.missing { font-size: 0.8rem; padding-left: 1.2em; }
details > summary { cursor: pointer; font-size: 0.88rem; padding: 4px 0; }

/* モード2 */
.lead-note { margin: 0 0 12px; padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius); font-size: 0.92rem; }
.tl-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.speed-pick { display: inline-flex; align-items: center; gap: 6px; }
.scrub-wrap { display: flex; align-items: center; gap: 10px; flex: 1 1 260px; }
.scrub { flex: 1; accent-color: var(--a); min-height: 32px; }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.tl-toggles { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 6px; }
.check input { width: 18px; height: 18px; accent-color: var(--a); }
.tl-main { display: grid; grid-template-columns: 1fr minmax(240px, 320px); gap: 20px; align-items: start; margin-top: 8px; }
.tl-view { min-width: 0; }
.tl-frame { position: relative; display: flex; gap: 16px; align-items: flex-end; min-height: 7.5rem; }
.tl-year { font-family: var(--font-serif); font-size: clamp(2.6rem, 8vw, 4.4rem); line-height: 1; color: var(--a); letter-spacing: 0.04em; }
.tl-head { min-width: 0; }
.tl-date { margin: 0; font-size: 0.9rem; }
.tl-name { font-family: var(--font-serif); font-size: 1.4rem; margin: 0; line-height: 1.4; }
.tl-sub, .tl-ann { margin: 0; color: var(--muted); font-size: 0.85rem; }
.tl-stage {
  margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background-color: var(--stage-bg);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid, 20px) var(--grid, 20px);
}
.tl-stage.is-entering { animation: tl-fade 0.45s ease-out; }
@keyframes tl-fade { from { opacity: 0; } to { opacity: 1; } }
.tl-figs { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: flex-end; min-height: var(--figs-min-height, 0); }
.tl-fig { margin: 0; }
.tl-fig figcaption { font-size: 0.8rem; margin-top: 4px; }
.tl-shapes { display: flex; align-items: flex-end; border-bottom: 1px dashed var(--muted); }
.shape { border: 1px solid var(--a-edge); }
.shape-front { background: var(--a-front); }
.shape-side { background: var(--a-side); }
.tl-fig-missing { max-width: 14em; }
.missing-box { border: 2px dashed var(--muted); color: var(--muted); padding: 10px 12px; font-size: 0.85rem; text-align: center; border-radius: 6px; background: rgba(16, 19, 31, 0.86); }
.tl-details { margin-top: 12px; }
.tl-more { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 14px; background: var(--surface); }
.tl-nav { min-width: 0; }
.tl-nav .section-title:first-child { margin-top: 0; }
.tl-list { position: relative; }
.tl-list, .tl-side-list { list-style: none; padding: 0; margin: 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tl-side-list { max-height: none; }
.tl-item { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; width: 100%; text-align: left; border: none; border-bottom: 1px solid var(--line); background: none; padding: 6px 10px; cursor: pointer; min-height: 40px; }
.tl-item:hover { background: var(--surface-3); }
.tl-item[aria-current] { background: var(--a-soft); box-shadow: inset 4px 0 0 var(--a); font-weight: 700; }
.tl-item.is-planned { background: var(--warn-bg); color: var(--warn-text); }
.tl-item-date { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.8rem; }
.tl-item-name { font-size: 0.9rem; }
.tl-outside-detail { margin-top: 12px; font-size: 0.9rem; }

/* データについて */
.about { margin: 36px 0 24px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.about h2 { font-family: var(--font-serif); font-size: 1.15rem; margin: 0 0 6px; }
.about-list { padding-left: 1.2em; font-size: 0.9rem; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }

/* レスポンシブ */
@media (max-width: 900px) {
  .compare-layout, .tl-main { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .tl-list { max-height: 320px; }
}
@media (max-width: 520px) {
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 4px; }
  .tl-frame { flex-direction: column; align-items: flex-start; gap: 4px; }
  .tabs [role="tab"] { flex: 1; padding: 10px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .tl-stage.is-entering { animation: none; }
}
