:root {
  --bg: #fbfaf8;
  --fg: #1e1c1a;
  --dim: #8a857e;
  --rule: #e6e2dc;
  --error: #b4331f;
  --help: #a4700c;
  --clean: #4f7a3f;
  --error-wash: #f7e3de;
  --help-wash: #f6ecd6;
  --tip-bg: #ffffff;
  --tip-shadow: rgba(30, 28, 26, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --fg: #e8e5e0;
    --dim: #7d7872;
    --rule: #2b2930;
    --error: #ef7a63;
    --help: #dcab4a;
    --clean: #82b86c;
    --error-wash: #3a221c;
    --help-wash: #332b18;
    --tip-bg: #201e26;
    --tip-shadow: rgba(0, 0, 0, 0.5);
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 2.5rem 1.5rem 6rem;
  background: var(--bg);
  color: var(--fg);
  font:
    16px/1.6 ui-serif,
    Georgia,
    "Times New Roman",
    serif;
}
main {
  max-width: 46rem;
  margin: 0 auto;
}
header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
h1 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}
.live {
  font:
    11px ui-monospace,
    monospace;
  color: var(--dim);
}
.live.down {
  color: var(--error);
}
.aside {
  font:
    11px ui-monospace,
    monospace;
  color: var(--dim);
  margin-left: auto;
}
/* Two panes: what you write, and what the tutor thought of it. The editor
holds every line you have; the view holds what has been looked at. */
.panes {
  display: grid;
  gap: 2rem;
}
.pane-label {
  font:
    10px ui-monospace,
    monospace;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--dim);
  margin-bottom: 0.4rem;
}
textarea {
  width: 100%;
  min-height: 15rem;
  resize: vertical;
  display: block;
  padding: 0.8rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--tip-bg);
  color: var(--fg);
  font:
    15px/1.8 ui-serif,
    Georgia,
    serif;
}
textarea:focus {
  outline: none;
  border-color: var(--dim);
}
textarea::placeholder {
  color: var(--dim);
  font-style: italic;
}
#document {
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  min-height: 4rem;
  background: var(--tip-bg);
}
.line {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1rem;
  padding: 0.35rem 0;
}
.gutter {
  font:
    11px/1.9 ui-monospace,
    monospace;
  text-align: right;
  white-space: nowrap;
}
.recheck {
  margin-left: 0.45rem;
  padding: 0 0.25rem;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--dim);
  font:
    13px/1 ui-monospace,
    monospace;
  cursor: pointer;
  vertical-align: baseline;
}
.recheck:hover,
.recheck:focus-visible {
  color: var(--fg);
  background: var(--rule);
}
.id {
  color: var(--rule);
  user-select: all;
}
.line:hover .id {
  color: var(--dim);
}
.flag {
  margin-right: 0.4rem;
}
.clean .flag {
  color: var(--clean);
}
.error .flag {
  color: var(--error);
}
.help .flag {
  color: var(--help);
}
.pending .flag {
  color: var(--dim);
}
.blank {
  height: 0.9rem;
}
.clean .text {
  color: var(--fg);
}
.error .text,
.help .text {
  border-left: 2px solid;
  padding-left: 0.75rem;
  margin-left: -0.75rem;
}
.error .text {
  border-color: var(--error);
}
.help .text {
  border-color: var(--help);
}
.issue {
  position: relative;
  display: inline-grid;
  justify-items: start;
  vertical-align: baseline;
  cursor: help;
  margin: 0 0.3em;
  padding: 0 0.3em;
  border-radius: 3px;
}
.issue.error {
  background: var(--error-wash);
}
.issue.help {
  background: var(--help-wash);
}
mark {
  background: none;
  color: inherit;
  padding: 0;
}
.fixes {
  justify-self: stretch;
  white-space: nowrap;
  padding-top: 0.12em;
  font:
    600 12px/1.5 ui-monospace,
    monospace;
}
.fix + .fix {
  margin-left: 0.6em;
}
.issue.error .fixes {
  color: var(--error);
  border-top: 1.5px solid var(--error);
}
.issue.help .fixes {
  color: var(--help);
  border-top: 1px dotted var(--help);
}
.issue:focus {
  outline: none;
}
.tip {
  position: absolute;
  left: 0;
  top: calc(100% + 0.3em);
  z-index: 5;
  display: none;
  width: min(22rem, calc(100vw - 3rem));
  padding: 0.4rem 0.6rem;
  border-left: 3px solid;
  border-radius: 3px;
  background: var(--tip-bg);
  box-shadow: 0 4px 14px var(--tip-shadow);
  font:
    13px/1.5 ui-sans-serif,
    system-ui,
    sans-serif;
  cursor: auto;
  white-space: normal;
  overflow-wrap: anywhere;
}
/* Keep the popup connected to its mark while the pointer crosses the
visual gap between them. Without this bridge, :hover ends before the
pointer can reach the why button and the popup disappears. */
.tip::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 0.3em;
}
.issue:hover > .tip,
.issue:focus > .tip,
.issue:focus-within > .tip {
  display: block;
}
.issue.error > .tip {
  border-color: var(--error);
}
.issue.help > .tip {
  border-color: var(--help);
}
.cat + .cat {
  margin-top: 0.3rem;
}
.cat {
  display: block;
  font:
    10px/1.6 ui-monospace,
    monospace;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--dim);
}
.cat b {
  font-weight: 600;
}
.cat.error b {
  color: var(--error);
}
.cat.help b {
  color: var(--help);
}
/* The why button and its card. The button lives in the hover card, which
already exists; the card that answers it takes its place, one child, so
the hover that revealed the button keeps the card alive. */
.why {
  display: none;
  margin-top: 0.45rem;
  width: 100%;
  text-align: left;
  font:
    11px ui-monospace,
    monospace;
  color: var(--error);
  background: none;
  border: none;
  border-top: 1px dashed var(--rule);
  padding: 0.35rem 0 0;
  cursor: pointer;
}
.issue:hover .why,
.issue:focus .why,
.issue:focus-within .why {
  display: block;
}
.why:hover {
  text-decoration: underline;
}
.because {
  display: none;
  margin-top: 0.45rem;
  font:
    13px/1.55 ui-sans-serif,
    system-ui,
    sans-serif;
  color: var(--fg);
  cursor: auto;
}
.because.on {
  display: block;
}
.because:empty::after {
  content: "thinking…";
  color: var(--dim);
  font-style: italic;
}
.because.error,
.because.error:empty::after {
  color: var(--error);
}
.empty {
  color: var(--dim);
  font-style: italic;
}
/* Footer: one line that says what the page is doing. */
footer {
  margin-top: 2rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.status {
  font:
    12px ui-monospace,
    monospace;
  color: var(--dim);
  min-height: 1.4em;
}
.status.busy {
  color: var(--fg);
}
.status.error {
  color: var(--error);
}

#review {
  margin-top: 0.8rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--fg);
  color: var(--bg);
  cursor: pointer;
  font: inherit;
}
.privacy {
  color: var(--dim);
  font:
    12px/1.6 system-ui,
    sans-serif;
  margin-top: 1.5rem;
}
@media (max-width: 540px) {
  body {
    padding: 1.5rem 0.8rem 3rem;
  }
  .line {
    grid-template-columns: 2rem 1fr;
    gap: 0.5rem;
  }
  .id {
    display: none;
  }
  .aside {
    margin-left: 0;
  }
  .tip {
    max-width: 75vw;
  }
}

/* Shared navigation and the independent flashcard workspace. */
[hidden] {
  display: none !important;
}
.main-nav {
  max-width: 76rem;
  margin: -1rem auto 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  border-bottom: 1px solid var(--rule);
  padding: 1.2rem 0 1.8rem;
  font-family: system-ui, sans-serif;
}
.brand {
  font-size: 1.7rem;
  font-weight: 750;
  letter-spacing: -0.07em;
  text-decoration: none;
  color: var(--fg);
}
.brand span {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--dim);
}
.nav-links {
  display: flex;
  gap: 0.6rem;
}
.nav-links a {
  text-decoration: none;
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 0.8rem;
  padding: 0.8rem 2rem;
  min-width: 10rem;
  font-size: 1.2rem;
  font-weight: 650;
}
.nav-links a span {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--dim);
}
.nav-links a[aria-current] {
  background: var(--fg);
  color: var(--bg);
}
.nav-links a[aria-current] span {
  color: inherit;
  opacity: 0.75;
}
#cards-page {
  max-width: 76rem;
  font-family: system-ui, sans-serif;
}
#cards-page h1 {
  font-size: 2rem;
  letter-spacing: -0.04em;
}
#cards-page h2 {
  font-size: 1.2rem;
  margin: 0 0 1rem;
}
#cards-page h3 {
  font-size: 1rem;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  font:
    11px/1.6 system-ui,
    sans-serif;
}
.cards-heading,
.deck-title-row,
.browse-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
#cards-page button,
#cards-page .button {
  border: 1px solid var(--rule);
  background: var(--tip-bg);
  color: var(--fg);
  padding: 0.65rem 0.9rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font:
    13px/1.4 system-ui,
    sans-serif;
}
#cards-page button:hover,
#cards-page .button:hover {
  border-color: var(--dim);
}
#cards-page button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#cards-page .primary {
  background: var(--fg);
  color: var(--bg);
}
#cards-page .danger {
  color: var(--error);
}
#cards-page input {
  width: 100%;
  min-width: 0;
  background: var(--tip-bg);
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  padding: 0.7rem;
  font: inherit;
}
#cards-page label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}
.cards-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2rem;
  margin-top: 1.5rem;
}
.cards-layout.is-empty {
  grid-template-columns: minmax(0, 34rem);
  justify-content: center;
  margin-top: 3rem;
}
.cards-layout.is-empty .deck-sidebar {
  padding: 2rem;
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  background: var(--tip-bg);
  box-shadow: 0 12px 36px rgba(30, 28, 26, 0.06);
}
.cards-layout.is-empty .deck-sidebar h2 {
  margin-bottom: 0.75rem;
}
.deck-sidebar {
  padding-right: 1.5rem;
  border-right: 1px solid var(--rule);
}
#deck-list {
  display: grid;
  gap: 0.5rem;
}
#deck-list button {
  text-align: left;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  overflow-wrap: anywhere;
}
#deck-list button[aria-pressed="true"] {
  background: var(--rule);
}
#new-deck {
  border-top: 1px solid var(--rule);
  margin-top: 1.5rem;
  padding-top: 1.5rem;
}
#new-deck button {
  margin-top: 0.5rem;
}
.deck-stats {
  display: flex;
  gap: 2rem;
  margin: 1rem 0;
  color: var(--dim);
  font-size: 0.85rem;
}
.deck-stats strong {
  display: block;
  color: var(--fg);
  font-size: 1.6rem;
}
.study-start {
  width: 100%;
  margin-bottom: 1.5rem;
}
#card-form {
  background: var(--tip-bg);
  border: 1px solid var(--rule);
  border-radius: 0.7rem;
  padding: 1.2rem;
}
.card-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
#cards-page textarea {
  min-height: 6rem;
  font:
    15px/1.6 system-ui,
    sans-serif;
}
.browse-heading {
  margin-top: 1.5rem;
}
#cards-page #card-search {
  max-width: 16rem;
}
.card-row {
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
}
.card-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.card-preview p {
  margin: 0 0 0.35rem;
}
.card-preview small {
  color: var(--dim);
}
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--dim);
}
#cards-message {
  min-height: 1.4rem;
  font-size: 0.85rem;
  color: var(--clean);
}
#cards-message.error {
  color: var(--error);
}
.study-card {
  margin: 1.5rem 0;
  padding: 2.5rem 1.5rem;
  border: 1px solid var(--rule);
  background: var(--tip-bg);
  border-radius: 1rem;
  text-align: center;
  min-height: 16rem;
}
#study-front,
#study-back {
  font:
    1.7rem/1.5 Georgia,
    serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.study-card hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}
#show-answer {
  display: block;
  width: 100%;
}
#show-answer span {
  opacity: 0.65;
  font-size: 0.75rem;
  margin-left: 1rem;
}
.ratings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.ratings small {
  display: block;
  margin-top: 0.3rem;
  color: var(--dim);
}
#cards-page [data-rating="again"] {
  border-color: var(--error);
}
#cards-page [data-rating="good"] {
  border-color: var(--clean);
}
#study-finished {
  text-align: center;
  background: var(--help-wash);
  padding: 1.5rem;
  border-radius: 0.6rem;
}
@media (max-width: 700px) {
  .main-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 2rem;
  }
  .nav-links a {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 1rem;
  }
  .cards-layout {
    grid-template-columns: 1fr;
  }
  .deck-sidebar {
    border-right: 0;
    padding-right: 0;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1rem;
  }
  #deck-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card-fields {
    grid-template-columns: 1fr;
  }
  .ratings {
    grid-template-columns: repeat(2, 1fr);
  }
  .card-row {
    grid-template-columns: 1fr;
  }
}
