:root {
  --bg: #f6f1ea;
  --panel: #fffaf3;
  --ink: #211b16;
  --muted: #71665c;
  --line: #e5d8c8;
  --accent: #a33a2a;
  --accent-2: #2b6b59;
  --soft: #f0dfce;
  --good: #2f7d4f;
  --bad: #a43d3d;
  --shadow: 0 18px 45px rgba(50, 35, 20, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff3df 0, var(--bg) 35%, #efe7dc 100%);
  min-height: 100vh;
}

button, input, select { font: inherit; }
button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--ink);
  padding: 0.72rem 1rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.app-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: .78rem; color: var(--accent); font-weight: 800; margin: 0 0 .35rem; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 4rem); letter-spacing: -.05em; }
h2 { margin: 0 0 .65rem; font-size: 1.3rem; }
h3 { margin: .25rem 0 1rem; font-size: clamp(1.35rem, 3vw, 2.05rem); line-height: 1.15; }
p { line-height: 1.55; }
.subtitle { color: var(--muted); max-width: 48rem; margin: .5rem 0 0; }

.streak-card {
  min-width: 120px;
  min-height: 100px;
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  padding: 1rem;
  text-align: center;
}
.streak-card span { display: block; font-size: 2.6rem; font-weight: 900; color: var(--accent); line-height: 1; }
.streak-card small { color: var(--muted); font-weight: 700; }

.layout { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem 2.5rem; }
.tabs {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .75rem 0 1.25rem;
}
.tab.active { background: var(--ink); color: white; border-color: var(--ink); }
.view { display: none; }
.view.active { display: block; }
.grid.two { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .8fr); gap: 1rem; }
.panel {
  background: rgba(255,250,243,.94);
  border: 1px solid rgba(229,216,200,.95);
  border-radius: 28px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.hero-panel { min-height: 280px; display: flex; flex-direction: column; justify-content: space-between; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.progress-wrap { margin-top: 1rem; }
.progress-bar { width: 100%; height: 13px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0%; background: var(--accent-2); border-radius: inherit; transition: width .25s ease; }
.method-list { padding-left: 1.1rem; color: var(--muted); }
.method-list li { margin: .75rem 0; }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem; }
.topic-card { border: 1px solid var(--line); border-radius: 20px; padding: 1rem; background: #fffdf8; }
.topic-card strong { display: block; margin-bottom: .35rem; }
.topic-card .mini { font-size: .9rem; color: var(--muted); }
.section-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
select, .answer-input {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 18px;
  padding: .8rem 1rem;
  color: var(--ink);
}
.lesson-box, .muted-box {
  border-radius: 22px;
  background: #fff7ec;
  border: 1px solid var(--line);
  padding: 1rem;
}
.lesson-box table, .grammar-grid table { width: 100%; border-collapse: collapse; margin: .65rem 0; }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .9rem; }
.trainer-panel { min-height: 520px; }
.card {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 1.3rem;
  min-height: 300px;
}
.card-topic { margin: 0 0 .5rem; color: var(--accent); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; font-size: .78rem; }
.answer-input { display: block; width: 100%; margin: 1rem 0 .35rem; font-size: 1.05rem; }
.feedback { margin-top: 1rem; padding: 1rem; border-radius: 18px; border: 1px solid var(--line); background: #f8efe4; }
.feedback.good { border-color: rgba(47,125,79,.35); background: rgba(47,125,79,.08); }
.feedback.bad { border-color: rgba(164,61,61,.35); background: rgba(164,61,61,.08); }
.feedback .answer { font-size: 1.25rem; font-weight: 800; }
.hidden { display: none !important; }
.rating { border: 1px solid var(--line); border-radius: 22px; padding: 1rem; margin-top: 1rem; background: #fff7ec; }
.rating p { margin-top: 0; }
.rating button { margin: .2rem; }
.exam-question { border: 1px solid var(--line); border-radius: 20px; padding: 1rem; margin: .75rem 0; background: #fffdf8; }
.exam-question.correct { border-color: rgba(47,125,79,.45); }
.exam-question.incorrect { border-color: rgba(164,61,61,.45); }
.grammar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.grammar-card { border: 1px solid var(--line); border-radius: 20px; background: #fffdf8; padding: 1rem; }
.grammar-card ul { padding-left: 1.1rem; color: var(--muted); }
footer { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem 2rem; color: var(--muted); }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); border-radius: 7px; padding: .12rem .35rem; }
@media (max-width: 760px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .grid.two { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; }
  .tabs { position: sticky; top: 0; padding: .5rem 0; background: rgba(246,241,234,.92); backdrop-filter: blur(8px); z-index: 3; }
}
.translation-toggle {
  display: inline-block;
  margin: .15rem 0;
}
.translation-toggle summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}
.translation-toggle span {
  display: inline-block;
  margin-top: .25rem;
  color: var(--ink);
  font-weight: 700;
}
.exam-mode {
  margin: 0 0 .75rem;
  color: var(--muted);
}
.compact-actions {
  margin-top: 0;
  justify-content: flex-end;
}
@media (max-width: 760px) {
  .compact-actions { justify-content: flex-start; }
}
