:root {
  --paper: #fff8ec;
  --card: #ffffff;
  --ink: #1d2b4f;
  --muted: #5d6b8a;
  --line: #e8dcc6;
  --primary: #2b4c9b;
  --primary-ink: #ffffff;
  --success: #1f8a4c;
  --success-soft: #dff3e6;
  --miss: #b25b00;
  --miss-soft: #fdebd3;
  --masculine: #2b5fd9;
  --feminine: #d23c45;
  --radius: 20px;
  --shadow: 0 3px 0 rgba(29, 43, 79, 0.12);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151b2c;
    --card: #1f2840;
    --ink: #f1ece2;
    --muted: #a7b0c7;
    --line: #34405f;
    --primary: #7d9cff;
    --primary-ink: #10162a;
    --success: #5fd08d;
    --success-soft: #1c3a2a;
    --miss: #ffb35c;
    --miss-soft: #3e2c17;
    --masculine: #8fb0ff;
    --feminine: #ff8c93;
    --shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 20px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 40px;
  min-height: 100dvh;
}

h1, h2, h3 { margin: 0.2em 0; line-height: 1.2; }
h1 { font-size: 2.4rem; }

button, .file-button {
  font: inherit;
  color: inherit;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 20px;
  min-height: 56px;
  cursor: pointer;
  box-shadow: var(--shadow);
  touch-action: manipulation;
}
button:active { transform: translateY(2px); box-shadow: none; }
button:disabled { cursor: default; }

.button-primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
  font-weight: 700;
  width: 100%;
  margin-top: 16px;
}
.button-huge { font-size: 1.6rem; min-height: 96px; }
.button-secondary { display: inline-block; margin: 8px 8px 0 0; }

.home-header { text-align: center; margin: 24px 0; }
.today-summary { font-size: 1.15rem; color: var(--muted); }
.home-menu { display: grid; gap: 14px; margin-top: 28px; }
.home-menu button { display: flex; justify-content: space-between; align-items: center; text-align: left; font-size: 1.2rem; }

.badge {
  display: inline-block;
  min-width: 2em;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--paper);
  border: 2px solid var(--line);
  text-align: center;
  font-weight: 700;
  font-size: 0.9em;
}

.hint { color: var(--muted); font-size: 0.95rem; }
.warning, .message {
  background: var(--miss-soft);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.95rem;
}

/* Session */
.session-bar { display: flex; align-items: center; gap: 14px; }
.button-quit { min-height: 48px; padding: 8px 16px; box-shadow: none; }
.progress { flex: 1; height: 16px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--success); border-radius: 999px; transition: width 0.3s; }

.exercise { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 16px; }
.label { color: var(--muted); font-weight: 600; margin: 0; }
.picture-large { font-size: clamp(96px, 26vw, 180px); line-height: 1.1; }
.picture-text { font-size: 2.2rem; font-weight: 700; padding: 30px 0; }
.german { color: var(--muted); font-size: 1.2rem; margin: 0; }
.instruction { font-size: 1.1rem; margin: 8px 0 0; }
.answer { font-size: 1.4rem; margin: 0; }
.hook { background: var(--card); border: 2px dashed var(--line); border-radius: 12px; padding: 8px 16px; }

.speak-word { font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; border: none; background: none; box-shadow: none; padding: 4px 12px; }
.french { font-weight: 800; }
.gender-m { color: var(--masculine); }
.gender-f { color: var(--feminine); }

.button-listen { font-size: 1.3rem; }
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: 100%; margin-top: 8px; }
.option { min-height: 150px; display: grid; place-items: center; padding: 8px; }
.picture-option { font-size: 72px; }
.option .picture-text { font-size: 1.3rem; padding: 0; }
.option-correct { border-color: var(--success); background: var(--success-soft); }
.option-wrong { border-color: var(--miss); background: var(--miss-soft); animation: shake 0.35s; }
.option:disabled:not(.option-correct):not(.option-wrong) { opacity: 0.45; }

@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.flip-card {
  width: 100%;
  max-width: 520px;
  min-height: 260px;
  display: grid;
  place-items: center;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-top: 8px;
}
.flip-card.is-flipped { animation: flip-in 0.4s ease-out; border-color: var(--primary); }
.flip-face { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.flip-german { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; margin: 0; }
.flip-picture { font-size: 64px; line-height: 1.1; }
@keyframes flip-in {
  from { transform: perspective(800px) rotateY(90deg); }
  to { transform: perspective(800px) rotateY(0); }
}
.grade-buttons button:disabled { opacity: 0.45; }

.grade-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; margin-top: 8px; }
.button-knew { border-color: var(--success); background: var(--success-soft); font-weight: 700; min-height: 80px; }
.button-miss { border-color: var(--miss); background: var(--miss-soft); font-weight: 700; min-height: 80px; }

.hook-field { width: 100%; text-align: left; font-size: 0.95rem; color: var(--muted); margin-top: 8px; }
input[type="text"], textarea, select {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  width: 100%;
  margin-top: 4px;
}
select { width: auto; margin-left: 8px; }

.finished h2 { font-size: 2rem; }

/* Typing and dictée */
.typed-answer { font-size: 1.8rem; text-align: center; max-width: 520px; margin-top: 8px; }
.accent-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 560px; }
.accent { min-width: 52px; min-height: 52px; padding: 6px; font-size: 1.4rem; box-shadow: none; }
.picture-medium { font-size: 80px; line-height: 1.1; }
.feedback { font-size: 1.3rem; font-weight: 700; margin: 8px 0 0; padding: 6px 18px; border-radius: 12px; }
.feedback-exact { background: var(--success-soft); color: var(--success); }
.feedback-close { background: var(--miss-soft); color: var(--miss); }
.feedback-wrong { background: var(--miss-soft); }
.typed-own { color: var(--muted); margin: 0; }
mark { background: #ffd84d; color: #1d2b4f; border-radius: 6px; padding: 0 3px; }

/* Screens with a back button */
.screen-header { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.screen-header button { min-height: 48px; padding: 6px 16px; }

.legend { font-size: 0.9rem; }

details { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); margin: 12px 0; padding: 4px 16px; }
summary { display: flex; align-items: center; gap: 12px; min-height: 52px; cursor: pointer; font-weight: 700; }
summary small { color: var(--muted); font-weight: 400; margin-left: auto; }
.box-5 { border-color: #e2b23a; }

.word-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.manage-list { list-style: none; padding: 0; }
.manage-list li { border-top: 1px solid var(--line); }
.manage-item { display: flex; align-items: center; gap: 8px; }
.manage-item .manage-row { flex: 1; }
.button-edit { min-height: 44px; padding: 4px 12px; box-shadow: none; }
.edit-form { width: 100%; padding: 10px 0; }
.edit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.edit-actions select { margin-left: 0; }
.edit-actions .button-secondary { margin: 0; }
.edit-save { width: auto; margin: 0 0 0 auto; }
.manage-row { display: flex; align-items: center; gap: 14px; min-height: 52px; cursor: pointer; }
.manage-row input[type="checkbox"] { width: 26px; height: 26px; flex: none; accent-color: var(--feminine); }
.manage-row:has(input:checked) { background: var(--miss-soft); }
.select-all { color: var(--muted); font-size: 0.95rem; }
.manage-list small { color: var(--muted); margin-left: 6px; }
.bulk-bar { position: sticky; bottom: 12px; margin-top: 12px; }
.button-danger { width: 100%; background: var(--feminine); border-color: var(--feminine); color: #fff; font-weight: 700; }

.panel { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
details.panel { padding: 4px 16px; }
.panel details { background: var(--paper); }
.example { background: var(--paper); border-radius: 12px; padding: 10px 14px; font-size: 0.9rem; white-space: pre-wrap; }
code { font-size: 0.95em; }

@media (min-width: 900px) and (orientation: landscape) {
  .options { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
