/* ---------- Home ---------- */
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: stretch; margin-bottom: 16px; }
.home-lead { display: flex; flex-direction: column; min-width: 0; }
.home-lead h1 { font-size: clamp(28px, 4vw, 40px); margin: 0; }
.lead-text { margin: 8px 0 20px; color: var(--ink-2); }

.today { display: grid; justify-items: center; align-content: center; gap: 18px; padding: 24px; }
.today-side { display: grid; gap: 16px; width: 100%; }
.streak { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-2); font-size: var(--fs-md); }
.streak .icon { width: 24px; height: 24px; color: var(--accent); }
.streak strong { font-size: 20px; color: var(--ink); }
.week { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 0; padding: 14px 0 0; border-top: 1px solid var(--border); }
.week li { display: grid; justify-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.week i { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); }
.week .on i { background: var(--accent); }
.week .now span { color: var(--ink); font-weight: 700; }
.week .now i { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--accent) 55%, transparent); }

.continue {
  flex: 1; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 24px;
  padding: 28px; border: 0; color: var(--primary-ink); background: var(--primary); position: relative; overflow: hidden;
}
.continue::after { content: ""; position: absolute; right: -60px; bottom: -110px; width: 300px; height: 300px; border-radius: 50%;
  border: 44px solid color-mix(in srgb, var(--primary-ink) 9%, transparent); pointer-events: none; }
.continue > * { position: relative; z-index: 1; }
.continue h2 { margin: 0 0 8px; font-size: clamp(21px, 2.6vw, 28px); max-width: 22ch; }
.continue p { margin: 0; opacity: .92; }
.continue form { margin: 0; }
.continue .btn { background: light-dark(#FFFFFF, #0F1115); color: light-dark(#1B1F24, #ECEDEF); }
.continue .btn:hover { background: light-dark(#EEF1FD, #1F232C); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 16px; }
.stat { padding: 16px 20px; }
.home-top + .stat-row .stat { display: flex; align-items: baseline; gap: 10px; }
.stat strong { display: block; font-size: 26px; line-height: 1.15; letter-spacing: -.02em; }
.stat span { color: var(--ink-2); font-size: var(--fs-md); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter);
  background: radial-gradient(60rem 30rem at 50% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 70%); }
.auth-card { width: 100%; max-width: 420px; padding: 40px 32px 28px; box-shadow: var(--shadow-up); }
.auth-card .theme-switch { width: 168px; margin: 24px auto 0; padding: 0; }
.auth-card .logo { --mark: 44px; font-size: 30px; display: flex; width: fit-content; margin-inline: auto; }
.auth-switch { text-align: center; margin: 20px 0 0; color: var(--ink-2); font-size: var(--fs-md); }
.auth-switch a { font-weight: 600; }
.field .hint { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.auth-card .tagline { text-align: center; color: var(--ink-2); margin: 6px 0 28px; }
.auth-foot { display: flex; justify-content: center; margin-top: 20px; }
.auth-foot .theme-switch { padding: 0; width: 180px; }

/* ---------- Topics ---------- */
.topic-card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.topic-card-head { display: flex; gap: 12px; align-items: center; min-height: 48px; }
.topic-card h3 { margin: 0 0 2px; font-size: 17px; line-height: 1.3; }
.topic-card p { margin: 0; }
.topic-card > .badge { align-self: flex-start; }
.topic-card .bar { margin-top: auto; }
.topic-card .quick { position: relative; z-index: 1; margin: 0; }
.topic-card .quick .btn { width: 100%; }
.topic-card .quick .btn:hover { border-color: var(--topic); color: var(--topic-text); }
.stretched { color: var(--ink); }
.stretched::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.stretched:hover { text-decoration: none; }
.topic-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--topic, var(--primary)) 14%, transparent); color: var(--topic-text); }
.topic-icon .icon { width: 22px; height: 22px; }
.topic-icon.big { width: 64px; height: 64px; border-radius: 18px; }
.topic-icon.big .icon { width: 32px; height: 32px; }

.topic-hero { padding: 24px; border-radius: var(--radius); margin-bottom: 8px;
  background: color-mix(in srgb, var(--topic, var(--primary)) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--topic, var(--primary)) 22%, var(--border)); }
.hero-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.hero-text { flex: 1 1 320px; }
.hero-text h1 { margin-bottom: 6px; font-size: 34px; }
.hero-text p { margin: 0 0 10px; }
.hero-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: var(--fs-md); color: var(--ink-2); margin-bottom: 12px; }
.crumbs a { color: var(--ink-2); }
.tag-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-chips .chip { text-decoration: none; }
.tag-chips .chip:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }

.tree-card { padding: 8px 20px; }
.topic-tree { list-style: none; margin: 0; padding: 0; }
.topic-tree .topic-tree { padding-left: 24px; border-left: 2px solid var(--border); margin-left: 8px; }
.tree-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border); }
.topic-tree > li:last-child > .tree-row { border-bottom: 0; }
.tree-main { flex: 1 1 220px; display: grid; gap: 2px; }
.tree-chips { min-width: 180px; justify-content: flex-end; }
.tree-row > .badge { min-width: 92px; justify-content: center; }
.tree-name { font-weight: 600; color: var(--ink); }
.tree-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Glossary ---------- */
.glossary-filters { margin-bottom: 12px; }
.az { display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0 20px; }
.az a { min-width: 34px; height: 34px; padding: 0 8px; display: grid; place-items: center; border-radius: 8px;
  color: var(--ink-2); font-weight: 600; font-size: var(--fs-md); }
.az a:hover { background: var(--surface-2); text-decoration: none; }
.az a[aria-current="true"] { background: var(--primary); color: var(--primary-ink); }
.term-card { display: block; }
.term-card h3 { margin-bottom: 4px; font-size: 18px; color: var(--ink); }
.term-card p { margin: 0 0 6px; color: var(--ink-2); }
.lead { font-size: 19px; color: var(--ink-2); margin-top: 16px; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }

/* ---------- Term tooltips (inside question text) ---------- */
button.term {
  display: inline; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit; cursor: help;
  border-bottom: 2px dotted var(--primary);
}
button.term:hover, button.term[aria-expanded="true"] { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.term-pop {
  position: fixed; z-index: 80; display: none; width: max-content;
  max-width: min(320px, calc(100vw - 24px)); padding: 12px 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgb(0 0 0 / .18); font-size: var(--fs-md); line-height: 1.5; font-weight: 400; text-align: left;
}
.term-pop.open { display: block; }
.term-pop:empty { display: none !important; }
.term-pop .tip { display: grid; gap: 6px; }
.term-pop .def { color: var(--ink-2); }

/* ---------- Profiles ---------- */
.profile-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.profile-card { display: flex; flex-direction: column; gap: 14px; }
.profile-card > .profile-actions { margin-top: auto; }
.profile-card h3 a { color: var(--ink); }
.profile-card .chips { margin-top: 10px; }
.profile-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.profile-head h2 { font-size: 21px; margin: 0 0 4px; }
.profile-head p { margin: 0; }
.ready { display: grid; justify-items: end; min-width: 84px; }
.ready strong { font-size: 28px; line-height: 1; color: var(--primary); }
.ready span { font-size: var(--fs-sm); color: var(--ink-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.profile-actions form { margin: 0; }
.item-row { display: grid; grid-template-columns: 2fr 1.2fr 1.4fr auto; gap: 12px; align-items: end; padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.item-row .field { margin: 0; }
.small-h { font-size: 18px; margin: 20px 0 10px; }
.review-list { display: grid; gap: 12px; margin-top: 16px; }
.review-row { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.review-main { flex: 1; display: grid; gap: 6px; }
.review-main p { margin: 0; }
.icon-btn.is-on { color: var(--accent); }
.icon-btn.is-on .icon { fill: currentColor; }

/* ---------- Charts (server rendered SVG) ---------- */
.line-chart { width: 100%; height: auto; display: block; }
.line-chart .grid { stroke: var(--border); stroke-width: 1; }
.line-chart .axis { fill: var(--ink-2); font-size: 10px; }
.line-chart .series { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; }
.line-chart .dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2.5; }
.chart-pair { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 24px; margin-top: 44px; align-items: stretch; }
.chart-pair section { display: flex; flex-direction: column; min-width: 0; }
.chart-pair h2 { font-size: 19px; }
.chart-pair .card { flex: 1; display: grid; align-content: center; }
.heatmap { width: 100%; height: auto; display: block; }
body:not(:has(#show-children:checked)) tr.is-child { display: none; }
.heatmap .lv0 { fill: var(--surface-2); }
.heatmap .lv1 { fill: color-mix(in srgb, var(--success) 25%, var(--surface-2)); }
.heatmap .lv2 { fill: color-mix(in srgb, var(--success) 50%, var(--surface-2)); }
.heatmap .lv3 { fill: color-mix(in srgb, var(--success) 75%, var(--surface-2)); }
.heatmap .lv4 { fill: var(--success); }
.heatmap text { fill: var(--ink-2); font-size: 9px; }

@media (max-width: 640px) {
  .item-row { grid-template-columns: 1fr; }
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 21px; }
a.stat { color: var(--ink); display: block; }
a.stat:hover { text-decoration: none; }

@media (max-width: 900px) {
  .chart-pair { grid-template-columns: minmax(0, 1fr); }
  .home-top { grid-template-columns: minmax(0, 1fr); }
  .today { grid-template-columns: auto 1fr; justify-items: start; gap: 24px; }
  .today .ring { --size: 112px !important; }
  .streak { justify-content: flex-start; }
}
@media (max-width: 480px) {
  .home-top + .stat-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .home-top + .stat-row .stat { display: grid; gap: 2px; padding: 12px; }
  .home-top + .stat-row .stat span { font-size: 12px; line-height: 1.35; }
  .today { padding: 16px; gap: 16px; }
  .week { gap: 2px; }
  .week i { width: 18px; height: 18px; }
  .hero-row .btn { width: 100%; }
  .tree-row { gap: 8px; }
  .tree-main { flex-basis: 100%; }
  .tree-chips { display: none; }
  .tree-row .btn { margin-left: auto; }
}

.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; font-size: var(--fs-md); }
.auth-row .check { margin: 0; }
