/* =====================================================================
   Stasya · cozy english grammar
   Flat, compact, cohesive. One solid page (not floating cards):
   a fixed frame (header + side menu) wrapping a plain content surface.
   ===================================================================== */

:root {
  /* frame vs page */
  --bg: #f1e8da;         /* header + side menu */
  --content: #fffdf9;    /* the page body */
  --content-2: #f9f2e6;  /* subtle inset fill */

  /* ink */
  --ink: #443831;
  --ink-soft: #695a4d;
  --muted: #9a8776;

  /* accents (all flat) */
  --clay: #bd7659;
  --clay-deep: #a05f46;
  --clay-tint: #f2e0d4;
  --clay-line: #e6ceba;
  --sage: #869567;
  --sage-deep: #6c7a4f;
  --sage-tint: #e9edda;
  --sage-line: #d3ddbe;
  --rose: #bd857b;
  --rose-tint: #f1e4e1;
  --honey-tint: #f5e9d0;
  --honey-line: #e3cf9c;
  --sky-tint: #e5edf1;
  --sky-line: #c3d3db;
  --berry-tint: #ece1ef;
  --berry-line: #d8c6dc;

  /* structure */
  --line: #ece0cf;
  --line-strong: #ddccb5;

  --r-xs: 7px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-pill: 999px;

  --font-display: "Fredoka", ui-rounded, "Segoe UI", sans-serif;
  --font-body: "Nunito", ui-sans-serif, system-ui, -apple-system, sans-serif;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --topbar-h: 58px;
  --sidebar-w: 264px;
  --wrap: 900px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

p, h1, h2, h3, figure, ul, ol {
  margin: 0;
}

h1, h2, h3, .brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.2px;
}

::selection {
  background: var(--clay-tint);
  color: var(--clay-deep);
}

/* =====================================================================
   Banner (fixed, simple)
   ===================================================================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line-strong);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 100%;
  padding: 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--clay);
  color: #fff7ee;
  font-size: 1rem;
}

.brand-name {
  font-size: 1.32rem;
  font-weight: 600;
  color: var(--clay-deep);
  letter-spacing: 0.4px;
}

.topic-search {
  position: relative;
  flex: 1 1 360px;
  max-width: 460px;
  min-width: 180px;
}

.topic-search-input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: rgba(255, 253, 249, 0.72);
  color: var(--ink);
  font: 800 0.88rem/1 var(--font-body);
  outline: none;
  padding: 0 16px;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease), box-shadow 0.14s var(--ease);
}

.topic-search-input::placeholder {
  color: var(--muted);
}

.topic-search-input:focus {
  border-color: var(--clay);
  background: var(--content);
  box-shadow: 0 0 0 3px rgba(189, 118, 89, 0.14);
}

.topic-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 3px;
  max-height: min(380px, calc(100vh - var(--topbar-h) - 24px));
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--content);
  box-shadow: 0 16px 34px rgba(84, 65, 46, 0.16);
}

.topic-search-results[hidden] {
  display: none;
}

.topic-search-result {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink);
}

.topic-search-result:hover,
.topic-search-result.is-active {
  background: var(--clay-tint);
}

.topic-search-result[hidden] {
  display: none;
}

.topic-search-result-title {
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.2;
}

.topic-search-result-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-search-empty {
  padding: 9px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.language-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: rgba(255, 253, 249, 0.58);
}

.language-option {
  display: grid;
  place-items: center;
  min-width: 76px;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

.language-option:hover {
  background: var(--clay-tint);
  color: var(--clay-deep);
}

.language-option.is-active {
  background: var(--clay);
  color: #fff7ee;
}

.language-option-short {
  display: none;
}

/* =====================================================================
   Shell + fixed side menu (own internal scroll)
   ===================================================================== */
.site-shell {
  display: block;
}

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  z-index: 15;
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--line-strong);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px 8px 8px;
}

.sidebar-label {
  flex: none;
  padding: 2px 10px 12px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.course-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 6px 10px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(160, 95, 70, 0.35) transparent;
}

.course-nav::-webkit-scrollbar {
  width: 7px;
}

.course-nav::-webkit-scrollbar-thumb {
  border-radius: var(--r-pill);
  background: rgba(160, 95, 70, 0.28);
}

.course-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(160, 95, 70, 0.45);
}

.nav-summary {
  cursor: pointer;
  list-style: none;
}

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

/* level (drawer) row */
.level-summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  padding: 9px 30px 9px 12px;
  border-radius: var(--r-sm);
  color: var(--ink);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.level-summary:hover {
  background: #fff6eb;
}

.level-summary::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.22s var(--ease), border-color 0.15s var(--ease);
}

.level-group[open] > .level-summary::after {
  transform: translateY(-30%) rotate(225deg);
}

.test-direct::after {
  display: none;
}

.level-summary-text {
  display: grid;
  min-width: 0;
  line-height: 1.15;
}

.level-summary-main {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
}

.level-summary-sub {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-summary-count {
  flex: none;
  margin-left: auto;
  max-width: 88px;
  color: var(--muted);
  font-size: 0.56rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.level-group.is-active > .level-summary,
.test-direct.is-active {
  background: var(--clay);
  color: #fff7ee;
}

.level-group.is-active > .level-summary .level-summary-sub,
.level-group.is-active > .level-summary .level-summary-count,
.test-direct.is-active .level-summary-sub,
.test-direct.is-active .level-summary-count {
  color: #fbe4d5;
}

.level-group.is-active > .level-summary::after {
  border-color: #fbe4d5;
}

/* tree */
.nav-children {
  display: grid;
  gap: 2px;
}

.topic-list {
  margin: 3px 0 4px 13px;
  padding-left: 11px;
  border-left: 1px solid var(--line-strong);
}

.page-list {
  margin: 2px 0 4px 8px;
  padding-left: 11px;
  border-left: 1px solid var(--line);
}

/* topic (sub-drawer) row */
.topic-summary {
  display: flex;
  align-items: center;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  transition: background 0.15s var(--ease);
}

.topic-summary:hover {
  background: #fff6eb;
}

.topic-summary-content {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.topic-summary-emoji {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: var(--r-xs);
  background: var(--clay-tint);
  font-size: 0.85rem;
  line-height: 1;
}

.topic-summary-text {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.18;
}

.topic-summary-title {
  overflow-wrap: anywhere;
  font-size: 0.83rem;
  font-weight: 800;
  color: var(--ink);
}

.topic-summary-sub {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.topic-summary-count {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 19px;
  height: 19px;
  margin-left: auto;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--clay-tint);
  color: var(--clay-deep);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
}

.topic-group.is-active > .topic-summary,
.topic-summary.is-active {
  background: var(--clay-tint);
}

.topic-group.is-active > .topic-summary .topic-summary-title,
.topic-summary.is-active .topic-summary-title {
  color: var(--clay-deep);
}

.topic-group.is-active > .topic-summary .topic-summary-emoji,
.topic-summary.is-active .topic-summary-emoji {
  background: #fff;
}

/* page (leaf) row */
.nav-page-direct {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 9px;
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

.nav-page-direct:hover {
  background: #fff6eb;
  color: var(--ink);
}

.nav-page-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--content-2);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 600;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

.nav-page-title {
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
}

.nav-page-direct.is-active {
  background: var(--clay-tint);
  color: var(--clay-deep);
  font-weight: 800;
}

.nav-page-direct.is-active .nav-page-num {
  background: var(--clay);
  color: #fff7ee;
}

.nav-page-direct.is-active .nav-page-title {
  color: var(--clay-deep);
}

.nav-empty {
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  font-style: italic;
}

/* =====================================================================
   Page surface
   ===================================================================== */
.page {
  position: relative;
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  background: var(--content);
}

.page-inner {
  position: relative;
  z-index: 1;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 52px) 56px;
}

/* =====================================================================
   Watercolor flowers — soft hand-painted blooms in the page corners
   ===================================================================== */
.page-flora {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.flora {
  position: absolute;
}

.flora-svg {
  display: block;
  width: 100%;
  height: auto;
}

.flora-tr {
  top: -18px;
  right: -26px;
  width: 210px;
  opacity: 0.78;
}

.flora-ml {
  top: 34%;
  left: -44px;
  width: 150px;
  opacity: 0.6;
}

.flora-br {
  bottom: 40px;
  right: -30px;
  width: 205px;
  opacity: 0.62;
}

.flora-bl {
  bottom: 20px;
  left: -34px;
  width: 190px;
  opacity: 0.72;
}

/* Gentle breeze — flowers sway softly, hedgehog breathes. */
@keyframes flora-sway {
  0%, 100% { transform: rotate(-1.8deg); }
  50%      { transform: rotate(1.8deg); }
}

.flora-tr, .flora-ml, .flora-br {
  transform-origin: bottom center;
  animation: flora-sway 7s ease-in-out infinite;
}

.flora-tr { animation-duration: 6.5s; }
.flora-ml { animation-duration: 8s; animation-delay: -2s; }
.flora-br { animation-duration: 7.5s; animation-delay: -4s; }

/* Hedgehog ambles gently to and fro, bobbing as he goes. */
@keyframes hog-walk {
  0%, 100% { transform: translateX(0) translateY(0) rotate(-0.6deg); }
  25%      { transform: translateX(6px) translateY(-2.5px) rotate(0.6deg); }
  50%      { transform: translateX(12px) translateY(0) rotate(-0.6deg); }
  75%      { transform: translateX(6px) translateY(-2.5px) rotate(0.6deg); }
}

@keyframes hog-step {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2.5px); }
}

.flora-bl {
  transform-origin: bottom center;
  animation: hog-walk 3.2s ease-in-out infinite;
}

.hog-foot {
  transform-box: fill-box;
  transform-origin: center;
  animation: hog-step 0.8s ease-in-out infinite;
}

.hog-foot-r { animation-delay: -0.4s; }

@media (prefers-reduced-motion: reduce) {
  .flora-tr, .flora-ml, .flora-br, .flora-bl, .hog-foot { animation: none; }
}

@media (max-width: 860px) {
  .flora-tr { width: 150px; opacity: 0.42; }
  .flora-ml { display: none; }
  .flora-br { width: 150px; opacity: 0.34; }
  .flora-bl { width: 132px; opacity: 0.46; }
}

[id] {
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

/* hero */
.lesson-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.hero-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: var(--clay-tint);
  font-size: 1.5rem;
  line-height: 1;
}

.hero-text {
  min-width: 0;
}

.hero-kicker {
  font-weight: 900;
  font-size: 0.7rem;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--clay);
}

.hero-text h1 {
  margin-top: 4px;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--ink);
}

.hero-meta {
  margin-top: 5px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.78rem;
}

/* =====================================================================
   Lesson flow (one continuous column, no cards)
   ===================================================================== */
.lesson-grid {
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-badge {
  padding: 3px 12px;
  border-radius: var(--r-pill);
  background: var(--clay);
  color: #fff7ee;
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.practice-badge {
  background: var(--sage);
}

.panel-head h2 {
  font-size: 1.16rem;
  font-weight: 500;
  color: var(--ink);
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: stretch;
}

.practice-panel {
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--line-strong);
}

.lesson-choice-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: -8px 0 24px;
  padding: 2px 2px 8px;
  -webkit-overflow-scrolling: touch;
}

.lesson-choice {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  max-width: min(260px, 68vw);
  padding: 9px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--content);
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease);
}

.lesson-choice:hover {
  background: var(--clay-tint);
  border-color: var(--clay-line);
}

.lesson-choice.is-active {
  background: var(--clay);
  border-color: var(--clay);
}

.lesson-choice-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--clay-tint);
  color: var(--clay-deep);
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 600;
}

.lesson-choice.is-active .lesson-choice-num {
  background: #fff7ee;
  color: var(--clay-deep);
}

.lesson-choice-title {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-choice.is-active .lesson-choice-title {
  color: #fff7ee;
}

/* =====================================================================
   Text blocks (flat)
   ===================================================================== */
.block-heading {
  align-self: flex-start;
  max-width: 100%;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--clay-tint);
  color: var(--clay-deep);
  font-size: 0.98rem;
  font-weight: 500;
}

.block-p {
  color: var(--ink-soft);
}

.inline-link {
  display: inline;
  color: var(--clay-deep);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.inline-link:hover {
  color: var(--sage-deep);
}

.section-break {
  width: 100%;
  height: 1px;
  margin: 10px 0 2px;
  background: var(--line-strong);
}

.note {
  padding: 12px 15px 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--clay);
  background: var(--content-2);
  color: var(--ink);
  font-weight: 600;
}

.soft-list {
  display: grid;
  gap: 8px;
  padding-left: 4px;
  list-style: none;
}

.soft-list li {
  position: relative;
  padding-left: 24px;
  color: var(--ink-soft);
}

.soft-list li::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 0.6em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--clay);
}

.numbered-list {
  counter-reset: rule;
}

.numbered-list li {
  counter-increment: rule;
  padding-left: 32px;
}

.numbered-list li::before {
  content: counter(rule);
  top: 0.05em;
  left: 0;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--clay);
  color: #fff7ee;
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 600;
}

.rule-examples {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
  counter-reset: rule;
}

.rule-example {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  counter-increment: rule;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--content-2);
}

.rule-number {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--clay);
  color: #fff7ee;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
}

.rule-number::before {
  content: counter(rule);
}

.rule-text {
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
}

.rule-example-box {
  grid-column: 2;
  width: fit-content;
  max-width: 100%;
  padding: 7px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--content);
  color: var(--ink-soft);
  font-weight: 700;
  font-style: italic;
}

.checklist {
  display: grid;
  gap: 8px;
  list-style: none;
  padding: 0;
}

.checklist li {
  position: relative;
  padding: 10px 14px 10px 42px;
  border-radius: var(--r-sm);
  background: var(--sage-tint);
  border: 1px solid var(--sage-line);
  font-weight: 700;
  color: var(--sage-deep);
}

.checklist li::before {
  content: "✓";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--sage);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

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

.chip {
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--clay-tint);
  border: 1px solid var(--clay-line);
  color: var(--clay-deep);
  font-weight: 800;
  font-size: 0.88rem;
}

.lines {
  display: grid;
  gap: 8px;
}

.lines p {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--content-2);
  border: 1px dashed var(--line-strong);
  color: var(--ink-soft);
  font-weight: 600;
}

.formula-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.formula-box {
  padding: 9px 15px;
  border-radius: var(--r-sm);
  background: var(--clay-tint);
  border: 1px solid var(--clay-line);
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--clay-deep);
}

.formula-plus {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--clay);
}

/* callouts (flat) */
.callout {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid;
}

.callout-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.callout-line {
  color: var(--ink-soft);
  font-weight: 600;
}

.callout-line + .callout-line {
  margin-top: 3px;
}

.spaced-rules .callout-line + .callout-line {
  margin-top: 14px;
}

.link-callout {
  border-width: 1.5px;
}

.callout-link {
  display: inline-block;
  margin: 0 3px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--clay-deep);
  font-family: var(--font-display);
  font-weight: 700;
  transition: background 0.14s var(--ease);
}

.callout-link:hover {
  background: var(--clay-tint);
}

.callout-honey { background: var(--honey-tint); border-color: var(--honey-line); }
.callout-honey .callout-title { color: #9c7a2f; }

.callout-sage { background: var(--sage-tint); border-color: var(--sage-line); }
.callout-sage .callout-title { color: var(--sage-deep); }

.callout-sky { background: var(--sky-tint); border-color: var(--sky-line); }
.callout-sky .callout-title { color: #5c7c8f; }

.callout-berry { background: var(--berry-tint); border-color: var(--berry-line); }
.callout-berry .callout-title { color: #7d6288; }

/* tables (flat) */
.table-card {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 22px rgba(74, 59, 50, 0.06);
  -webkit-overflow-scrolling: touch;
}

.table-card + .table-card {
  margin-top: 14px;
}

table {
  width: 100%;
  min-width: min(620px, 100%);
  border-collapse: collapse;
}

th {
  padding: 12px 16px;
  background: var(--table-head, var(--clay));
  color: var(--table-head-text, #fff7ee);
  font-family: var(--font-display);
  font-weight: 600;
  text-align: left;
  font-size: 0.95rem;
  letter-spacing: 0;
}

td {
  padding: 14px 16px;
  border-top: 1px solid var(--table-line, var(--line));
  color: var(--ink);
  line-height: 1.85;
  vertical-align: top;
}

td + td,
th + th {
  border-left: 1px solid var(--table-line, var(--line));
}

tbody tr:nth-child(odd) td {
  background: var(--table-row-a, var(--content));
}

tbody tr:nth-child(even) td {
  background: var(--table-row-b, var(--content-2));
}

tbody tr:hover td {
  background: var(--table-hover, var(--clay-tint));
}

.table-tone-0 {
  --table-head: #9c6b52;
  --table-head-text: #fff7ee;
  --table-row-a: #fffdf9;
  --table-row-b: #f6ece4;
  --table-hover: #f1dfd1;
  --table-line: #dfc7b8;
}

.table-tone-1 {
  --table-head: #75835a;
  --table-head-text: #fbfff1;
  --table-row-a: #fffdf9;
  --table-row-b: #edf1df;
  --table-hover: #e2e9cf;
  --table-line: #cdd8ad;
}

.table-tone-2 {
  --table-head: #8d7895;
  --table-head-text: #fff7ff;
  --table-row-a: #fffdf9;
  --table-row-b: #f0e8f2;
  --table-hover: #e6d9ea;
  --table-line: #d8c7dd;
}

.table-tone-3 {
  --table-head: #6f85a3;
  --table-head-text: #f7fbff;
  --table-row-a: #fffdf9;
  --table-row-b: #e9eef5;
  --table-hover: #dce5ef;
  --table-line: #c8d3e0;
}

.word-table td {
  width: 50%;
}

.word-cell {
  font-weight: 800;
}

.answer-cell {
  padding: 8px 12px;
}

/* poster / conjugation (flat) */
.poster {
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--content);
}

.poster-title {
  padding: 12px 18px;
  background: var(--clay);
  color: #fff7ee;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  text-align: center;
}

.poster-cols {
  display: grid;
  gap: 1px;
  background: var(--line-strong);
}

.poster-cols.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.poster-cols.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.poster-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 18px 14px;
  background: var(--content);
  text-align: center;
}

.poster-head {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.05;
}

.accent-clay .poster-head { color: var(--clay); }
.accent-olive .poster-head { color: var(--sage-deep); }
.accent-rose .poster-head { color: var(--rose); }

.poster-sub {
  font-weight: 800;
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: -3px;
}

.poster-dots {
  display: block;
  width: 60%;
  height: 0;
  margin: 4px 0;
  border-top: 2px dotted var(--line-strong);
}

.poster-formula {
  font-weight: 800;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.framed-formulas .poster-formula {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--clay);
  background: var(--clay-tint);
  color: var(--clay-deep);
}

.framed-formulas .accent-olive .poster-formula {
  border-color: var(--sage);
  background: var(--sage-tint);
  color: var(--sage-deep);
}

.framed-formulas .accent-rose .poster-formula {
  border-color: var(--rose);
  background: var(--rose-tint);
  color: #a06a60;
}

.poster-lines {
  display: grid;
  gap: 3px;
}

.poster-lines span {
  color: var(--ink);
  font-weight: 600;
}

.poster-example {
  margin-top: auto;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--clay-tint);
  border: 1px dashed var(--clay);
  color: var(--clay-deep);
  font-weight: 700;
}

.accent-olive .poster-example {
  background: var(--sage-tint);
  border-color: var(--sage);
  color: var(--sage-deep);
}

.accent-rose .poster-example {
  background: var(--rose-tint);
  border-color: var(--rose);
  color: #a06a60;
}

/* scheme */
.scheme-body {
  display: grid;
  gap: 1px;
  background: var(--line-strong);
}

.scheme-section {
  padding: 16px 18px;
  background: var(--content);
}

.scheme-section-title {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--clay-deep);
  margin-bottom: 12px;
}

.scheme-rows {
  display: grid;
  gap: 9px;
}

.scheme-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: var(--r-sm);
  background: var(--content-2);
  border: 1px solid var(--line);
}

.tag {
  justify-self: start;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: lowercase;
}

.tag-affirmative { background: var(--clay-tint); color: var(--clay-deep); }
.tag-negative { background: #ece2d8; color: #7a6858; }
.tag-question { background: var(--honey-tint); color: #9c7a2f; }

.scheme-formula {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--ink);
}

.scheme-example {
  color: var(--ink-soft);
  font-weight: 600;
}

.scheme-mark {
  display: inline-block;
  padding: 0 4px;
  border-radius: 5px;
  background: var(--honey-tint);
  color: var(--clay-deep);
  font-weight: 900;
}

.scheme-mark-future {
  background: var(--sky-tint);
  color: #4f7185;
}

.scheme-mark-green {
  background: var(--sage-tint);
  color: var(--sage-deep);
}

.inline-tone-result {
  color: var(--sage-deep);
}

.scheme-note {
  padding: 12px 18px;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
  font-style: italic;
  background: var(--content-2);
}

/* photo */
.photo {
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--content);
}

.photo img {
  display: block;
  width: 100%;
  height: auto;
}

.photo figcaption {
  padding: 10px 16px;
  color: var(--ink-soft);
  font-weight: 700;
  text-align: center;
}

/* =====================================================================
   Typable exercises (flat)
   ===================================================================== */
.blank {
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--clay-deep);
  background: var(--content-2);
  border: none;
  border-bottom: 2px solid var(--line-strong);
  padding: 3px 8px;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease);
}

.blank::placeholder {
  color: var(--muted);
  font-weight: 600;
}

.blank:focus {
  outline: none;
  border-bottom-color: var(--clay);
  background: var(--clay-tint);
}

.blank.is-filled {
  border-bottom-color: var(--sage);
}

.blank.is-correct {
  border-color: var(--sage);
  border-bottom-color: var(--sage);
  background: var(--sage-tint);
  color: var(--sage-deep);
}

.blank.is-wrong {
  border-color: var(--rose);
  border-bottom-color: var(--rose);
  background: var(--rose-tint);
  color: #a0605a;
}

.blank-inline {
  width: 88px;
  text-align: center;
  border-radius: 6px 6px 0 0;
}

.blank-answer {
  flex: 1;
  min-width: 120px;
  border-radius: 6px 6px 0 0;
}

.blank-cell {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--content-2);
  padding: 8px 12px;
}

.blank-cell:focus { border-color: var(--clay); }
.blank-cell.is-filled { border-color: var(--sage); }

.blank-full {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--content-2);
  padding: 8px 12px;
}

.blank-full:focus { border-color: var(--clay); }
.blank-full.is-filled { border-color: var(--sage); }

textarea.blank-full {
  resize: vertical;
  min-height: 76px;
  line-height: 1.45;
  text-align: left;
}

select.blank {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--clay) 50%),
    linear-gradient(135deg, var(--clay) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) calc(1.05em),
    calc(100% - 12px) calc(1.05em);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.exercise-card {
  display: flex;
  gap: 11px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--content-2);
  border: 1px solid var(--line);
  transition: border-color 0.14s var(--ease);
}

.exercise-card:focus-within {
  border-color: var(--clay);
}

.exercise-number {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--clay-tint);
  color: var(--clay-deep);
  font-family: var(--font-display);
  font-size: 0.8rem;
}

.exercise-body {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  flex: 1;
}

.exercise-prompt {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.9;
}

.exercise-list {
  display: grid;
  gap: 9px;
  list-style: none;
  padding: 0;
  counter-reset: ex;
}

.exercise-list li {
  counter-increment: ex;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 14px 11px 44px;
  position: relative;
  border-radius: var(--r-md);
  background: var(--content-2);
  border: 1px solid var(--line);
  transition: border-color 0.14s var(--ease);
}

.exercise-list li:focus-within {
  border-color: var(--clay);
}

.exercise-list li::before {
  content: counter(ex);
  position: absolute;
  left: 12px;
  top: 11px;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--clay-tint);
  color: var(--clay-deep);
  font-family: var(--font-display);
  font-size: 0.78rem;
}

.exercise-list .exercise-prompt {
  font-weight: 700;
}

.arrow {
  color: var(--clay);
  font-weight: 900;
  font-size: 1rem;
}

.drag-gap {
  display: grid;
  gap: 14px;
}

.drag-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--sky-tint);
  border: 1px solid var(--sky-line);
}

.drag-chip {
  min-height: 34px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  border: 1px solid #b7c9d8;
  background: var(--content);
  color: #4d6f84;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 0.9rem;
  cursor: grab;
  box-shadow: 0 4px 10px rgba(74, 59, 50, 0.05);
}

.drag-chip:active {
  cursor: grabbing;
}

.drag-chip.is-selected {
  border-color: var(--clay);
  color: var(--clay-deep);
  background: var(--clay-tint);
}

.drag-chip:disabled {
  opacity: 0.38;
  cursor: default;
}

.drag-gap-list {
  display: grid;
  gap: 10px;
}

.drag-gap-card {
  display: flex;
  gap: 11px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--content-2);
  border: 1px solid var(--line);
}

.drag-gap-prompt {
  flex: 1;
  min-width: 0;
}

.drag-drop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 138px;
  min-height: 34px;
  margin: 0 4px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  border: 1px dashed #90aac0;
  background: #f7fbff;
  color: #4d6f84;
  font-family: var(--font-body);
  font-weight: 900;
  vertical-align: middle;
  cursor: pointer;
}

.drag-drop::before {
  content: "";
}

.drag-drop.is-filled {
  border-style: solid;
  background: var(--sky-tint);
}

.drag-drop.is-over {
  border-color: var(--clay);
  background: var(--clay-tint);
}

.writing {
  display: grid;
  gap: 10px;
}

.ai-writing-check {
  display: grid;
  gap: 12px;
}

.ai-writing-lines {
  display: grid;
  gap: 10px;
}

.ai-writing-line {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--content-2);
  border: 1px solid var(--line);
  transition: border-color 0.14s var(--ease);
}

.ai-writing-line:focus-within {
  border-color: var(--clay);
}

.ai-writing-input {
  flex: 1;
}

.ai-writing-result {
  white-space: pre-wrap;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--sage-line);
  background: var(--sage-tint);
  color: var(--sage-deep);
  font-weight: 700;
  line-height: 1.55;
}

.ai-writing-result.is-error {
  border-color: var(--rose);
  background: var(--rose-tint);
  color: #a0605a;
}

.ai-writing-result[hidden] {
  display: none;
}

.placement-test {
  display: grid;
  gap: 16px;
}

.placement-test-list {
  display: grid;
  gap: 10px;
}

.placement-question {
  display: flex;
  gap: 11px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--content-2);
  border: 1px solid var(--line);
  transition: border-color 0.14s var(--ease);
}

.placement-question:focus-within {
  border-color: var(--clay);
}

.placement-question-body {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.placement-topic {
  width: fit-content;
  max-width: 100%;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--clay-tint);
  color: var(--clay-deep);
  font-size: 0.72rem;
  font-weight: 900;
}

.placement-actions {
  display: grid;
  gap: 12px;
}

.btn-check {
  justify-self: start;
  padding: 10px 22px;
  border-radius: var(--r-pill);
  border: none;
  background: var(--clay);
  color: #fff7ee;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.14s var(--ease);
}

.btn-check:hover {
  background: var(--clay-deep);
}

.btn-check:disabled {
  cursor: wait;
  opacity: 0.7;
}

.placement-result {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--sage-line);
  background: var(--sage-tint);
  color: var(--sage-deep);
  font-weight: 700;
}

.placement-result[hidden] {
  display: none;
}

.placement-result-title {
  color: var(--clay-deep);
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 600;
}

.placement-result-link {
  color: var(--clay-deep);
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.placement-result-link:hover {
  color: var(--clay);
}

/* exercise tabs (flat) */
.exercise-tabs {
  display: grid;
  gap: 14px;
}

.exercise-tab-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.exercise-tab {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 54px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--content);
  color: var(--ink-soft);
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease);
}

.exercise-tab:hover {
  background: var(--clay-tint);
}

.exercise-tab.is-active {
  border-color: var(--clay);
  background: var(--clay);
  color: #fff7ee;
}

.exercise-tab.is-active .exercise-tab-subtitle {
  color: #fbe4d5;
}

.exercise-tab-title {
  overflow-wrap: anywhere;
  font-weight: 900;
  line-height: 1.15;
}

.exercise-tab-subtitle {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
}

.exercise-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.exercise-tab-panel[hidden] {
  display: none;
}

.practice-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px dashed var(--line-strong);
}

.btn-clear {
  padding: 9px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--content);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 800;
  cursor: pointer;
  transition: background 0.14s var(--ease);
}

.btn-clear:hover {
  background: var(--clay-tint);
}

.saved-hint {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.83rem;
}

/* pager */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 28px;
}

.pager-btn {
  display: grid;
  gap: 2px;
  padding: 13px 18px;
  border-radius: var(--r-md);
  background: var(--content);
  border: 1px solid var(--line-strong);
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease);
}

.pager-btn.next {
  text-align: right;
}

.pager-btn:hover {
  background: var(--clay-tint);
  border-color: var(--clay-line);
}

.pager-dir {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--clay-deep);
}

.pager-label {
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.88rem;
}

/* footer */
.page-foot {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
}

.page-foot span {
  font-family: var(--font-display);
  color: var(--clay-deep);
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1024px) {
  .topbar {
    position: sticky;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line-strong);
  }

  .sidebar-inner {
    height: auto;
    padding: 12px 14px;
  }

  .course-nav {
    max-height: 46vh;
  }

  .page {
    margin-left: 0;
    margin-top: 0;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 0 12px;
    gap: 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  .brand-name {
    font-size: 1.08rem;
  }

  .topic-search {
    flex-basis: 130px;
    min-width: 0;
  }

  .topic-search-input {
    height: 34px;
    padding: 0 12px;
    font-size: 0.8rem;
  }

  .topic-search-results {
    position: fixed;
    top: calc(var(--topbar-h) + 6px);
    left: 12px;
    right: 12px;
    max-height: min(360px, calc(100vh - var(--topbar-h) - 18px));
  }

  .language-switch {
    gap: 4px;
    padding: 3px;
  }

  .language-option {
    min-width: 38px;
    min-height: 32px;
    padding: 7px 9px;
    font-size: 0.72rem;
  }

  .language-option-name {
    display: none;
  }

  .language-option-short {
    display: inline;
  }

  .exercise-grid {
    grid-template-columns: 1fr;
  }

  .exercise-tab-list {
    grid-template-columns: 1fr;
  }

  .scheme-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .poster-cols.cols-3 {
    grid-template-columns: 1fr;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager-btn.next {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
