/* Layout: 登録台帳（レジストリ）。左上に台帳名、上部に検索・絞り込み、下に作品カードのグリッド。
   詳細は全画面パネルで、左に台帳情報、右に「実物を動かすステージ」。 */
:root {
  --bg: #eef0ec;
  --surface: #ffffff;
  --ink: #1a1f1c;
  --muted: #5d6862;
  --line: #d5dbd5;
  --accent: #2440d0;
  --accent-ink: #ffffff;
  --accent-soft: #e3e8ff;
  --internal: #b4471c;
  --internal-soft: #fbe9df;
  --stage: #dfe3de;
  --ok: #1f7a4d;
  --shadow: 0 1px 2px rgb(20 30 25 / 0.06), 0 8px 24px rgb(20 30 25 / 0.06);

  --f-display: "Dela Gothic One", "Hiragino Kaku Gothic StdN", sans-serif;
  --f-body: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513; --surface: #191e1b; --ink: #e7ebe6; --muted: #98a39d; --line: #2b3330;
    --accent: #8b9cff; --accent-ink: #0d1230; --accent-soft: #232a4f;
    --internal: #f08c5c; --internal-soft: #3a2419; --stage: #0c0f0d; --ok: #59c48e;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111513; --surface: #191e1b; --ink: #e7ebe6; --muted: #98a39d; --line: #2b3330;
  --accent: #8b9cff; --accent-ink: #0d1230; --accent-soft: #232a4f;
  --internal: #f08c5c; --internal-soft: #3a2419; --stage: #0c0f0d; --ok: #59c48e;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

/* ---------- Header ---------- */
.masthead { border-bottom: 1px solid var(--line); background: var(--surface); }
.masthead .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-block: 18px; }
.brand { display: flex; align-items: baseline; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-mark { font-family: var(--f-display); font-size: 26px; letter-spacing: 0.02em; line-height: 1; }
.brand-sub { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.mode {
  margin-left: auto; font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  padding: 4px 10px; border-radius: 999px; border: 1px solid currentColor;
}
.mode.public { color: var(--accent); }
.mode.internal { color: var(--internal); background: var(--internal-soft); }

.intro .wrap { padding-block: 36px 8px; display: grid; gap: 6px; }
.intro h1 { margin: 0; font-size: clamp(22px, 3.2vw, 32px); font-weight: 700; text-wrap: balance; line-height: 1.35; }
.intro p { margin: 0; color: var(--muted); max-width: 62ch; }

/* ---------- Toolbar ---------- */
.toolbar .wrap { display: grid; gap: 12px; padding-block: 20px; }
.search {
  width: 100%; padding: 12px 14px 12px 40px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23889' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px center;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 13px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.filters .sep { width: 1px; height: 22px; background: var(--line); margin-inline: 4px; }
.select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 13px;
}
.count { margin-left: auto; font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Grid ---------- */
.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  padding-block: 4px 64px;
}
.card {
  display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
  min-width: 0;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--muted); }
.cover {
  position: relative; aspect-ratio: 16 / 10; max-width: 100%;
  display: grid; place-items: end start; padding: 14px;
  color: #fff; overflow: hidden;
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .cover-id {
  position: relative; font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.08em;
  background: rgb(0 0 0 / 0.35); padding: 2px 8px; border-radius: 4px;
}
.cover .cover-type {
  position: absolute; top: 14px; left: 14px; font-family: var(--f-display); font-size: 22px;
  line-height: 1.1; opacity: 0.95; max-width: 80%;
}
.cover .runnable {
  position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 700;
  background: #fff; color: #111; padding: 3px 8px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
.cover .runnable::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #1f9d5c; }
.card-body { padding: 14px 16px 16px; display: grid; gap: 6px; }
.card-title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.45; }
.meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.meta .status-end { color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { font-size: 11.5px; padding: 1px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--ink); }
.badge-sample { font-size: 11px; font-weight: 700; color: var(--internal); border: 1px dashed currentColor; border-radius: 4px; padding: 0 6px; }
.badge-private { font-size: 11px; font-weight: 700; color: var(--internal-soft); background: var(--internal); border-radius: 4px; padding: 0 6px; }

.empty { padding: 60px 0; text-align: center; color: var(--muted); grid-column: 1 / -1; }

/* ---------- Detail ---------- */
.detail {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: grid; grid-template-rows: auto 1fr; overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
}
.detail:focus { outline: none; }
.detail-bar {
  display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--surface);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
.back { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 5px 14px; cursor: pointer; font-size: 13px; }
.detail-bar .id { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.detail-bar .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.detail-main { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; min-height: 0; }
.info {
  overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface);
  padding: 24px max(20px, env(safe-area-inset-left, 0px)) 40px 22px; display: grid; gap: 22px; align-content: start;
}
.info h2 { margin: 0; font-size: 22px; line-height: 1.4; text-wrap: balance; }
.info .summary { margin: 0; }
.ledger { display: grid; grid-template-columns: 6.5em 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.ledger dt { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; padding-top: 2px; }
.ledger dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; margin: 0 0 8px; }
.internal-box { border: 1px solid var(--internal); background: var(--internal-soft); border-radius: var(--r); padding: 14px 16px; }
.internal-box .section-label { color: var(--internal); }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; cursor: pointer;
  border: 1px solid var(--accent); color: var(--accent); background: transparent;
  border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 500;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }

.stage-wrap { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; min-width: 0; background: var(--stage); }
.stage-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.stage-tools .w { font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stage-tools .spacer { flex: 1; }
.stage { position: relative; overflow: hidden; min-height: 0; display: grid; place-items: start center; padding: 8px 16px 16px; }
.frame-slot { position: relative; max-width: 100%; }
.frame-box {
  position: absolute; top: 0; left: 0; transform-origin: 0 0; background: #fff;
  border-radius: 12px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12), 0 20px 50px rgb(0 0 0 / 0.18); overflow: hidden;
}
.frame-box.phone { border-radius: 28px; box-shadow: 0 0 0 10px #16191a, 0 20px 50px rgb(0 0 0 / 0.25); }
.frame-box iframe { display: block; border: 0; width: 100%; height: 100%; background: #fff; }
.stage-note { font-size: 12px; color: var(--muted); padding: 6px 16px 12px; }
.no-embed { align-self: center; max-width: 440px; text-align: center; display: grid; gap: 12px; justify-items: center; color: var(--muted); padding: 24px; }
.shots { display: flex; gap: 12px; overflow-x: auto; padding: 8px 0; max-width: 100%; }
.shots img { height: 360px; width: auto; border-radius: 12px; box-shadow: var(--shadow); }

footer.site { border-top: 1px solid var(--line); }
footer.site .wrap { padding-block: 20px 28px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px 20px; }

@media (max-width: 820px) {
  .detail-main { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow-y: auto; }
  .info { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; padding-right: max(20px, env(safe-area-inset-right, 0px)); }
  .stage-wrap { min-height: 80vh; }
  .count { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.gallery a { display: block; border-radius: 6px; overflow: hidden; aspect-ratio: 3 / 2; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .15s; }
.gallery a:hover img { opacity: .85; }
