:root {
  color-scheme: light;
  --ground: #f2f4fa;
  --paper: #fff;
  --ink: #202a45;
  --muted: #58647c;
  --line: #dce1ef;
  --brand: #4c50c6;
  --brand-deep: #393dad;
  --lavender: #e8e8ff;
  --green: #16684f;
  --green-soft: #e4f4ed;
  --red: #a12b46;
  --red-soft: #ffedf1;
  --radius: 20px;
  --pad: clamp(15px, 3.3vw, 32px);
  font: 16px/1.52 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ground);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
:is(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid #7c7ef2;
  outline-offset: 3px;
}
button[disabled] { opacity: .55; cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .face-question {
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.16;
  letter-spacing: -.035em;
}
h1 { font-size: clamp(1.85rem, 5vw, 3rem); }
h2 { font-size: clamp(1.25rem, 3.7vw, 1.72rem); }
h3 { font-size: 1.13rem; }
.icon { width: 1.23em; height: 1.23em; flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.boot { max-width: 33rem; min-height: 80svh; margin: auto; padding: 30px; display: grid; place-content: center; justify-items: start; gap: 14px; }
#app { min-height: 100dvh; display: grid; grid-template-columns: minmax(0,1fr); }
.sidebar { display: none; }
.stage { min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 3; min-height: 61px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: calc(max(env(safe-area-inset-top), var(--tg-safe-top, 0px)) + 10px) var(--pad) 9px;
  background: var(--ground); border-bottom: 1px solid var(--line);
}
.identity { background: none; border: 0; padding: 0; display: flex; align-items: center; text-align: left; gap: 8px; cursor: pointer; min-width: 0; line-height: 1.08; }
.identity img { flex: 0 0 auto; width: 34px; height: 34px; }
.identity strong, .identity small { display: block; }
.identity strong { font-size: 1.05rem; letter-spacing: -.035em; }
.identity small { margin-top: 4px; color: var(--muted); font-size: .69rem; }
.desk-title { display: none; }
.top-actions { display: flex; gap: 7px; flex: 0 0 auto; align-items: center; }
.content { width: min(100%, 1060px); margin: auto; padding: 16px var(--pad) calc(94px + max(env(safe-area-inset-bottom), var(--tg-safe-bottom, 0px))); }
.content:focus { outline: none; }
.bottom {
  position: fixed; z-index: 4; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
  padding: 5px clamp(8px, 3vw, 22px) calc(max(env(safe-area-inset-bottom), var(--tg-safe-bottom, 0px)) + 4px);
  background: var(--paper); border-top: 1px solid var(--line);
}
.bottom button, .sidebar nav button {
  appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 12px;
  min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 4px;
}
.bottom button { flex-direction: column; font-weight: 650; font-size: .7rem; line-height: 1.14; }
.bottom button .icon { width: 21px; height: 21px; }
.bottom button[aria-current] , .sidebar nav button[aria-current] { background: var(--lavender); color: var(--brand-deep); }
.button {
  appearance: none; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 13px; text-align: center; border: 1px solid transparent; border-radius: 12px;
  font-size: .91rem; font-weight: 690; line-height: 1.25; text-decoration: none; cursor: pointer;
  overflow-wrap: anywhere;
}
.primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 3px 0 #363b9c25; }
.secondary, .icon-button { background: var(--paper); color: var(--ink); border-color: var(--line); }
.quiet { background: transparent; color: var(--brand-deep); min-height: 42px; }
.chip { min-height: 42px; border-color: var(--line); background: var(--paper); padding-inline: 10px; color: var(--muted); font-size: .79rem; }
.chip.selected { background: var(--lavender); color: var(--brand-deep); border-color: #c6c5ff; }
.icon-button { width: 44px; flex: 0 0 auto; padding: 0; }
.icon-button.is-star { color: #6c5100; background: #fff4ce; border-color: #f2e1a2; }
.is-star .icon { fill: #f3c543; }
.success { color: var(--green); background: var(--green-soft); border-color: #b8dece; }
.full { width: 100%; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.hero { isolation: isolate; background: var(--lavender); min-height: 230px; border-radius: 24px; position: relative; overflow: hidden; padding: clamp(18px, 4.2vw, 33px); display: flex; align-items: center; }
.hero-copy { z-index: 1; width: 100%; }
.hero h1 { letter-spacing: -.061em; font-weight: 840; font-size: clamp(1.75rem, 6.6vw, 3.55rem); }
.eyebrow { color: var(--brand-deep); font-size: .73rem; line-height: 1.15; font-weight: 790; letter-spacing: .065em; }
.hero .eyebrow { margin-bottom: 12px; }
.hero-lead { margin: 11px 0 17px; color: #4f5b75; max-width: 25ch; font-size: .93rem; }
.hero .button { margin-top: 0; padding-inline: 13px; }
.deck-art { width: 105px; height: 132px; position: absolute; right: clamp(5px, 4.2vw, 37px); top: 16px; rotate: 7deg; opacity: .94; }
.art-card { position: absolute; inset: 0; border-radius: 15px; }
.back-one { background: #b1aff8; rotate: -23deg; translate: -7px 6px; }
.back-two { background: #c7c5ff; rotate: 18deg; translate: 4px -2px; }
.front { display: flex; flex-direction: column; justify-content: space-between; background: var(--paper); padding: 12px; box-shadow: 0 9px 16px #3c39ac32; rotate: -7deg; }
.front span { color: var(--brand); font-size: .71rem; font-weight: 850; }
.front strong { font-family: ui-rounded, -apple-system, sans-serif; font-weight: 850; font-size: clamp(.8rem, 2.7vw, 1.25rem); line-height: 1.1; letter-spacing: -.04em; }
.front i { width: 26px; height: 3px; background: var(--brand); border-radius: 3px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.stat { min-height: 80px; padding: 9px 10px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; text-align: start; gap: 3px; }
button.stat { cursor: pointer; }
.stat strong { font-size: clamp(1.27rem, 4vw, 2rem); line-height: 1; letter-spacing: -.05em; }
.stat .icon { color: var(--brand); width: 17px; height: 17px; }
.stat span { grid-column: 1/-1; font-size: .75rem; color: var(--muted); line-height: 1.18; }
.section { margin-top: clamp(22px, 6vw, 34px); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.mode-tile { appearance: none; display: flex; flex-direction: column; align-items: start; text-align: left; gap: 5px; padding: 13px; cursor: pointer; }
.mode-tile > strong { letter-spacing: -.02em; font-size: .98rem; }
.mode-tile > span:last-child { color: var(--muted); font-size: .8rem; line-height: 1.38; }
.mode-icon { background: var(--lavender); color: var(--brand-deep); width: 36px; height: 36px; border-radius: 11px; display: inline-grid; place-items: center; margin-bottom: 3px; }
.mode-icon .icon { width: 20px; height: 20px; }
.lecture-list { overflow: hidden; }
.lecture-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; cursor: pointer; text-align: left; min-height: 64px; }
.lecture-row:last-child { border-bottom: 0; }
.lecture-number { width: 35px; height: 35px; flex: 0 0 auto; display: grid; place-items: center; color: var(--brand-deep); background: var(--lavender); font-weight: 800; border-radius: 10px; }
.lecture-text { flex: 1; min-width: 0; line-height: 1.22; }
.lecture-text small { color: var(--muted); display: block; margin-bottom: 4px; font-size: .74rem; }
.lecture-text strong { font-size: .96rem; }
.lecture-row > .icon { color: var(--muted); }
.page-heading { margin: 7px 0 16px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.page-heading p, .setup p, .empty p { color: var(--muted); margin-top: 8px; }
.setup, .empty { padding: clamp(18px, 5vw, 32px); }
.setup .actions, .empty .button { margin-top: 13px; }
.setup h2, .empty h2 { margin-top: 5px; }
.step-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; align-items: center; color: var(--muted); font-size: .81rem; font-weight: 650; }
.step-row .button { padding-right: 0; }
progress { display: block; border: 0; width: 100%; height: 8px; appearance: none; border-radius: 99px; background: var(--lavender); overflow: hidden; accent-color: var(--brand); }
progress::-webkit-progress-bar { background: var(--lavender); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--brand); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--brand); }
.card-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; column-gap: 3px; margin: -4px 0 9px; min-height: 44px; color: var(--muted); font-size: .83rem; font-weight: 680; }
.card-meta > div { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; }
.card-meta .quiet { padding-inline: 5px; font-size: .8rem; font-weight: 650; }
.card-meta .icon-button { border: none; }
.study-card { padding: clamp(12px, 4.1vw, 24px); overflow-wrap: anywhere; }
.study-card h2 { font-size: clamp(1.28rem, 4.7vw, 2.08rem); }
.study-card > .eyebrow { margin-bottom: 9px; }
.study-hint { color: var(--muted); margin-top: 11px; }
.study-actions, .rating { margin-top: 12px; }
.actions { display: flex; align-items: stretch; gap: 8px; }
.actions > :not(.icon-button) { flex: 1; }
.actions .icon-button { min-height: 44px; }
.study-actions .button { min-height: 49px; }
.face { display: flex; flex-direction: column; align-items: start; text-align: start; gap: 14px; padding: clamp(14px, 5vw, 31px); width: 100%; min-height: 177px; border: 0; background: #f5f5ff; border-radius: 13px; color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.face-question { font-size: clamp(1.35rem, 5vw, 2.4rem); font-weight: 790; }
.face-answer, .prose { line-height: 1.56; font-size: clamp(.98rem, 3.6vw, 1.06rem); }
.flashcard .face { position: relative; min-height: clamp(235px, 43dvh, 390px); }
.flashcard .face[data-side="question"] { justify-content: center; padding-block: 48px; }
.flashcard .face[data-side="question"] .eyebrow { position: absolute; top: 17px; }
.prose p + p { margin-top: .7em; }
.explain { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 14px; }
.explain h3 { margin-bottom: 7px; }
.toggles { display: flex; flex-wrap: wrap; column-gap: 14px; margin-bottom: 7px; }
.check-row { display: flex; align-items: start; gap: 8px; font-size: .91rem; line-height: 1.32; min-height: 40px; padding: 9px 0; cursor: pointer; }
input:is([type=checkbox], [type=radio]) { accent-color: var(--brand); width: 19px; height: 19px; margin: 0; flex: 0 0 auto; }
.rubric { margin-top: 18px; }
.rubric .section-heading { color: var(--muted); }
.rubric h3 { color: var(--ink); }
.rubric-row { background: #f4f4ff; border-radius: 10px; padding: 10px; margin-top: 5px; }
.quiz-sizes { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; border: 0; margin: 12px 0; }
.quiz-sizes legend { font-weight: 650; margin-bottom: 5px; }
.quiz-sizes label { border: 1px solid var(--line); min-height: 44px; padding: 8px 12px; border-radius: 9px; display: flex; gap: 7px; align-items: center; cursor: pointer; }
.options { display: grid; gap: 8px; margin-top: 13px; }
.option { appearance: none; text-align: left; display: flex; align-items: start; gap: 9px; padding: 10px; min-height: 48px; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; background: var(--paper); cursor: pointer; line-height: 1.44; }
.option span:first-child { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 auto; border-radius: 6px; color: var(--brand-deep); background: var(--lavender); font-weight: 720; }
.option.picked, .pair-tile.picked { border-color: #8e90eb; background: #f1f1ff; }
.option.correct, .pair-tile.matched { color: var(--green); background: var(--green-soft); border-color: #b8dece; opacity: 1; }
.option.incorrect { color: var(--red); background: var(--red-soft); border-color: #efbbc7; opacity: 1; }
.question-steps { margin-top: 13px; display: flex; flex-wrap: wrap; gap: 4px; }
.question-dot { min-width: 42px; background: var(--paper); border-color: var(--line); }
.question-dot.answered { background: var(--lavender); color: var(--brand-deep); }
.question-dot.active { border-color: var(--brand); }
.pair-layout { display: grid; gap: 10px; }
.pair-list { display: grid; gap: 7px; padding: 13px; align-content: start; }
.pair-list h2 { margin: 3px 0; }
.pair-tile { text-align: left; justify-content: start; border-color: var(--line); background: var(--paper); }
.pair-feedback { color: var(--muted); margin-top: 9px; }
.results-list { display: grid; gap: 8px; }
.results-list .prose { margin-top: 6px; }
.search { border: 1px solid var(--line); background: var(--paper); border-radius: 12px; display: flex; align-items: center; padding: 0 11px; gap: 7px; margin: 0 0 12px; color: var(--muted); }
.search input { border: 0; background: transparent; padding: 10px 3px; min-height: 46px; width: 100%; color: var(--ink); }
.search input:focus-visible { outline-offset: -2px; }
.catalog-results { display: grid; gap: 8px; margin-top: 8px; }
.catalog-card { padding: 10px 13px; }
.catalog-card .card-meta { margin-bottom: 0; }
.catalog-card summary { cursor: pointer; font-weight: 730; line-height: 1.35; min-height: 36px; }
.catalog-card .prose { padding: 5px 0 9px; color: var(--muted); overflow-wrap: anywhere; }
.catalog-actions { display: flex; justify-content: end; }
.catalog-actions .button { padding-right: 0; }
.filter-note { color: var(--muted); font-size: .82rem; margin-bottom: 7px; }
.progress-panel { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 17px; }
.progress-panel h2 { margin: 7px 0; }
.progress-panel p:not(.eyebrow) { color: var(--muted); font-size: .87rem; }
.progress-panel > strong { color: var(--brand-deep); font-size: 1.75rem; letter-spacing: -.05em; }
.progress-panel progress { grid-column: 1/-1; }
.activity, .detail-progress { padding: 15px; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 4px; margin-top: 12px; }
.day { display: grid; justify-items: center; gap: 3px; color: var(--muted); font-size: .8rem; }
.bar-track { width: 65%; height: 75px; background: #f1f0fd; border-radius: 7px; display: flex; align-items: end; }
.bar-track > div { height: var(--bar); width: 100%; background: var(--brand); border-radius: 7px; }
.detail-progress { display: grid; gap: 12px; }
.detail-progress > div { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 5px 10px; font-size: .91rem; }
.detail-progress progress { grid-row: 2; }
.detail-progress span:last-child { color: var(--muted); }
dialog {
  padding: 0; width: min(550px, calc(100% - 22px)); max-height: min(760px, 87dvh); background: var(--paper);
  border: 1px solid var(--line); border-radius: 20px; color: var(--ink); box-shadow: 0 24px 90px #2b306940;
}
dialog::backdrop { background: #161b45a3; }
dialog.source-dialog { width: min(920px, calc(100% - 18px)); }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; gap: 9px; align-items: center; padding: 9px 13px; background: var(--paper); border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 1.2rem; }
.dialog-body { display: grid; gap: 11px; padding: 14px; }
.dialog-body p { color: var(--muted); }
.dialog-body fieldset { border: 1px solid var(--line); margin: 0; border-radius: 10px; padding: 4px 10px; min-width: 0; }
.dialog-body legend { font-weight: 720; padding-inline: 4px; }
.field-label { display: flex; flex-direction: column; gap: 4px; margin: 3px 0; font-weight: 690; }
.field-label :is(input, select, textarea), #copy-field { border: 1px solid var(--line); min-height: 44px; border-radius: 10px; background: var(--paper); padding: 8px 10px; width: 100%; color: var(--ink); }
.field-label textarea { resize: vertical; font-weight: 400; }
.source-image { width: 100%; display: block; background: #f2f4fa; border-radius: 7px; }
.source-pages { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.source-pages .button { padding-inline: 9px; background: #f3f3ff; }
.form-error, .dialog-body .form-error { color: var(--red); font-size: .91rem; }
.notice { background: var(--red-soft); color: var(--red); padding: 10px 13px; border-radius: 12px; margin-bottom: 12px; font-size: .91rem; }
.notice.success-notice { background: var(--green-soft); color: var(--green); }
.sticky-free { position: relative; }
@media (max-width: 350px) {
  .icon-label span { display: none; }
  .chip { padding-inline: 10px; }
  .deck-art { width: 69px; height: 96px; top: 42px; right: 11px; }
  .front { padding: 8px; }
  .hero h1 { font-size: 1.52rem; }
  .hero .eyebrow { font-size: .69rem; }
}
@media (min-width: 351px) and (max-width: 459px) {
  .deck-art { width: 95px; height: 123px; top: 34px; right: 15px; }
  .hero h1 { font-size: clamp(1.52rem, 6.15vw, 1.8rem); }
}
@media (max-width: 459px) {
  .hero h1, .hero-lead { max-width: calc(100% - 100px); }
}
@media (max-width: 350px) {
  .hero h1, .hero-lead { max-width: calc(100% - 71px); }
  .content:has(.flashcard) .page-heading p { display: none; }
  .flashcard .card-meta { flex-wrap: nowrap; }
  .flashcard .card-meta > span { min-width: 0; }
  .flashcard .face { min-height: clamp(274px, 39dvh, 335px); }
}
@media (min-width: 460px) {
  .deck-art { width: 135px; height: 165px; top: 15%; }
  .stats { gap: 12px; }
  .stat { padding: 12px 16px; }
  .mode-tile { padding: 15px; }
}
@media (min-width: 690px) {
  .pair-layout { grid-template-columns: 1.2fr 1fr; }
  .deck-art { width: 160px; height: 192px; top: 13%; right: 8%; }
  .front { padding: 17px; }
  .hero-lead { max-width: 38ch; }
  .hero { min-height: 268px; }
  .flashcard .face { min-height: 235px; }
}
@media (min-width: 850px) {
  #app { grid-template-columns: 220px minmax(0,1fr); }
  .sidebar { display: flex; flex-direction: column; align-items: stretch; gap: 26px; position: sticky; align-self: start; top: 0; height: 100dvh; padding: 24px 14px; background: var(--paper); border-right: 1px solid var(--line); }
  .sidebar .identity { padding-inline: 9px; gap: 9px; }
  .sidebar .identity img { width: 43px; height: 43px; }
  .sidebar .identity strong { font-size: 1.22rem; }
  .sidebar nav { display: grid; gap: 4px; }
  .sidebar nav button { justify-content: start; gap: 9px; padding-inline: 10px; font-size: .91rem; font-weight: 680; }
  .side-foot { margin-top: auto; }
  .mobile-brand, .bottom { display: none; }
  .desk-title { display: block; font-weight: 750; }
  .content { padding-bottom: var(--pad); }
  .top { padding-top: 9px; }
  .mode-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
}
@media (hover: hover) {
  .primary:hover { background: var(--brand-deep); }
  .secondary:hover, .quiet:hover, .icon-button:hover, .mode-tile:hover, .lecture-row:hover, button.stat:hover { background: #f2f2ff; }
}
@media (prefers-reduced-motion: no-preference) {
  .button, .mode-tile, .lecture-row { transition: background-color .14s, border-color .14s; }
  .face { animation: appear .18s ease-out; }
  @keyframes appear { from { opacity: .75; } to { opacity: 1; } }
}
