/* History puts missing days before record details and the full month. */
body[data-student-view="history"] .history-spread {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(17rem, .65fr);
  gap: 1rem clamp(1rem, 3vw, 2.4rem);
}
body[data-student-view="history"] .history-detail { grid-column: 1; }
body[data-student-view="history"] .history-missing,
body[data-student-view="history"] .history-calendar,
body[data-student-view="history"] .phase-banner { grid-column: 1 / -1; }
body[data-student-view="history"] .history-head { align-items: end; padding-block: .15rem 1rem; }
body[data-student-view="history"] .history-total { display: grid; gap: .18rem; line-height: 1.15; }
body[data-student-view="history"] .history-total > span { color: var(--muted); font-size: .8rem; }
body[data-student-view="history"] .history-total > strong {
  color: var(--forest);
  font: 600 clamp(2.6rem, 6vw, 4.4rem)/1 Georgia, "Yu Mincho", serif;
  font-variant-numeric: lining-nums tabular-nums;
}
body[data-student-view="history"] .history-total small { margin-inline-start: .25rem; font-size: 1rem; }
body[data-student-view="history"] .entry-row { gap: .45rem; padding-block: .9rem; }
body[data-student-view="history"] .entry-row .button-row { flex-wrap: nowrap; }
body[data-student-view="history"] .entry-row .button { min-height: 44px; }
body[data-student-view="history"] .entry-row .help { font-variant-numeric: tabular-nums; }
body[data-student-view="history"] .history-picker .range-form { align-items: end; gap: .65rem; }
body[data-student-view="history"] .history-picker label { flex: 1 1 9rem; }
.history-today, .history-entry-actions .button { min-height: 44px; }
.history-entry-actions { margin-top: .9rem; }
body[data-student-view="history"] .history-missing {
  --missing-edge: #d7af76;
  border-color: var(--missing-edge);
  border-top: 3px solid #a3682d;
  background: #fff5e4;
  color: #492d18;
}
.history-missing-summary { margin-block: .3rem .7rem; }
.history-missing-days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 5.25rem), 1fr));
  gap: .35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.history-missing-days a {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding-inline: .25rem;
  border: 1px solid var(--missing-edge);
  border-radius: .3rem;
  background: #fffcf4;
  color: #663a17;
  font-size: .86rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-underline-offset: .23em;
}
.history-missing-days a:is(:hover, :focus-visible) { background: #ffe7c2; }
.history-calendar-controls strong { font-size: clamp(1rem, 2.5vw, 1.15rem); }
body[data-student-view="history"] .history-month { font-variant-numeric: tabular-nums; }
body[data-student-view="history"] .history-month td a { min-height: clamp(3.15rem, 6vw, 4.8rem); gap: .38rem; }
body[data-student-view="history"] .history-month td a[aria-current="date"] { background: var(--lime); }
body[data-student-view="history"] .history-month td time { color: var(--ink); }
body[data-student-view="history"] .history-month td.history-month-missing { background: #fff0d9; }

/* The student's progress leads, with cohort figures available on demand. */
body[data-student-view="stats"] .stats-filters { gap: .75rem; }
body[data-student-view="stats"] .stats-period { gap: 0; border-bottom: 1px solid var(--border); }
body[data-student-view="stats"] .stats-period a {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  padding: .5rem clamp(.5rem, 2vw, 1.3rem);
  min-height: 44px;
}
body[data-student-view="stats"] .stats-period a[aria-current="page"] {
  color: var(--forest);
  border-bottom-color: var(--forest);
  font-weight: 760;
}
body[data-student-view="stats"] .stats-filters form { margin: 0; }
body[data-student-view="stats"] .stats-filters select { max-width: 100%; }
body[data-student-view="stats"] .stats-range-label { margin: 0; font-variant-numeric: tabular-nums; }
body[data-student-view="stats"] .stats-personal {
  display: grid;
  align-items: center;
  gap: clamp(1rem, 3.5vw, 2.5rem);
  border-top: 4px solid var(--forest);
  padding: clamp(1rem, 3.5vw, 2.1rem);
  background: linear-gradient(140deg, color-mix(in srgb, var(--forest) 10%, var(--paper)), var(--paper) 76%);
}
body[data-student-view="stats"] .stats-personal-copy h2 {
  color: var(--deep);
  font-size: clamp(1.55rem, 5vw, 2.4rem);
  line-height: 1.3;
  text-wrap: balance;
}
body[data-student-view="stats"] .stats-personal-copy p { max-inline-size: 36ch; margin: .55rem 0 0; }
body[data-student-view="stats"] .stats-personal-copy .button { margin-top: .9rem; }
body[data-student-view="stats"] .stats-own-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
  margin: 0;
}
body[data-student-view="stats"] .stats-own-metrics .metric {
  padding: .6rem .65rem;
  border-inline-start: 2px solid color-mix(in srgb, var(--forest) 45%, var(--border));
  background: color-mix(in srgb, var(--forest) 3%, var(--paper));
}
body[data-student-view="stats"] .stats-own-metrics .metric dd { color: var(--deep); overflow-wrap: anywhere; }
body[data-student-view="stats"] .journal-chart { min-width: 0; }
/* Start a long period at its most recent days. Keep labels and bars chronological. */
body[data-student-view="stats"] .study-chart-scroll { direction: rtl; }
body[data-student-view="stats"] .study-chart {
  direction: ltr;
  width: max-content;
  min-width: 100%;
  grid-auto-columns: minmax(3rem, 1fr);
}
body[data-student-view="stats"] .study-chart-plot {
  background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), var(--border) calc(25% - 1px) 25%);
}
body[data-student-view="stats"] .study-chart-bar { height: .82rem; }
body[data-student-view="stats"] .study-chart-value { font-variant-numeric: tabular-nums; }
body[data-student-view="stats"] .comparison-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
body[data-student-view="stats"] .comparison-table :is(th, td) {
  white-space: normal;
  text-align: start;
  padding: .7rem clamp(.35rem, 1.7vw, 1rem);
  background: transparent;
  line-height: 1.4;
  border: 0;
  border-bottom: 1px solid var(--border);
}
body[data-student-view="stats"] .comparison-table th { font-weight: 650; }
body[data-student-view="stats"] .comparison-table thead th:first-child { width: 29%; color: var(--muted); }
body[data-student-view="stats"] .comparison-table thead th { border-bottom: 2px solid var(--forest); color: var(--forest); }
body[data-student-view="stats"] .comparison-table tbody tr { background: none; }
body[data-student-view="stats"] .comparison-table tbody th { color: var(--muted); font-size: .86rem; }
body[data-student-view="stats"] .comparison-table tbody td:nth-child(2) { background: color-mix(in srgb, var(--forest) 6%, var(--paper)); }
body[data-student-view="stats"] .comparison-table :is(td, th):first-child { padding-left: 0; }
body[data-student-view="stats"] .comparison-table td strong {
  font: 600 clamp(1.2rem, 2.7vw, 2rem)/1.2 Georgia, "Yu Mincho", serif;
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: anywhere;
}
body[data-student-view="stats"] .comparison-unit { margin-inline-start: .2em; font-size: .75rem; }
body[data-student-view="stats"] .comparison-table td small,
body[data-student-view="stats"] .comparison-table .stats-feedback { display: block; color: var(--muted); font-size: .75rem; }
body[data-student-view="stats"] .week-averages { display: flex; flex-wrap: wrap; gap: .75rem 2.5rem; margin: 1rem 0 0; }
body[data-student-view="stats"] .week-averages dt { color: var(--muted); font-size: .84rem; }
body[data-student-view="stats"] .week-averages dt small { margin-inline-start: .25rem; }
body[data-student-view="stats"] .week-averages dd { margin: .15rem 0 0; font-size: 1.22rem; }
body[data-student-view="stats"] :is(.stats-context, .stats-missing-details) > summary {
  min-height: 44px;
  padding-block: .55rem;
  cursor: pointer;
  font-weight: 700;
}
body[data-student-view="stats"] .stats-context .comparison-sheet { margin-top: .45rem; }
body[data-student-view="stats"] .stats-class-context { margin-top: .9rem; color: var(--muted); }
body[data-student-view="stats"] .missing-list { max-height: 16rem; overflow-y: auto; }
body[data-student-view="stats"] .missing-list a { min-height: 44px; display: inline-flex; align-items: center; }

/* A season opens with the student's score sheet, then the standings. */
body[data-student-view="ranking"] .ranking-layout { grid-template-columns: minmax(0, 1fr) minmax(17rem, .44fr); }
body[data-student-view="ranking"] .ranking-personal {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .72fr);
  align-items: start;
  column-gap: clamp(1.5rem, 6vw, 6rem);
  padding: clamp(1.15rem, 3.3vw, 2.75rem);
  color: var(--ink);
  border: 1px solid var(--border);
  border-top: 4px solid var(--forest);
  border-radius: 2px;
  background: var(--paper);
  background-image: linear-gradient(110deg, transparent 48%, color-mix(in srgb, var(--forest) 6%, transparent) 100%);
}
body[data-student-view="ranking"] .ranking-personal-header { grid-column: 1 / -1; margin-bottom: .95rem; }
body[data-student-view="ranking"] .ranking-status {
  padding: .12rem .55rem;
  color: var(--forest);
  border: 1px solid var(--forest);
  border-radius: 3px;
  background: transparent;
}
body[data-student-view="ranking"] .ranking-personal-season {
  grid-column: 1;
  color: var(--ink);
  opacity: 1;
  margin: 0;
  font: 650 clamp(1.2rem, 3vw, 2.15rem)/1.45 var(--journal-display, "Hiragino Mincho ProN", "Yu Mincho", serif);
}
body[data-student-view="ranking"] .ranking-duration { grid-column: 1; grid-row: span 2; }
body[data-student-view="ranking"] .ranking-time {
  color: var(--forest);
  font: 500 clamp(3.6rem, 8vw, 6.8rem)/1 Georgia, "Yu Mincho", serif;
  margin: .32rem 0 0;
  letter-spacing: -.045em;
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: anywhere;
}
body[data-student-view="ranking"] .ranking-time span { font-family: sans-serif; font-weight: 650; font-size: 1rem; }
body[data-student-view="ranking"] .ranking-hours { color: var(--muted); }
body[data-student-view="ranking"] .ranking-praise {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  color: var(--forest);
  margin: 0;
  font-weight: 680;
}
body[data-student-view="ranking"] .ranking-personal-progress { grid-column: 2; border: 0; padding: .25rem 0 0; margin-top: .3rem; }
body[data-student-view="ranking"] .ranking-personal-progress progress { color: var(--forest); background: var(--border); height: 7px; border-radius: 1px; }
body[data-student-view="ranking"] .ranking-personal-dates { grid-column: 1 / -1; border-top: 1px dashed var(--border); padding-top: .6rem; color: var(--muted); opacity: 1; }
body[data-student-view="ranking"] .ranking-first-entry { color: var(--forest); }
body[data-student-view="ranking"] .ranking-personal :is(.ranking-first-entry, .ranking-own-badge) { grid-column: 2; justify-self: start; }
body[data-student-view="ranking"] .ranking-layout .ranking-archive { grid-column: auto; }
body[data-student-view="ranking"] .ranking-archive summary,
body[data-student-view="ranking"] .ranking-guide summary { min-height: 44px; align-content: center; }
body[data-student-view="ranking"] .ranking-board-controls { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
body[data-student-view="ranking"] .ranking-toggle { border: 1px solid var(--border); border-radius: 4px; background: var(--paper); }
body[data-student-view="ranking"] .ranking-toggle a { border-radius: 2px; }
body[data-student-view="ranking"] .ranking-row { min-height: 56px; }
body[data-student-view="ranking"] .ranking-position { font-family: Georgia, serif; font-size: 1.23rem; white-space: nowrap; }
body[data-student-view="ranking"] .ranking-standings .ranking-row { grid-template-columns: 3rem minmax(0, 1fr) max-content; }
body[data-student-view="ranking"] .ranking-row small { font-family: sans-serif; }
body[data-student-view="ranking"] .ranking-row progress { height: 3px; color: var(--forest); }
body[data-student-view="ranking"] .ranking-value { font-size: 1rem; }

body[data-student-view="ranking"] .ranking-board-heading h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  font-weight: 750;
}
.ranking-personal-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ranking-personal-labels .ranking-own-position {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .6rem;
  border: 1px solid var(--place-edge, var(--border));
  border-radius: 4px;
  color: var(--place-ink, var(--deep));
  background: var(--place-paper, var(--lime));
  font-size: .79rem;
  white-space: nowrap;
}
.ranking-own-position .ranking-medal { font-size: 1.05rem; line-height: 1.35; }
.ranking-layout [data-rank="1"] {
  --place-ink: #624202;
  --place-paper: #fff1c8;
  --place-edge: #c89d45;
}
.ranking-layout [data-rank="2"] {
  --place-ink: #2c435d;
  --place-paper: #e9f1fb;
  --place-edge: #9aacbf;
}
.ranking-layout [data-rank="3"] {
  --place-ink: #703a26;
  --place-paper: #f8e6db;
  --place-edge: #c4937b;
}
.ranking-podium {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: clamp(6px, 1.3vw, 12px);
  margin-block: .8rem 1rem;
}
.ranking-podium > li {
  min-width: 0;
  overflow: clip;
  border: 1px solid var(--place-edge);
  border-block-start-width: 3px;
  border-radius: .7rem;
  background: var(--place-paper);
  color: var(--place-ink);
}
body[data-student-view="ranking"] .ranking-podium .ranking-row {
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: .35rem;
  min-height: 7.2rem;
  padding: .65rem clamp(.38rem, 1.5vw, .85rem);
}
body[data-student-view="ranking"] .ranking-podium .ranking-position {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 .25rem;
  padding: 0;
  color: inherit;
}
.ranking-podium .ranking-medal {
  font-size: clamp(1.3rem, 4.4vw, 2rem);
  line-height: 1.25;
}
body[data-student-view="ranking"] .ranking-podium .ranking-value {
  text-align: start;
  overflow-wrap: anywhere;
}
.ranking-podium summary:hover { background: color-mix(in srgb, var(--place-ink) 7%, transparent); }
.ranking-podium .ranking-chevron { color: inherit; }
.ranking-podium .ranking-tied-names {
  margin: 0 .45rem .6rem;
  border-top: 1px solid var(--place-edge);
  padding: .3rem .18rem 0;
  color: inherit;
}
.ranking-podium summary:focus-visible { outline-offset: -4px; }
@media (min-width: 960px) {
  body[data-student-view="ranking"] .ranking-layout { grid-template-rows: auto 1fr; }
  body[data-student-view="ranking"] .ranking-board { grid-column: 1; grid-row: 1 / span 2; }
  body[data-student-view="ranking"] .ranking-personal {
    grid-column: 2;
    grid-row: 1;
    grid-template-columns: minmax(0, 1fr);
    padding: clamp(1rem, 2vw, 1.6rem);
  }
  body[data-student-view="ranking"] .ranking-personal > * { grid-column: 1; grid-row: auto; }
  body[data-student-view="ranking"] .ranking-personal-season { font-size: clamp(1.2rem, 2vw, 1.75rem); }
  body[data-student-view="ranking"] .ranking-time { font-size: clamp(2.85rem, 5vw, 4.75rem); }
  body[data-student-view="ranking"] .ranking-praise { margin-top: .8rem; }
  body[data-student-view="ranking"] .ranking-personal-progress { margin-top: .5rem; }
  body[data-student-view="ranking"] .ranking-personal :is(.ranking-first-entry, .ranking-own-badge) { grid-column: 1; }
  body[data-student-view="ranking"] .ranking-layout .ranking-archive { grid-column: 2; grid-row: 2; }
}
@media (max-width: 345px) {
  .ranking-podium { grid-auto-flow: row; }
  body[data-student-view="ranking"] .ranking-podium .ranking-row { min-height: 0; }
}

/* Palette samples show each pair as a sheet and a margin of contrasting ink. */
body[data-student-view="settings"] .theme-card { max-width: 57rem; }
body[data-student-view="settings"] .palette-progress { max-width: 36rem; margin-block: .75rem 1.45rem; }
body[data-student-view="settings"] .reward-progress { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; }
body[data-student-view="settings"] .reward-progress strong { font-size: 1rem; }
body[data-student-view="settings"] .palette-progress .progress { display: block; height: 4px; margin-top: .6rem; }
body[data-student-view="settings"] .theme-group { border-top: 1px solid var(--border); padding-top: .75rem; }
body[data-student-view="settings"] .theme-group legend { margin: 0; padding-inline-end: .8rem; }
body[data-student-view="settings"] .theme-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.7rem), 1fr)); gap: .5rem; }
body[data-student-view="settings"] .theme-option { position: relative; min-width: 0; border-radius: 3px; min-height: 47px; padding: .5rem; background: var(--paper); }
body[data-student-view="settings"] .theme-option:has(input:focus-visible) { outline: 3px solid var(--forest); outline-offset: 3px; }
body[data-student-view="settings"] .theme-option:is(.is-locked, :disabled) { border-style: dashed; opacity: 1; color: var(--muted); }
body[data-student-view="settings"] .preset-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body[data-student-view="settings"] .theme-preset { display: grid; gap: .45rem; align-content: start; text-align: left; padding: .55rem; }
body[data-student-view="settings"] .theme-swatch-pair {
  position: relative;
  display: grid;
  grid-template-columns: 3fr 1fr;
  width: 100%;
  height: 2rem;
  border-radius: 1px;
}
body[data-student-view="settings"] .theme-swatch-pair::after {
  content: "";
  position: absolute;
  inset: 35% 39% 35% 8%;
  border-block: 1px solid #0004;
}
body[data-student-view="settings"] .theme-option input { margin-inline-end: .07rem; }
body[data-student-view="settings"] .theme-option small { margin-top: .18rem; font-size: .71rem; }
body[data-student-view="settings"] .ranking-check { cursor: pointer; }

@media (max-width: 760px) {
  body[data-student-view="history"] .history-spread,
  body[data-student-view="ranking"] .ranking-layout { grid-template-columns: minmax(0, 1fr); }
  body[data-student-view="ranking"] .ranking-personal { grid-template-columns: minmax(0, 1fr); padding: .95rem; }
  body[data-student-view="ranking"] .ranking-personal > * { grid-column: 1; grid-row: auto; }
  body[data-student-view="ranking"] .ranking-personal-header { margin-bottom: .55rem; }
  body[data-student-view="ranking"] .ranking-time { font-size: clamp(2.85rem, 11.5vw, 4.75rem); }
  body[data-student-view="ranking"] .ranking-praise { margin-top: .55rem; }
  body[data-student-view="ranking"] .ranking-personal-progress { margin-top: .45rem; }
  body[data-student-view="ranking"] .ranking-personal :is(.ranking-first-entry, .ranking-own-badge) { grid-column: 1; }
}
@media (max-width: 379px) {
  body[data-student-view="ranking"] .ranking-board-controls { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 380px) and (max-width: 520px) {
  body[data-student-view="ranking"] .ranking-board-controls:has(.ranking-choice + .ranking-choice) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-student-view="ranking"] .ranking-toggle a { font-size: .79rem; padding-inline: 1px; }
}
@media (max-width: 520px) {
  body[data-student-view="stats"] .stats-period { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  body[data-student-view="stats"] .stats-period a { width: 100%; padding-inline: 1px; font-size: clamp(.7rem, 3.2vw, .83rem); }
  body[data-student-view="stats"] .comparison-sheet { padding-inline: .8rem; }
  body[data-student-view="stats"] .comparison-table thead th { font-size: .81rem; }
  body[data-student-view="settings"] .preset-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 860px) {
  body[data-student-view="stats"] .stats-spread {
    align-items: start;
    grid-template-columns: minmax(0, 1.45fr) minmax(18rem, .85fr);
  }
  body[data-student-view="stats"] .stats-spread > :is(.stats-filters, .stats-range-label, .stats-personal, .stats-context, .phase-banner) { grid-column: 1 / -1; }
  body[data-student-view="stats"] .stats-personal { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  body[data-student-view="stats"] .stats-filters { grid-template-columns: 1fr auto; align-items: center; }
  body[data-student-view="stats"] .stats-filters:has([data-form="show-period"]) { grid-template-columns: 1fr; }
}

/* A straight paper edge and a running title give the four reading views a common rhythm. */
body:is([data-student-view="history"], [data-student-view="stats"], [data-student-view="ranking"], [data-student-view="settings"]) .card {
  border-radius: 3px;
  box-shadow: none;
}
body:is([data-student-view="history"], [data-student-view="stats"], [data-student-view="ranking"], [data-student-view="settings"]) .card h2 {
  font-family: var(--journal-display, "Hiragino Mincho ProN", "Yu Mincho", serif);
  letter-spacing: .025em;
}
body[data-student-view="history"] .history-detail,
body[data-student-view="settings"] .theme-card:first-of-type { border-top: 3px solid var(--forest); }
body[data-student-view="stats"] .comparison-table thead { background: transparent; }
body[data-student-view="stats"] .coverage-sheet .progress::-webkit-progress-value,
body[data-student-view="settings"] .palette-progress .progress::-webkit-progress-value { background: var(--forest); }
body[data-student-view="stats"] .coverage-sheet .progress::-moz-progress-bar,
body[data-student-view="settings"] .palette-progress .progress::-moz-progress-bar { background: var(--forest); }

/* The preview stays in sight as students browse their collection. */
.emote-settings {
  width: min(100%, 56rem);
  margin-inline: auto;
}

.emote-form {
  display: grid;
  gap: clamp(1rem, 3vw, 1.65rem);
}

.emote-preview {
  display: grid;
  grid-template-columns: clamp(6.75rem, 32vw, 11rem) minmax(0, 1fr);
  align-items: center;
  gap: clamp(.75rem, 3vw, 1.5rem);
  padding: clamp(.75rem, 3vw, 1.35rem);
  border-top: 3px solid var(--forest);
}

.emote-preview-stage {
  display: grid;
  min-width: 0;
  min-height: 8.25rem;
  place-items: center;
  overflow: clip;
  border: 1px solid color-mix(in srgb, var(--forest) 26%, var(--paper));
  border-radius: .65rem;
  background: radial-gradient(ellipse 28% 5% at 50% 86%, #1d2e251a 75%, transparent 100%),
    color-mix(in srgb, var(--lime) 75%, var(--paper));
}

.emote-preview-stage .stick-figure { transform: translateY(.6rem) scale(1.25); }
.emote-preview-content { min-width: 0; }
.emote-preview-content h2 { margin-block: .12rem .4rem; font-size: clamp(1.1rem, 3.9vw, 1.55rem); }
.emote-preview-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .45rem; }
.emote-rarity-badge {
  padding: .07rem .42rem;
  border: 1px solid var(--rarity-border);
  border-radius: .3rem;
  background: var(--rarity-paper);
  color: var(--rarity-ink);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.36;
}
.emote-preview-status { margin: 0; color: var(--forest); font-size: .8rem; font-weight: 700; }
.emote-preview-content .button-row { gap: .35rem .55rem; }
.emote-preview-content .button { min-height: 44px; padding: .4rem .65rem; text-wrap: balance; }
.emote-preview-content .form-error:empty { display: none; }

.emote-gallery {
  display: block;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.emote-gallery legend {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .3rem .65rem;
  margin-block-end: .65rem;
  padding: 0;
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 760;
}

.emote-gallery legend small { font-size: .81rem; font-weight: 600; color: var(--muted); }

.emote-demo-help { margin-block: .15rem 1rem; }
.emote-catalog-group + .emote-catalog-group { margin-block-start: 1.55rem; }
.emote-catalog-group h2 { margin-block-end: .55rem; font-size: 1rem; }
.emote-catalog-group h2 small { margin-inline-start: .35rem; color: var(--muted); font-weight: 550; }

.emote-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
}

.emote-card {
  position: relative;
  display: grid;
  grid-template-rows: 3.85rem auto;
  justify-items: center;
  align-content: start;
  gap: .35rem;
  min-height: 6.8rem;
  padding: .55rem .42rem;
  border: 1px solid var(--border);
  border-radius: .55rem;
  background: var(--paper);
  text-align: center;
  cursor: pointer;
}

.emote-card:hover { border-color: var(--forest); }
.emote-card:has(input:checked) {
  border-color: var(--forest);
  background: color-mix(in srgb, var(--lime) 55%, var(--paper));
  box-shadow: inset 0 0 0 1px var(--forest);
}

.emote-card:has(input:focus-visible) {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

.emote-card input {
  position: absolute;
  inset-block-start: .5rem;
  inset-inline-end: .5rem;
  inline-size: 1rem;
  block-size: 1rem;
  margin: 0;
  accent-color: var(--forest);
  scroll-margin-block-start: 14rem;
}

.emote-card-figure {
  display: grid;
  place-items: center;
  align-self: stretch;
}

.emote-card-figure .stick-figure { transform: translateY(.45rem) scale(.83); }
.emote-card-name { max-width: 100%; font-size: .85rem; font-weight: 680; line-height: 1.35; overflow-wrap: anywhere; }
.emote-card-active { color: var(--forest); font-size: .72rem; font-weight: 700; }
.emote-settings > .help { margin-block-start: .85rem; }

@media (min-width: 610px) {
  .emote-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }
}

@media (min-height: 520px) {
  .emote-preview { position: sticky; inset-block-start: .55rem; z-index: 2; }
}
