:root {
  --paper: #ffffff;
  --ink: #1b2a4a;
  --muted: #69738a;
  --rule: #dde2ea;
  --soft: #f2f4f8;
  --marker: #ffe45c;
  --learned: #2f7d5f;
  --serif: 'Literata', Georgia, serif;
  --sans: 'Public Sans', system-ui, sans-serif;
  --gutter: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141a26;
    --ink: #e6eaf2;
    --muted: #98a2b8;
    --rule: #2b3446;
    --soft: #1c2433;
    --marker: #8a7414;
    --learned: #6cc59f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button:disabled { opacity: 0.35; cursor: default; }

/* One container sets the horizontal padding for every block. */
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px var(--gutter) 96px;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font: 600 28px/1.2 var(--serif);
  letter-spacing: -0.01em;
}

.tabs { display: flex; gap: 4px; }

.tab {
  border: 0;
  background: none;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
}
.tab[aria-pressed='true'] { background: var(--soft); color: var(--ink); }
#gap-count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Frequency profile: the memorable element. */
.profile { margin-top: 32px; }

/* Which list the bars, pages and gaps belong to. */
.list-choice {
  display: inline-flex;
  margin-bottom: 16px;
  padding: 3px;
  border-radius: 8px;
  background: var(--soft);
}
.list-choice button {
  border: 0;
  background: none;
  padding: 6px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
}
.list-choice button[aria-pressed='true'] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--rule);
}

.mode-choice { display: inline-flex; gap: 4px; margin-top: 12px; }
.mode-choice button {
  border: 1px solid var(--rule);
  background: none;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}
.mode-choice button[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* Scrolling: one word at a time, the word is the whole screen. */
.rsvp {
  margin-top: 24px;
  min-height: 260px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  border-radius: 8px;
  background: var(--soft);
  padding: 32px 0;
}
.rsvp-word.word {
  width: auto;
  padding: 4px 0;
  font: 600 56px/1.1 var(--serif);
  letter-spacing: -0.01em;
}
.rsvp-word.word[data-status='pending'] { color: var(--ink); }
.rsvp-translation { min-height: 48px; text-align: center; max-width: 44ch; padding: 0 16px; }
.rsvp-flash { margin: 0; min-height: 1.5em; font-size: 13px; color: var(--muted); }

.rsvp-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.rsvp-controls .primary { min-width: 140px; }

.rsvp-speed { display: flex; align-items: center; gap: 12px; margin-top: 16px; color: var(--muted); font-size: 14px; }
.rsvp-speed input { flex: 1; accent-color: var(--ink); }
.rsvp-speed-value { min-width: 88px; text-align: right; font-variant-numeric: tabular-nums; }

.rsvp-marked { color: var(--muted); font-size: 14px; }
.credit { margin-top: 24px; font-size: 12px; color: var(--muted); }
.credit a { color: inherit; }

@media (max-width: 640px) {
  .rsvp { min-height: 200px; }
  .rsvp-word.word { font-size: 40px; }
  .rsvp-controls .primary { min-width: 0; }
}

.gap-rank { font: 400 12px var(--sans); color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

.bands {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.band {
  width: 100%;
  border: 0;
  background: none;
  padding: 0;
  display: grid;
  gap: 2px;
  text-align: left;
}

.bar {
  display: flex;
  align-items: flex-end;
  height: 96px;
  background: var(--soft);
  border-radius: 4px;
  overflow: hidden;
}
.fill { width: 100%; background: var(--ink); transition: height 300ms ease; }
.band[aria-current='true'] .bar { box-shadow: inset 0 0 0 2px var(--ink); }

.band-rate { font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.band-name { font: 600 13px/1.2 var(--serif); }
.band-seen { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.band-tag { font-size: 12px; line-height: 1.3; color: var(--muted); }

/* What the open band of Nation's list opens up. */
.band-info[hidden] { display: none; }
.standing { margin: 20px 0 0; }
.standing strong { font-weight: 600; }
.milestone { margin-top: 12px; padding: 16px; border-radius: 8px; background: var(--soft); }
.milestone h2 { margin: 0 0 4px; font: 600 17px/1.3 var(--serif); }
.milestone p { margin: 0; max-width: 70ch; }
.milestone .milestone-you { margin-top: 8px; font-weight: 500; }
.milestone-sources { margin-top: 8px; font-size: 12px; color: var(--muted); }
.milestone-sources a { color: inherit; }

.profile-note {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 70ch;
}

main { margin-top: 40px; border-top: 1px solid var(--rule); padding-top: 24px; }

.sweep-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

h2 { margin: 0; font: 600 22px/1.3 var(--serif); }

.pager { display: flex; align-items: center; gap: 8px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ghost {
  border: 1px solid var(--rule);
  background: none;
  border-radius: 6px;
  padding: 4px 10px;
}
.ghost:hover:not(:disabled) { background: var(--soft); }

.hint { margin: 8px 0 0; color: var(--muted); max-width: 70ch; }

/* Words are set like a page of text: you mark the ones you don't know, as with a highlighter. */
.field {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 8px;
}

/* Vertical padding only, so the words line up with the headings; the marker spills sideways with a shadow. */
.word {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  padding: 6px 0;
  font: 400 19px/1.35 var(--serif);
}
.mark { border-radius: 2px; }
.word:hover .mark { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 4px; }
.word[data-status='known'] { color: var(--muted); }
.word[data-status='unknown'] .mark { background: var(--marker); box-shadow: -4px 0 0 var(--marker), 4px 0 0 var(--marker); color: var(--ink); }
.word[data-status='learned'] { color: var(--learned); }
.word[data-status='learned'] .mark { text-decoration: underline; text-underline-offset: 4px; }

.actions {
  position: sticky;
  bottom: 0;
  margin-top: 24px;
  padding: 16px 0;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tally { color: var(--muted); font-variant-numeric: tabular-nums; }

.primary {
  border: 0;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 10px 18px;
  font-weight: 600;
}

.gap-band { margin-top: 24px; }
h3 { margin: 0 0 8px; font: 600 17px/1.3 var(--serif); }
h3 span { font: 400 13px var(--sans); color: var(--muted); margin-left: 6px; }

.gap-list { list-style: none; margin: 0; padding: 0; }
.gap-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}
.gap-word { font: 400 19px/1.35 var(--serif); }
.gap-list a { color: var(--muted); font-size: 13px; }
.gap-list .ghost { font-size: 13px; }

.learned { margin-top: 40px; }
.learned summary { cursor: pointer; font-weight: 600; }

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

.tabs { align-items: center; }
.save-status { font-size: 12px; color: var(--muted); margin-right: 8px; }

/* Before the password: nothing personal on screen. */
body.locked .tabs, body.locked .profile { display: none; }
body.locked main { border-top: 0; margin-top: 24px; padding-top: 0; }

.login { display: grid; gap: 12px; max-width: 360px; }
.login .hint { margin: 0; }
.login input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.login input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.login .primary { justify-self: start; }
.login-error { margin: 0; min-height: 1.5em; color: #b3261e; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  margin: 0;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .bands { gap: 3px; }
  .bar { height: 64px; }
  .band-rate { font-size: 12px; }
  .band-seen, .band-tag, .unit { display: none; }
  .field { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .fill, .toast { transition: none; }
}

/* A word's card: same content in the grid, the scrolling and the Lacunes tab. */
.detail-main { margin: 0; font-size: 17px; }
.detail-other { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.detail-also { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.detail-sense { font-size: 13px; color: var(--muted); margin-left: 6px; }
.detail-also .detail-sense { font-size: 12px; margin-left: 4px; }
.detail-none { margin: 0; font-size: 14px; color: var(--muted); }
/* Synonyms and antonyms: one small line under the senses, the English words in ink. */
.detail-related { margin: 8px 0 0; font-size: 13px; line-height: 1.45; }
.detail-related-label { color: var(--muted); }
/* The written American pronunciation and the button that says the word. */
.detail-say { display: flex; align-items: center; gap: 6px; margin: 2px 0 10px; }
.detail-ipa { border: 0; background: none; padding: 0; font-size: 15px; color: var(--muted); text-decoration: underline dotted; text-underline-offset: 3px; }
.detail-ipa:hover { color: var(--ink); }
.say { display: inline-grid; place-items: center; width: 32px; height: 32px; margin: -4px 0; border: 0; border-radius: 999px; background: none; color: var(--muted); }
.say:hover { background: var(--soft); color: var(--ink); }
.rsvp-translation .detail-say { justify-content: center; }
.rsvp .say:hover { background: var(--paper); }
.detail-example { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); }
.detail-example p[lang='en'] { margin: 0; font: 400 18px/1.4 var(--serif); }
.detail-example strong { font-weight: 600; background: var(--marker); box-shadow: -2px 0 0 var(--marker), 2px 0 0 var(--marker); border-radius: 2px; }
.detail-link { display: inline-block; margin-top: 12px; font-size: 13px; color: var(--muted); }

.word-card {
  position: fixed;
  z-index: 20;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(27, 42, 74, 0.16);
}
.word-card[hidden] { display: none; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.card-head .detail-say { margin-bottom: 0; }
.card-word { margin: 0; font: 600 24px/1.2 var(--serif); }
.card-close { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); }
.card-status { margin: 0; font-size: 13px; color: var(--muted); }
.card-actions .ghost { margin-left: auto; }
.link-button { border: 0; background: none; padding: 0; font-size: 13px; color: var(--muted); text-decoration: underline; }

@media (max-width: 640px) {
  .word-card { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 70vh; border-radius: 14px 14px 0 0; padding: 16px 16px 24px; }
}

/* The lesson on reading the pronunciation: one line per sound, its symbol, how it sounds, examples. */
.lesson { margin-top: 8px; }
.ipa { font-family: var(--sans); }
.lesson mark { background: var(--marker); color: inherit; border-radius: 2px; padding: 0 1px; }
.decode { margin-top: 20px; padding: 16px; border-radius: 8px; background: var(--soft); }
.decode-word { display: flex; align-items: center; gap: 10px; margin: 0; }
.decode-word [lang='en'] { font: 600 24px/1.2 var(--serif); }
.decode-word .ipa { font-size: 18px; color: var(--muted); }
.decode-parts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.decode-parts a { display: grid; gap: 2px; padding: 8px 10px; border-radius: 6px; background: var(--paper); color: inherit; text-decoration: none; }
.decode-parts a:hover { outline: 1px solid var(--rule); }
.decode-parts .ipa { font-size: 20px; line-height: 1.2; }
.decode-parts span:last-child { font-size: 12px; color: var(--muted); }
.sound-group { margin-top: 32px; }
.sound-list { margin: 12px 0 0; padding: 0; list-style: none; }
.sound { display: grid; grid-template-columns: 56px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--rule); scroll-margin-top: 16px; }
.sound:target { background: var(--soft); }
.sound-symbol { font-size: 28px; line-height: 1.1; text-align: center; }
.sound-as { margin: 0; font-weight: 500; }
.sound-note { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.sound-examples { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 6px 0 0; padding: 0; list-style: none; }
.sound-examples li { display: inline-flex; align-items: center; gap: 6px; }
.sound-examples [lang='en'] { font-family: var(--serif); }
.sound-examples .ipa { color: var(--muted); }
.sound-examples .say { margin: -6px -6px -6px -4px; }
