/* Big, plain and high-contrast: the reader is in his sixties and may be on a phone. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #55554f;
  --line: #c9c7bf;
  --green: #2f7a3f;
  --green-dark: #22602f;
  --green-wash: #e6f2e8;
  --mark: #b8860b;
  --radius: 10px;
  --font:
    "Noto Sans", "DejaVu Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 20px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 0.6em 0 0.5em;
}

h2 {
  font-size: 1.3rem;
  margin: 1.4em 0 0.4em;
}

h3 {
  font-size: 1.05rem;
  margin: 1.2em 0 0.4em;
  color: var(--muted);
}

p {
  margin: 0.6em 0;
  max-width: 44em;
}

a {
  color: var(--green-dark);
}

.lead {
  font-size: 1.1rem;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  background: #fde8e8;
  border: 2px solid #b42318;
  padding: 10px 14px;
  border-radius: var(--radius);
}

:focus-visible {
  outline: 3px solid #1f5fbf;
  outline-offset: 2px;
}

/* ── buttons ─────────────────────────────────────────────── */

button,
.button {
  font: inherit;
  cursor: pointer;
}

.big,
.button {
  display: inline-block;
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-weight: 600;
  text-decoration: none;
  min-height: 52px;
}

.big:hover,
.button:hover {
  background: var(--green-dark);
}

.linkish {
  background: none;
  border: 0;
  color: inherit;
  text-decoration: underline;
  padding: 0;
}

.chip {
  background: var(--surface);
  border: 2px solid var(--green);
  color: var(--green-dark);
  border-radius: 999px;
  padding: 8px 18px;
  margin: 0 8px 8px 0;
  min-height: 48px;
}

.chip:hover {
  background: var(--green-wash);
}

/* ── header ──────────────────────────────────────────────── */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.bar-home {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.bar-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.bar-links form {
  margin: 0;
}

.crumbs {
  margin-top: 0.4em;
}

/* ── login ───────────────────────────────────────────────── */

.login {
  max-width: 420px;
  margin: 8vh auto 0;
}

.login label {
  display: block;
  margin: 16px 0;
  font-weight: 600;
}

.login input {
  display: block;
  width: 100%;
  font: inherit;
  padding: 12px;
  margin-top: 6px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

/* ── the list of questions ───────────────────────────────── */

.packs,
.cards {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pack-link {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px;
  margin: 12px 0;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 1.1rem;
}

.pack-title {
  font-weight: 700;
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
}

.card:hover {
  border-color: var(--green);
}

.card-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 14px;
  background: #efeee9;
}

.card-title {
  font-weight: 700;
  line-height: 1.3;
}

.status {
  grid-column: 2;
  font-size: 0.85rem;
  color: var(--muted);
}

.card.done .status {
  color: var(--green-dark);
  font-weight: 700;
}

.card.done {
  border-color: #9cc7a5;
}

.card-thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  background: #ddd;
}

.card-thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.card-ask {
  padding: 12px 14px;
  font-size: 0.95rem;
}

.num {
  display: inline-block;
  min-width: 2.2em;
  text-align: center;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 8px;
}

/* ── a question ──────────────────────────────────────────── */

.q-title .num {
  font-size: 1.2rem;
  vertical-align: 0.15em;
  margin-right: 6px;
}

.samples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.samples .thumb img {
  aspect-ratio: 4 / 3;
}

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

.ask {
  background: var(--green-wash);
  border: 2px solid #9cc7a5;
  border-radius: var(--radius);
  padding: 14px 18px 8px;
  margin: 20px 0;
}

.ask > p:first-child {
  font-size: 1.15rem;
}

.ask strong {
  color: var(--green-dark);
}

.answer-label {
  display: block;
  font-weight: 700;
  margin: 12px 0 6px;
}

textarea {
  display: block;
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  resize: vertical;
}

.quick {
  margin: 12px 0 0;
  max-width: none;
}

.save-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  max-width: none;
}

#saved {
  color: var(--green-dark);
  font-weight: 600;
}

#saved.failed {
  color: #b42318;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}

.thumb {
  position: relative;
  display: block;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 6px;
  background: #ddd;
  overflow: hidden;
}

.thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

.thumb:hover {
  border-color: var(--green);
}

.thumb.marked {
  border-color: var(--mark);
}

.badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.mark-badge {
  display: none;
  left: auto;
  right: 4px;
  background: var(--mark);
}

.thumb.marked .mark-badge {
  display: block;
}

.context {
  margin: 20px 0;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.context summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.context .grid {
  margin: 10px 0 4px;
}

.q-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
}

.help-item {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 18px 10px;
  margin: 16px 0;
}

.help-item h2 {
  margin-top: 0.8em;
}

.example {
  font-family: ui-monospace, monospace;
  background: #efeee9;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
}

/* ── the viewer ──────────────────────────────────────────── */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #111;
  color: #fff;
  touch-action: none;
}

.viewer[hidden] {
  display: none;
}

.v-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.v-stage img,
.v-stage video {
  max-width: 100%;
  max-height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: 0 0;
  will-change: transform;
}

.v-stage img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  max-height: none;
}

.v-top,
.v-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.6);
}

.v-top {
  top: 0;
  justify-content: space-between;
}

.v-bottom {
  bottom: 0;
  flex-wrap: wrap;
}

.v-count {
  font-weight: 700;
}

.v-btn {
  background: #fff;
  color: #111;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-weight: 700;
  min-height: 48px;
}

.v-btn.on {
  background: #f5c542;
}

.v-side {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 64px;
  height: 120px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 3rem;
  line-height: 1;
}

.v-side:disabled {
  opacity: 0.2;
}

.v-left {
  left: 8px;
}

.v-right {
  right: 8px;
}

.v-note-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 320px;
}

.v-note-row[hidden] {
  display: none;
}

.v-note-row input {
  flex: 1;
  font: inherit;
  padding: 10px;
  border-radius: var(--radius);
  border: 0;
  min-width: 0;
}

.v-hint {
  margin-left: auto;
  color: #ccc;
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  html {
    font-size: 18px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
  .samples {
    grid-template-columns: repeat(2, 1fr);
  }
  .v-side {
    width: 44px;
    height: 90px;
    font-size: 2.2rem;
  }
  .v-hint {
    display: none;
  }
}
