:root {
  --bg: #000;
  --bar: #2b2b2d;
  --card: #1c1c1e;
  --line: #2c2c2e;
  --text: #f2f2f2;
  --dim: #8e8e93;
  --opt: #a9a9ae;
  --accent: #f0a830;
  --ok: #66bb55;
  --bad: #ea6a62;
  --blue: #4a9eff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; }

#app { max-width: 560px; height: 100vh; height: 100dvh; margin: 0 auto; }
.screen { position: relative; height: 100%; display: flex; flex-direction: column; background: var(--bg); }

/* ---- шапка ---- */
.top {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 12px; background: var(--bar);
}
.top h1 { margin: 0; flex: 1; text-align: center; font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--card); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; flex: none;
}
.icon-btn.ghost { background: none; cursor: default; }
.content { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.content.pad { padding: 16px 18px 40px; display: flex; flex-direction: column; gap: 14px; }

/* ---- кнопки и поля ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px;
  border: 0; border-radius: 14px; background: var(--accent); color: #1a1100; font-size: 17px; font-weight: 600; cursor: pointer;
}
.btn.big { min-height: 54px; font-size: 18px; }
.btn.ghost { background: var(--card); color: var(--text); }
.btn:disabled { opacity: .4; cursor: default; }
.inp {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid #38383a; border-radius: 12px;
  background: #111; color: var(--text); font: inherit; font-size: 17px;
}
textarea.inp { resize: vertical; }
.dim { color: var(--dim); margin: 0; }
.note { color: var(--dim); font-size: 14px; margin: 0; line-height: 1.35; }
.empty { color: var(--dim); text-align: center; padding: 30px 20px; }

/* ---- главная ---- */
.seg { display: flex; background: var(--card); border-radius: 14px; padding: 4px; gap: 4px; }
.seg-btn { flex: 1; min-height: 44px; border: 0; border-radius: 11px; background: none; font-size: 17px; color: var(--dim); cursor: pointer; }
.seg-btn.on { background: #3a3a3c; color: var(--text); font-weight: 600; }
.lessons { display: flex; flex-direction: column; gap: 10px; }
.lcard {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 16px; border-radius: 16px; background: var(--card);
}
.lt { grid-column: 1; grid-row: 1; font-size: 19px; font-weight: 500; }
.lp { grid-column: 2; grid-row: 1; align-self: center; color: var(--accent); font-weight: 600; text-align: right; }
.ls { grid-column: 1 / -1; grid-row: 2; color: var(--dim); font-size: 14px; }
.lcard .bar { grid-column: 1 / -1; grid-row: 3; margin-top: 4px; }
.bar { height: 5px; border-radius: 3px; background: #3a3a3c; overflow: hidden; }
.bar.light { background: #d8d8d8; height: 6px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }

/* ---- нижняя «таблетка» вкладок ---- */
.tabs {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex; gap: 6px; padding: 5px; border-radius: 40px; background: #161618; border: 1px solid #333; z-index: 5;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 22px 6px; border-radius: 34px;
  color: #d0d0d4; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.tab svg { display: block; }
.tab.on { background: #2c2c2e; color: var(--blue); }

/* ---- список слов ---- */
.list { padding: 8px 0 130px; }
.sec { text-align: center; font-weight: 300; font-size: 30px; margin: 20px 0 8px; }
.row-w { display: flex; align-items: center; gap: 14px; padding: 0 0 0 16px; cursor: pointer; }
.ring { flex: none; width: 40px; height: 40px; }
.row-w .txt { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 18px 22px 0; border-bottom: 1px solid var(--line); }
.row-w .tg { font-size: 22px; }
.row-w .ru { text-align: right; color: var(--dim); font-size: 19px; }
.list .add { margin: 24px 18px 0; display: flex; }

/* ---- тренировка ---- */
.train { position: relative; height: 100%; display: flex; flex-direction: column; padding: 10px 18px calc(env(safe-area-inset-bottom) + 118px); overflow: hidden; }
.chain { flex: none; height: 56px; display: flex; align-items: center; justify-content: center; }
.node { width: 28px; height: 28px; border-radius: 50%; border: 4px solid var(--accent); background: transparent; transition: background .3s; }
.node.on { background: var(--accent); }
.link { width: 34px; height: 4px; background: var(--accent); }
.pic { flex: none; height: 96px; display: flex; align-items: center; justify-content: center; font-size: 72px; line-height: 1; }
.prompt {
  flex: none; min-height: 84px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 0 8px; font-size: clamp(32px, 10vw, 54px); font-weight: 300; line-height: 1.1; overflow-wrap: anywhere;
}
.prompt.ru { text-transform: uppercase; }
.prompt.tg { cursor: pointer; }
.opts { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; margin: 6px 0; }
.opt {
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px 8px; border: 0; background: none;
  color: var(--opt); font-size: clamp(21px, 6.2vw, 31px); font-weight: 300; line-height: 1.15; cursor: pointer; overflow-wrap: anywhere;
}
.opt.ok { color: var(--ok); font-weight: 400; }
.opt.bad { color: var(--bad); }
.opt.pop { animation: pop .55s cubic-bezier(.2, .9, .3, 1.3) both; }
.pct { flex: none; text-align: center; color: var(--dim); font-size: 24px; font-weight: 300; padding: 4px 0 6px; }
.bounce { animation: bounce .6s ease both; }
.nodepop { animation: nodepop .5s ease both; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.32); } 100% { transform: scale(1.12); } }
@keyframes bounce { 0% { transform: scale(1); } 30% { transform: scale(1.4) rotate(-7deg); } 60% { transform: scale(.94) rotate(5deg); } 100% { transform: scale(1); } }
@keyframes nodepop { 0% { transform: scale(1); } 50% { transform: scale(1.55); } 100% { transform: scale(1); } }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.spark { position: absolute; font-size: 15px; line-height: 1; will-change: transform, opacity; }

/* фраза после верного ответа */
.opts.phrasing { display: flex; align-items: center; justify-content: center; }
.phrase { text-align: center; padding: 0 10px; animation: fadein .35s ease both; }
.ph-t { font-size: clamp(26px, 8vw, 38px); font-weight: 300; line-height: 1.2; overflow-wrap: anywhere; }
.ph-t b { color: var(--accent); font-weight: 500; }
.ph-ru { margin-top: 12px; color: var(--dim); font-size: 15px; }
.ph-hint { margin-top: 26px; color: var(--blue); font-size: 16px; }
.ph-timer { width: 58%; height: 4px; margin: 12px auto 0; border-radius: 2px; background: #2c2c2e; overflow: hidden; }
.ph-timer i { display: block; width: 100%; height: 100%; background: var(--blue); }

.done { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; padding-bottom: 30px; }
.done h2 { margin: 0; font-weight: 400; font-size: 28px; }
.bigemoji { font-size: 84px; line-height: 1; }

/* ---- редактор ---- */
.erows { display: flex; flex-direction: column; gap: 12px; }
.erow { background: var(--card); border-radius: 14px; padding: 10px; border: 1px solid transparent; }
.erow.miss { border-color: #6b3a37; }
.erow.warn { border-color: #8a6f1d; }
.btns { display: flex; gap: 10px; }
.btns .btn { flex: 1; padding: 0 12px; }
.how { background: var(--card); border-radius: 14px; padding: 2px 14px 12px; }
.how summary { cursor: pointer; color: var(--dim); font-size: 14px; padding: 10px 0; }
.how svg { display: block; width: 100%; max-width: 270px; margin: 2px auto 12px; }
.how ol { margin: 0; padding-left: 20px; color: var(--opt); font-size: 14px; line-height: 1.5; }
.how li + li { margin-top: 4px; }
.erow-main { display: flex; gap: 8px; align-items: flex-start; }
.inp.em { width: 54px; flex: none; text-align: center; padding: 10px 4px; font-size: 22px; }
.ecol { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.icon-btn.x { width: 38px; height: 38px; font-size: 16px; background: #2c2c2e; color: var(--dim); }
.more { margin-top: 8px; }
.more summary { color: var(--dim); font-size: 14px; cursor: pointer; padding: 6px 2px; }
.more .inp { margin-top: 8px; }

/* ---- окна ---- */
.ov { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.ov.center { align-items: center; padding: 20px; }
.sheet { width: 100%; max-width: 560px; background: #232325; border-radius: 20px 20px 0 0; padding: 10px 14px calc(env(safe-area-inset-bottom) + 14px); display: flex; flex-direction: column; gap: 4px; }
.sheet-btn { min-height: 52px; border: 0; border-radius: 12px; background: none; font-size: 18px; text-align: left; padding: 0 12px; cursor: pointer; }
.sheet-btn:active { background: #2f2f32; }
.sheet-btn.danger { color: var(--bad); }
.sheet-btn.cancel { color: var(--blue); text-align: center; margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0; }
.dlg { width: 100%; max-width: 380px; background: #232325; border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg p { margin: 0; line-height: 1.4; font-size: 17px; }
.dlg .row { display: flex; gap: 10px; justify-content: flex-end; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 110px); transform: translateX(-50%); z-index: 30;
  background: #3a3a3c; color: var(--text); padding: 12px 18px; border-radius: 14px; font-size: 15px; max-width: 86vw; text-align: center;
  animation: fadein .25s ease both;
}
