:root {
  --bg: #0c0c0b;
  --bg-2: #141412;
  --ink: #f3f1ea;
  --muted: #9a968c;
  --line: rgba(243, 241, 234, 0.14);
  --line-strong: rgba(243, 241, 234, 0.28);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: Inter, "Segoe UI", sans-serif;
  --pad: clamp(16px, 3vw, 36px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--sans);
  min-height: 100vh;
}
body.is-lock { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img, video { max-width: 100%; display: block; }
svg { display: block; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.kicker, .meta, .count, .foot, .viewer__index, .card__no, .card__ratio, .card__kind, .spec {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
}
.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7dffb2;
  box-shadow: 0 0 0 4px rgba(125, 255, 178, 0.12);
}

.mast {
  padding: 28px var(--pad) 8px;
}
.mast h1 {
  margin: 10px 0 8px;
  font-size: clamp(64px, 12vw, 128px);
  line-height: 0.84;
  letter-spacing: -0.055em;
  font-weight: 600;
}
.lead { margin: 0; max-width: 38rem; color: var(--muted); font-size: 16px; }
.meta { margin: 14px 0 0; color: var(--muted); }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px var(--pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
}
.toolbar.is-stuck { border-bottom-color: var(--line); }
.toolbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.seg {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
}
.seg__btn {
  flex: none;
  white-space: nowrap;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  line-height: 1;
}
.seg__btn svg { width: 16px; height: 16px; }
.seg__btn svg rect { fill: none; stroke: currentColor; stroke-width: 1.5; }
.seg__btn[aria-pressed="true"] { background: var(--ink); color: #161614; }
.search input {
  width: min(240px, 36vw);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  outline: none;
}
.search input:focus { border-color: var(--line-strong); }
.count { margin: 0; color: var(--muted); min-width: 4.5rem; text-align: right; }

main { padding: 18px var(--pad) 48px; }
.grid { position: relative; }
.cell {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}
.cell.is-move {
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.card {
  position: relative;
  height: 100%;
  background: #171714;
  overflow: hidden;
}
.card__media, .card__media img, .card__media video {
  width: 100%;
  height: 100%;
}
.card__media img, .card__media video {
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.card__media.is-loaded img, .card__media.is-loaded video { opacity: 1; }
.card__no, .card__ref, .card__kind {
  position: absolute;
  z-index: 2;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}
.card__no { top: 10px; left: 10px; }
.card__count {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(12, 12, 11, 0.78);
  font-family: var(--mono);
  font-size: 12px;
}
.card__ref, .card__kind { top: 10px; right: 10px; }
.card__open {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 0;
  background: transparent;
}
.card__bar {
  position: absolute;
  z-index: 2;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.card:hover .card__bar, .card:focus-within .card__bar { opacity: 1; transform: none; }
.card__ratio {
  min-width: 0;
  overflow: hidden;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}
.card__copy, .iconbtn, .act, .reveal {
  border: 1px solid var(--line-strong);
  background: rgba(12, 12, 11, 0.72);
  color: var(--ink);
}
.card__copy {
  border-radius: 999px;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}
.card__copy.is-done { background: var(--ink); color: #161614; }
.empty {
  margin: 48px 0;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px var(--pad) 28px;
  color: var(--muted);
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  background: #0c0c0b;
}
.viewer[hidden] { display: none; }
.viewer__stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 28px;
}
.stage__tag {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(12, 12, 11, 0.78);
  font-family: var(--mono);
  font-size: 12px;
}
.stage__tag[hidden] { display: none; }
.shots {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 14px;
}
.shots[hidden] { display: none; }
.groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(420px, 46vh);
  margin: 0 0 16px;
  overflow: auto;
}
.groups[hidden] { display: none; }
.group {
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
}
.group[aria-current="true"] {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}
.group__no {
  margin: 0 0 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.group[aria-current="true"] .group__no { color: var(--ink); }
.group__row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}
.shot {
  flex: none;
  width: 64px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171714;
}
.shot[aria-pressed="true"] { border-color: var(--ink); }
.shot img { width: 64px; height: 80px; object-fit: cover; background: #111; }
.shot span {
  display: block;
  padding: 3px 4px 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 12px;
}
.links:empty { display: none; }
.setlink {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.refs { margin-top: 16px; }
.refs[hidden] { display: none; }
.refs__head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.refs__row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.ref {
  flex: none;
  width: 88px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #171714;
  text-align: left;
}
.ref[aria-pressed="true"] { border-color: var(--ink); }
.ref img { width: 88px; height: 88px; object-fit: cover; background: #111; }
.ref span {
  display: block;
  padding: 5px 6px 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.35;
}
.viewer__frame {
  max-width: 100%;
  max-height: 100%;
}
.viewer__frame img, .viewer__frame video {
  max-width: min(100%, calc(100vw - 460px));
  max-height: calc(100vh - 56px);
  width: auto;
  height: auto;
  box-shadow: var(--shadow);
}
.viewer__panel {
  width: min(420px, 100%);
  border-left: 1px solid var(--line);
  background: #10100e;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.viewer__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.viewer__index { color: var(--muted); }
.viewer__nav { display: flex; gap: 6px; }
.iconbtn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
}
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.viewer__body {
  padding: 18px 18px 28px;
  overflow: auto;
}
.viewer__no {
  margin: 0;
  font-family: var(--sans);
  font-size: 42px;
  letter-spacing: -0.05em;
  font-weight: 600;
}
.viewer__body h2 {
  margin: 8px 0 16px;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
}
.spec { margin: 0; }
.spec div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.spec dt { color: var(--muted); }
.spec dd { margin: 0; }
.viewer__acts { display: grid; gap: 8px; margin-top: 16px; }
.act, .reveal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: #161614;
  border-color: transparent;
}
.act--ghost, .reveal {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.act.is-done { background: #7dffb2; color: #102216; }
.reveal svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  transition: transform 0.2s ease;
}
.reveal[aria-expanded="true"] svg { transform: rotate(180deg); }
.fold__in { display: none; padding-bottom: 12px; }
.fold.is-open .fold__in { display: block; }
.fold__text, .fold__neg {
  margin: 12px 0 0;
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 14px;
}
.fold__neg { color: var(--muted); }

.age {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 8, 7, 0.96);
}
.age[hidden] { display: none; }
.age__card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  background: #121210;
}
.age__card h2 { margin: 12px 0 8px; font-size: 32px; letter-spacing: -0.04em; }
.age__card p { color: var(--muted); line-height: 1.6; }
.age__acts { display: flex; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #161614;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-on { opacity: 1; transform: translateX(-50%); }

.genbtn {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  line-height: 1;
  background: var(--ink);
  color: #161614;
}
.gen {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 8, 7, 0.82);
}
.gen[hidden] { display: none; }
.gen__card {
  width: min(760px, 100%);
  max-height: min(920px, 100%);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  background: #121210;
}
.gen__head { display: flex; justify-content: space-between; align-items: center; }
.gen__card h2 { margin: 8px 0 16px; font-size: 32px; letter-spacing: -0.04em; }
.gen label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.gen textarea, .gen select {
  width: 100%;
  background: #0c0c0b;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.gen textarea { min-height: 180px; resize: vertical; line-height: 1.55; font-size: 14px; }
.gen__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.gen__refs { margin-top: 16px; }
.gen__refs-head, .gen__ref-acts { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.gen__refs-head { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.gen__chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 8px; margin: 10px 0; }
.gen__chip { position: relative; width: 72px; }
.gen__chip img { width: 72px; height: 96px; object-fit: cover; background: #111; }
.gen__chip button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  line-height: 1;
}
.gen__ref-acts { display: grid; grid-template-columns: 1fr 1fr; }
.gen__note, .gen__status { color: var(--muted); font-size: 12px; line-height: 1.5; }
.gen__status { min-height: 1.2em; color: var(--ink); }
.gen__card .act { margin-top: 8px; }
.gen__card .act:disabled { opacity: 0.55; cursor: progress; }

@media (max-width: 860px) {
  .toolbar, .toolbar__right { flex-wrap: wrap; }
  .search input { width: 100%; }
  .count { text-align: left; }
  .viewer { flex-direction: column; }
  .viewer__stage { padding: 12px; min-height: 42vh; }
  .viewer__frame img, .viewer__frame video {
    max-width: 100%;
    max-height: 46vh;
  }
  .viewer__panel { width: 100%; border-left: 0; border-top: 1px solid var(--line); flex: 1; }
  .gen__grid, .gen__ref-acts { grid-template-columns: 1fr; }
  .card__bar { opacity: 1; transform: none; }
  .foot__keys { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cell.is-move, .card__media img, .toast { transition: none; }
}
