:root {
  color-scheme: light;

  /* Ink & text */
  --ink: #1c1d22;
  --ink-2: #3a3b41;
  --muted: #8a8b91;
  --muted-2: #b8b9bf;

  /* Hairlines */
  --line: rgba(58, 46, 26, 0.09);
  --line-strong: rgba(58, 46, 26, 0.16);

  /* Surfaces */
  --page: #f7f1e6;
  --cream: #fffaf2;
  --card: #ffffff;
  --card-2: #fffaf2;

  /* Brand accents */
  --green: #4a6d3e;
  --green-2: #6b8b59;
  --green-soft: #eef3e7;
  --gold: #c89b3c;
  --gold-2: #d6a943;
  --gold-soft: #fbecbf;
  --gold-deep: #8a5d12;
  --coral: #df7458;
  --coral-soft: #fbe7da;

  /* iOS materials */
  --bar: rgba(255, 250, 242, 0.72);
  --bar-bd: rgba(58, 46, 26, 0.10);
  --fill-1: rgba(118, 118, 128, 0.10);   /* iOS systemFill */
  --fill-2: rgba(118, 118, 128, 0.16);
  --fill-3: rgba(118, 118, 128, 0.20);

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(40, 28, 12, 0.04), 0 6px 18px rgba(40, 28, 12, 0.06);
  --shadow-2: 0 1px 2px rgba(40, 28, 12, 0.06), 0 16px 36px rgba(40, 28, 12, 0.10);
  --shadow-card: 0 1px 0 rgba(40, 28, 12, 0.03), 0 1px 2px rgba(40, 28, 12, 0.05), 0 8px 24px rgba(40, 28, 12, 0.06);

  /* Geometry */
  --r-card: 18px;
  --r-control: 12px;
  --r-pill: 999px;

  /* Motion — Apple's spring-ish curve */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-emphasized: cubic-bezier(0.2, 0.9, 0.1, 1);

  /* Type stacks */
  --display: "New York", "Charter", "Iowan Old Style", ui-serif, Georgia, "Apple Garamond", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Helvetica", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[v-cloak] { display: none; }

html, body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 110% -10%, rgba(243, 217, 162, 0.45), transparent 55%),
    radial-gradient(900px 700px at -10% 30%, rgba(225, 234, 213, 0.40), transparent 60%),
    var(--page);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: -0.005em;
  padding-bottom: env(safe-area-inset-bottom);
}

a {
  color: #2c4f8a;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: opacity 160ms var(--ease);
}
a:hover { opacity: 0.78; }

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

::selection { background: rgba(212, 159, 56, 0.30); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(58, 46, 26, 0.18);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(58, 46, 26, 0.30);
  background-clip: padding-box;
}

/* ============================================================
   TOP BAR — iOS translucent material
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 8px 22px calc(8px + env(safe-area-inset-top, 0px) * 0);
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--bar-bd);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 18px;
  height: 24px;
  filter: drop-shadow(0 1px 0 rgba(40, 28, 12, 0.06));
}

.brand-mark span {
  position: absolute;
  left: 8px;
  bottom: 1px;
  width: 2px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, #a98260, #8b6f4e);
  transform: rotate(-8deg);
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  width: 8px;
  height: 11px;
  border-radius: 9px 9px 9px 2px;
  content: "";
}

.brand-mark::before {
  left: 1px;
  top: 2px;
  background: linear-gradient(180deg, #93b182, #78936a);
  transform: rotate(-28deg);
}

.brand-mark::after {
  right: 0;
  top: 0;
  background: linear-gradient(180deg, #ec8d72, #df7458);
  transform: rotate(26deg);
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.022em;
}

.brand p { display: none; }

/* iOS pill search (rounded, fill-tinted, focus halo) */
.top-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 32vw);
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--fill-2);
  color: var(--ink-2);
  transition: background 200ms var(--ease), box-shadow 200ms var(--ease);
}

.top-search:focus-within {
  background: #fff;
  box-shadow: 0 0 0 4px rgba(74, 109, 62, 0.14), inset 0 0 0 1px rgba(74, 109, 62, 0.4);
}

.top-search .ico {
  flex: 0 0 auto;
  color: var(--muted);
}

.top-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--ink);
  font-size: 14px;
  letter-spacing: -0.005em;
}

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

.top-search kbd {
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(58, 46, 26, 0.10);
  padding: 2px 6px;
  color: var(--muted);
  font: 600 11px/1 var(--sans);
}

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

/* iOS segmented control */
.mode-tabs {
  display: inline-flex;
  gap: 0;
  padding: 2px;
  border: 0;
  border-radius: 10px;
  background: var(--fill-2);
}

.mode-tabs button {
  position: relative;
  min-width: 50px;
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: color 180ms var(--ease);
}

.mode-tabs button:hover { color: var(--ink); }

.mode-tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(40, 28, 12, 0.10), 0 3px 8px rgba(40, 28, 12, 0.06);
}

/* Filled iOS pill button — primary tinted */
.ask-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px 0 12px;
  border: 0;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, #5d8552 0%, #4a6d3e 100%);
  box-shadow:
    0 1px 2px rgba(40, 28, 12, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: transform 120ms var(--ease), box-shadow 200ms var(--ease), filter 200ms var(--ease);
}

.ask-button:hover { filter: brightness(1.05); }
.ask-button:active { transform: scale(0.97); }

.ask-button svg { opacity: 0.92; }

.avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(150deg, #2c2c33 0%, #16161a 100%);
  color: #fff;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(40, 28, 12, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  transition: transform 120ms var(--ease), filter 200ms var(--ease);
}

.avatar:hover { filter: brightness(1.1); }
.avatar:active { transform: scale(0.94); }

/* ============================================================
   SHELL
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

/* ============================================================
   SIDEBAR — iOS sidebar with material/translucency
   ============================================================ */
.sidebar {
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);
  overflow: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.55), rgba(255, 250, 242, 0));
  padding: 22px 14px 28px;
}

.sidebar-head,
.lesson-filter-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 6px;
}

.sidebar-head p,
.filter-group p,
.lesson-filter-title p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-head strong,
.lesson-filter-title strong {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.search-panel { display: none; }

.filter-group {
  margin-bottom: 14px;
  padding: 0 6px;
}

.check-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  cursor: default;
  text-align: left;
}

.check-row span,
.filters button::before {
  display: inline-block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-right: 10px;
  border: 0;
  border-radius: 6px;
  background: var(--fill-2);
  content: "";
  vertical-align: middle;
}

.check-row.active span,
.filters button.active::before {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center/12px 12px no-repeat,
    linear-gradient(180deg, #5d8552 0%, #4a6d3e 100%);
  box-shadow: 0 1px 2px rgba(74, 109, 62, 0.30);
}

.check-row strong {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
}

.check-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
}

/* Grade filter rows — iOS list-style */
.filters {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 14px;
  padding: 0 6px;
}

.filters button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-align: left;
  transition: background 160ms var(--ease);
}

.filters button:hover { background: var(--fill-1); }
.filters button.active { background: var(--fill-2); }

/* Stats card — was hidden, now an iOS-style segmented stat tile */
.progress-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 4px 6px 18px;
  padding: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
  overflow: hidden;
}

.progress-box > div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  position: relative;
}

.progress-box > div + div::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}

.progress-box strong {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

.progress-box span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Lesson list rows — selectable cards */
.lesson-list {
  display: grid;
  gap: 2px;
  padding: 4px 0 24px;
}

.lesson-list button {
  position: relative;
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 10px 26px 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 160ms var(--ease), transform 120ms var(--ease), box-shadow 200ms var(--ease);
}

.lesson-list button:hover { background: var(--fill-1); }
.lesson-list button:active { transform: scale(0.99); }

.lesson-list button.active {
  background: #fff;
  box-shadow:
    0 1px 0 rgba(40, 28, 12, 0.03),
    0 1px 2px rgba(40, 28, 12, 0.06),
    0 8px 22px rgba(40, 28, 12, 0.07),
    inset 0 0 0 1px var(--line);
}

/* iOS chevron at right of active row */
.lesson-list button.active::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-right: 1.5px solid var(--muted);
  border-top: 1.5px solid var(--muted);
  transform: rotate(45deg);
  opacity: 0.6;
}

.lesson-row-top {
  display: flex;
  gap: 10px;
  align-items: start;
  justify-content: space-between;
}

.lesson-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.lesson-subtitle,
.lesson-count {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
  margin-top: 5px;
}

.status-dot.done {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.mini-progress,
.toolbar-progress {
  display: block;
  overflow: hidden;
  height: 4px;
  border-radius: 999px;
  background: var(--fill-2);
}

.mini-progress span,
.toolbar-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  transition: width 420ms var(--ease-emphasized);
}

/* ============================================================
   CONTENT
   ============================================================ */
.content {
  min-width: 0;
  padding: 32px 40px 56px;
}

.lesson {
  max-width: 1180px;
  margin: 0 auto;
  animation: fadeUp 380ms var(--ease) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero — iOS large-title moment */
.lesson-hero {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffaf2 0%, #fdf3df 100%);
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--line);
}

.lesson-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(420px 220px at 88% -10%, rgba(225, 188, 110, 0.32), transparent 60%),
    radial-gradient(360px 280px at -10% 110%, rgba(150, 178, 130, 0.22), transparent 60%);
  pointer-events: none;
}

.lesson-title-block {
  flex: 1 1 auto;
  padding: 36px 32px;
  position: relative;
}

.eyebrow {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 22px;
  padding: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.eyebrow span {
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(200, 155, 60, 0.14);
  color: #8a5d12;
  text-transform: uppercase;
}

.eyebrow span + span {
  background: rgba(223, 116, 88, 0.14);
  color: #b3502c;
}

.lesson-hero h2 {
  max-width: 880px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(36px, 4.6vw, 56px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.04;
}

.english-title {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.lesson-meta {
  display: flex;
  flex: 0 0 240px;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  border-left: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.55);
  padding: 28px 22px;
  position: relative;
}

.lesson-meta span {
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 10px 14px;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lesson-meta .status-pill {
  background: rgba(74, 109, 62, 0.10);
  box-shadow: inset 0 0 0 1px rgba(74, 109, 62, 0.22);
  color: var(--green);
}

/* Toolbar */
.lesson-toolbar {
  display: grid;
  gap: 14px;
  margin: 22px 0 28px;
}

.toolbar-progress { height: 6px; }

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

.utility-row a,
.utility-row button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--fill-1);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms var(--ease), transform 120ms var(--ease), color 160ms var(--ease);
}

.utility-row a:hover,
.utility-row button:hover {
  background: var(--fill-2);
  color: var(--ink);
}

.utility-row a:active,
.utility-row button:active {
  transform: scale(0.97);
}

/* Module strip */
.module-strip {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: inset 0 0 0 1px var(--line);
}

.module-strip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.module-strip strong {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

/* Lesson blocks — iOS card stack */
.blocks {
  display: grid;
  gap: 14px;
}

.lesson-block {
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--line);
}

.lesson-block h3 {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffaf2, #fff7e9);
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.012em;
}

.block-index {
  display: grid;
  flex: 0 0 auto;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(180deg, #fbecbf, #f6d987);
  box-shadow: inset 0 0 0 1px rgba(200, 155, 60, 0.36), 0 1px 0 rgba(0, 0, 0, 0.02);
  color: var(--gold-deep);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0;
}

.block-heading-text { min-width: 0; }

.lesson-block h3 small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.segments { display: grid; }

.segment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  transition: background 200ms var(--ease);
}

.segment:nth-child(even) { background: #fdfaf2; }
.segment:last-child { border-bottom: 0; }
.segment:hover { background: #fffaef; }

.segment p {
  margin: 0;
  line-height: 1.62;
  font-size: 15.5px;
  letter-spacing: -0.003em;
}

.segment .vi {
  position: relative;
  padding-left: 14px;
  font-weight: 500;
  color: var(--ink);
}

.segment .vi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2.5px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--green-2), var(--green));
}

.segment .en {
  position: relative;
  padding-left: 14px;
  color: var(--muted);
}

.segment .en::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2.5px;
  border-radius: 999px;
  background: rgba(58, 46, 26, 0.14);
}

.segment .only {
  grid-column: 1 / -1;
  color: var(--ink);
}

.segment .only::before { background: rgba(58, 46, 26, 0.30); }

.segment.missing .vi {
  color: #8a5d12;
  font-style: italic;
  font-weight: 500;
}

.segment.missing .vi::before { background: var(--gold); }

/* Asset section */
.asset-section {
  margin-top: 28px;
  padding-bottom: 32px;
}

.asset-section h3 {
  margin: 0 0 14px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.asset-grid a {
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 92px;
  padding: 16px 18px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  text-decoration: none;
  transition: transform 180ms var(--ease), box-shadow 240ms var(--ease);
}

.asset-grid a:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line-strong);
}

.asset-grid a:active { transform: translateY(0); }

.asset-grid span {
  color: var(--gold-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.asset-grid strong {
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* Empty / loading */
.empty-state {
  display: grid;
  min-height: 50vh;
  place-items: center;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: -0.005em;
}

.empty-state.error { color: var(--coral); }

/* Mobile menu button */
.mobile-only { display: none; }

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--fill-2);
  cursor: pointer;
  transition: background 160ms var(--ease), transform 120ms var(--ease);
}

.icon-button:active { transform: scale(0.96); }

.icon-lines,
.icon-lines::before,
.icon-lines::after {
  display: block;
  width: 16px;
  height: 1.6px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--ink);
  content: "";
}

.icon-lines::before { transform: translateY(-5px); }
.icon-lines::after { transform: translateY(3.4px); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .top-search { width: min(360px, 34vw); }
}

@media (max-width: 980px) {
  .ask-button { display: none; }
  .content { padding: 28px 28px 48px; }
}

@media (max-width: 860px) {
  .topbar {
    min-height: 56px;
    padding: 8px 12px;
    gap: 10px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .brand h1 { font-size: 22px; }

  .top-search { display: none; }

  .mobile-only { display: grid; }

  .shell { display: block; }

  .sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(90vw, 360px);
    height: auto;
    transform: translateX(-105%);
    background: rgba(255, 250, 242, 0.92);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    box-shadow: 0 20px 45px rgba(40, 28, 12, 0.18);
    transition: transform 320ms var(--ease-emphasized);
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }

  .sidebar.open { transform: translateX(0); }

  .search-panel {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    padding: 0 6px;
  }

  .search-panel label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .search-panel input {
    width: 100%;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    background: var(--fill-2);
    outline: none;
    font-size: 14.5px;
    color: var(--ink);
    transition: background 200ms var(--ease), box-shadow 200ms var(--ease);
  }

  .search-panel input:focus {
    background: #fff;
    box-shadow: inset 0 0 0 1.5px rgba(74, 109, 62, 0.4),
      0 0 0 4px rgba(74, 109, 62, 0.12);
  }

  .content { padding: 18px 16px 40px; }

  .lesson-hero { display: grid; }
  .lesson-title-block { padding: 24px 22px 22px; }

  .lesson-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px;
  }

  .lesson-hero h2 { font-size: clamp(30px, 9vw, 42px); }

  .segment {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px;
  }
}

@media (max-width: 520px) {
  .topbar { gap: 8px; }
  .mode-tabs button { min-width: 38px; min-height: 28px; font-size: 12px; padding: 0 8px; }
  .avatar { width: 30px; height: 30px; font-size: 12px; }
  .lesson-meta { grid-template-columns: 1fr; }
  .utility-row a,
  .utility-row button {
    flex: 1 1 auto;
    justify-content: center;
  }
  .progress-box strong { font-size: 22px; }
}

/* ============================================================
   SIDEBAR SCRIM (mobile drawer dismiss)
   ============================================================ */
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 56px 0 0 0;
  z-index: 25;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(20, 16, 10, 0.32);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  cursor: pointer;
  animation: scrimIn 220ms var(--ease) both;
}

@keyframes scrimIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 860px) {
  .sidebar-scrim { display: block; }
}

/* ============================================================
   ASK SEEDS DRAWER (right-side panel + scrim)
   ============================================================ */
.ask-scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(20, 16, 10, 0.36);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  cursor: pointer;
}

.ask-drawer {
  position: fixed;
  z-index: 90;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(440px, calc(100vw - 32px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: 22px;
  background: rgba(255, 250, 242, 0.88);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 30px 60px rgba(40, 28, 12, 0.18),
    0 8px 24px rgba(40, 28, 12, 0.10),
    inset 0 0 0 1px rgba(58, 46, 26, 0.10);
  overflow: hidden;
}

/* Transitions */
.ask-enter-active, .ask-leave-active { transition: transform 320ms var(--ease-emphasized), opacity 220ms var(--ease); }
.ask-enter-from { transform: translateX(24px) scale(0.985); opacity: 0; }
.ask-leave-to { transform: translateX(24px) scale(0.985); opacity: 0; }

.scrim-enter-active, .scrim-leave-active { transition: opacity 220ms var(--ease); }
.scrim-enter-from, .scrim-leave-to { opacity: 0; }

.ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.7), rgba(255, 250, 242, 0.4));
}

.ask-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ask-spark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(180deg, #5d8552, #4a6d3e);
  color: #fff;
  box-shadow: 0 1px 2px rgba(74, 109, 62, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.ask-title strong {
  display: block;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.1;
}

.ask-title small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.ask-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ask-icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: var(--fill-1);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 160ms var(--ease), transform 120ms var(--ease), color 160ms var(--ease);
}

.ask-icon-button:hover { background: var(--fill-2); color: var(--ink); }
.ask-icon-button:active { transform: scale(0.94); }

/* Body */
.ask-body {
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.ask-welcome {
  display: grid;
  gap: 14px;
  padding: 6px 4px 4px;
}

.ask-welcome-line {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: -0.005em;
}

.ask-welcome-line strong { color: var(--ink); font-weight: 700; }

.ask-prompts {
  display: grid;
  gap: 8px;
}

.ask-prompt {
  text-align: left;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 160ms var(--ease), transform 120ms var(--ease), box-shadow 200ms var(--ease);
}

.ask-prompt:hover {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 1px 2px rgba(40, 28, 12, 0.04);
}

.ask-prompt:active { transform: scale(0.99); }

/* Messages */
.ask-msg {
  display: flex;
  width: 100%;
}

.ask-msg.user { justify-content: flex-end; }
.ask-msg.assistant { justify-content: flex-start; }

.ask-msg-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  word-wrap: break-word;
}

.ask-msg.user .ask-msg-bubble {
  background: linear-gradient(180deg, #2a2b32 0%, #16161a 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 1px 2px rgba(40, 28, 12, 0.18);
}

.ask-msg.assistant .ask-msg-bubble {
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  border-bottom-left-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.ask-msg-bubble p { margin: 0 0 8px; }
.ask-msg-bubble p:last-child { margin-bottom: 0; }

.ask-msg-bubble a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 2.5px;
}

/* Citation chips */
.ask-cite {
  display: inline-flex;
  align-items: center;
  margin: 0 2px;
  padding: 2px 9px;
  border: 0;
  border-radius: 999px;
  background: rgba(74, 109, 62, 0.12);
  color: var(--green);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 160ms var(--ease), transform 120ms var(--ease);
}

.ask-cite::before {
  content: "↗";
  margin-right: 4px;
  font-size: 11px;
  opacity: 0.7;
}

.ask-cite:hover {
  background: rgba(74, 109, 62, 0.22);
}

.ask-cite:active { transform: scale(0.97); }

.ask-msg.user .ask-cite {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.ask-msg.user .ask-cite:hover {
  background: rgba(255, 255, 255, 0.28);
}

.ask-error {
  margin: 0 4px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(223, 116, 88, 0.10);
  color: #b3502c;
  font-size: 13px;
  font-weight: 500;
  box-shadow: inset 0 0 0 1px rgba(223, 116, 88, 0.30);
}

/* Footer / form */
.ask-foot {
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.6);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}

.ask-form {
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border-radius: 18px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(40, 28, 12, 0.04);
  transition: box-shadow 200ms var(--ease);
}

.ask-form:focus-within {
  box-shadow: inset 0 0 0 1.5px rgba(74, 109, 62, 0.45),
    0 0 0 4px rgba(74, 109, 62, 0.10);
}

.ask-input {
  flex: 1;
  min-height: 24px;
  max-height: 160px;
  padding: 6px 0 6px;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.45;
  letter-spacing: -0.005em;
}

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

.ask-send {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #5d8552, #4a6d3e);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(74, 109, 62, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: transform 120ms var(--ease), filter 200ms var(--ease);
}

.ask-send:hover:not(:disabled) { filter: brightness(1.07); }
.ask-send:active:not(:disabled) { transform: scale(0.94); }

.ask-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ask-send-spinner {
  display: inline-flex;
  gap: 3px;
}
.ask-send-spinner span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  animation: dotPulse 1.2s ease-in-out infinite;
}
.ask-send-spinner span:nth-child(2) { animation-delay: 0.15s; }
.ask-send-spinner span:nth-child(3) { animation-delay: 0.30s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.30; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.ask-foot-note {
  margin: 8px 4px 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

@media (max-width: 520px) {
  .ask-drawer {
    top: auto;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: 88vh;
    border-radius: 22px 22px 0 0;
  }
  .ask-enter-from, .ask-leave-to {
    transform: translateY(28px);
    opacity: 0;
  }
}

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