:root {
  --background: #11110f;
  --background-deep: #191917;
  --text: #d0d0d0;
  --muted: #999;
  --faint: #777;
  --line: #555;
  --strong-line: #d0d0d0;
  --correct: #72c894;
  --imperfect: #d6a94d;
  --incorrect: #f2777f;
  --focus: #79a9e8;
  --measure: 1180px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: var(--text);
  background: var(--background);
  color-scheme: dark;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

[hidden] { display: none !important; }

.site-header {
  position: fixed;
  z-index: 10;
  inset: 0 auto auto 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(calc(100% - 44px), var(--measure));
  height: 82px;
  border-bottom: 3px solid var(--strong-line);
  pointer-events: none;
}

.site-header > * { pointer-events: auto; }

.wordmark {
  color: var(--focus);
  font-size: 14px;
  font-weight: 700;
}

.word-count {
  display: flex;
  gap: 0.38em;
  align-items: baseline;
  padding: 9px 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0;
}

#word-count-number {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

main { min-height: 100vh; }

.view {
  width: min(calc(100% - 44px), var(--measure));
  min-height: 100vh;
  margin: 0 auto;
}

.login {
  display: grid;
  align-content: center;
  width: min(calc(100% - 44px), 460px);
  padding: 96px 0;
}

.login h1, .words-dialog h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
}

.login h1 { margin-bottom: 42px; font-size: 24px; }

.login-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  border-bottom: 2px solid var(--strong-line);
  transition: border-color 160ms ease;
}

.field-row:focus-within { border-color: var(--text); }

.field-row input {
  min-width: 0;
  padding: 12px 0 13px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
}

.field-row button {
  align-self: center;
  padding: 8px 0 8px 24px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.field-row button:disabled { color: var(--faint); cursor: wait; }

.form-note {
  min-height: 1.5em;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.text-action {
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}

.text-action:hover { color: var(--text); border-color: var(--faint); }

.practice { padding: 0 0 90px; }

.exercise {
  width: 100%;
  padding-top: 34vh;
}

.phrase {
  max-width: none;
  margin: 0 auto;
  font-size: clamp(24px, 2.8vw, 32px);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
  text-align: center;
  text-wrap: pretty;
}

.translation-form { margin-top: clamp(40px, 7vh, 64px); }

.translation-form textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  max-height: 180px;
  padding: 4px 0 12px;
  resize: none;
  overflow-y: auto;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  caret-color: var(--focus);
  font-size: clamp(18px, 2.3vw, 23px);
  line-height: 1.45;
  text-align: center;
  transition: border-color 160ms ease;
}

.translation-form textarea::placeholder { color: #747168; opacity: 1; }
.translation-form textarea:focus::placeholder { color: transparent; }
.translation-form textarea:focus { border-color: var(--strong-line); }

.phase-action {
  display: block;
  margin: 15px auto 0;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.phase-action:hover {
  border-color: var(--strong-line);
  color: var(--text);
}

.evaluating {
  display: flex;
  justify-content: center;
  gap: 7px;
  height: 82px;
  padding-top: 56px;
}

.evaluating > span:not(.visually-hidden) {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: consider 1.1s infinite ease-in-out;
}

.evaluating > span:nth-child(2) { animation-delay: 120ms; }
.evaluating > span:nth-child(3) { animation-delay: 240ms; }

@keyframes consider { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.evaluation { margin-top: clamp(36px, 6vh, 58px); text-align: center; }
.evaluation:focus { outline: 0; }

.evaluated-answer {
  font-size: clamp(18px, 2.3vw, 23px);
  line-height: 1.65;
  text-wrap: balance;
}

.evaluated-answer .token {
  display: inline;
  padding: 1px 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  line-height: inherit;
}

.evaluated-answer button.token { cursor: help; border-bottom: 1px solid currentColor; }
.token.correct { color: var(--correct); }
.token.imperfect { color: var(--imperfect); }
.token.incorrect { color: var(--incorrect); }
.token.order { text-decoration: underline wavy; text-decoration-thickness: 1px; text-underline-offset: 5px; }

.missing-mark {
  display: inline-block;
  margin: 0 0.12em;
  padding: 0;
  border: 0;
  color: var(--incorrect);
  background: transparent;
  cursor: help;
  font-size: 0.62em;
  vertical-align: 0.32em;
}

.summary {
  max-width: 720px;
  margin: 5px auto 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.explanation {
  max-width: 640px;
  min-height: 72px;
  margin: 14px auto 0;
  padding: 8px 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.explanation strong { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.03em; }

.natural-translation {
  margin: 18px auto 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.evaluation .phase-action { margin-top: 24px; }

.practice-error {
  min-height: 1.4em;
  margin: 22px 0 0;
  color: var(--incorrect);
  font-size: 13px;
  text-align: center;
}

.exercise.leaving { animation: leave 180ms ease forwards; }
.exercise.arriving { animation: arrive 260ms ease both; }
@keyframes leave { to { opacity: 0; transform: translateY(-6px); } }
@keyframes arrive { from { opacity: 0; transform: translateY(7px); } }

.words-dialog {
  width: min(calc(100% - 30px), 760px);
  max-height: min(84vh, 760px);
  padding: 34px clamp(24px, 5vw, 48px) 25px;
  overflow: hidden;
  border: 2px solid var(--strong-line);
  border-radius: 0;
  background: var(--background-deep);
  color: var(--text);
  box-shadow: none;
}

.words-dialog::backdrop { background: rgba(0, 0, 0, .72); }
.dialog-header { display: flex; justify-content: space-between; align-items: start; }
.words-dialog h2 { font-size: 22px; }

.close-button {
  padding: 0 4px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 29px;
  font-weight: 200;
  line-height: 1;
}

.words-list { max-height: calc(84vh - 190px); margin-top: 35px; overflow-y: auto; padding-right: 8px; }
.word-group + .word-group { margin-top: 31px; }
.word-group h3 { margin: 0 0 10px; color: var(--faint); font-size: 11px; letter-spacing: .03em; }
.word-row { display: grid; grid-template-columns: minmax(130px, .8fr) 1.2fr; gap: 24px; padding: 10px 0; border-top: 1px solid var(--line); }
.word-german { font-size: 14px; font-weight: 700; }
.word-meaning { color: var(--muted); font-size: 13px; line-height: 1.45; }
.empty-words { margin: 70px 0; color: var(--muted); text-align: center; }
.dialog-footer { display: flex; justify-content: space-between; margin-top: 25px; padding-top: 18px; border-top: 2px solid var(--strong-line); }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 560px) {
  .site-header { height: 68px; }
  .practice { padding-top: 88px; }
  .phrase { font-size: 23px; }
  .word-row { grid-template-columns: 1fr; gap: 5px; }
  .words-dialog { padding-top: 27px; }
}

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