/* Учёба: страница набора и режимы. Токены и общие компоненты (кнопки, шторка) — в app.css.
   «Знаю» — голубой, «ещё учу» — бежевый/оранжевый, акцент учёбы — фиолетовый. */
:root {
  --know-bg: var(--sky); --know-ink: #24405E;
  --learn-bg: var(--beige); --learn-ink: #B8481F;
  --face: var(--surface);
  --face-back: #FFF3EC;
  --new: color-mix(in srgb, var(--ink) 20%, transparent);
}
html.dark {
  --know-bg: #2F5278; --know-ink: #DCEBFF;
  --learn-bg: #4A3340; --learn-ink: #FFB399;
  --face-back: #263B5E;
}

.study { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding-top: 6px; background: var(--bg); overscroll-behavior: contain; }

/* шапка */
.sx-head { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; padding: 4px 14px 10px; }
.sx-title { min-width: 0; }
.sx-title b { display: block; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-title span { display: block; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-title span:empty { display: none; }
.sx-right { display: flex; align-items: center; gap: 6px; }
.sx-progress { height: 4px; margin: 0 16px; border-radius: 2px; background: var(--line); overflow: hidden; }
.sx-bar { display: block; height: 100%; border-radius: 2px; background: var(--violet); transform-origin: left; transform: scaleX(0); transition: transform .6s var(--ease); }
.sx-body { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); will-change: transform; }
.sx-body > * { min-height: 100%; }
.sx-section { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 10px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.sx-count { font-size: 14px; font-weight: 400; color: var(--ink-2); }
.muted { color: var(--ink-2); }

/* ---------- страница набора ---------- */
.hub { display: flex; flex-direction: column; }
.peek-wrap { margin: -4px -16px 0; }
.peek-track { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 9% 16px; scrollbar-width: none; overscroll-behavior-x: contain; }
.peek-track::-webkit-scrollbar { display: none; }
.peek { flex: 0 0 100%; scroll-snap-align: center; height: 196px; padding: 0; border: 0; background: none; perspective: 1100px; transition: transform .25s var(--ease), opacity .25s; }
.peek-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .65s var(--ease); }
.peek-inner.flipped { transform: rotateY(180deg); }
.peek-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 22px; border-radius: 24px;
  background: var(--face); box-shadow: var(--shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.peek-face.back { transform: rotateY(180deg); background: var(--face-back); }
.peek-term { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.peek-ipa { font-size: 15px; color: var(--ink-2); }
.peek-tr { font-size: 22px; font-weight: 500; line-height: 1.3; text-align: center; overflow-wrap: anywhere; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 132px; padding: 14px 16px 16px; border: 0; border-radius: var(--r-l); text-align: left;
  transition: transform .2s var(--ease); }
.mode-tile:active { transform: scale(.97); }
.mt-ic { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: auto; border-radius: 14px; }
.mode-tile b { margin-top: 14px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.mode-tile .mt-sub { font-size: 13.5px; line-height: 1.3; }
.mode-tile.m-cards { background: var(--blue); color: #FFFDF5; }
.mode-tile.m-cards .mt-ic { background: rgba(255, 253, 245, .16); }
.mode-tile.m-cards .mt-sub { color: #DCE7F3; }
.mode-tile.m-learn { background: var(--violet); color: #1E1750; }
.mode-tile.m-learn .mt-ic { background: rgba(255, 255, 255, .3); }
.mode-tile.m-learn .mt-sub { color: #1E1750; }
.mode-tile.m-test { background: var(--sky); color: #24405E; }
.mode-tile.m-test .mt-ic { background: rgba(36, 64, 94, .1); }
.mode-tile.m-test .mt-sub, .mode-tile.m-match .mt-sub { color: #3A5878; }
.mode-tile.m-match { background: var(--beige); color: #24405E; }
.mode-tile.m-match .mt-ic { background: var(--orange); color: #fff; }
.mode-tile.off { opacity: .45; }

.mastery { margin-top: 22px; padding: 16px; border-radius: var(--r-l); background: var(--surface); }
.result .mastery-bar, .result .mastery-legend { width: 100%; }
.mastery-bar { display: flex; gap: 3px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line); }
.mastery-bar.big { height: 10px; margin: 10px 0 2px; }
.seg { min-width: 6px; border-radius: 4px; transition: flex .7s var(--ease); }
.seg.known { background: var(--blue); } html.dark .seg.known { background: var(--sky); }
.seg.learning { background: var(--orange); }
.seg.new { background: var(--new); }
.mastery-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; font-size: 13.5px; color: var(--ink-2); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 8px; height: 8px; border-radius: 50%; }
.lg.known i { background: var(--blue); } html.dark .lg.known i { background: var(--sky); }
.lg.learning i { background: var(--orange); } .lg.new i { background: var(--new); }

.wl, .hub-group { background: var(--surface); border-radius: var(--r-l); overflow: hidden; }
.wl.compact { width: 100%; margin-top: 4px; text-align: left; }
.wl-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; min-height: 60px; padding: 10px 8px 10px 16px; }
.wl-row + .wl-row, .pref-row + .pref-row, .type-row + .type-row { border-top: 1px solid var(--line); }
.wl-row.tap { transition: background .2s; }
.wl-row.tap:active { background: var(--surface-2); }
.wl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--new); }
.wl-dot.known { background: var(--blue); } html.dark .wl-dot.known { background: var(--sky); }
.wl-dot.learning { background: var(--orange); }
.wl-text { min-width: 0; }
.wl-text b { display: block; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.wl-text span { display: block; margin-top: 1px; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.wl-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; }
.wl-mark.ok { background: var(--know-bg); color: var(--know-ink); }
.wl-mark.no { background: var(--learn-bg); color: var(--learn-ink); }
.wl-misses { padding-right: 10px; font-size: 15px; font-weight: 600; color: var(--learn-ink); font-variant-numeric: tabular-nums; }
.prefs { margin-bottom: 8px; }
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 12px 16px; font-weight: 500; }
.seg-ctl { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.seg-ctl button { min-height: 44px; padding: 6px 12px; border: 0; border-radius: 9px; background: none; color: var(--ink-2); font-size: 14px; font-weight: 500; transition: background .25s, color .25s; }
.seg-ctl button.on { background: var(--blue); color: #FFFDF5; }
html.dark .seg-ctl button.on { background: var(--sky); color: #24405E; }

/* ---------- Карточки ---------- */
.fc { display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.fc-counts { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fc-count { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.fc-count b { display: inline-grid; place-items: center; min-width: 32px; height: 28px; padding: 0 9px; border-radius: 14px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fc-count.learn b { background: var(--learn-bg); color: var(--learn-ink); }
.fc-count.know { flex-direction: row-reverse; }
.fc-count.know b { background: var(--know-bg); color: var(--know-ink); }
.fc-deck { position: relative; flex: 1; min-height: min(340px, 44vh); max-height: 470px; }
.fc-card { position: absolute; inset: 0; z-index: 2; perspective: 1400px; touch-action: none; user-select: none; -webkit-user-select: none; will-change: transform; }
.fc-card.under { z-index: 1; transform: translate3d(0, 12px, 0) scale(.95); pointer-events: none; will-change: auto; }
.fc-card.under .fc-face { box-shadow: none; }
.fc-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s var(--ease); }
.fc-inner.flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 10px; padding: 36px 24px; text-align: center; overflow-y: auto; scrollbar-width: none;
  border-radius: 28px; background: var(--face); box-shadow: var(--shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.fc-face.back { transform: rotateY(180deg); background: var(--face-back); }
.fc-term { font-size: clamp(32px, 9.4vw, 42px); font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; overflow-wrap: anywhere; }
.fc-ipa { font-size: 17px; color: var(--ink-2); }
.fc-tr { font-size: clamp(24px, 6.8vw, 30px); font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; overflow-wrap: anywhere; }
.fc-tr.big { font-size: clamp(28px, 8vw, 36px); }
.fc-ex { max-width: 32ch; margin-top: 10px; font-size: 15.5px; line-height: 1.5; }
.fc-ex .ru { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); }
.fc-stamp { position: absolute; top: 26px; z-index: 3; padding: 6px 14px; border-radius: 14px; font-size: 16px; font-weight: 600; opacity: 0; pointer-events: none; }
.fc-stamp.know { left: 22px; background: var(--blue); color: #FFFDF5; transform: rotate(-8deg) scale(.8); }
.fc-stamp.learn { right: 22px; background: var(--orange); color: #1B3350; transform: rotate(8deg) scale(.8); }
.fc-hint { text-align: center; font-size: 13.5px; color: var(--ink-2); transition: opacity .4s; }
.fc-hint.gone { opacity: 0; }
.fc-controls { display: grid; grid-template-columns: auto 1fr 1fr auto; align-items: center; gap: 12px; padding-bottom: 4px; }
.fc-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 58px; border: 0; border-radius: 20px; font-size: 15px; font-weight: 600; transition: transform .2s var(--ease); }
.fc-btn:active { transform: scale(.94); }
.fc-btn.no { background: var(--learn-bg); color: var(--learn-ink); }
.fc-btn.yes { background: var(--know-bg); color: var(--know-ink); }

/* ---------- вопросы (заучивание, тест) ---------- */
.q { display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.q-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 22px 28px; border-radius: 26px; background: var(--face); box-shadow: var(--shadow); text-align: center; }
.q-label { margin-bottom: 6px; font-size: 14px; color: var(--ink-2); }
.q-term { font-size: clamp(30px, 8.6vw, 38px); font-weight: 600; letter-spacing: -0.025em; line-height: 1.12; overflow-wrap: anywhere; }
.q-ipa { font-size: 16px; color: var(--ink-2); }
.q-tr { font-size: clamp(23px, 6.6vw, 29px); font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; overflow-wrap: anywhere; }
.q-hint { max-width: 34ch; margin-top: 6px; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }
.q-speak { position: absolute; top: 8px; right: 8px; background: transparent; color: var(--accent-ink); }
.tf-eq { font-size: 18px; color: var(--ink-2); }
.choices { display: grid; gap: 10px; }
.choice { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 12px 16px; border: 0; border-radius: 18px;
  background: var(--surface); text-align: left; font-size: 16px; font-weight: 500; box-shadow: inset 0 0 0 1px var(--line);
  transition: background .3s, box-shadow .3s, opacity .35s, transform .2s var(--ease); }
.choice:active { transform: scale(.985); }
.choice-k { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.choice-t { line-height: 1.35; overflow-wrap: anywhere; }
.choices.answered .choice:not(.right):not(.wrong) { opacity: .45; }
.choice.right { background: var(--know-bg); color: var(--know-ink); box-shadow: none; }
.choice.right .choice-k { background: var(--blue); color: #FFFDF5; }
.choice.wrong { background: var(--learn-bg); color: var(--learn-ink); box-shadow: none; }
.choice.wrong .choice-k { background: var(--orange); color: #fff; }
.w-box { display: flex; flex-direction: column; gap: 10px; }
.w-input { width: 100%; min-height: 60px; padding: 14px; border: 0; border-radius: 18px; background: var(--surface); text-align: center; font-size: 22px; font-weight: 600; outline: none;
  caret-color: var(--violet); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .25s, background .25s; }
.w-input::placeholder { font-size: 16px; font-weight: 400; color: var(--ink-2); opacity: .75; }
.w-input:focus { box-shadow: inset 0 0 0 2px var(--violet); }
.w-input.right { background: var(--know-bg); color: var(--know-ink); box-shadow: none; }
.w-input.wrong { background: var(--learn-bg); color: var(--learn-ink); box-shadow: none; }
.w-fb { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 22px; text-align: center; font-size: 15.5px; }
.fb-ok { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent-ink); }
.fb-yours s { color: var(--learn-ink); text-decoration-thickness: 1.5px; }
.fb-right b { font-size: 18px; font-weight: 600; }
.fb-ex { max-width: 34ch; font-size: 14px; color: var(--ink-2); }
.q-foot { display: grid; gap: 10px; margin-top: auto; }
.q-foot.two { grid-template-columns: 1fr 1fr; }
.btn.tf-yes { background: var(--know-bg); color: var(--know-ink); box-shadow: none; min-height: 58px; }
.btn.tf-no { background: var(--learn-bg); color: var(--learn-ink); box-shadow: none; min-height: 58px; }

/* ---------- итоги ---------- */
.result { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 14px; text-align: center; }
.result h2 { margin-top: 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.result p { max-width: 34ch; color: var(--ink-2); font-size: 15.5px; line-height: 1.5; }
.result-big { display: flex; align-items: baseline; gap: 6px; }
.result-big b { font-size: 80px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--accent-ink); }
.result-big span { font-size: 20px; font-weight: 500; color: var(--ink-2); }
.result-big.done { display: grid; place-items: center; width: 88px; height: 88px; margin-bottom: 6px; border-radius: 50%; background: var(--sky); color: #24405E; }
.result.round { align-items: stretch; text-align: left; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 14px; }
.split-item { padding: 14px; border-radius: 18px; text-align: center; }
.split-item b { display: block; font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.split-item span { font-size: 13.5px; font-weight: 500; }
.split-item.know { background: var(--know-bg); color: var(--know-ink); }
.split-item.learn { background: var(--learn-bg); color: var(--learn-ink); }
.result-actions { display: grid; gap: 10px; width: 100%; margin-top: 20px; }
.best { font-size: 15px; color: var(--ink-2); }
.best b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- тест: настройка ---------- */
.setup h2 { margin: 0 2px 4px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.setup > p { margin: 0 2px 16px; font-size: 15px; }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper .icon-btn { width: 44px; height: 44px; background: var(--surface-2); font-size: 20px; }
.stepper-v { min-width: 30px; text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.type-row { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 16px; border: 0; background: none; text-align: left; }
.mode-text b { display: block; font-size: 16px; font-weight: 500; }
.mode-text span { display: block; font-size: 13.5px; color: var(--ink-2); }
.tick { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; box-shadow: inset 0 0 0 1.5px var(--line); color: transparent; transition: background .25s, color .25s; }
.type-row.on .tick { background: var(--violet); box-shadow: none; color: #fff; }

/* ---------- подбор ---------- */
.clock { min-width: 70px; text-align: right; font-size: 18px; font-weight: 600; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.mt-grid { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; align-content: start; }
.mt-grid.dense { grid-auto-rows: minmax(96px, auto); }
.mt-tile { display: grid; place-items: center; padding: 10px 8px; border: 0; border-radius: 18px; background: var(--surface); text-align: center; font-size: 14.5px; font-weight: 500; line-height: 1.25;
  min-width: 0; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; box-shadow: inset 0 0 0 1px var(--line); transition: transform .22s var(--ease), background .2s, opacity .3s; }
.mt-tile.term { font-size: 16px; font-weight: 600; }
.mt-tile.long { font-size: 13.5px; } .mt-tile.xlong { font-size: 12.5px; }
.mt-tile:active { transform: scale(.95); }
.mt-tile.picked { background: var(--violet); color: #1E1750; box-shadow: none; transform: scale(1.04); }
.mt-tile.hit { background: var(--know-bg); color: var(--know-ink); box-shadow: none; }
.mt-tile.miss { background: var(--learn-bg); color: var(--learn-ink); box-shadow: none; }
.mt-tile.gone { opacity: 0; transform: scale(.75); pointer-events: none; }
.penalty { position: absolute; left: 50%; top: 40%; font-size: 22px; font-weight: 600; color: var(--learn-ink); pointer-events: none; animation: rise .9s var(--ease) forwards; }
@keyframes rise { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -50px); } }

/* ---------- шторка со словом ---------- */
.ws-top { display: flex; align-items: center; justify-content: space-between; }
.ws-status { padding: 4px 10px; border-radius: 12px; background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.ws-status.known { background: var(--know-bg); color: var(--know-ink); }
.ws-status.learning { background: var(--learn-bg); color: var(--learn-ink); }
.ws-speak { background: var(--tonal); color: var(--on-tonal); }
.ws-term { margin-top: 14px; font-size: 34px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; overflow-wrap: anywhere; }
.ws-ipa { margin-top: 4px; font-size: 16px; color: var(--ink-2); }
.ws-tr { margin-top: 12px; font-size: 20px; font-weight: 500; line-height: 1.3; }
.ws-ex { margin-top: 18px; padding: 14px 16px; border-radius: var(--r-m); background: var(--surface); font-size: 15.5px; line-height: 1.5; }
.ws-ex .ru { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  .sx-bar, .fc-inner, .peek-inner, .seg, .peek, .mt-tile { transition: none; }
  .penalty { animation: none; opacity: 0; }
}
@media (max-height: 620px) {
  .fc-face { padding: 20px 18px; }
  .fc-hint { display: none; }
  .fc-btn { height: 50px; }
}
@media (max-width: 350px) { .mt-grid { grid-template-columns: repeat(2, 1fr); } .mt-grid.dense { grid-auto-rows: minmax(72px, auto); } }
@media (min-width: 520px) { .peek-track { padding-left: 14%; padding-right: 14%; } }

/* ---------- настройки карточек: строка в меню набора, шторка, кнопки на экране карточек ---------- */
.prefs-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; margin-top: 12px; padding: 10px 14px 10px 12px; border: 0; border-radius: var(--r-l); background: var(--surface); color: var(--ink); text-align: left; }
.prefs-link .pl-ic { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); }
.prefs-link > .ic:last-child { flex: none; color: var(--ink-2); }
.pt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.pt b { font-weight: 600; font-size: 16px; }
.pt span { font-size: 13.5px; font-weight: 400; line-height: 1.35; color: var(--ink-2); }
.prefs.in-sheet { margin-top: 16px; background: var(--surface-2); }
.pref-row.col { flex-direction: column; align-items: stretch; gap: 12px; }
.seg-ctl.wide { display: flex; background: var(--surface); }
.seg-ctl.wide button { flex: 1; }
.fc-opts { display: flex; gap: 8px; min-width: 0; margin-top: -4px; overflow: hidden; }
.opt-chip.round { justify-content: center; width: 44px; padding: 0; }
.fc-opts .opt-chip:last-child { margin-left: auto; }
.opt-chip { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 44px; padding: 0 13px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .2s, color .2s, border-color .2s; }
.opt-chip.on { border-color: transparent; background: color-mix(in srgb, var(--violet) 16%, var(--surface)); color: var(--ink); }
.opt-chip:active { transform: scale(.97); }
@media (max-width: 350px) { .fc-opts { gap: 6px; } .opt-chip:not(.round) { padding: 0 12px; } .opt-chip:not(.round) .ic { display: none; } }
@media (prefers-reduced-motion: reduce) { .opt-chip { transition: none; } .opt-chip:active { transform: none; } }
