:root {
  color-scheme: dark;
  --bg: #18130f;
  --bg-2: #211912;
  --surface: #2a2118;
  --surface-2: #36291d;
  --line: rgba(235, 211, 163, 0.2);
  --line-strong: rgba(235, 211, 163, 0.36);
  --text: #f4ead7;
  --muted: #baa98c;
  --faint: #89785e;
  --gold: #e6b84a;
  --gold-2: #f1d68c;
  --green: #58c28a;
  --red: #e46f50;
  --shadow: rgba(0, 0, 0, 0.32);
  --radius: 8px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sticky-nav-top: 88px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(230, 184, 74, 0.07) 1px, transparent 1px) 0 0 / 64px 64px,
    linear-gradient(180deg, #21170f 0%, #15110e 46%, #21170f 100%);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

.side-rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in oklch, var(--bg-2) 90%, black 10%);
}

.brand-mark {
  display: grid;
  gap: 7px;
}

.brand-kicker,
.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-mark strong {
  font-size: 21px;
  line-height: 1.15;
}

.rail-nav {
  display: grid;
  gap: 8px;
}

.rail-link,
.mobile-tab,
.mobile-back,
.category-button,
.text-button,
.copy-button,
.section-toggle,
.reference-card,
.icon-button {
  border: 0;
  cursor: pointer;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease);
}

.rail-link:hover,
.rail-link.is-active {
  background: rgba(230, 184, 74, 0.13);
  color: var(--text);
}

.rail-link:active {
  transform: translateY(1px);
}

.icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon svg,
.icon-button svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  line-height: 1.6;
}

.workspace {
  min-width: 0;
  padding: 22px clamp(14px, 2.5vw, 34px) 34px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 430px);
  gap: 18px;
  align-items: center;
  padding: 14px 0 18px;
  background: linear-gradient(180deg, rgba(24, 19, 15, 0.98) 75%, rgba(24, 19, 15, 0));
}

.title-group {
  min-width: 0;
}

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

h1 {
  margin-top: 5px;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.05;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(42, 33, 24, 0.92);
  box-shadow: 0 14px 38px var(--shadow);
}

.search-box:focus-within {
  border-color: color-mix(in oklch, var(--gold) 80%, white 20%);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--faint);
}

.mobile-tabs {
  display: none;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 560px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.lineup-column {
  min-width: 0;
}

.category-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}

.section-nav {
  position: sticky;
  z-index: 18;
  top: var(--sticky-nav-top);
  margin: 0 0 14px;
  padding: 4px 0 8px;
  background: linear-gradient(180deg, rgba(24, 19, 15, 0.98) 78%, rgba(24, 19, 15, 0));
}

.category-strip::-webkit-scrollbar {
  display: none;
}

.category-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(42, 33, 24, 0.76);
  color: var(--muted);
  white-space: nowrap;
  transition: border-color 180ms var(--ease), background 180ms var(--ease), color 180ms var(--ease);
}

.category-button span {
  color: var(--faint);
  font-size: 12px;
}

.category-button:hover,
.category-button.is-active {
  border-color: rgba(230, 184, 74, 0.72);
  background: rgba(230, 184, 74, 0.16);
  color: var(--text);
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.result-bar strong {
  color: var(--text);
  margin-right: 8px;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--gold-2);
}

.text-button:hover {
  color: var(--text);
}

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

.lineup-card {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  min-height: 128px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(42, 33, 24, 0.68);
  color: var(--text);
  text-align: left;
  transition: transform 180ms var(--ease), border-color 180ms var(--ease), background 180ms var(--ease);
}

.lineup-card:hover,
.lineup-card.is-selected {
  border-color: rgba(230, 184, 74, 0.76);
  background: rgba(58, 45, 31, 0.92);
}

.lineup-card:active {
  transform: translateY(1px);
}

.thumb {
  position: relative;
  overflow: hidden;
  min-height: 108px;
  border-radius: 6px;
  background: #100d0a;
}

.thumb img {
  width: 100%;
  height: 100%;
  min-height: 108px;
  object-fit: cover;
  object-position: 50% 18%;
}

.thumb::after {
  position: absolute;
  inset: 0;
  content: "";
  border: 1px solid rgba(244, 234, 215, 0.14);
  border-radius: inherit;
  pointer-events: none;
}

.card-body {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.tier {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(230, 184, 74, 0.14);
  color: var(--gold-2);
  font-weight: 800;
}

.rank {
  color: var(--faint);
}

.card-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  font-weight: 850;
  line-height: 1.28;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-summary {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.detail-column {
  position: sticky;
  top: 88px;
  min-width: 0;
  max-height: calc(100vh - 108px);
  overflow: auto;
  scrollbar-color: rgba(230, 184, 74, 0.4) transparent;
}

.detail-empty {
  display: grid;
  gap: 10px;
  min-height: 320px;
  align-content: center;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(42, 33, 24, 0.36);
}

.detail-empty span {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.detail-empty strong {
  max-width: 430px;
  color: var(--text);
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.25;
}

.detail-panel {
  display: grid;
  gap: 14px;
}

.mobile-detail-bar {
  display: none;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 4px;
}

.detail-title {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.detail-title h2 {
  font-size: clamp(23px, 3vw, 38px);
  line-height: 1.08;
}

.meta-line {
  color: var(--muted);
  font-size: 13px;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--gold);
  color: #251a0b;
  font-weight: 850;
  white-space: nowrap;
}

.detail-image {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #100d0a;
}

.detail-image button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.detail-image img {
  width: 100%;
  height: auto;
}

.sections {
  display: grid;
  gap: 8px;
}

.section-block {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(42, 33, 24, 0.7);
}

.section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 850;
}

.section-toggle svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 180ms var(--ease);
}

.section-block.is-open .section-toggle svg {
  transform: rotate(180deg);
}

.section-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms var(--ease);
}

.section-block.is-open .section-content {
  grid-template-rows: 1fr;
}

.section-content-inner {
  overflow: hidden;
}

.section-content p {
  padding: 0 14px 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.guide-view,
.reference-view {
  max-width: 1060px;
}

.guide-head {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.guide-head h2 {
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.1;
}

.guide-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.guide-card {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(42, 33, 24, 0.72);
}

.guide-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 16px 18px;
  border: 0;
  background: transparent;
  color: var(--gold-2);
  cursor: pointer;
  font-weight: 850;
  text-align: left;
}

.guide-toggle span {
  font-size: 19px;
  line-height: 1.25;
}

.guide-toggle svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 180ms var(--ease);
}

.guide-card.is-open .guide-toggle svg {
  transform: rotate(180deg);
}

.guide-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms var(--ease);
}

.guide-card.is-open .guide-content {
  grid-template-rows: 1fr;
}

.guide-content-inner {
  overflow: hidden;
}

.guide-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0 18px 18px;
  list-style: none;
}

.guide-card li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.reference-list {
  display: grid;
  gap: 18px;
}

.reference-group {
  display: grid;
  gap: 12px;
}

.reference-group-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.reference-group-head h3 {
  color: var(--gold-2);
  font-size: 22px;
  line-height: 1.2;
}

.reference-group-head p,
.reference-group-head span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.reference-card {
  display: grid;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(42, 33, 24, 0.68);
  color: var(--text);
  text-align: left;
  transition: border-color 180ms var(--ease), background 180ms var(--ease), transform 180ms var(--ease);
}

.reference-card:hover {
  border-color: rgba(230, 184, 74, 0.72);
  background: rgba(58, 45, 31, 0.92);
}

.reference-card:active {
  transform: translateY(1px);
}

.reference-thumb {
  display: grid;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  place-items: center;
  border-radius: 6px;
  background: #100d0a;
}

.reference-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.empty-state,
.load-state {
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(42, 33, 24, 0.36);
}

.empty-state strong,
.load-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 20px;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(88, 194, 138, 0.45);
  border-radius: var(--radius);
  background: rgba(26, 39, 28, 0.94);
  color: #dff7e8;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.back-top {
  position: fixed;
  z-index: 120;
  right: 22px;
  bottom: 78px;
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(42, 33, 24, 0.95);
  color: var(--gold-2);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease), border-color 180ms var(--ease);
}

.back-top:hover {
  border-color: rgba(230, 184, 74, 0.72);
}

.back-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-top svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.image-viewer {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: rgba(15, 11, 8, 0.96);
}

.viewer-bar {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px 42px;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.viewer-title {
  overflow: hidden;
  color: var(--text);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(42, 33, 24, 0.72);
}

.icon-button:hover {
  border-color: rgba(230, 184, 74, 0.7);
}

.viewer-canvas {
  overflow: auto;
  padding: 18px;
}

.viewer-canvas img {
  width: min(100%, 1180px);
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #100d0a;
}

[hidden] {
  display: none !important;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-rail {
    display: none;
  }

  .workspace {
    padding-top: 12px;
    padding-bottom: 84px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 8px 0 10px;
  }

  .mobile-tabs {
    position: fixed;
    z-index: 40;
    right: 14px;
    bottom: 14px;
    left: 14px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(33, 25, 18, 0.96);
    box-shadow: 0 18px 44px var(--shadow);
  }

  .mobile-tab {
    min-height: 42px;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-weight: 850;
  }

  .mobile-tab.is-active {
    background: rgba(230, 184, 74, 0.16);
    color: var(--text);
  }

  .back-top {
    right: 18px;
    bottom: 92px;
  }
}

@media (max-width: 880px) {
  .topbar {
    gap: 8px;
    padding: 6px 0 8px;
  }

  .topbar .eyebrow {
    font-size: 11px;
  }

  .topbar h1 {
    margin-top: 2px;
    font-size: 22px;
    line-height: 1.08;
  }

  .search-box {
    height: 40px;
    padding: 0 12px;
    box-shadow: 0 8px 22px var(--shadow);
  }

  .section-nav {
    margin-bottom: 8px;
  }

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

  .detail-column {
    position: fixed;
    z-index: 70;
    inset: 0;
    max-height: none;
    padding: max(12px, env(safe-area-inset-top)) 12px calc(18px + env(safe-area-inset-bottom));
    background:
      linear-gradient(90deg, rgba(230, 184, 74, 0.05) 1px, transparent 1px) 0 0 / 52px 52px,
      linear-gradient(180deg, #21170f 0%, #15110e 100%);
    overflow: auto;
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
    transition: transform 260ms var(--ease), opacity 180ms var(--ease);
  }

  .detail-column.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .detail-empty {
    display: none;
  }

  .detail-panel {
    margin: 0;
    padding-bottom: 10px;
  }

  .mobile-detail-bar {
    position: sticky;
    z-index: 4;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -12px -12px 12px;
    padding: max(12px, env(safe-area-inset-top)) 12px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(33, 25, 18, 0.98);
  }

  .mobile-detail-bar span {
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: var(--radius);
    background: rgba(230, 184, 74, 0.14);
    color: var(--text);
    font-weight: 850;
  }

  body.has-mobile-detail {
    overflow: hidden;
  }

  body.has-mobile-detail .mobile-tabs {
    display: none;
  }

  body.has-mobile-detail .back-top {
    bottom: 18px;
  }

  .lineup-card {
    grid-template-columns: 108px minmax(0, 1fr);
    min-height: 118px;
  }

  .guide-list {
    grid-template-columns: 1fr;
  }

  .reference-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .workspace {
    padding-inline: 12px;
    padding-top: 8px;
  }

  h1 {
    font-size: 20px;
  }

  .topbar {
    gap: 7px;
    padding: 5px 0 7px;
  }

  .topbar .eyebrow {
    font-size: 10px;
  }

  .topbar h1 {
    overflow: hidden;
    max-width: 100%;
    font-size: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .search-box {
    height: 38px;
    gap: 8px;
    padding: 0 11px;
  }

  .search-box input {
    font-size: 15px;
  }

  .lineup-card {
    grid-template-columns: 96px minmax(0, 1fr);
    min-height: 108px;
    gap: 10px;
    padding: 8px;
  }

  .thumb,
  .thumb img {
    min-height: 92px;
  }

  .card-title {
    font-size: 16px;
  }

  .card-summary {
    -webkit-line-clamp: 1;
  }

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

  .reference-card {
    grid-template-columns: 1fr;
  }

  .reference-thumb {
    aspect-ratio: 4 / 3;
  }

  .detail-head {
    display: grid;
  }

  .copy-button {
    justify-content: center;
    width: 100%;
  }

  .viewer-bar {
    grid-template-columns: 38px minmax(0, 1fr) 38px 38px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }
}
