:root {
  color-scheme: light;
  --page: #eef3f1;
  --surface: #ffffff;
  --surface-alt: #f7f9fb;
  --ink: #17201d;
  --muted: #68746f;
  --line: #d9e1de;
  --teal: #176b62;
  --teal-deep: #0f4f49;
  --teal-soft: #dcefeb;
  --coral: #b84b3f;
  --coral-soft: #f3dfdd;
  --gold: #c9971f;
  --gold-soft: #f6edce;
  --blue: #2f618b;
  --blue-soft: #dfeaf3;
  --violet: #63508a;
  --violet-soft: #e7e2f0;
  --shadow: 0 18px 45px rgba(23, 32, 29, 0.08);
  --radius: 8px;
  --font: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(23, 107, 98, 0.08), transparent 36%),
    linear-gradient(315deg, rgba(184, 75, 63, 0.08), transparent 34%),
    var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.topbar,
.metrics-row,
.workspace,
.list-section,
.site-foot {
  width: 100%;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(420px, 1.2fr);
  gap: 18px;
  align-items: end;
  margin-bottom: 16px;
}

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

.brand-mark {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 13px);
  grid-template-rows: repeat(3, 13px);
  gap: 4px;
  width: 56px;
  min-width: 56px;
  height: 56px;
  padding: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid var(--teal);
  border-radius: 4px;
}

.brand-mark::after {
  inset: 22px 8px 8px 22px;
  border-color: var(--coral);
}

.brand-mark span {
  display: block;
  background: var(--gold);
  border-radius: 50%;
}

.brand-mark span:nth-child(2) {
  background: var(--blue);
}

.brand-mark span:nth-child(3) {
  background: var(--violet);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.18;
  font-weight: 500;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 19px;
}

.top-controls,
.button-row,
.floor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.top-controls {
  justify-content: flex-end;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  min-width: 150px;
}

.wide-field {
  min-width: min(100%, 260px);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 11px;
  outline-color: var(--teal);
}

.field textarea {
  min-height: 124px;
  resize: vertical;
  line-height: 1.55;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.control-panel,
.palace-stage,
.detail-panel,
.list-section {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 76px;
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(280px, 380px);
  gap: 16px;
  align-items: start;
}

.control-panel,
.palace-stage,
.detail-panel,
.list-section {
  padding: 16px;
}

.panel-section + .panel-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-head,
.stage-head,
.list-head,
.word-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.section-head {
  margin-bottom: 12px;
}

.button-row {
  align-items: center;
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.danger-button,
.mark-button,
.floor-tab,
.room-button,
.word-row {
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 40px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.primary-button,
.secondary-button,
.danger-button,
.mark-button,
.floor-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  font-weight: 500;
}

.primary-button {
  background: var(--teal);
  color: #ffffff;
}

.secondary-button,
.floor-tab {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.danger-button {
  background: var(--coral-soft);
  color: #7f2e26;
  border-color: #e6bdb8;
}

.mark-button {
  background: var(--gold-soft);
  color: #6a5011;
  border-color: #e8d387;
  min-width: 96px;
}

.mark-button[aria-pressed="true"] {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.secondary-button[aria-pressed="true"] {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.mark-button:hover,
.floor-tab:hover,
.room-button:hover,
.word-row:hover {
  transform: translateY(-1px);
}

.review-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.review-strip strong {
  color: var(--ink);
  font-size: 20px;
  font-weight: 500;
}

.stage-head {
  align-items: center;
  margin-bottom: 12px;
}

.room-focus,
.route-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 13px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.floor-tabs {
  margin-bottom: 14px;
}

.floor-tab {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 13px;
}

.floor-tab[aria-pressed="true"] {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.palace-map {
  min-height: 560px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent 0 7%, rgba(47, 97, 139, 0.08) 7% 14%, transparent 14% 86%, rgba(184, 75, 63, 0.08) 86% 93%, transparent 93%),
    repeating-linear-gradient(0deg, transparent 0 62px, rgba(23, 32, 29, 0.045) 63px 64px),
    var(--surface-alt);
}

.map-legend {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

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

.room-button {
  position: relative;
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 116px;
  width: 100%;
  padding: 11px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  text-align: left;
  overflow: hidden;
}

.room-button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 4px solid var(--teal);
  opacity: 0.9;
}

.room-button[data-wing="1"]::before {
  border-color: var(--blue);
}

.room-button[data-wing="2"]::before {
  border-color: var(--gold);
}

.room-button[data-wing="3"]::before {
  border-color: var(--coral);
}

.room-button[aria-pressed="true"] {
  background: var(--teal-soft);
  border-color: var(--teal);
}

.room-number {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.room-title {
  min-height: 40px;
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.room-range,
.room-count {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.room-progress {
  width: 100%;
  height: 6px;
  margin-top: auto;
  overflow: hidden;
  border-radius: 99px;
  background: var(--line);
}

.room-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--teal);
}

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

.word-card {
  display: grid;
  gap: 14px;
}

.word-heading {
  align-items: start;
}

.word-heading h2 {
  font-size: 30px;
  overflow-wrap: anywhere;
}

.meaning {
  margin: 0;
  min-height: 56px;
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 17px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.word-facts {
  display: grid;
  gap: 9px;
  margin: 0;
}

.word-facts div {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.word-facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.word-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.memory-scene {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--violet-soft);
  border: 1px solid #d3c9e5;
  border-radius: var(--radius);
}

.memory-scene span {
  color: #4f3e72;
  font-size: 12px;
  font-weight: 500;
}

.memory-scene p {
  margin: 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 9px;
}

.list-section {
  margin-top: 16px;
}

.list-head {
  align-items: center;
  margin-bottom: 12px;
}

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

.word-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  width: 100%;
  min-height: 82px;
  padding: 10px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  text-align: left;
}

.word-row[aria-pressed="true"] {
  background: var(--blue-soft);
  border-color: var(--blue);
}

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

.word-main strong {
  display: block;
  font-size: 17px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.word-main span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.word-place {
  color: var(--teal-deep);
  font-size: 12px;
  font-weight: 500;
  text-align: right;
}

.known-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--gold);
  vertical-align: middle;
}

.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.site-foot a {
  color: var(--teal-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

@media (max-width: 1180px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .top-controls {
    justify-content: flex-start;
  }

  .detail-panel {
    position: static;
  }

  .word-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

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

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

  .palace-map {
    min-height: auto;
  }

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

@media (max-width: 560px) {
  h1 {
    font-size: 24px;
  }

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

  .brand-mark {
    grid-template-columns: repeat(3, 10px);
    grid-template-rows: repeat(3, 10px);
    gap: 3px;
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 6px;
  }

  .top-controls,
  .button-row,
  .card-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .field,
  .wide-field,
  .primary-button,
  .secondary-button,
  .danger-button,
  .mark-button {
    width: 100%;
  }

  .metrics-row,
  .room-grid,
  .word-list {
    grid-template-columns: 1fr;
  }

  .stage-head,
  .list-head,
  .word-heading,
  .section-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .word-heading h2 {
    font-size: 26px;
  }

  .word-facts div {
    grid-template-columns: 1fr;
  }
}
