:root {
  color-scheme: dark;
  --bg: #16120f;
  --surface: #f3e5c8;
  --surface-soft: #fff4db;
  --surface-strong: #221813;
  --text: #251814;
  --text-light: #fff1d3;
  --muted: #735f4d;
  --line: #b38a4c;
  --accent: #a8342f;
  --accent-dark: #6f211d;
  --gold: #d3a64a;
  --stone: #342922;
  --shadow: 0 22px 52px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(179, 138, 76, 0.2), transparent 30%),
    radial-gradient(circle at 88% 8%, rgba(168, 52, 47, 0.18), transparent 34%),
    linear-gradient(135deg, #17120f, #332820 48%, #19130f);
  color: var(--text-light);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  line-height: 1.6;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 34px 34px;
  content: "";
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 34px clamp(16px, 5vw, 72px) 28px;
  background:
    linear-gradient(90deg, rgba(34, 24, 19, 0.98), rgba(47, 34, 26, 0.94)),
    var(--surface-strong);
  border-bottom: 1px solid rgba(211, 166, 74, 0.45);
  color: var(--text-light);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  flex: 0 0 auto;
  width: clamp(72px, 9vw, 108px);
  height: clamp(72px, 9vw, 108px);
  border: 1px solid rgba(211, 166, 74, 0.65);
  border-radius: 50%;
  background: #fffaf0;
  object-fit: contain;
  padding: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.45rem);
  line-height: 1.1;
}

.lead {
  max-width: 620px;
  margin-bottom: 0;
  color: #e8ddd0;
}

.header-stat {
  align-self: flex-end;
  min-width: 116px;
  padding: 16px;
  border: 1px solid rgba(211, 166, 74, 0.42);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
  text-align: center;
}

.header-stat span {
  display: block;
  font-size: 2rem;
  font-weight: 800;
}

.header-stat small {
  color: #e8ddd0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  gap: 22px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 48px) 48px;
}

.browser-panel,
.detail-panel {
  min-width: 0;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 180px) minmax(140px, 180px);
  gap: 12px;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 6px;
  color: #e7d5b4;
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(211, 166, 74, 0.55);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 12px;
}

.script-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.script-card {
  display: grid;
  gap: 10px;
  grid-template-rows: auto 1fr;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  padding: 0;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(45, 35, 28, 0.06);
}

.script-card:hover,
.script-card.is-active {
  border-color: var(--gold);
  box-shadow: var(--shadow);
}

.script-card strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1.25;
}

.script-card span {
  color: var(--muted);
}

.script-card__image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #241f1d, #8a2e2a 55%, #c49a46);
  object-fit: cover;
}

.script-card__image--empty {
  display: grid;
  place-items: center;
  color: #fff8ee;
  font-size: 1.6rem;
  font-weight: 900;
}

.script-card__body {
  display: grid;
  gap: 10px;
  padding: 16px 18px 18px;
}

.script-card__meta,
.role-count {
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.detail-panel {
  position: sticky;
  top: 16px;
  align-self: start;
}

.detail-content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  padding: 0;
  box-shadow: var(--shadow);
}

.detail-hero {
  display: block;
  width: 100%;
  max-height: 520px;
  background: linear-gradient(135deg, #241f1d, #8a2e2a 55%, #c49a46);
  object-fit: cover;
}

.image-zoom {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
  display: block;
  padding: 0;
  position: relative;
  text-align: inherit;
  width: 100%;
}

.image-zoom::after {
  position: absolute;
  right: 12px;
  bottom: 12px;
  border: 1px solid rgba(255, 244, 219, 0.7);
  border-radius: 999px;
  background: rgba(37, 24, 20, 0.82);
  color: #fff4db;
  content: "点击放大";
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 9px;
}

.image-zoom:hover::after,
.image-zoom:focus-visible::after {
  background: var(--accent-dark);
}

.image-zoom:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.detail-hero img,
.role-sheet__image img {
  display: block;
  width: 100%;
}

.detail-hero img {
  max-height: 520px;
  object-fit: cover;
}

.detail-hero--empty {
  display: grid;
  min-height: 210px;
  place-items: center;
  color: #fff8ee;
  font-size: 2rem;
  font-weight: 900;
}

.detail-heading,
.detail-stats,
.role-sheet,
.role-group {
  margin-left: 22px;
  margin-right: 22px;
}

.detail-heading {
  margin-top: 22px;
}

.detail-heading h2 {
  margin-bottom: 10px;
  color: var(--accent-dark);
  font-size: 1.9rem;
  line-height: 1.18;
}

.detail-heading p:last-child {
  color: #453327;
  font-weight: 600;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  margin-bottom: 20px;
}

.detail-stats span {
  border: 1px solid #ead7be;
  border-radius: 999px;
  background: #fff8ee;
  color: var(--accent-dark);
  padding: 5px 10px;
  font-size: 0.88rem;
  font-weight: 800;
}

.role-group {
  margin-top: 22px;
}

.role-sheet {
  margin-top: 22px;
}

.role-sheet h3 {
  margin-bottom: 10px;
  font-size: 1rem;
  color: var(--accent-dark);
}

.role-sheet__image {
  border-radius: 8px;
}

.role-sheet__image img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0e8df;
}

.role-group h3 {
  margin-bottom: 10px;
  font-size: 1rem;
  color: var(--accent-dark);
}

.role-list {
  display: grid;
  gap: 10px;
}

.role-item {
  border-top: 1px solid rgba(111, 33, 29, 0.22);
  padding-top: 12px;
}

.role-item div {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.role-item strong {
  color: #7f211c;
  font-weight: 900;
  line-height: 1.3;
}

.role-item span {
  border: 1px solid #c7ad82;
  border-radius: 999px;
  background: #eadcc0;
  color: #635747;
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
  padding: 3px 8px;
  white-space: nowrap;
}

.role-item p {
  margin: 6px 0 0;
  color: #3f3028;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.65;
}

.is-viewing-image {
  overflow: hidden;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
}

.image-viewer__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(10, 7, 6, 0.88);
  cursor: zoom-out;
}

.image-viewer__frame {
  position: relative;
  z-index: 1;
  display: grid;
  max-width: min(1180px, 96vw);
  max-height: 92vh;
}

.image-viewer__frame img {
  display: block;
  max-width: 100%;
  max-height: 92vh;
  border: 1px solid rgba(211, 166, 74, 0.7);
  border-radius: 8px;
  background: #16120f;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
  object-fit: contain;
}

.image-viewer__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  min-height: 38px;
  border: 1px solid rgba(255, 244, 219, 0.78);
  border-radius: 999px;
  background: rgba(37, 24, 20, 0.88);
  color: #fff4db;
  cursor: pointer;
  font-weight: 900;
  padding: 0 14px;
}

.image-viewer__close:hover,
.image-viewer__close:focus-visible {
  background: var(--accent-dark);
}

.empty-state {
  border: 1px dashed rgba(211, 166, 74, 0.55);
  border-radius: 8px;
  background: rgba(243, 229, 200, 0.9);
  color: var(--muted);
  padding: 18px;
}

@media (max-width: 980px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .header-stat {
    align-self: flex-start;
  }

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

  .detail-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding-top: 28px;
  }

  .brand-lockup {
    flex-direction: column;
    gap: 12px;
  }

  .brand-logo {
    width: 82px;
    height: 82px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .script-grid {
    grid-template-columns: 1fr;
  }

  .script-card {
    min-height: 0;
  }

  .detail-content {
    padding: 0;
  }

  .detail-heading,
  .detail-stats,
  .role-sheet,
  .role-group {
    margin-left: 18px;
    margin-right: 18px;
  }

  .role-item div {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}
