/* ==========================================================================
   App chrome. Two layouts share one system:
   - student: phone-first, large type and touch targets, bottom tab bar
   - teacher: desktop dashboard with sidebar
   ========================================================================== */

:root {
  --ink: #161a20; --ink-2: #4a5260; --ink-3: #7a8291;
  --paper: #f6f5f1; --card: #ffffff; --line: #e5e1d8; --line-2: #efece6;
  --brand: #1e3658; --brand-2: #2a4a76; --brand-soft: #e7edf6;
  --ok: #2c7a4b; --ok-soft: #e3f2e8; --warn: #9a5c0b; --warn-soft: #fbefd9; --bad: #b0311f; --bad-soft: #fbe5df;
  --cue: #c62828;
  --u1: #2f6db5; --u2: #2e8b57; --u3: #d9811a; --u4: #1f8a8a; --u5: #7b4fc4; --u6: #8a5a3c;
  --r: 16px; --r-sm: 11px;
  --shadow: 0 1px 0 rgba(30, 25, 10, .04), 0 10px 30px -22px rgba(30, 25, 10, .5);
  --fs: 1;
  --font: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --display: 'Rubik', 'Golos Text', system-ui, sans-serif;
  --en: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.ic { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.2em; }
html { font-size: calc(16px * var(--fs)); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 1.85rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.en { font-family: var(--en); }
.cue { color: var(--cue); font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--ink-3); font-size: 1.1rem; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- buttons ---------------------------------------------------------------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 42px; padding: 0 1.05em; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { background: #fbfaf7; border-color: #d6d1c5; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 1.2em; height: 1.2em; flex: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #efc9c0; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, .05); }
.btn.sm { min-height: 34px; padding: 0 .75em; font-size: .85rem; border-radius: 10px; }
.btn.lg { min-height: 58px; padding: 0 1.4em; font-size: 1.1rem; border-radius: 16px; }
.btn.xl { min-height: 72px; padding: 0 1.6em; font-size: 1.25rem; border-radius: 20px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; pointer-events: none; }
.pp-btn { flex: 1 1 190px; min-width: 0; white-space: normal; text-align: center; line-height: 1.2; padding-top: .4em; padding-bottom: .4em; }
.icon-btn { appearance: none; border: 0; background: transparent; width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: rgba(0, 0, 0, .06); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }

/* --- surfaces ---------------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card h2 + *, .card h3 + * { margin-top: 10px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 12px; }
.section-title h2 { font-size: 1.2rem; }
.eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.empty { text-align: center; color: var(--ink-3); padding: 34px 16px; border: 2px dashed var(--line); border-radius: var(--r); }
.empty img { width: 110px; height: 110px; opacity: .9; display: block; margin: 0 auto 10px; }
.divider { height: 1px; background: var(--line-2); margin: 14px 0; border: 0; }

/* --- pills & badges --------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: .35em; padding: .22em .7em; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill svg { width: 1.05em; height: 1.05em; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; font-weight: 800; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); display: inline-block; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-family: var(--display); font-weight: 700; color: #fff; font-size: 1.05rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.4rem; }

/* --- forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: .8rem; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 11px; border: 1.5px solid var(--line);
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea, textarea.input { min-height: 92px; resize: vertical; line-height: 1.45; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 4px var(--brand-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--line-2); border-radius: 12px; }
.seg button { appearance: none; border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: .9rem; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

/* --- toasts, modals ------------------------------------------------------- */
#toasts { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1d2230; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5); max-width: min(92vw, 520px); animation: toastIn .25s ease; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-back { position: fixed; inset: 0; z-index: 300; background: rgba(18, 22, 30, .45); display: grid; place-items: center; padding: 16px; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: #fff; border-radius: 20px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.modal-body { padding: 8px 20px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }

/* --- media widgets -------------------------------------------------------- */
.recorder { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 22px 16px; border-radius: 22px; background: #fff; border: 1.5px solid var(--line); }
.rec-btn { appearance: none; border: 0; cursor: pointer; width: 112px; height: 112px; border-radius: 50%; background: #d23b2a; color: #fff; display: grid; place-items: center; box-shadow: 0 14px 30px -14px rgba(180, 40, 20, .8), inset 0 -6px 0 rgba(0, 0, 0, .12); transition: transform .12s; }
.rec-btn:active { transform: scale(.97); }
.rec-btn svg { width: 46px; height: 46px; }
.rec-btn.recording { background: #1f2430; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(210, 59, 42, .45); } 50% { box-shadow: 0 0 0 18px rgba(210, 59, 42, 0); } }
.rec-time { font-family: var(--display); font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-hint { color: var(--ink-2); text-align: center; font-size: 1.05rem; }
.rec-meter { width: min(260px, 80%); height: 10px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.rec-meter i { display: block; height: 100%; width: 0; background: #d23b2a; border-radius: 99px; transition: width .08s; }
.clip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: #f3f6fb; border: 1px solid #e1e8f2; }
.clip audio { flex: 1 1 auto; min-width: 0; height: 44px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo-tile { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 1; background: #eee; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo-tile .icon-btn { position: absolute; top: 6px; right: 6px; background: rgba(255, 255, 255, .92); }
.progressbar { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.progressbar i { display: block; height: 100%; width: 0; background: var(--brand-2); transition: width .15s; }
.stars { display: inline-flex; gap: 4px; }
.stars button, .stars span { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; color: #d9d3c4; }
.stars span { cursor: default; }
.stars svg { width: 30px; height: 30px; }
.stars .on { color: #e9a91f; }
.lightbox { position: fixed; inset: 0; z-index: 500; background: rgba(10, 12, 16, .92); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.qr { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 16px; border: 1px solid var(--line); }
.qr img { width: 240px; height: 240px; image-rendering: pixelated; }
.linkbox { display: flex; gap: 8px; align-items: center; }
.linkbox input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

/* --- lesson cards (shared) ------------------------------------------------------ */
.unit-head { display: flex; align-items: center; gap: 12px; margin: 34px 0 12px; }
.unit-head .unit-chip { font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; padding: .35em .8em; border-radius: 999px; color: #fff; }
.unit-head h2 { font-size: 1.3rem; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.lcard {
  position: relative; display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px 14px 14px 16px; box-shadow: var(--shadow);
  overflow: hidden; transition: transform .12s, box-shadow .15s;
}
.lcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--uc, var(--u1)); }
a.lcard:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -24px rgba(30, 25, 10, .6); }
.lcard .lnum { font-family: var(--display); font-weight: 800; font-size: 1.7rem; color: var(--uc); width: 40px; text-align: center; flex: none; }
.lcard .lplate { width: 58px; height: 58px; border-radius: 50%; background: var(--ut, #eef3fa); display: grid; place-items: center; flex: none; }
.lcard .lplate img { width: 46px; height: 46px; }
.lcard .lplate .vis-emoji { font-size: 30px; }
.lcard .ltitle { display: block; font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.lcard .lsub { display: block; color: var(--ink-3); font-size: .85rem; line-height: 1.35; margin-top: 2px; }
.li > .ic { color: var(--ink-3); }
.lcard.locked { opacity: .55; box-shadow: none; background: #fbfaf7; }
.lcard.locked .lplate { filter: grayscale(1); }
.lcard .ldone { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; }
.lcard .ldone svg { width: 15px; height: 15px; }
.lcard .lock { position: absolute; top: 10px; right: 10px; color: var(--ink-3); }
.lcard .lock svg { width: 18px; height: 18px; }
.lcard .lbar { position: absolute; left: 5px; right: 0; bottom: 0; height: 4px; background: var(--line-2); }
.lcard .lbar i { display: block; height: 100%; background: var(--uc); opacity: .75; }
.lwrap { position: relative; display: grid; }
.lwrap .lcard { padding-right: 58px; }
.lpresent { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--uc, var(--brand)); background: var(--ut, var(--brand-soft)); text-decoration: none;
  transition: transform .12s, background .12s; }
.lpresent:hover { transform: translateY(-50%) scale(1.06); background: var(--uc, var(--brand)); color: #fff; }
.lpresent svg { width: 22px; height: 22px; }
.hw-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: -4px 0 16px; border-bottom: 1px solid var(--line); }
.hw-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: -1px; text-decoration: none;
  color: var(--ink-3); font-weight: 700; border-bottom: 3px solid transparent; }
.hw-tabs a.on { color: var(--ink); border-bottom-color: var(--brand); }
.hw-tabs a svg { width: 20px; height: 20px; }
.hw-tabs .count { position: static; }

/* ==================== STUDENT LAYOUT ==================== */
.app.student { --fs: 1.15; min-height: 100vh; padding-bottom: 96px; }
.s-top { position: sticky; top: 0; z-index: 20; background: rgba(246, 245, 241, .92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-2); }
.s-top-in { max-width: 860px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.brand svg { width: 34px; height: 34px; flex: none; }
.s-main { max-width: 860px; margin: 0 auto; padding: 18px 16px 30px; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; background: #fff3cf; border-top: 1px solid #f0dfa8; font-weight: 700; font-size: .9rem; color: #6b4e00; }
.preview-bar .ic { vertical-align: -0.25em; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); box-shadow: 0 -8px 24px -18px rgba(0, 0, 0, .35); }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; border-radius: 12px; text-decoration: none; color: var(--ink-3); font-size: .78rem; font-weight: 700; }
.tab svg { width: 28px; height: 28px; }
.tab.on { color: var(--brand); background: var(--brand-soft); }
.tab .count { position: absolute; top: 2px; right: calc(50% - 26px); }
@media (min-width: 900px) {
  .app.student { padding-bottom: 30px; }
  .tabbar { position: static; box-shadow: none; border: 0; background: transparent; max-width: 860px; margin: 0 auto; padding: 4px 16px 0; display: flex; gap: 6px; }
  .tab { flex-direction: row; gap: 8px; padding: 9px 14px; font-size: .95rem; }
  .tab svg { width: 22px; height: 22px; }
  .tab .count { position: static; }
}
.hello h1 { font-size: 2rem; }
.hello p { color: var(--ink-2); margin-top: 4px; font-size: 1.05rem; }
.hero {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; overflow: hidden;
  background: var(--ut, #eef3fa); border-radius: 24px; padding: 22px; color: var(--ink); text-decoration: none; margin-top: 18px;
}
.hero .eyebrow { color: var(--uc); }
.hero h2 { font-size: 1.75rem; margin-top: 4px; }
.hero .sub { color: var(--ink-2); margin-top: 4px; }
.hero .plates { display: flex; }
.hero .plates span { width: 96px; height: 96px; border-radius: 50%; background: #fff; display: grid; place-items: center; margin-left: -18px; box-shadow: 0 10px 24px -16px rgba(0, 0, 0, .5); }
.hero .plates img { width: 74px; height: 74px; }
.hero .plates .vis-emoji { font-size: 44px; }
.hero .actions { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.hero .plates-link { text-decoration: none; }
@media (max-width: 520px) { .hero .actions .btn { flex: 1 1 100%; justify-content: center; } }
.hero .meter { grid-column: 1 / -1; }
@media (max-width: 520px) { .hero { grid-template-columns: 1fr; } .hero .plates { order: -1; } }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: #fff7e0; border: 1px solid #f0dfa8; }
.notice svg { width: 26px; height: 26px; color: #b07d0b; flex: none; margin-top: 2px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; border-radius: 20px; background: #fff; border: 1px solid var(--line-2); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); min-height: 120px; }
.tile img { width: 54px; height: 54px; }
.tile b { font-size: 1.1rem; }
.tile span { color: var(--ink-3); font-size: .9rem; }
.task { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: #fff; border: 1px solid var(--line-2); border-radius: 18px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.task .ticon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.task .ticon svg { width: 28px; height: 28px; }
.task b { display: block; font-size: 1.05rem; line-height: 1.3; }
.task .grow { min-width: 0; }
.task .pill { white-space: normal; text-align: center; flex: 0 1 auto; max-width: 42%; line-height: 1.25; }
.task small { color: var(--ink-3); }
.sentences { display: flex; flex-direction: column; gap: 10px; }
.sentence { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: #fff; border: 1px solid var(--line-2); }
.sentence .en { font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
.sentence .cue { font-size: .98rem; }
.sentence .ru { color: var(--ink-2); font-size: .95rem; }
.say-btn { appearance: none; border: 0; flex: none; width: 50px; height: 50px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; cursor: pointer; }
.say-btn svg { width: 26px; height: 26px; }
.say-btn.playing { background: var(--brand); color: #fff; }
.voice-opt { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: 16px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; }
.voice-opt.on { border-color: var(--brand); background: var(--brand-soft); }
.voice-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink-3); flex: none; }
.voice-opt.on .voice-dot { border-color: var(--brand); box-shadow: inset 0 0 0 5px #fff; background: var(--brand); }
.feedback { border-radius: 18px; padding: 16px; background: var(--ok-soft); border: 1px solid #c9e6d3; }
.feedback.redo { background: var(--warn-soft); border-color: #efd7a8; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step-n { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-family: var(--display); }

/* flashcards */
.cardstage { min-height: calc(100vh - 140px); display: flex; flex-direction: column; align-items: center; gap: 18px; padding-top: 10px; }
.flash { position: relative; width: min(560px, 100%); aspect-ratio: 4 / 4.3; perspective: 1400px; cursor: pointer; }
.flash-in { position: absolute; inset: 0; transition: transform .5s cubic-bezier(.3, .7, .2, 1); transform-style: preserve-3d; }
.flash.flipped .flash-in { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 28px; background: #fff; box-shadow: 0 30px 60px -36px rgba(30, 25, 10, .6); border: 1px solid var(--line-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; }
.face.back { transform: rotateY(180deg); background: #fffdf6; }
.face .fvis { width: 46%; aspect-ratio: 1; border-radius: 50%; background: var(--ut, #eef3fa); display: grid; place-items: center; }
.face .fvis img { width: 82%; height: 82%; }
.face .fvis .vis-emoji { font-size: 5rem; }
.face .fvis .vis-swatch { width: 62%; height: 62%; border-radius: 50%; display: block; box-shadow: inset 0 -8px 0 rgba(0,0,0,.12), 0 0 0 6px #fff; }
.face .fen { font-family: var(--en); font-weight: 780; font-size: clamp(2.4rem, 9vw, 3.6rem); line-height: 1.05; }
.face .fen.long { font-size: clamp(1.6rem, 6.4vw, 2.4rem); line-height: 1.15; text-wrap: balance; }
.face .fcue { color: var(--cue); font-weight: 600; font-size: 1.6rem; }
.face .fru { font-size: 1.6rem; font-weight: 600; color: var(--ink); }
.face .fhint { color: var(--ink-3); font-size: .95rem; }
.answer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: min(560px, 100%); }
.answer .btn { min-height: 66px; font-size: 1.15rem; border-radius: 18px; white-space: normal; line-height: 1.2; padding: .4em .7em; }
.deckmeter { width: min(560px, 100%); display: flex; align-items: center; gap: 12px; }

/* ==================== TEACHER LAYOUT ==================== */
.app.teacher { --fs: 1; display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: #1b2638; color: #dbe3ef; display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; }
.side .brand { color: #fff; padding: 6px 8px 16px; }
.side .brand small { display: block; font-family: var(--font); font-weight: 500; font-size: .75rem; color: #8fa0b8; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: #c6d1e1; text-decoration: none; font-weight: 600; font-size: .95rem; }
.nav-item svg { width: 21px; height: 21px; flex: none; opacity: .9; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.on { background: #2d3e58; color: #fff; }
.nav-item .count { margin-left: auto; }
.nav-sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 10px 8px; }
.side-foot { margin-top: auto; padding: 12px 8px 4px; display: flex; align-items: center; gap: 10px; color: #aebbd0; font-size: .85rem; }
.side-foot .icon-btn { color: #aebbd0; }
.side-foot .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.t-main { min-width: 0; }
.t-top { display: none; }
.t-page { max-width: 1180px; margin: 0 auto; padding: 28px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { color: var(--ink-2); margin-top: 6px; }
.crumbs { font-size: .85rem; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line-2); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.stat b { display: block; font-family: var(--display); font-size: 2.1rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-3); font-size: .88rem; font-weight: 600; }
.stat.alert b { color: var(--bad); }
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: var(--ink); }
.li:last-child { border-bottom: 0; }
a.li:hover { background: #fbfaf7; }
.li .li-main { flex: 1 1 auto; min-width: 0; }
.li .li-main b { display: block; font-weight: 650; }
.li .li-main small { color: var(--ink-3); }
.kinds { display: inline-flex; gap: 4px; color: var(--ink-3); }
.kinds svg { width: 18px; height: 18px; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.minibar { width: 120px; height: 7px; border-radius: 99px; background: var(--line-2); overflow: hidden; display: inline-block; vertical-align: middle; }
.minibar i { display: block; height: 100%; background: var(--ok); }
.review-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
.sticky { position: sticky; top: 18px; }
.course-unlock { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--r); background: #fff; border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.course-unlock input[type=range] { flex: 1 1 260px; accent-color: var(--brand); }
.lcard .lmeta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.lcard.open-mark::after { content: ""; position: absolute; top: 12px; right: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.action { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; text-decoration: none; color: var(--ink); cursor: pointer; font-weight: 600; text-align: left; }
.action:hover { border-color: #cfc8b9; background: #fbfaf7; }
.action svg { width: 26px; height: 26px; color: var(--brand); flex: none; }
.action small { display: block; color: var(--ink-3); font-weight: 500; }
.slide-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.slide-thumb { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.slide-thumb .cap { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; font-size: .78rem; color: var(--ink-3); border-top: 1px solid var(--line-2); }
@media (max-width: 1000px) {
  .cols, .review-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app.teacher { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: 20px 0 60px -30px rgba(0, 0, 0, .6); }
  .app.teacher.menu-open .side { transform: none; }
  .t-top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; z-index: 40; }
  .t-page { padding: 18px 14px 50px; }
}

/* ==================== AUTH ==================== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(circle at 12% 18%, #e2ecf8 0 120px, transparent 121px),
  radial-gradient(circle at 88% 82%, #fae4c6 0 160px, transparent 161px), var(--paper); }
.auth-card { width: min(440px, 100%); background: #fff; border-radius: 26px; padding: 30px 26px; box-shadow: 0 30px 80px -40px rgba(20, 30, 50, .55); border: 1px solid var(--line-2); }
.auth-card .brand { justify-content: center; font-size: 1.25rem; margin-bottom: 18px; }
.auth-card .brand svg { width: 44px; height: 44px; }
.auth-card h1 { font-size: 1.5rem; text-align: center; }
.auth-card p.lead { text-align: center; color: var(--ink-2); margin: 8px 0 20px; }
.auth-art { display: flex; justify-content: center; gap: 10px; margin-bottom: 16px; }
.auth-art img { width: 64px; height: 64px; padding: 6px; border-radius: 50%; background: #f3f0e9; }

/* ==================== PRINTABLE WORKSHEET ==================== */
.print-wrap { max-width: 820px; margin: 0 auto; padding: 24px; background: #fff; }
.print-bar { position: sticky; top: 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); z-index: 5; }
@media (max-width: 560px) { .print-bar .muted { display: none; } .print-wrap { padding: 16px; } .ws-words { grid-template-columns: 1fr; } }
.ws-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid var(--ink); padding-bottom: 10px; margin-bottom: 16px; }
.ws-head h1 { font-size: 1.7rem; }
.ws-head .who { font-size: .95rem; color: var(--ink-2); }
.ws-sec { margin: 18px 0; break-inside: avoid; }
.ws-sec h2 { font-size: 1.05rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 10px; color: var(--ink-2); }
.ws-words { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 22px; }
.ws-word { display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid #ddd; break-inside: avoid; }
.ws-word img, .ws-word .vis-emoji { width: 48px; height: 48px; font-size: 34px; display: grid; place-items: center; }
.ws-word .vis-swatch { width: 40px; height: 40px; border-radius: 50%; display: block; border: 1px solid #ccc; }
.ws-word .en { font-size: 1.35rem; font-weight: 700; }
.ws-word .cue { font-size: .95rem; }
.ws-word .ru { color: #444; font-size: .95rem; }
.ws-copy { break-inside: avoid; margin-bottom: 14px; }
.ws-copy .model { font-family: var(--en); font-size: 1.45rem; font-weight: 700; }
.ws-copy .model .cue { font-family: var(--font); font-size: .95rem; margin-left: 8px; }
.ws-lines { height: 46px; margin-top: 6px; background:
  linear-gradient(#9fb6d6, #9fb6d6) 0 30% / 100% 1px no-repeat,
  linear-gradient(#c6d3e6, #c6d3e6) 0 62% / 100% 1px no-repeat,
  linear-gradient(#9fb6d6, #9fb6d6) 0 94% / 100% 1px no-repeat; border-left: 3px solid #e9b3a8; }
.ws-fill { font-family: var(--en); font-size: 1.4rem; line-height: 2.4; }
.ws-fill .gap { display: inline-block; min-width: 130px; border-bottom: 2px solid #555; margin: 0 6px; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .print-bar { display: none; }
  .print-wrap { padding: 0; max-width: none; }
  .ws-lines { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ==================== PRESENTER NOTES WINDOW ==================== */
.presenter { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 18px; padding: 18px; background: #151c28; color: #e7ecf4; }
.presenter h2 { color: #fff; font-size: 1rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; }
.presenter .pv { border-radius: 14px; overflow: hidden; box-shadow: 0 20px 40px -20px #000; }
.presenter .pv.next { opacity: .75; }
.presenter .pnotes { background: #fffdf6; color: #222; border-radius: 16px; padding: 18px 20px; overflow: auto; max-height: calc(100vh - 160px); }
.presenter .pnotes h3 { font-size: 1.1rem; margin: 10px 0 6px; }
.presenter .pnotes li { margin: 6px 0; line-height: 1.45; }
.presenter .pnotes .cur { background: #fff3cf; border-radius: 10px; padding: 6px 10px; margin: 0 -10px; }
.presenter .pbar { display: flex; gap: 10px; align-items: center; }
.presenter .timer { font-family: var(--display); font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.presenter .btn { background: #26334a; border-color: #34445f; color: #fff; }
.presenter .btn:hover { background: #2f3e58; }
@media (max-width: 860px) { .presenter { grid-template-columns: 1fr; } }

/* ==================== SLIDE EDITOR ==================== */
.editor { display: grid; grid-template-columns: 270px minmax(0, 1fr) minmax(360px, 520px); height: 100vh; background: var(--paper); }
.ed-list { border-right: 1px solid var(--line); background: #fff; overflow-y: auto; display: flex; flex-direction: column; }
.ed-list-head { position: sticky; top: 0; background: #fff; z-index: 2; padding: 14px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.ed-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; font-size: .88rem; }
.ed-item:hover { background: #faf9f6; }
.ed-item.on { background: var(--brand-soft); box-shadow: inset 4px 0 0 var(--brand); }
.ed-item .n { width: 24px; color: var(--ink-3); font-weight: 700; text-align: right; flex: none; }
.ed-item .t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item .ty { font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: .15em .5em; border-radius: 6px; background: var(--line-2); color: var(--ink-2); flex: none; }
.ed-item.teacher .ty { background: #fbebbd; color: #6b4e00; }
.ed-center { overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ed-form { overflow-y: auto; border-left: 1px solid var(--line); background: #fff; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.ed-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wordrow { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1.5px solid var(--line); border-radius: 12px; background: #fcfbf8; }
.wchip { display: flex; flex-direction: column; gap: 3px; padding: 6px; background: #fff; border: 1px solid var(--line-2); border-radius: 9px; }
.wchip .w-en { font-family: var(--en); font-weight: 700; font-size: .95rem; text-align: center; }
.wchip input { width: 92px; min-height: 30px; padding: 3px 6px; font-size: .85rem; color: var(--cue); border: 1px solid var(--line); border-radius: 7px; text-align: center; }
.wchip input.missing { border-color: var(--bad); background: var(--bad-soft); }
.lineblock { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: #f8f7f3; border: 1px solid var(--line-2); }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; max-height: 50vh; overflow-y: auto; padding: 4px; }
.pick { appearance: none; border: 1.5px solid var(--line-2); background: #fff; border-radius: 12px; padding: 6px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; color: var(--ink-2); }
.pick img { width: 54px; height: 54px; }
.pick.on, .pick:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.ed-pic { width: 64px; height: 64px; border-radius: 50%; background: var(--line-2); display: grid; place-items: center; overflow: hidden; flex: none; }
.ed-pic img { width: 52px; height: 52px; object-fit: contain; }
.ed-pic .vis-photo { width: 64px; height: 64px; object-fit: cover; border-radius: 50%; box-shadow: none; }
.ed-pic .vis-emoji { font-size: 34px; }
.ed-pic .vis-swatch { width: 40px; height: 40px; border-radius: 50%; display: block; }
.warnbox { border-radius: 12px; background: var(--warn-soft); border: 1px solid #efd7a8; padding: 10px 12px; font-size: .85rem; color: #6b4a0f; max-height: 160px; overflow: auto; }
@media (max-width: 1150px) {
  .editor { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto; height: auto; min-height: 100vh; }
  .ed-form { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 700px) { .editor { grid-template-columns: 1fr; } .ed-list { max-height: 40vh; } }

/* --- flashcards: options, own sets, set builder ------------------------------------ */
.cards-opts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.toggle { appearance: none; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 6px 14px 6px 6px; font: inherit; font-weight: 600; font-size: .92rem; color: var(--ink-2); cursor: pointer; }
.toggle .knob { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.toggle .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.toggle.on { color: var(--ink); border-color: var(--brand); }
.toggle.on .knob { background: var(--brand); }
.toggle.on .knob::after { transform: translateX(16px); }
.toggle svg { width: 18px; height: 18px; }
.buildset { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 16px 18px; border-radius: 20px; text-decoration: none;
  color: var(--ink); background: #fff; border: 2px dashed #b9c6da; box-shadow: var(--shadow); }
.buildset:hover { border-color: var(--brand); }
.buildset b { display: block; font-size: 1.15rem; }
.buildset small { display: block; color: var(--ink-3); margin-top: 2px; }
.buildset-ic { width: 52px; height: 52px; border-radius: 16px; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.buildset-ic svg { width: 28px; height: 28px; }
.buildset > svg { color: var(--ink-3); flex: none; }
.setpick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.setpick { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; background: #fff; border: 2px solid var(--line-2);
  border-radius: 18px; cursor: pointer; box-shadow: var(--shadow); min-height: 74px; }
.setpick input { position: absolute; opacity: 0; pointer-events: none; }
.setpick .lplate { width: 52px; height: 52px; border-radius: 50%; background: var(--ut, #eef3fa); display: grid; place-items: center; flex: none; }
.setpick .lplate img { width: 42px; height: 42px; }
.setpick .lplate .lnum { font-family: var(--display); font-weight: 800; font-size: 1.4rem; color: var(--uc); }
.setpick b { display: block; font-size: 1.05rem; line-height: 1.25; }
.setpick small { display: block; color: var(--ink-3); font-size: .85rem; }
.setpick .tick { width: 32px; height: 32px; border-radius: 10px; border: 2px solid #c9c3b7; display: grid; place-items: center; color: transparent; flex: none; background: #fff; }
.setpick .tick svg { width: 20px; height: 20px; }
.setpick.on { border-color: var(--uc, var(--brand)); background: color-mix(in srgb, var(--ut, #eef3fa) 45%, #fff); }
.setpick.on .tick { background: var(--uc, var(--brand)); border-color: var(--uc, var(--brand)); color: #fff; }
.setpick:focus-within { outline: 3px solid color-mix(in srgb, var(--uc, var(--brand)) 40%, transparent); outline-offset: 2px; }
.setpick-bar { position: sticky; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 15; margin-top: 22px; display: grid; gap: 10px;
  padding: 14px 16px; background: rgba(255, 255, 255, .97); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, .35); }
.setpick-sum { font-weight: 700; font-size: 1.05rem; }
.check.big { font-size: 1.05rem; font-weight: 600; }
.check.big input { width: 26px; height: 26px; }
.icon-only { padding-left: 8px; padding-right: 8px; }
@media (min-width: 900px) { .setpick-bar { bottom: 12px; } }
