@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600&display=swap');

:root {
  --bg:          #f5efe6;
  --surface:     #faf6ef;
  --ink:         #2b2a26;
  --ink-soft:    #6b665e;
  --line:        #e3dccf;
  --accent:      #2f6b5e;
  --accent-soft: #d4e3df;
  --correct:     #4a7c59;
  --wrong:       #b85450;
  --wrong-soft:  #f3dad8;
  --shadow:      0 1px 2px rgba(43,42,38,0.04);
  --radius:      12px;
  --radius-sm:   8px;
}

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

html { font-size: 16px; }

body {
  font-family: 'Lexend', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  letter-spacing: 0.01em;
  min-height: 100vh;
}

/* ── Layout ── */
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 24px 0;
  gap: 20px;
}
.screen.active { display: flex; }

/* ── Progress bar ── */
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-action {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.card-action:hover { background: #f0ebe1; }
.card-action:active { background: var(--accent-soft); }

.card-action .card-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}
.card-action .card-sub {
  font-size: 0.875rem;
  color: var(--ink-soft);
}

/* ── Buttons ── */
button {
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s, opacity 0.15s;
  line-height: 1.4;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 14px 24px;
  width: 100%;
  font-weight: 500;
  font-size: 1.05rem;
}
.btn-primary:hover:not(:disabled) { background: #255a4e; }
.btn-primary:active:not(:disabled) { background: #1d4a40; }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 12px 20px;
}
.btn-secondary:hover:not(:disabled) { background: var(--line); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 12px;
  font-size: 0.875rem;
}
.btn-ghost:hover { color: var(--ink); }

.btn-icon {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.btn-icon:hover { background: var(--accent-soft); color: var(--accent); }

/* ── Session size selector ── */
.session-sizes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.session-size-btn {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink-soft);
  transition: all 0.15s;
}
.session-size-btn.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 500;
}

/* ── Mode tabs ── */
.mode-tabs {
  display: flex;
  background: var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.mode-tab {
  flex: 1;
  background: transparent;
  color: var(--ink-soft);
  padding: 10px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 400;
  text-align: center;
}
.mode-tab.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--shadow);
}

/* ── Select dropdowns ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 7L11 1' stroke='%236b665e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Progress text ── */
.progress-text {
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.progress-text strong { color: var(--ink); }

/* ── Word visual (card center) ── */
.word-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  font-size: 80px;
  line-height: 1;
}
.word-visual img {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

/* ── Study card ── */
.study-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.word-en {
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.word-ru {
  font-size: 1.1rem;
  color: var(--ink-soft);
  font-weight: 400;
}
.word-forms {
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--bg);
  border-radius: 6px;
  padding: 6px 12px;
  width: 100%;
}

/* ── Dots (correct counter) ── */
.correct-dots {
  display: flex;
  gap: 6px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.2s;
}
.dot.filled { background: var(--accent); }

/* ── Quiz answer buttons ── */
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.quiz-option {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  font-size: 0.95rem;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}
.quiz-option:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.quiz-option.correct { border-color: var(--correct); background: #e8f2eb; color: var(--correct); font-weight: 500; }
.quiz-option.wrong   { border-color: var(--wrong);   background: var(--wrong-soft); color: var(--wrong); }
.quiz-option:disabled { cursor: default; }

/* ── Phrase builder ── */
.phrase-prompt-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow);
}

.phrase-assembly {
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  min-height: 52px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.phrase-assembly.empty { opacity: 0.5; }
.phrase-assembly-placeholder {
  font-size: 0.85rem;
  color: var(--accent);
  font-style: italic;
}

.phrase-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-chip {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.word-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.word-chip.placed { background: var(--accent); color: #fff; border-color: var(--accent); }
.word-chip.correct-chip { background: #e8f2eb; border-color: var(--correct); color: var(--correct); }
.word-chip.wrong-chip   { background: var(--wrong-soft); border-color: var(--wrong); color: var(--wrong); }

/* ── Hint block ── */
.hint-block {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  display: none;
}
.hint-block.visible { display: block; }

/* ── Phrase action row ── */
.phrase-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Header row ── */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.screen-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
}

/* ── Session header ── */
.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.session-counter {
  font-size: 0.875rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ── Stats screen ── */
.stats-level-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stats-level-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.stats-level-label strong { color: var(--ink); }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-tile .num {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
}
.stat-tile .lbl {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ── Finish screen ── */
.finish-icon {
  font-size: 3rem;
  text-align: center;
}
.finish-title {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
}
.finish-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.finish-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.finish-stat span:last-child { color: var(--ink); font-weight: 500; }

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43,42,38,0.45);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 16px;
}
.modal-backdrop.open { display: flex; }
.modal-sheet {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-sheet h2 { font-size: 1.1rem; font-weight: 600; }
.example-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--ink-soft);
  line-height: 1.5;
}
.example-item:last-child { border-bottom: none; }

/* ── Logo ── */
.logo {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.logo span { color: var(--ink-soft); font-weight: 300; }

/* ── Misc ── */
.divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.row.spaced { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ── Responsive ── */
@media (max-width: 400px) {
  .word-en { font-size: 1.6rem; }
  .quiz-options { grid-template-columns: 1fr; }
  .session-sizes { gap: 6px; }
  .session-size-btn { padding: 7px 12px; font-size: 0.875rem; }
}

/* ── Feedback states ── */
.feedback-correct { color: var(--correct); }
.feedback-wrong   { color: var(--wrong); font-size: 0.85rem; }
