:root {
  --paper: #f4efe2;
  --paper-strong: #fffaf0;
  --ink: #1d2927;
  --muted: #62706a;
  --rule: #d2c7ad;
  --green: #126b5b;
  --blue: #243e73;
  --red: #9d3f32;
  --gold: #c98f2a;
  --shadow: 0 18px 50px rgba(34, 31, 24, .16);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(29, 41, 39, .06) 1px, transparent 1px),
    linear-gradient(rgba(29, 41, 39, .05) 1px, transparent 1px),
    radial-gradient(circle at 82% 18%, rgba(201, 143, 42, .22), transparent 22rem),
    radial-gradient(circle at 8% 32%, rgba(36, 62, 115, .18), transparent 24rem),
    var(--paper);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: -999px;
  padding: .7rem;
  background: var(--ink);
  color: var(--paper);
  z-index: 20;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.topbar,
main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 20px 0;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--gold);
  font-family: "Fraunces", serif;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: flex-end;
}

.topbar nav a {
  min-height: 38px;
  padding: .5rem .75rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.topbar nav a:hover {
  border-color: var(--rule);
  background: rgba(255, 250, 240, .72);
  color: var(--ink);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, .55fr);
  align-items: end;
  gap: 2rem;
  padding: 58px 0 34px;
}

.eyebrow {
  margin: 0 0 .55rem;
  color: var(--red);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: "Fraunces", Georgia, serif;
  line-height: 1.04;
}

h1 {
  max-width: 850px;
  margin: 0;
  font-size: clamp(3.1rem, 8vw, 7rem);
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

h3 {
  margin: 0 0 .7rem;
  font-size: 1.35rem;
}

.lede {
  max-width: 720px;
  margin: 1.2rem 0 0;
  color: var(--muted);
  font-size: 1.18rem;
}

.hero-stats {
  display: grid;
  gap: .8rem;
}

.hero-stats div,
.tool-panel,
.library,
.guide,
.sources {
  border: 1px solid var(--rule);
  background: rgba(255, 250, 240, .82);
  box-shadow: var(--shadow);
}

.hero-stats div {
  padding: 1rem;
  border-radius: 6px;
}

.hero-stats strong,
.hero-stats span {
  display: block;
}

.hero-stats strong {
  color: var(--green);
  font: 800 1.8rem "Fraunces", serif;
}

.hero-stats span,
.status,
.result-note,
.limit-note,
.source-note {
  color: var(--muted);
}

.tool-panel,
.library,
.guide,
.faq-section,
.sources {
  margin: 22px 0;
  padding: clamp(1rem, 3vw, 2rem);
  border-radius: 8px;
}

.section-head {
  display: grid;
  gap: .45rem;
  margin-bottom: 1.25rem;
}

.section-head p {
  margin: 0;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-bottom: 1rem;
}

.mode-tab,
.primary,
.ghost,
.load-more {
  min-height: 46px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: .65rem 1rem;
  font-weight: 800;
}

.mode-tab {
  background: transparent;
  color: var(--ink);
}

.mode-tab.is-active,
.primary {
  background: var(--ink);
  color: var(--paper-strong);
}

.ghost,
.load-more {
  background: var(--paper-strong);
  color: var(--ink);
}

.mode-panel {
  display: none;
}

.mode-panel.is-visible {
  display: block;
}

.field-grid,
.library-tools {
  display: grid;
  gap: 1rem;
}

.field-grid.two,
.library-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: .4rem;
  color: var(--muted);
  font-weight: 800;
}

select,
input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--ink);
  padding: .7rem .8rem;
}

select:focus,
input:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(18, 107, 91, .35);
  outline-offset: 3px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: .7rem;
  margin-top: 1rem;
}

.result {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--rule);
}

.empty {
  margin: 0;
  color: var(--muted);
}

.combo-list {
  display: grid;
  gap: .75rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.combo-list li {
  padding: .8rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fffdf7;
}

.combo-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: .55rem;
}

.op {
  color: var(--red);
  font-weight: 900;
}

.pal-chip {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: .55rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.pal-chip img,
.portrait img {
  display: block;
  object-fit: contain;
}

.pal-chip img {
  width: 38px;
  height: 38px;
}

.pal-chip b,
.pal-chip small {
  display: block;
}

.pal-chip small,
.combo-list small {
  color: var(--muted);
}

.pal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: .9rem;
  margin-top: 1rem;
}

.pal-card a {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: .85rem;
  width: 100%;
  min-height: 108px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  padding: .75rem;
  text-align: left;
  text-decoration: none;
}

.pal-card a:hover {
  border-color: var(--green);
  transform: translateY(-2px);
}

.portrait {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: linear-gradient(145deg, #fff9e8, #e7f0de);
}

.portrait img {
  width: 62px;
  height: 62px;
}

.portrait.large {
  width: 104px;
  height: 104px;
}

.portrait.large img {
  width: 92px;
  height: 92px;
}

.pal-card-copy {
  display: grid;
  gap: .15rem;
}

.pal-card-copy small,
.pal-card-copy span {
  color: var(--muted);
}

.pal-card-copy strong {
  font-size: 1.1rem;
}

.load-more {
  grid-column: 1 / -1;
  justify-self: center;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.guide-grid article {
  border-top: 3px solid var(--ink);
  padding-top: 1rem;
}

.guide-grid span {
  color: var(--red);
  font-weight: 900;
}

.faq-list {
  display: grid;
  gap: .75rem;
}

.faq-list details {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fffdf7;
  padding: .9rem 1rem;
}

.faq-list summary {
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.faq-list p {
  margin: .7rem 0 0;
  color: var(--muted);
}

.sources p {
  max-width: 760px;
  color: var(--muted);
}

.source-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--green);
  font-weight: 900;
}

.pal-page {
  padding-top: 1.2rem;
}

.pal-profile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(1rem, 4vw, 2rem);
  align-items: center;
  padding: clamp(1rem, 4vw, 2.4rem) 0;
}

.hero-portrait {
  width: clamp(110px, 18vw, 170px);
  height: clamp(110px, 18vw, 170px);
}

.mini-list {
  display: grid;
  gap: .65rem;
  margin: 1rem 0 0;
  padding-left: 1.35rem;
}

.mini-list li {
  padding: .55rem .65rem;
  border-bottom: 1px solid var(--rule);
  line-height: 1.55;
}

.mini-list a {
  color: var(--green);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.mini-list small {
  display: block;
  color: var(--muted);
}

.note {
  color: var(--muted);
}

.pal-dialog {
  width: min(940px, calc(100% - 28px));
  max-height: min(820px, calc(100vh - 28px));
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-strong);
  color: var(--ink);
  box-shadow: 0 22px 80px rgba(0, 0, 0, .35);
}

.pal-dialog::backdrop {
  background: rgba(29, 41, 39, .58);
}

.dialog-close {
  position: sticky;
  top: 0;
  float: right;
  width: 42px;
  height: 42px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: #fffdf7;
  font-size: 1.5rem;
  z-index: 2;
}

.detail-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.detail-head h2 {
  margin: 0;
}

.detail-head p {
  margin: .35rem 0 0;
  color: var(--muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin: 1rem 0;
}

@media (max-width: 760px) {
  .topbar,
  .hero,
  .field-grid.two,
  .library-tools,
  .guide-grid,
  footer {
    grid-template-columns: 1fr;
  }

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

  .hero {
    padding-top: 26px;
  }

  .actions,
  .mode-tabs {
    justify-content: stretch;
  }

  .actions {
    flex-direction: column;
  }

  .combo-line {
    grid-template-columns: 1fr;
  }

  .op {
    text-align: center;
  }
}
