body:has(.poly-page) { --page-width: 100%; }

.poly-page {
  --poly-tint: #f2f7ed;
  --poly-edge: #cedfc6;
  --poly-warm: #fff2d9;
  --poly-warm-ink: #765017;
  --poly-pad: clamp(15px, 2vw, 28px);
  margin-top: 18px;
}
.poly-page [hidden] { display: none !important; }
.poly-page .eyebrow { margin: 0 0 4px; }
.poly-page .button.ghost { background: var(--white); color: var(--green); box-shadow: none; }
.poly-page .button.ghost:hover { background: var(--soft); }
.poly-page .button.small { min-height: 44px; padding: 7px 16px; font-size: 16px; }
.poly-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px 32px;
  padding: clamp(20px, 3vw, 42px);
  border: 1px solid var(--poly-edge);
  border-radius: 26px;
  background: radial-gradient(ellipse at top right, #dbeecd 0%, transparent 65%), var(--poly-tint);
}
.poly-hero h1 { margin: 0 0 4px; }
.poly-lead { margin: 0 0 16px; max-width: 40em; color: var(--muted); }
.poly-jump, .poly-actions, .poly-detail-links, .poly-review {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.poly-demo {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--poly-edge);
  border-radius: 20px;
  background: var(--white);
  box-shadow: 0 5px 0 #22634c12;
}
.poly-demo-char {
  display: grid;
  place-items: center;
  width: clamp(62px, 9vw, 114px);
  aspect-ratio: 1;
  border-radius: 15px;
  background: var(--soft);
  color: var(--green);
  font-size: clamp(40px, 5vw, 72px);
  font-weight: 850;
  line-height: 1;
}
.poly-demo-words { display: grid; gap: 6px; }
.poly-demo-words button {
  display: grid;
  grid-template-columns: auto minmax(2.4em, auto) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 3px 8px;
  border: 0;
  border-radius: 9px;
  background: var(--poly-warm);
  color: var(--poly-warm-ink);
  font-size: 16px;
}
.poly-demo-words button:nth-child(2) { background: var(--soft); color: var(--green); }
.poly-demo-words button:hover { box-shadow: inset 0 0 0 1px currentColor; }

.poly-starters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 16px 0;
  padding: 12px var(--poly-pad);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
}
.poly-starters h2 { margin: 0; color: var(--muted); font-size: 17px; }
.poly-starter-list { display: flex; flex-wrap: wrap; gap: 7px; }
.poly-starter-list a {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--poly-edge);
  border-radius: 12px;
  background: var(--poly-tint);
  color: var(--green);
  font-size: 23px;
  font-weight: 750;
}

.poly-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(365px, 1fr);
  align-items: start;
  gap: 16px;
}
.poly-main { display: grid; gap: 16px; min-width: 0; }
.poly-card {
  min-width: 0;
  padding: var(--poly-pad);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--white);
}
.poly-card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 12px;
}
.poly-card-heading h2 { margin: 0; font-size: clamp(23px, 2vw, 31px); }
#poly-detail-heading strong { font-size: clamp(44px, 5vw, 64px); line-height: 1.15; }
#poly-detail-heading span { color: var(--muted); font-size: 17px; font-weight: 600; }
.poly-readings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 265px), 1fr));
  gap: 10px;
}
.poly-reading {
  padding: 12px 14px;
  border: 1px solid var(--poly-edge);
  border-radius: 16px;
  background: var(--poly-tint);
}
.poly-reading-pinyin { margin: 0; color: var(--green-dark); font-size: 30px; }
.poly-tone-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--poly-warm);
  color: var(--poly-warm-ink);
  font-size: 13px;
  vertical-align: middle;
}
.poly-meaning { margin: 2px 0 8px; font-size: 17px; }
.poly-words { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.poly-word-chip {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  max-width: 100%;
}
.poly-word-chip a { display: grid; padding: 3px 6px 3px 9px; line-height: 1.45; }
.poly-word-chip b { font-size: 17px; overflow-wrap: anywhere; }
.poly-word-chip em { color: var(--green); font-style: normal; text-decoration: underline; text-underline-offset: 3px; }
.poly-word-chip a span { color: var(--muted); font-size: 14px; }
.poly-word-chip button {
  flex: 0 0 36px;
  padding: 0;
  border: 0;
  border-radius: 0 9px 9px 0;
  background: none;
  font-size: 15px;
}
.poly-word-chip :is(a, button):hover { background: var(--soft); }
.poly-example { margin: 8px 0 0; color: var(--muted); font-size: 16px; }
.poly-extra { margin-top: 6px; color: var(--green); font-size: 15px; }
.poly-extra summary { cursor: pointer; }
.poly-detail-links { margin-top: 12px; }
.poly-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--green);
  font-size: 16px;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.poly-practice { background: #fffaf0; border-color: #efdfbb; }
.poly-score, .poly-hint { margin: 0; color: var(--muted); font-size: 16px; }
.poly-score b { color: var(--green); font-variant-numeric: tabular-nums; }
.poly-word { display: inline-flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.poly-cell {
  display: grid;
  justify-items: center;
  min-width: 45px;
  font-size: 19px;
  line-height: 1.55;
}
.poly-cell b { font-size: clamp(29px, 3vw, 42px); line-height: 1.3; }
.poly-target { color: var(--green); text-decoration: underline 3px; text-underline-offset: 5px; }
.poly-mask { min-width: 44px; padding-inline: 3px; border: 1px dashed var(--poly-edge); border-radius: 7px; text-align: center; }
.poly-options { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.poly-option {
  min-width: 70px;
  min-height: 44px;
  padding: 4px 12px;
  border: 1px solid var(--poly-edge);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-weight: 750;
}
.poly-option:hover:not([aria-disabled]) { background: var(--soft); }
.poly-option[aria-disabled] { cursor: default; }
.poly-option.ok { border-color: var(--green); background: var(--green); color: #fff; }
.poly-option.bad { border-color: #b75145; background: #ffebe8; color: #852d23; }
.poly-feedback, .poly-status { margin: 8px 0; font-weight: 650; }
.poly-feedback:empty, .poly-status:empty { margin: 0; }
.poly-feedback { color: var(--green-dark); }
.poly-review { margin-bottom: 12px; }
.poly-actions { margin-top: 8px; }
.poly-actions [aria-disabled="true"] { opacity: .65; cursor: wait; }

.poly-browse { position: sticky; top: 16px; }
.poly-count { color: var(--muted); font-size: 15px; white-space: nowrap; }
.poly-search-row { display: flex; align-items: center; gap: 10px; }
.poly-search-row input { min-height: 44px; padding: 7px 11px; font-size: 16px; }
.poly-search-row button { flex-shrink: 0; }
.poly-buckets, .poly-alphabet { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.poly-buckets button {
  min-height: 34px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--poly-tint);
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 650;
}
.poly-buckets small { font-weight: 500; }
.poly-alphabet a {
  display: grid;
  place-items: center;
  min-width: 28px;
  min-height: 28px;
  border-radius: 7px;
  background: var(--poly-tint);
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 750;
}
.poly-alphabet a:hover, .poly-buckets button:hover { background: var(--soft); }
.poly-groups {
  max-height: clamp(270px, 52vh, 720px);
  overflow-y: auto;
  margin-top: 9px;
  padding: 2px 7px 6px 3px;
  border-top: 1px solid var(--line);
  scrollbar-gutter: stable;
}
.poly-group { padding-top: 5px; }
.poly-group-head {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 17px;
}
.poly-group-head span { color: var(--muted); font-size: 13px; font-weight: 500; }
.poly-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.poly-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  max-width: 100%;
  padding: 3px 8px 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--poly-tint);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.poly-chip b { font-size: 21px; }
.poly-chip span { color: var(--muted); font-size: 13px; }
.poly-chip:hover, .poly-starter-list a:hover { border-color: var(--green); }
.poly-chip[aria-current], .poly-starter-list a[aria-current], .poly-buckets [aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.poly-chip[aria-current] span { color: #fff; }
.poly-empty, .poly-note { margin: 12px 0 0; color: var(--muted); font-size: 15px; }

@media (max-width: 960px) {
  .poly-shell { grid-template-columns: minmax(0, 1fr); }
  .poly-browse { position: static; }
}
