:root {
  --paper: #f7f2e7;
  --panel: #fffdf8;
  --ink: #201a15;
  --muted: #6f6257;
  --line: #d8cdbd;
  --jade: #24655a;
  --red: #a03d2f;
  --gold: #a66b18;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.25;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.home-link {
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--gold);
}

.evidence-tag {
  max-width: 430px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  line-height: 1.65;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 18px;
  margin-top: 18px;
}

.stage,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stage {
  min-height: 650px;
  overflow: hidden;
  background: #fffdf7;
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.stage-kicker {
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.status-badge.found {
  color: #fff;
  background: var(--jade);
}

.status-badge.missing {
  color: #fff;
  background: var(--red);
}

.image-wrap {
  display: grid;
  place-items: center;
  min-height: 530px;
  padding: 30px;
  background:
    linear-gradient(90deg, rgba(36, 101, 90, 0.05), transparent 35%),
    #fffdf7;
}

.image-wrap img {
  display: block;
  width: min(70%, 500px);
  max-height: 520px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(32, 26, 21, 0.14));
}

.empty-state {
  width: min(520px, 100%);
  padding: 48px 34px;
  text-align: center;
  color: #fff;
  background: var(--red);
  border-radius: 8px;
}

.empty-state strong {
  display: block;
  margin-bottom: 10px;
  font-size: 28px;
}

.empty-state span {
  display: block;
  color: #f8e7dc;
  font-size: 15px;
  line-height: 1.8;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  min-height: 650px;
  padding: 26px;
  background: var(--panel);
}

.word-title {
  margin: 2px 0 2px;
  font-size: 84px;
  line-height: 1;
}

.pinyin {
  margin: 12px 0 4px;
  color: var(--jade);
  font-size: 19px;
}

.rank-line {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.source-line {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.source-line a {
  color: var(--red);
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
}

.detail-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.detail-actions button,
.detail-actions a {
  min-height: 0;
  padding: 5px 9px;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  text-decoration: none;
}

.detail-actions button.primary {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.detail-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.draw-box {
  display: none;
  min-height: 180px;
  margin-bottom: 16px;
  place-items: center;
  background: #fffaf0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.draw-box.active {
  display: grid;
}

.draw-box svg {
  display: block;
  width: 220px;
  height: auto;
}

.intro-box {
  margin: 0;
  padding: 18px;
  color: #31251d;
  background: #f3ead9;
  border-left: 4px solid var(--gold);
  border-radius: 0 6px 6px 0;
  font-size: 16px;
  line-height: 1.95;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 20px;
}

.controls button {
  height: 34px;
  font-size: 13px;
  color: #fff;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 5px;
}

.controls button:hover {
  color: var(--ink);
  background: #e7b64e;
  border-color: var(--gold);
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  margin-top: auto;
  padding-top: 22px;
}

.thumb {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  color: var(--muted);
  background: #f5ede0;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 13px;
}

.thumb.found::after,
.thumb.missing::after {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 50%;
  box-shadow: 0 0 0 1px #fffdf8;
}

.thumb.found::after {
  background: #24655a;
}

.thumb.missing::after {
  background: #c03a2b;
}

.thumb-legend {
  display: flex;
  gap: 14px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
}

.legend-dot.found {
  background: #24655a;
}

.legend-dot.missing {
  background: #c03a2b;
}

.thumb.found {
  color: var(--jade);
}

.thumb.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .stage,
  .detail-panel {
    min-height: auto;
  }
}

@media (max-width: 600px) {
  .shell {
    width: min(100% - 20px, 1400px);
    padding-top: 14px;
  }

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

  .evidence-tag {
    max-width: none;
    text-align: left;
  }

  .word-title {
    font-size: 64px;
  }

  .image-wrap {
    min-height: 360px;
    padding: 18px;
  }

  .image-wrap img {
    width: 74%;
    max-height: 340px;
  }

  .thumbs {
    grid-template-columns: repeat(10, minmax(26px, 1fr));
  }
}
