/* Language Up — стили. Mobile-first, нативно под Telegram (тема из theme params). */
:root {
  --bg: var(--tg-bg, #17212b);
  --sec-bg: var(--tg-secondary-bg, #0e1621);
  --panel: var(--tg-section-bg, #1d2733);
  --text: var(--tg-text, #ffffff);
  --hint: var(--tg-hint, #8a99a8);
  --subtitle: var(--tg-subtitle, #8a99a8);
  --accent: var(--tg-button, #3a8df0);
  --accent-text: var(--tg-button-text, #ffffff);
  --link: var(--tg-link, #6ab3f3);
  --destructive: var(--tg-destructive, #e85c5c);
  --ok: #4caf72;
  --bad: #e85c5c;
  --radius: 16px;
  --radius-sm: 11px;
  --gap: 12px;
  --maxw: 560px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--sec-bg); color: var(--text);
  overscroll-behavior: none; -webkit-font-smoothing: antialiased;
  font-size: 16px; line-height: 1.4;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: 16px; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: var(--maxw); margin: 0 auto; }

/* ---- topbar ---- */
#topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg); flex: 0 0 auto;
  border-bottom: 1px solid rgba(255,255,255,.05); }
.tb-title { font-weight: 700; font-size: 17px; }
.tb-streak { font-weight: 600; font-size: 15px; }

/* ---- screen ---- */
#screen { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 16px 90px; }
body.onboarding #topbar, body.onboarding #tabbar { display: none; }

/* ---- tabbar ---- */
#tabbar { flex: 0 0 auto; display: flex; background: var(--bg);
  border-top: 1px solid rgba(255,255,255,.06);
  padding-bottom: env(safe-area-inset-bottom, 0); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px; color: var(--hint); font-size: 11px; transition: color .15s; }
.tab .tab-ic { font-size: 21px; line-height: 1; filter: grayscale(.4) opacity(.7); }
.tab.active { color: var(--accent); }
.tab.active .tab-ic { filter: none; }

/* ---- panels / sections ---- */
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; margin-bottom: var(--gap); }
.section { margin: 18px 0 8px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 0 6px 8px; font-weight: 600; }
.section-hint { font-size: 13px; color: var(--hint); margin: -4px 6px 10px; }
.screen-title { font-size: 24px; font-weight: 800; margin: 4px 0 4px; }
.screen-sub { color: var(--hint); font-size: 14px; margin: 0 0 16px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-sm); padding: 13px 18px; font-weight: 600; font-size: 16px;
  transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: var(--panel); color: var(--text); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 17px; font-size: 17px; }
.btn-sm { padding: 9px 14px; font-size: 14px; }
.btn-row { display: flex; gap: var(--gap); margin-bottom: var(--gap); }
.btn-row .btn { flex: 1; }

/* ---- learn ---- */
.learn-head { margin-bottom: 14px; }
.learn-hi { font-size: 22px; font-weight: 800; }
.learn-date { color: var(--hint); font-size: 14px; text-transform: capitalize; }
.ring-card { display: flex; align-items: center; justify-content: center; position: relative; padding: 20px; }
.ring { width: 150px; height: 150px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-center { position: absolute; text-align: center; }
.ring-num { font-size: 30px; font-weight: 800; }
.ring-lbl { font-size: 12px; color: var(--hint); }
.mini-stats { display: flex; gap: var(--gap); margin-bottom: var(--gap); }
.mini-stat { flex: 1; background: var(--panel); border-radius: var(--radius-sm); padding: 12px 6px; text-align: center; }
.mini-v { font-size: 17px; font-weight: 700; }
.mini-l { font-size: 11px; color: var(--hint); margin-top: 2px; }
.empty-note { text-align: center; color: var(--hint); font-size: 14px; }
.empty-emoji { font-size: 34px; margin-bottom: 6px; }
.wotd { }
.wotd-tag { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.wotd-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wotd-w { font-size: 20px; font-weight: 700; }
.wotd-ru { color: var(--hint); }
.wotd-audio { font-size: 18px; }
.wotd-ex { margin-top: 8px; font-style: italic; color: var(--subtitle); font-size: 14px; }

/* ---- themes screen ---- */
.theme-cards { }
.theme-card { }
.theme-card-top { display: flex; align-items: center; gap: 12px; }
.theme-card-emoji { font-size: 26px; }
.theme-card-info { flex: 1; }
.theme-card-label { font-weight: 700; font-size: 16px; }
.theme-card-meta { color: var(--hint); font-size: 13px; }
.theme-toggle { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 18px; font-weight: 700; color: var(--hint); }
.theme-toggle.on { background: var(--accent); color: var(--accent-text); }
.tbar { height: 6px; background: rgba(255,255,255,.08); border-radius: 4px; margin: 12px 0; overflow: hidden; }
.tbar-fill { height: 100%; background: var(--accent); border-radius: 4px; }

/* ---- dictionary ---- */
.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-input, .type-input { flex: 1; background: var(--panel); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-sm); padding: 13px 14px; color: var(--text); outline: none; }
.search-input:focus, .type-input:focus { border-color: var(--accent); }
.loading { color: var(--hint); padding: 12px; text-align: center; }
.dict-card .dict-head { display: flex; align-items: center; gap: 10px; }
.dict-word { font-size: 24px; font-weight: 800; }
.dict-ipa { color: var(--link); margin: 4px 0; }
.dict-ru { font-size: 17px; margin: 6px 0; }
.dict-ex { margin: 10px 0; }
.my-word { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; }
.my-word-w { font-weight: 700; }
.my-word-ru { color: var(--hint); margin-left: 6px; font-size: 14px; }

/* ---- progress ---- */
.prog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-bottom: var(--gap); }
.big-stat { text-align: center; padding: 18px 10px; }
.big-stat-v { font-size: 26px; font-weight: 800; }
.big-stat-l { color: var(--hint); font-size: 13px; margin-top: 2px; }
.big-pct { font-size: 34px; font-weight: 800; color: var(--accent); }
.heat { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin-top: 10px; }
.heat-cell { width: 100%; aspect-ratio: 1; border-radius: 3px; background: rgba(255,255,255,.06); }
.heat-1 { background: rgba(58,141,240,.35); } .heat-2 { background: rgba(58,141,240,.6); }
.heat-3 { background: rgba(58,141,240,.8); } .heat-4 { background: var(--accent); }

/* ---- rows / controls ---- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 8px; }
.row.col { flex-direction: column; align-items: stretch; gap: 12px; }
.row.tap:active { opacity: .6; }
.row.danger .row-label { color: var(--destructive); }
.row-left { flex: 1; min-width: 0; }
.row-label { font-weight: 600; }
.row-hint { color: var(--hint); font-size: 13px; margin-top: 2px; }
.row-arrow { color: var(--hint); font-size: 22px; }
.seg { display: flex; background: rgba(255,255,255,.06); border-radius: var(--radius-sm); padding: 4px; gap: 4px; }
.seg-btn { flex: 1; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--hint); font-size: 14px; }
.seg-btn.active { background: var(--accent); color: var(--accent-text); }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper-b { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.1); font-size: 20px; font-weight: 700; }
.stepper-v { min-width: 32px; text-align: center; font-weight: 700; font-size: 18px; }
.switch { width: 50px; height: 30px; border-radius: 16px; background: rgba(255,255,255,.15); position: relative; transition: background .2s; flex: 0 0 auto; }
.switch.on { background: var(--accent); }
.switch-dot { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on .switch-dot { transform: translateX(20px); }

/* ---- level picker / theme grid ---- */
.level-list { display: flex; flex-direction: column; gap: 10px; }
.level-it { text-align: left; background: var(--panel); border: 2px solid transparent; border-radius: var(--radius); padding: 14px; transition: border-color .15s; }
.level-it.active { border-color: var(--accent); }
.level-it.disabled { opacity: .4; pointer-events: none; }
.level-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.level-badge { background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 13px; padding: 2px 8px; border-radius: 7px; }
.level-name { font-weight: 700; }
.level-tag { color: var(--hint); font-size: 12px; margin-left: auto; }
.level-hint { color: var(--subtitle); font-size: 13px; line-height: 1.45; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-it { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 2px solid transparent; border-radius: var(--radius-sm); padding: 14px 12px; text-align: left; position: relative; }
.theme-it.active { border-color: var(--accent); }
.theme-emoji { font-size: 20px; }
.theme-label { font-size: 14px; font-weight: 600; flex: 1; }
.theme-check { opacity: 0; color: var(--accent); font-weight: 800; }
.theme-it.active .theme-check { opacity: 1; }
.preset-row { display: flex; gap: 10px; flex-wrap: wrap; }
.preset { flex: 1; min-width: 60px; padding: 16px 0; border-radius: var(--radius-sm); background: var(--panel); border: 2px solid transparent; font-size: 18px; font-weight: 700; }
.preset.active { border-color: var(--accent); color: var(--accent); }

/* ---- onboarding ---- */
.onb { display: flex; flex-direction: column; min-height: 100dvh; padding: 16px 18px env(safe-area-inset-bottom, 16px); }
.onb-dots { display: flex; gap: 6px; justify-content: center; padding: 10px 0 18px; }
.onb-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.15); transition: all .2s; }
.onb-dot.active { background: var(--accent); width: 22px; border-radius: 5px; }
.onb-dot.done { background: var(--accent); opacity: .5; }
.onb-body { flex: 1; display: flex; flex-direction: column; }
.onb-logo { font-size: 60px; text-align: center; margin: 24px 0 10px; }
.onb-h1 { font-size: 26px; font-weight: 800; text-align: center; margin: 8px 0; }
.onb-h2 { font-size: 22px; font-weight: 800; margin: 6px 0 6px; }
.onb-p { color: var(--subtitle); text-align: center; line-height: 1.5; padding: 0 6px; }
.onb-sub { color: var(--hint); font-size: 14px; margin: 0 0 16px; }
.onb-foot { margin-top: auto; padding-top: 18px; position: sticky; bottom: 0; }

/* ---- session ---- */
.session { position: fixed; inset: 0; z-index: 50; background: var(--sec-bg); display: none; }
.session.open { display: block; }
.session.hidden { display: none; }
.sess-wrap { max-width: var(--maxw); margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; padding: 12px 16px env(safe-area-inset-bottom, 16px); }
.sess-top { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; }
.sess-prog { flex: 1; height: 8px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.sess-prog-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.sess-count { font-size: 13px; color: var(--hint); min-width: 48px; text-align: right; }
.sess-x { font-size: 18px; color: var(--hint); padding: 0 4px; }
.ex { flex: 1; display: flex; flex-direction: column; }
.ex-tag { text-align: center; color: var(--hint); font-size: 14px; margin-bottom: 14px; }
.ex-help { text-align: center; color: var(--hint); font-size: 13px; margin: 12px 0; }

.card { background: var(--panel); border-radius: 20px; padding: 28px 20px; }
.card-face, .flip { text-align: center; }
.wh { text-align: center; position: relative; }
.wh-word { font-size: 34px; font-weight: 800; }
.wh-ipa { color: var(--link); font-size: 16px; margin-top: 6px; letter-spacing: .02em; }
.wh-pos { color: var(--hint); font-size: 13px; font-style: italic; margin-top: 2px; }
.wh-audio { font-size: 26px; margin-top: 12px; }
.card-ru { font-size: 22px; font-weight: 700; margin: 6px 0; }
.card-ex { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.card-ex-en { font-style: italic; font-size: 16px; }
.card-ex-ru { color: var(--hint); font-size: 14px; margin-top: 6px; }
.ex-intro .card { margin-bottom: auto; }
.ex-tag.intro { color: var(--accent); }

.flip { cursor: pointer; min-height: 180px; display: flex; flex-direction: column; justify-content: center; }
.flip-hint { color: var(--hint); font-size: 13px; margin-top: 18px; }
.rate-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; padding-top: 14px; }
.rate-btn { padding: 15px; border-radius: var(--radius-sm); font-weight: 700; font-size: 15px; }
.r-again { background: rgba(232,92,92,.18); color: #ff9a9a; }
.r-hard { background: rgba(240,180,60,.16); color: #ffd089; }
.r-good { background: rgba(76,175,114,.18); color: #8fe0a8; }
.r-easy { background: rgba(58,141,240,.18); color: #9ec9ff; }

.mc-prompt { text-align: center; margin-bottom: 22px; }
.mc-prompt-ru { font-size: 26px; font-weight: 800; }
.mc-opts { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.mc-opt { background: var(--panel); border: 2px solid transparent; border-radius: var(--radius-sm); padding: 16px; font-size: 16px; font-weight: 600; text-align: center; transition: all .15s; }
.mc-opt:active { transform: scale(.98); }
.mc-opt.ok { border-color: var(--ok); background: rgba(76,175,114,.18); }
.mc-opt.bad { border-color: var(--bad); background: rgba(232,92,92,.18); }
.mc-opt.dim { opacity: .3; }

.ex-typing .type-prompt, .ex-listen { text-align: center; }
.type-prompt { margin-bottom: 18px; }
.type-input { width: 100%; text-align: center; font-size: 18px; margin-bottom: 12px; }
.type-fb { min-height: 28px; text-align: center; font-size: 16px; margin-bottom: 12px; }
.type-fb.ok { color: var(--ok); font-weight: 700; }
.type-fb.bad { color: var(--bad); }
.type-fb .btn { margin-top: 12px; }
.listen-big { font-size: 56px; align-self: center; margin: 20px 0; width: 110px; height: 110px; border-radius: 50%; background: var(--panel); }
.hint-btn { align-self: center; margin: 14px auto 4px; color: var(--link); font-size: 14px; padding: 8px 14px; border-radius: 20px; background: rgba(255,255,255,.05); }

.ex-construct .ex-help { color: var(--subtitle); font-style: italic; }
.cons-slot { min-height: 64px; background: var(--panel); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; margin-bottom: 14px; border: 1px dashed rgba(255,255,255,.12); }
.cons-slot-ph { color: var(--hint); font-size: 14px; align-self: center; }
.cons-bank { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: auto; }
.tile { background: rgba(255,255,255,.1); border-radius: 9px; padding: 10px 13px; font-size: 15px; font-weight: 600; transition: transform .08s; }
.tile:active { transform: scale(.94); }
.tile.placed { background: var(--accent); color: var(--accent-text); }

.ex-done { text-align: center; justify-content: center; align-items: center; }
.done-emoji { font-size: 64px; margin: 30px 0 10px; }
.done-title { font-size: 24px; font-weight: 800; margin-bottom: 24px; }
.done-stats { display: flex; gap: 16px; margin-bottom: auto; }
.done-stat { background: var(--panel); border-radius: var(--radius-sm); padding: 16px 22px; }
.done-stat-v { font-size: 24px; font-weight: 800; }
.done-stat-l { color: var(--hint); font-size: 12px; }
.ex-done .btn-row { width: 100%; margin-top: 24px; }

/* ---- profile ---- */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; padding: 6px 2px 14px; }
.profile-ava { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; text-transform: uppercase; }
.profile-name { font-size: 20px; font-weight: 800; }
.profile-sub { color: var(--hint); font-size: 14px; }
.app-foot { text-align: center; color: var(--hint); font-size: 12px; margin: 24px 0 8px; }

/* ---- modal / sheet ---- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: var(--maxw); border-radius: 20px 20px 0 0; max-height: 88dvh; overflow-y: auto; animation: sheetUp .25s ease; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; position: sticky; top: 0; background: var(--bg); }
.sheet-title { font-size: 18px; font-weight: 800; }
.sheet-x { font-size: 18px; color: var(--hint); }
.sheet-body { padding: 8px 18px 24px; }
.sheet-p { color: var(--hint); font-size: 14px; margin: 4px 0 12px; }
.backup-area { width: 100%; min-height: 120px; background: var(--panel); color: var(--text); border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; resize: vertical; }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 80;
  background: #000; color: #fff; padding: 11px 18px; border-radius: 22px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); animation: toastIn .2s; max-width: 80%; text-align: center; }
.toast.hidden { display: none; }
@keyframes toastIn { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---- светлая тема (для теста в обычном браузере) ---- */
@media (prefers-color-scheme: light) {
  :root {
    --bg: var(--tg-bg, #ffffff); --sec-bg: var(--tg-secondary-bg, #f0f2f5);
    --panel: var(--tg-section-bg, #ffffff); --text: var(--tg-text, #000000);
    --hint: var(--tg-hint, #8a8a8e); --subtitle: var(--tg-subtitle, #6d6d72);
  }
  .panel { box-shadow: 0 1px 3px rgba(0,0,0,.06); }
}
.hidden { display: none !important; }
