:root {
  --paper: #f4efe5;
  --paper-deep: #e7ddcc;
  --ink: #191816;
  --muted: #6f695f;
  --line: rgba(25, 24, 22, 0.18);
  --blue: #064cff;
  --blue-dark: #0736a6;
  --white: #fffaf0;
  --shadow: 0 20px 70px rgba(25, 24, 22, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(6, 76, 255, 0.08), transparent 30rem),
    linear-gradient(135deg, rgba(25, 24, 22, 0.05) 0 1px, transparent 1px),
    var(--paper);
  background-size: auto, 22px 22px, auto;
  font-family: "Noto Sans TC", "Inter", system-ui, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.hero {
  position: relative;
  min-height: 92vh;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}

.hero::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(90deg, rgba(244, 239, 229, 0.98), rgba(244, 239, 229, 0.91) 49%, rgba(244, 239, 229, 0.18)),
    linear-gradient(0deg, rgba(244, 239, 229, 1), transparent 32%);
}

.hero__image {
  position: absolute;
  inset: 0;
  z-index: -2;
}

.hero__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: grayscale(0.85) contrast(1.02);
  opacity: 0.95;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0;
}

.brand,
.topbar__link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Inter", sans-serif;
  font-weight: 800;
}

.brand__mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--white);
  background: var(--ink);
  border: 2px solid var(--ink);
}

.topbar__link {
  padding: 10px 14px;
  border: 1px solid var(--ink);
  background: rgba(255, 250, 240, 0.7);
}

.hero__content {
  width: min(760px, calc(100% - 40px));
  margin: 13vh auto 0;
  transform: translateX(-24%);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--blue);
  font-family: "Inter", sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  margin-bottom: 24px;
  font-size: clamp(2.65rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.hero__lead {
  max-width: 660px;
  color: #2d2a25;
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.85;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.button--primary {
  color: var(--white);
  background: var(--blue);
  border-color: var(--blue);
}

.button--ghost,
.button--small {
  background: rgba(255, 250, 240, 0.78);
}

.button--small {
  min-height: 44px;
}

.section {
  padding: 84px 0;
}

.section__inner {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.intro {
  background: var(--ink);
  color: var(--white);
}

.intro .eyebrow {
  color: #9bb4ff;
}

.intro__grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.15fr);
  gap: 48px;
  align-items: center;
  margin-bottom: 34px;
}

.intro h2,
.section__header h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.intro p:last-child,
.section__header p {
  color: rgba(255, 250, 240, 0.78);
  font-size: 1.05rem;
  line-height: 1.85;
}

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

.analogy-ladder article,
.role-map p {
  border: 1px solid rgba(255, 250, 240, 0.18);
  background: rgba(255, 250, 240, 0.06);
}

.analogy-ladder article {
  min-height: 190px;
  padding: 22px;
}

.analogy-ladder span {
  display: block;
  margin-bottom: 24px;
  color: #9bb4ff;
  font-family: "Inter", sans-serif;
  font-weight: 900;
}

.analogy-ladder h3 {
  margin-bottom: 12px;
  color: var(--white);
  font-size: 1.35rem;
}

.analogy-ladder p {
  margin-bottom: 0;
  color: rgba(255, 250, 240, 0.72);
  line-height: 1.75;
}

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

.role-map p {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: start;
  margin: 0;
  padding: 16px;
  line-height: 1.65;
}

.role-map strong {
  color: #9bb4ff;
  font-family: "Inter", sans-serif;
  font-size: 0.95rem;
}

.role-map span {
  color: rgba(255, 250, 240, 0.78);
}

.section__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.section__header p {
  max-width: 390px;
  color: var(--muted);
}

.category-map {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.category-card {
  min-height: 190px;
  padding: 22px;
  text-align: left;
  background: rgba(255, 250, 240, 0.72);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.category-card:hover {
  transform: translateY(-4px);
  border-color: var(--blue);
  box-shadow: var(--shadow);
}

.category-card__icon,
.category-card__title,
.category-card__description,
.category-card__count {
  display: block;
}

.category-card__icon {
  margin-bottom: 28px;
  color: var(--blue);
  font-family: "Inter", sans-serif;
  font-size: 1rem;
  font-weight: 800;
}

.category-card__title {
  margin-bottom: 10px;
  font-size: 1.25rem;
  font-weight: 900;
}

.category-card__description {
  min-height: 58px;
  color: var(--muted);
  line-height: 1.55;
}

.category-card__count {
  margin-top: 18px;
  color: var(--blue);
  font-weight: 800;
}

.glossary-section {
  background: rgba(255, 250, 240, 0.42);
  border-top: 1px solid var(--line);
}

.result-count {
  font-family: "Inter", sans-serif;
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 16px;
}

.search {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 56px;
  border: 2px solid var(--ink);
  background: var(--white);
}

.search span {
  padding: 0 16px;
  font-weight: 900;
}

.search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 16px;
  border: 0;
  outline: 0;
  background: transparent;
}

.search:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(6, 76, 255, 0.12);
}

.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 22px;
}

.filter-tab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 250, 240, 0.76);
  cursor: pointer;
  font-weight: 800;
}

.filter-tab[aria-pressed="true"] {
  color: var(--white);
  background: var(--ink);
  border-color: var(--ink);
}

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

.term-card {
  display: flex;
  min-height: 310px;
  flex-direction: column;
  padding: 20px;
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.term-card:hover {
  transform: translateY(-3px);
  border-color: var(--blue);
  box-shadow: 0 18px 46px rgba(25, 24, 22, 0.12);
}

.term-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.term-card__category,
.term-card__number {
  color: var(--blue);
  font-family: "Inter", sans-serif;
  font-size: 0.76rem;
  font-weight: 800;
}

.term-card h3 {
  margin-bottom: 4px;
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1.45rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.term-card__zh {
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 800;
}

.term-card__summary,
.term-card__analogy {
  line-height: 1.65;
}

.term-card__summary {
  margin-bottom: 12px;
}

.term-card__analogy {
  margin-bottom: 18px;
  color: var(--blue-dark);
  font-weight: 700;
}

.term-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.term-card__tags span,
.tag-list button {
  padding: 5px 8px;
  border: 1px solid rgba(6, 76, 255, 0.24);
  color: var(--blue-dark);
  background: rgba(6, 76, 255, 0.07);
  font-size: 0.78rem;
  font-weight: 800;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255, 250, 240, 0.8);
  text-align: center;
}

.term-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: min(760px, calc(100% - 28px));
  padding: 34px;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.term-dialog::backdrop {
  background: rgba(25, 24, 22, 0.58);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}

.dialog-category {
  margin-bottom: 10px;
  color: var(--blue);
  font-family: "Inter", sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
}

.term-dialog h2 {
  margin-bottom: 6px;
  padding-right: 34px;
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.dialog-zh {
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 900;
}

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

.dialog-section h3 {
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 0.9rem;
}

.dialog-section p {
  margin-bottom: 0;
  line-height: 1.75;
}

.dialog-section--analogy {
  padding: 18px;
  background: rgba(6, 76, 255, 0.07);
  border: 1px solid rgba(6, 76, 255, 0.16);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list button {
  cursor: pointer;
}

.footer {
  padding: 28px 20px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer p {
  margin: 0;
}

@media (max-width: 980px) {
  .hero__content {
    transform: none;
  }

  .intro__grid,
  .analogy-ladder,
  .category-map,
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .role-map {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .topbar {
    width: min(100% - 28px, 1180px);
  }

  .brand span:last-child {
    display: none;
  }

  .hero {
    min-height: 780px;
  }

  .hero::after {
    background:
      linear-gradient(180deg, rgba(244, 239, 229, 0.94), rgba(244, 239, 229, 0.88) 58%, rgba(244, 239, 229, 0.98)),
      linear-gradient(0deg, rgba(244, 239, 229, 1), transparent 34%);
  }

  .hero__content,
  .section__inner {
    width: min(100% - 28px, 1180px);
    max-width: calc(100vw - 28px);
  }

  h1 {
    max-width: 340px;
    font-size: 2.6rem;
    line-height: 1.04;
  }

  .intro h2,
  .section__header h2 {
    font-size: 2rem;
    line-height: 1.14;
  }

  .hero__lead,
  .intro p,
  .analogy-ladder p,
  .role-map p {
    max-width: 340px;
    overflow-wrap: anywhere;
  }

  .intro h2,
  .section__header h2 {
    max-width: 340px;
  }

  .hero__lead {
    font-size: 1.04rem;
  }

  .section {
    padding: 58px 0;
  }

  .intro__grid,
  .analogy-ladder,
  .category-map,
  .cards,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .category-card,
  .term-card {
    min-height: auto;
  }

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

  .search input {
    min-height: 40px;
  }

  .term-dialog {
    padding: 26px 18px;
  }

  .role-map p {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
