/* Flashcards: /learn, a topic's sets, a set's page with its cards (public/js/learn-study.js), My learning and the
   editor (learn-editor.js). */

.learn-header {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.learn-header .page-title {
  margin-bottom: 0;
}

/* A topic page: the eyebrow sits right on its title, not a title's top margin away. */
.learn-eyebrow + .page-title {
  margin-top: calc(-1 * var(--space-2));
}

.learn-intro {
  max-width: var(--width-measure);
  margin: 0;
  color: var(--color-text-muted);
}

.learn-header-actions,
.set-actions,
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.learn-section {
  margin: var(--space-8) 0;
}

.learn-section > h2 {
  margin-bottom: var(--space-3);
  font-size: var(--text-xl);
}

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

.learn-cta {
  margin-top: var(--space-8);
  text-align: center;
}

.breadcrumb {
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

/* Audience: one segmented control, the chosen side filled with the accent. Plain links, so it works without a script. */
/* The filters: the language of the cards, the topic and the order. On a phone the language is one row, the topic
   select is full width under it, then the order. */
.learn-filter {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.learn-filter-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.audience-switch {
  flex: 1;
  font-size: var(--text-sm);
}

.topic-filter {
  display: flex;
  gap: var(--space-2);
}

/* The browser's own arrow sits on the very edge of a round select; draw one further in, like the search form's. */
.topic-select {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}

.topic-select::after {
  content: '';
  position: absolute;
  top: 50%;
  right: var(--space-4);
  width: var(--space-2);
  height: var(--space-2);
  border-right: var(--border-width-strong) solid var(--color-text-muted);
  border-bottom: var(--border-width-strong) solid var(--color-text-muted);
  transform: translateY(-75%) rotate(45deg);
  pointer-events: none;
}

.topic-filter select {
  flex: 1;
  min-width: 0;
  min-height: var(--size-control-lg);
  padding: var(--space-2) var(--space-10) var(--space-2) var(--space-4);
  appearance: none;
  color: var(--color-text);
  font-size: var(--text-base);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-control);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

/* "Make your own set": a plain link with a note, not a button. */
.make-set {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  margin: 0;
}

.make-set-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: var(--weight-semibold);
  align-self: center;
}

.make-set-note {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.audience-switch-track {
  display: flex;
  flex: 1;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-control);
  border-radius: var(--radius-pill);
}

.audience-switch a {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-height: var(--size-control-lg);
  padding: var(--space-1) var(--space-3);
  color: var(--color-text-muted);
  line-height: var(--leading-tight);
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition:
    color var(--duration-base),
    background-color var(--duration-base);
}

.audience-switch a:hover {
  color: var(--color-text);
}

.audience-switch a[aria-current='page'] {
  color: var(--color-on-accent);
  font-weight: var(--weight-semibold);
  background: var(--color-accent);
}

@media (min-width: 40rem) {
  .learn-filter {
    grid-template-columns: auto minmax(0, 16rem) auto;
    align-items: center;
    column-gap: var(--space-4);
  }

  .audience-switch {
    flex: none;
  }

  .audience-switch-track {
    flex: 0 0 auto;
  }

  .audience-switch a {
    flex: 0 0 auto;
    min-height: var(--size-control-md);
    padding: var(--space-1) var(--space-4);
  }
}

/* Order: quieter than the audience, since it only reorders. Small links, the current one underlined. */
.sort-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-4);
  font-size: var(--text-sm);
}

.sort-switch a {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-control-md);
  color: var(--color-text-muted);
  text-decoration: none;
}

.sort-switch a:hover {
  color: var(--color-text);
}

.sort-switch a[aria-current='page'] {
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
  text-decoration: underline;
  text-decoration-thickness: var(--border-width-strong);
  text-underline-offset: var(--space-1);
}

/* A topic's colour: anything with `data-hue` (topicColour(), src/learn/utils/topic-colour.ts) gets the topic's text
   colour (`--topic-ink`) from its hue and the tokens. Without a hue (the "other" topic) it is unset, and each rule
   below falls back to a page colour. */
[data-hue] {
  --topic-ink: oklch(var(--color-topic-ink-l) var(--color-topic-ink-c) var(--topic-hue));
}

/* Small spaced letters above a title: capitals in English; Chrome leaves Georgian as it is (no Mtavruli). */
.learn-eyebrow,
.set-tile-topic {
  margin: 0;
  color: var(--topic-ink, var(--color-text-muted));
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Sets: a grid of roomy cards with the topic on top, the title, a bit of the description, the facts and a call to
   study. The topic's colour is only on the eyebrow, the call and the hover border. */
.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.set-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-xl);
  transition:
    border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out),
    translate var(--duration-base) var(--ease-out);
}

.set-tile:hover {
  border-color: var(--topic-ink, var(--color-border-control));
  box-shadow: var(--shadow-sm);
  translate: 0 -2px;
}

.set-tile:active {
  translate: 0 1px;
}

/* The whole tile is the link (the title's ::after covers it). */
.set-tile-link {
  color: var(--color-text);
  font-size: var(--text-xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.set-tile-link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.set-tile-description {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.set-tile-meta,
.set-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.set-tile-likes {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* Pushed to the bottom, so the calls line up across a row of tiles. */
.set-tile-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: auto;
  padding-top: var(--space-1);
  color: var(--topic-ink, var(--color-accent));
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.set-tile-cta .icon {
  transition: translate var(--duration-base) var(--ease-out);
}

.set-tile:hover .set-tile-cta .icon {
  translate: 3px 0;
}

.visibility-private {
  opacity: var(--opacity-muted);
}

/* A set's page. */
.set-header {
  display: grid;
  gap: var(--space-2);
}

.set-header .page-title {
  margin-bottom: 0;
}

.set-forked,
.set-description {
  max-width: var(--width-measure);
  margin: 0;
}

.set-forked {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.set-description {
  white-space: pre-line;
}

/* Under the flashcards, as wide as they are: what the set is about, then like, copy and share. */
.set-about {
  display: grid;
  gap: var(--space-3);
  max-width: var(--width-deck);
  margin: 0 auto;
}

/* A private set with no description has nothing here: only the empty row of buttons. */
.set-about:not(:has(> :not(.set-actions:empty))) {
  display: none;
}

.set-actions:empty {
  display: none;
}

.set-actions .button {
  min-height: var(--size-control-md);
}

@media (pointer: fine) {
  .set-actions .button {
    min-height: auto;
  }
}

.like-button[aria-pressed='true'] {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* The flashcards. Every card sits in the same grid cell, so the one leaving moves over the one coming in. */
.study {
  --card-height: var(--size-flashcard);

  max-width: var(--width-deck);
  margin: var(--space-4) auto var(--space-6);
}

.study-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.study-count {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
}

/* Options scroll sideways in one row instead of wrapping into a tall block. */
.study-options {
  display: flex;
  gap: var(--space-2);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.study-options::-webkit-scrollbar {
  display: none;
}

.study-options .chip {
  flex: none;
  min-height: var(--size-control-md);
  padding: var(--space-1) var(--space-4);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  white-space: nowrap;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-control);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.study-options .chip[aria-pressed='true'] {
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.study-options .chip[hidden] {
  display: none;
}

.study-progress {
  height: var(--space-1);
  margin-top: var(--space-3);
  overflow: hidden;
  background: var(--color-border);
  border-radius: var(--radius-pill);
}

.study-progress-fill {
  display: block;
  height: 100%;
  background: var(--color-accent);
  border-radius: inherit;
  transform: scaleX(var(--done, 0));
  transform-origin: left;
  transition: transform var(--duration-base) var(--ease-out);
}

.study-stage {
  display: grid;
  min-height: var(--card-height);
  margin: var(--space-4) 0;
  perspective: 1200px;
}

/* No horizontal page scroll while a card flies off the side on a phone. */
@media (max-width: 47.99rem) {
  .study {
    overflow-x: clip;
  }
}

.study-stage > * {
  grid-area: 1 / 1;
}

.flashcard {
  position: relative;
  z-index: var(--z-raised);
  min-height: var(--card-height);
  cursor: grab;
  /* The drag (learn-swipe.js) moves the card sideways; a vertical drag still scrolls the page. */
  touch-action: pan-y;
  user-select: none;
  transform: translateX(var(--drag-x, 0)) rotate(var(--tilt, 0deg));
  transition:
    transform var(--duration-base) var(--ease-out),
    opacity var(--duration-base) var(--ease-out);
}

.flashcard.dragging {
  cursor: grabbing;
  transition: none;
}

/* The flip: two faces back to back in one rotating box. */
.flashcard-inner {
  position: relative;
  display: grid;
  min-height: inherit;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  grid-area: 1 / 1;
  padding: var(--space-8) var(--space-5);
  text-align: center;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flashcard-face.back {
  transform: rotateY(180deg);
  background: color-mix(in srgb, var(--color-accent) 5%, var(--color-surface));
}

.flashcard-word {
  margin: 0;
  font-family: var(--font-title);
  font-size: var(--text-display);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  overflow-wrap: anywhere;
}

.flashcard-script {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-lg);
}

.flashcard-meaning {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--weight-medium);
  overflow-wrap: anywhere;
}

.flashcard-note {
  max-width: var(--width-measure);
  margin: 0;
  color: var(--color-text-muted);
  white-space: pre-line;
}

.flashcard-link {
  font-size: var(--text-sm);
}

.flashcard-hint {
  position: absolute;
  bottom: var(--space-3);
  letter-spacing: 0.02em;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

.flashcard-hidden-text {
  margin: 0;
  color: var(--color-text-muted);
}

/* As the card leaves up ("I know it") or down ("Put back"), a stamp says what happened. */
.flashcard-stamp {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  z-index: 1;
  padding: var(--space-1) var(--space-3);
  font-weight: var(--weight-bold);
  border: var(--border-width-strong) solid currentColor;
  border-radius: var(--radius-md);
  translate: -50% 0;
  pointer-events: none;
  opacity: 0;
}

.flashcard-stamp.up {
  color: var(--color-success);
}

.flashcard-stamp.down {
  color: var(--color-accent);
}

/* Leaving: sideways for a move, up and away for "I know it", down for putting it back. leaveMs in learn-study.js
   matches the duration here. */
.flashcard.leaving {
  z-index: calc(var(--z-raised) + 1);
  pointer-events: none;
  opacity: 0;
  transition:
    transform 380ms var(--ease-out),
    opacity 380ms var(--ease-out);
}

.flashcard.leave-left {
  transform: translateX(-110%) rotate(-8deg);
}

.flashcard.leave-right {
  transform: translateX(110%) rotate(8deg);
}

.flashcard.leave-up {
  transform: translateY(-70%) scale(0.9);
}

.flashcard.leave-down {
  transform: translateY(40%) scale(0.9);
}

.flashcard.leave-up .flashcard-stamp.up,
.flashcard.leave-down .flashcard-stamp.down {
  opacity: 1;
}

.flashcard.entering {
  animation: flashcard-in 380ms var(--ease-out) backwards;
}

.flashcard.from-right {
  --enter-from: translateX(60%) rotate(4deg);
}

.flashcard.from-left {
  --enter-from: translateX(-60%) rotate(-4deg);
}

.flashcard.from-grow {
  --enter-from: scale(0.92);
}

@keyframes flashcard-in {
  from {
    opacity: 0;
    transform: var(--enter-from);
  }
}

/* The round's summary and an empty pile: a card of their own. */
.flashcard-summary {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-8);
  text-align: center;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  cursor: default;
}

.flashcard-summary-title {
  margin: 0;
}

.flashcard-summary-text {
  max-width: var(--width-measure);
  margin: 0;
}

.flashcard-summary-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

/* Prev, flip and next in one row of big targets, "I know it" under them. */
.study-controls {
  display: grid;
  grid-template-columns: var(--size-control-lg) minmax(0, 1fr) var(--size-control-lg);
  grid-template-areas:
    'prev flip next'
    'archive archive archive';
  gap: var(--space-2);
}

.study-controls > [data-study-prev] {
  grid-area: prev;
}

.study-controls > [data-study-next] {
  grid-area: next;
}

.study-controls > .study-flip {
  grid-area: flip;
  color: var(--color-on-accent);
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.study-controls > .study-archive,
.study-controls > .study-restore {
  grid-area: archive;
}

.study-controls > .study-archive[hidden],
.study-controls > .study-restore[hidden] {
  display: none;
}

.study-controls .button {
  min-height: var(--size-control-lg);
  font-size: var(--text-base);
}

.study-controls .study-archive,
.study-controls .study-restore {
  min-height: var(--size-control-md);
  font-size: var(--text-md);
}

.study-controls .study-flip:where(:hover:not(:disabled)) {
  background: color-mix(in srgb, var(--color-accent) 85%, var(--color-text));
  border-color: transparent;
}

.study-controls .study-flip:disabled {
  background: var(--color-surface);
  border-color: var(--color-border-control);
  color: var(--color-text);
}

.study-controls .study-move {
  width: var(--size-control-lg);
  height: var(--size-control-lg);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-control);
  border-radius: var(--radius-full);
}

.study-hint {
  margin: var(--space-3) 0 0;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  text-align: center;
}

/* Keys on a desktop, gestures on a touch screen. */
.study-gestures {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .study-keys {
    display: none;
  }

  .study-gestures {
    display: inline;
  }

  /* Every control is at least 44px. */
  .set-actions .button-small,
  .study-options .chip,
  .study-controls .study-archive,
  .study-controls .study-flip,
  .set-editor .button,
  .audience-switch-track a,
  .sort-switch a,
  .topic-links a {
    min-height: var(--size-control-touch);
  }

  .card-edit-actions .icon-button {
    width: var(--size-control-touch);
    height: var(--size-control-touch);
  }

  .breadcrumb a {
    display: inline-block;
    min-height: var(--size-control-touch);
    line-height: var(--size-control-touch);
  }

  /* The whole row is the target, not the 20px box inside it. */
  .choice {
    min-height: var(--size-control-touch);
  }
}

.study-noscript {
  align-self: center;
  color: var(--color-text-muted);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .study-progress-fill,
  .flashcard,
  .flashcard-inner,
  .flashcard.leaving {
    transition: none;
  }

  .flashcard.entering {
    animation: none;
  }

  .set-tile,
  .set-tile-cta .icon {
    transition: none;
  }

  .set-tile:hover,
  .set-tile:active,
  .set-tile:hover .set-tile-cta .icon {
    translate: none;
  }
}

/* Every card, listed under the flashcards. */
.card-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
}

.card-row-front {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.card-row-word {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

.card-row-back {
  display: grid;
  gap: var(--space-1);
}

.card-row-note {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  white-space: pre-line;
}

.card-row-link {
  font-size: var(--text-sm);
}

.card-row-hidden {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
}

@media (max-width: 35rem) {
  .card-row {
    grid-template-columns: 1fr;
  }

  .card-row-back {
    padding-top: var(--space-2);
    border-top: var(--border-width) solid var(--color-border);
  }
}

/* My learning: "from my favorites" opens a small form. */
.from-favorites {
  margin-bottom: var(--space-6);
}

.from-favorites > summary {
  display: inline-flex;
  list-style: none;
}

.from-favorites > summary::-webkit-details-marker {
  display: none;
}

.from-favorites-form {
  display: grid;
  gap: var(--space-3);
  max-width: var(--width-form);
  margin-top: var(--space-3);
}

.from-favorites-form label {
  display: grid;
  gap: var(--space-1);
}

/* The editor. */
.set-editor {
  display: grid;
  gap: var(--space-5);
  max-width: var(--width-reading);
}

.set-editor .field {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}

.set-editor legend {
  margin-bottom: var(--space-2);
  font-weight: var(--weight-semibold);
}

.set-editor label:not(.choice) {
  font-weight: var(--weight-semibold);
}

.set-editor input:not([type='radio'], [type='checkbox']),
.set-editor textarea,
.set-editor select,
.from-favorites-form input,
.from-favorites-form select {
  width: 100%;
  font: inherit;
  /* The site's colours, not the browser's (a flat grey box in dark mode): the surface of the choice rows below, the
     control outline, the accent on focus. */
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-control);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-base);
}

.set-editor input:not([type='radio'], [type='checkbox']):focus,
.set-editor textarea:focus,
.set-editor select:focus,
.from-favorites-form input:focus,
.from-favorites-form select:focus {
  border-color: var(--color-accent);
}

.set-editor ::placeholder,
.from-favorites-form ::placeholder {
  color: var(--color-text-placeholder);
}

/* Fields are big enough to tap; 16px text also keeps iOS from zooming in. */
.set-editor input:not([type='radio'], [type='checkbox']),
.set-editor select,
.from-favorites-form input,
.from-favorites-form select {
  min-height: var(--size-control-lg);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
}

.set-editor textarea {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
}

@media (pointer: fine) {
  .set-editor input:not([type='radio'], [type='checkbox']),
  .set-editor select,
  .from-favorites-form input,
  .from-favorites-form select {
    min-height: var(--size-control-md);
  }
}

/* Each choice is a whole tappable row. */
.choice {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 7%, var(--color-surface));
}

.choice input {
  flex: none;
  width: var(--space-5);
  height: var(--space-5);
  margin: 0;
  accent-color: var(--color-accent);
  translate: 0 var(--space-half);
}

.choice span {
  color: var(--color-text-muted);
}

.choice strong {
  color: var(--color-text);
}

.category-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.category-suggest input {
  flex: 1 1 10rem;
  width: auto;
}

.card-editor > h2 {
  font-size: var(--text-xl);
}

.card-picker {
  position: relative;
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.card-picker-list {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: var(--z-dropdown);
  max-height: 20rem;
  margin: var(--space-1) 0 0;
  padding: var(--space-1);
  overflow-y: auto;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.card-picker-list > * {
  display: grid;
  gap: var(--space-half);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.card-picker-list > [aria-selected='true'],
.card-picker-list > :hover {
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.card-picker-word {
  font-weight: var(--weight-semibold);
}

.card-picker-detail {
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.card-picker-own .card-picker-word {
  color: var(--color-accent);
  font-weight: var(--weight-regular);
}

.card-edit-list {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
}

.card-edit {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
}

.card-edit-number {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.card-edit-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: var(--space-2) var(--space-3);
}

.card-edit-fields label:not(.choice) {
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
}

.card-edit-note {
  grid-column: 1 / -1;
}

.card-edit-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* The template has one left-arrow icon for both moves: up turns it up, down turns it down. */
.card-edit-actions [data-move='-1'] .icon {
  rotate: 90deg;
}

.card-edit-actions [data-move='1'] .icon {
  rotate: -90deg;
}

/* On a phone the fields take the full width and the card's buttons sit in a row above them. */
@media (max-width: 35rem) {
  .card-edit {
    grid-template-columns: 1fr;
  }

  .card-edit-number {
    display: none;
  }

  .card-edit-actions {
    grid-row: 1;
    flex-direction: row;
    justify-content: flex-end;
  }

  .card-edit-actions .icon-button {
    width: var(--size-control-md);
    height: var(--size-control-md);
  }

  .card-edit-fields {
    grid-template-columns: 1fr;
  }
}

/* One example sentence per card: two lines at most (the editor allows 120 characters). */
.flashcard-example,
.flashcard-example-translation {
  display: -webkit-box;
  max-width: var(--width-measure);
  margin: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.flashcard-example {
  font-size: var(--text-sm);
}

.flashcard-example-translation {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.flashcard-example-label {
  color: var(--color-text-muted);
  font-weight: var(--weight-semibold);
}

.card-row-example {
  flex-basis: 100%;
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.card-row-example-translation {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

/* The editor: the direction of the dictionary picker, the save note, the history and the name dialog. */
.card-picker-direction {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.set-history {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.set-history-meta {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.name-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Every topic as a plain link under the hub's sets: the select is not crawlable, these are. */
.topic-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-8);
  font-size: var(--text-sm);
}

.topic-links-label {
  color: var(--color-text-muted);
}

.topic-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-control-md);
  color: var(--topic-ink, var(--color-accent));
}

/* "From the dictionary" on a card in the editor: a small outlined tag beside the vulgar checkbox, not a filled block
   stretched over its grid cell. */
.card-linked {
  justify-self: start;
  align-self: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  color: var(--color-accent);
  background: transparent;
  border: var(--border-width) solid color-mix(in srgb, var(--color-accent) 45%, transparent);
}

.card-linked::before {
  content: '';
  width: var(--space-2);
  height: var(--space-2);
  background: currentColor;
  border-radius: var(--radius-pill);
}

/* The vulgar checkbox with its info button beside it; the explanation opens underneath, across both. */
.card-vulgar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.card-vulgar > .choice {
  flex: 1;
}

.card-vulgar-hint {
  flex-basis: 100%;
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.card-vulgar [aria-expanded='true'] {
  color: var(--color-accent);
}

@media (pointer: coarse) {
  .card-vulgar .icon-button {
    width: var(--size-control-touch);
    height: var(--size-control-touch);
  }
}
