:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.975 0.004 330);
  --surface-strong: oklch(0.94 0.008 330);
  --ink: oklch(0.18 0.025 330);
  --muted: oklch(0.43 0.018 330);
  --primary: oklch(0.48 0.145 330);
  --primary-strong: oklch(0.39 0.15 330);
  --primary-soft: oklch(0.94 0.035 330);
  --accent: oklch(0.58 0.13 175);
  --accent-soft: oklch(0.92 0.035 175);
  --warning: oklch(0.58 0.14 42);
  --warning-soft: oklch(0.94 0.045 70);
  --danger-soft: oklch(0.94 0.035 25);
  --line: oklch(0.88 0.006 330);
  --focus: oklch(0.62 0.16 175);
  --radius: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

button:hover {
  background: var(--surface);
  border-color: oklch(0.74 0.018 330);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 1.9rem;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.55rem;
  line-height: 1.12;
  text-wrap: balance;
}

.app {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 16px 14px 28px;
}

.app-header {
  padding: 8px 0 12px;
}

.kicker {
  margin-bottom: 4px;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.session-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.session-stats span {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
}

.session-stats strong {
  display: block;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
}

.deck-panel,
.study-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.deck-panel {
  margin-bottom: 12px;
  overflow: clip;
}

.deck-panel summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  min-height: 58px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

.deck-panel summary::-webkit-details-marker {
  display: none;
}

.deck-panel summary::after {
  content: "+";
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  color: var(--primary-strong);
  font-size: 1.35rem;
  font-weight: 700;
}

.deck-panel[open] summary::after {
  content: "−";
}

.deck-panel summary span {
  font-weight: 800;
}

.deck-panel summary small {
  color: var(--muted);
}

.deck-controls {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.search-field {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.search-field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  padding: 0 12px;
}

.search-field input::placeholder {
  color: oklch(0.47 0.018 330);
}

.filter-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.filter-group legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 2px;
}

.chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: oklch(0.25 0.06 175);
}

.selector-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#resetProgressButton {
  grid-column: 1 / -1;
}

.pose-list {
  display: grid;
  max-height: 264px;
  overflow: auto;
  gap: 8px;
  padding-right: 2px;
}

.pose-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.pose-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.pose-item input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.pose-item strong,
.pose-item small {
  display: block;
}

.pose-item strong {
  line-height: 1.2;
}

.pose-item small {
  margin-top: 2px;
  color: var(--muted);
}

.full-button {
  width: 100%;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--bg);
}

.primary-button:hover {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
}

.study-panel {
  padding: 12px;
}

.study-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.study-toolbar button {
  min-width: 104px;
  padding: 0 12px;
}

.mode-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.mode-control legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.mode-control label {
  min-width: 0;
}

.mode-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-control span {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 0.84rem;
  font-weight: 800;
  text-align: center;
}

.mode-control input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.mode-control input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.flashcard {
  min-height: 440px;
}

.card-empty {
  display: grid;
  align-content: center;
  min-height: 420px;
  padding: 24px 10px;
}

.card-empty p {
  margin-bottom: 0;
  color: var(--muted);
}

.card-content {
  display: grid;
  gap: 10px;
}

.is-hidden {
  display: none;
}

.card-front {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.card-meta span,
.risk-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.card-meta span:first-child {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.card-meta span:last-child {
  background: var(--accent-soft);
  color: oklch(0.26 0.07 175);
}

#cardEnglish {
  margin-bottom: 8px;
}

#cardPrompt {
  margin-bottom: 0;
  color: var(--muted);
}

.reveal-grid {
  display: grid;
  gap: 8px;
}

.reveal-section {
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.reveal-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  text-align: left;
}

.reveal-toggle strong {
  color: var(--primary-strong);
  font-size: 0.84rem;
}

.reveal-toggle[aria-expanded="true"] {
  background: var(--primary-soft);
}

.reveal-body {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.reveal-body p {
  margin-bottom: 0;
}

.reveal-body ul {
  margin: 0;
  padding-left: 20px;
}

.reveal-body li + li {
  margin-top: 6px;
}

.name-stack {
  display: grid;
  gap: 4px;
}

.name-stack strong {
  font-size: 1.18rem;
}

.name-stack span {
  color: var(--muted);
}

.risk-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.risk-chip {
  background: var(--danger-soft);
  color: oklch(0.35 0.12 25);
}

.card-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 0 0;
  background: var(--bg);
}

#knownButton {
  border-color: var(--accent);
  color: oklch(0.26 0.07 175);
}

#reviewButton {
  border-color: var(--warning);
  color: oklch(0.34 0.11 42);
}

@media (min-width: 700px) {
  .app {
    padding-top: 24px;
  }

  h1 {
    font-size: 2.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
