:root {
  color-scheme: dark;
  --ink: #f4efe7;
  --muted: #a9a49d;
  --paper: #11110f;
  --panel: #191915;
  --panel-raised: #22221d;
  --line: #35352e;
  --accent: #e6b75c;
  --accent-dark: #241b0b;
  --danger: #ff9e92;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% 0%, rgb(230 183 92 / 10%), transparent 36rem),
    var(--paper);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

.masthead {
  display: flex;
  min-height: 5rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 5vw;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 1.4rem;
  font-weight: 700;
  transform: rotate(-3deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.entry-main small,
.preview-footer,
.status {
  color: var(--muted);
}

.account {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.primary-nav a {
  border-radius: 0.35rem;
  padding: 0.55rem 0.8rem;
  color: var(--muted);
  text-decoration: none;
}

.primary-nav a:hover,
.primary-nav a:focus-visible,
.primary-nav a[aria-current] {
  background: var(--panel-raised);
  color: var(--accent);
}

main {
  width: min(1100px, 90vw);
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 7rem) 0;
}

.welcome {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 850px;
  margin-bottom: 1.25rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 7vw, 5.7rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.lede {
  max-width: 660px;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  line-height: 1.65;
}

.primary-button,
.quiet-button,
.load-more,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: transparent;
  cursor: pointer;
}

.primary-button {
  border-color: var(--accent);
  padding: 0.85rem 1.4rem;
  background: var(--accent);
  color: #171109;
  font-weight: 800;
}

.quiet-button,
.load-more {
  padding: 0.58rem 0.85rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary-button:hover,
.primary-button:focus-visible {
  filter: brightness(1.08);
}

.quiet-button:hover,
.quiet-button:focus-visible,
.load-more:hover,
.load-more:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.error {
  margin-top: 1rem;
  color: var(--danger);
}

.explorer-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
}

.explorer-heading h1 {
  margin-bottom: 0;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 2.5rem 0 1.2rem;
}

.crumb {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.crumb::after {
  margin-left: 0.45rem;
  color: var(--line);
  content: "/";
}

.crumb:last-child {
  color: var(--ink);
}

.entries {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: rgb(25 25 21 / 82%);
}

.entry {
  display: grid;
  width: 100%;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.2rem;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.entry:last-child {
  border-bottom: 0;
}

.entry:hover,
.entry:focus-visible {
  background: var(--panel-raised);
}

.entry-icon {
  color: var(--accent);
  font-size: 1.2rem;
}

.entry-main {
  min-width: 0;
}

.entry-main strong,
.entry-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-main small {
  margin-top: 0.22rem;
  font-size: 0.78rem;
}

.entry-arrow {
  color: var(--muted);
  font-size: 0.8rem;
}

.status {
  padding: 1rem 0;
}

.empty {
  padding: 4rem 2rem;
  color: var(--muted);
  text-align: center;
}

.character-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
}

.character-card {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 1rem;
  background: var(--panel);
  text-align: left;
  cursor: pointer;
}

.character-card:hover,
.character-card:focus-visible {
  border-color: var(--accent);
  background: var(--panel-raised);
}

.character-card strong,
.character-card small {
  display: block;
}

.character-card small {
  margin-top: 0.2rem;
  color: var(--muted);
}

.character-monogram {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 1.2rem;
}

.back-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.back-button:hover,
.back-button:focus-visible {
  color: var(--accent);
}

.character-heading {
  margin: 2.5rem 0;
}

.character-heading h1 {
  margin-bottom: 1rem;
}

.character-heading .lede {
  margin-bottom: 0;
}

.model-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(15rem, 0.75fr);
  gap: 1.25rem;
  align-items: stretch;
}

.model-stage,
.model-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--panel);
}

.model-stage {
  min-height: 34rem;
}

model-viewer,
.model-fallback {
  width: 100%;
  height: min(70vh, 46rem);
  min-height: 34rem;
  background:
    radial-gradient(circle at 50% 30%, rgb(230 183 92 / 10%), transparent 45%),
    #0a0a09;
}

.model-poster,
.model-fallback {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* The poster slot must fit the viewer, not the portrait's intrinsic height.
   Otherwise the bottom-aligned load button is clipped outside the stage. */
.model-poster {
  width: 100%;
  height: 100%;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}

.model-poster img,
.model-fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.model-poster::after {
  position: absolute;
  inset: 50% 0 0;
  background: linear-gradient(transparent, rgb(0 0 0 / 78%));
  content: "";
  pointer-events: none;
}

.model-load {
  position: absolute;
  z-index: 1;
  bottom: 1.5rem;
}

.model-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 0.25rem;
  overflow: hidden;
  background: var(--line);
}

.model-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 160ms ease-out;
}

.model-fallback p {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  margin: 0;
  border-radius: 0.35rem;
  padding: 0.75rem 1rem;
  background: rgb(0 0 0 / 82%);
}

.model-panel {
  padding: 1.25rem;
}

.model-panel > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.5;
}

.model-help {
  margin: 1.25rem 0;
  font-size: 0.88rem;
}

.model-facts {
  margin: 1.5rem 0 0;
}

.model-facts div {
  display: grid;
  gap: 0.25rem;
  border-top: 1px solid var(--line);
  padding: 0.8rem 0;
}

.model-facts dt {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.model-facts dd {
  margin: 0;
}

.load-more {
  display: block;
  margin: 1.25rem auto 0;
}

.preview {
  width: min(1000px, 92vw);
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
}

.preview::backdrop {
  background: rgb(0 0 0 / 78%);
  backdrop-filter: blur(4px);
}

.preview-header,
.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.preview-header {
  border-bottom: 1px solid var(--line);
}

.preview-header h2 {
  overflow: hidden;
  max-width: 75vw;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-header .eyebrow {
  margin-bottom: 0.3rem;
}

.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.5rem;
}

.preview-body {
  display: grid;
  min-height: 20rem;
  max-height: 66vh;
  place-items: center;
  overflow: auto;
  background: #0a0a09;
}

.preview-body img,
.preview-body video {
  display: block;
  max-width: 100%;
  max-height: 66vh;
}

.preview-body audio {
  width: min(40rem, 80%);
}

.preview-body iframe {
  width: 100%;
  height: 65vh;
  border: 0;
  background: white;
}

.preview-footer {
  border-top: 1px solid var(--line);
}

.link-button {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

@media (max-width: 620px) {
  .masthead {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0 1rem;
  }

  .primary-nav {
    order: 3;
    width: 100%;
    border-top: 1px solid var(--line);
    padding: 0.4rem 0;
  }

  main {
    width: calc(100vw - 2rem);
  }

  .account #username {
    display: none;
  }

  .entry {
    grid-template-columns: 1.5rem minmax(0, 1fr) auto;
    gap: 0.7rem;
    padding: 0.9rem;
  }

  .preview-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .character-card {
    grid-template-columns: 3.5rem minmax(0, 1fr);
  }

  .character-card .entry-arrow {
    display: none;
  }

  .model-layout {
    grid-template-columns: 1fr;
  }

  .model-stage,
  model-viewer,
  .model-fallback {
    min-height: 30rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
