:root {
  --bg: #f6f5fb; --card: #ffffff; --ink: #1d1b2e; --muted: #6b6882; --line: #e4e1f0;
  --accent: #5b4bdb; --accent-ink: #ffffff; --accent-soft: #ece9ff;
  --ok: #16874a; --ok-soft: #dcf5e6; --bad: #c62f3e; --bad-soft: #fde3e6; --warn: #a96400; --warn-soft: #fff1d6;
  --shadow: 0 1px 2px rgba(30, 20, 80, .08), 0 6px 18px rgba(30, 20, 80, .06);
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12111c; --card: #1c1b2b; --ink: #f1effa; --muted: #a09cbc; --line: #2d2b44;
    --accent: #8b7dff; --accent-ink: #12111c; --accent-soft: #2a2650;
    --ok: #5fd491; --ok-soft: #153324; --bad: #ff7b88; --bad-soft: #3b1920; --warn: #ffc15e; --warn-soft: #3a2c10;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 17px; margin: 0; flex: 1; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  min-width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; font-size: 22px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; color: var(--ink);
}
.icon-btn:active { background: var(--accent-soft); }
.icon-btn[hidden] { display: none; }

main { max-width: 640px; margin: 0 auto; padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }
h2 { font-size: 24px; margin: 8px 0 4px; line-height: 1.2; }
.lead { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 16px; margin: 0 0 12px;
}
a.card, button.card { display: block; width: 100%; text-align: left; text-decoration: none; color: inherit; cursor: pointer; }
a.card:active, button.card:active { background: var(--accent-soft); }
.row { display: flex; align-items: center; gap: 12px; }
.row > .grow { flex: 1; min-width: 0; }
.title { font-weight: 650; font-size: 18px; }

.bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 8px; transition: width .3s; }
.bar.ok > i { background: var(--ok); }

.badge { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px;
  padding: 12px 18px; border-radius: 14px; border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font-weight: 650; font-size: 17px; cursor: pointer; text-decoration: none; margin: 0 0 10px;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; }
.btn:active { transform: translateY(1px); }
.btns { display: flex; gap: 10px; }
.btns .btn { flex: 1; }

.card.mode { display: flex; gap: 14px; align-items: center; }
.mode .ico { font-size: 28px; width: 44px; text-align: center; }
.mode .t { font-weight: 650; }
.mode .d { color: var(--muted); font-size: 14px; line-height: 1.3; }
.mode.hot { border-color: var(--accent); }

.pics { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 10px; }
.pic { background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--line); display: inline-flex; max-width: 100%; }
.pic img { display: block; height: auto; max-width: 100%; max-height: 150px; width: auto; }
.pics.small .pic { padding: 4px; border-radius: 8px; }
.pics.small .pic img { max-height: 52px; }

.prompt { text-align: center; padding: 8px 0 2px; }
.prompt .label { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
.prompt .big { font-size: 32px; font-weight: 750; line-height: 1.15; margin: 6px 0; overflow-wrap: anywhere; }
.prompt .mean { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 8px 0; }
.prompt .pron { color: var(--accent); font-size: 18px; font-style: italic; }
.spk { background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 99px; min-width: 48px; height: 48px; font-size: 22px; cursor: pointer; margin-left: 8px; vertical-align: middle; }
.spk.big { width: 96px; height: 96px; font-size: 44px; margin: 10px auto; display: block; }

.opts { display: grid; gap: 10px; margin: 14px 0; }
.opt {
  min-height: 56px; padding: 12px 16px; text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 14px;
  cursor: pointer; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere;
}
.opt:active { border-color: var(--accent); }
.opt.ok { background: var(--ok-soft); border-color: var(--ok); }
.opt.bad { background: var(--bad-soft); border-color: var(--bad); }
.opt:disabled { cursor: default; color: inherit; }

.field {
  width: 100%; min-height: 56px; padding: 12px 16px; font-size: 20px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card); margin: 12px 0 10px;
}
.field:focus { outline: none; border-color: var(--accent); }

.fb { border-radius: var(--r); padding: 14px 16px; margin: 12px 0; }
.fb.ok { background: var(--ok-soft); } .fb.bad { background: var(--bad-soft); } .fb.near { background: var(--warn-soft); }
.fb .h { font-weight: 700; margin-bottom: 4px; }

.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 0 0 12px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.counter { text-align: right; color: var(--muted); font-size: 14px; margin-bottom: 4px; }

.pair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.pair-grid .opt { min-height: 52px; font-size: 15px; padding: 8px 10px; }
.pair-grid .opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.pair-grid .opt.done { background: var(--ok-soft); border-color: var(--ok); opacity: .55; }

.ladder .slots { display: grid; gap: 8px; margin: 10px 0; }
.slot { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 2px dashed var(--line); }
.slot.filled { border-style: solid; background: var(--accent-soft); border-color: var(--accent); }
.slot.ok { background: var(--ok-soft); border-color: var(--ok); } .slot.bad { background: var(--bad-soft); border-color: var(--bad); }
.slot .n { font-weight: 700; color: var(--muted); width: 22px; }

.entry { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry .tt { font-weight: 700; font-size: 18px; }
.entry .mm { margin-top: 2px; }
.group-h { margin: 18px 0 4px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }

.stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 13px; }

.tmap { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.chip { padding: 5px 10px; border-radius: 99px; font-size: 14px; font-weight: 600; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.bad { background: var(--bad-soft); color: var(--bad); }

textarea.field { min-height: 110px; font-size: 14px; font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.foot { text-align: center; margin-top: 18px; }
.foot a { margin: 0 10px; }
.hide { display: none !important; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 15px; z-index: 50; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (min-width: 700px) { main { padding-top: 24px; } .opts.two { grid-template-columns: 1fr 1fr; } }

.report-btn { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 99px; height: 36px; padding: 0 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.report-btn:active { background: var(--accent-soft); }
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(10, 8, 30, .55); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal-box { background: var(--bg); width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
@media (min-width: 700px) { .modal { align-items: center; } .modal-box { border-radius: 20px; } }

/* ---- flash cards (Знакомство) ---- */
.stage { position: relative; margin: 4px 0 14px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.drag { position: relative; cursor: grab; touch-action: pan-y; outline: none; will-change: transform; }
.drag:active { cursor: grabbing; }
.drag.enter { animation: cardIn .3s cubic-bezier(.2,.8,.3,1); }
.drag.nudge { animation: nudge .7s ease .15s 1; }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes nudge { 0%,100% { transform: none; } 25% { transform: translateX(16px) rotate(1.6deg); } 60% { transform: translateX(-16px) rotate(-1.6deg); } }
.flip { perspective: 1200px; }
.flip-inner { display: grid; transition: transform .5s cubic-bezier(.3,.7,.3,1); transform-style: preserve-3d; }
.flip-inner.flipped { transform: rotateY(180deg); }
.face { grid-area: 1 / 1; min-height: 300px; display: flex; flex-direction: column; justify-content: center; background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow); padding: 18px 16px; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.face.back { transform: rotateY(180deg); border-color: var(--accent); }
.face .prompt .label { text-transform: none; letter-spacing: 0; font-size: 16px; }
.tap-hint { color: var(--muted); font-size: 14px; margin-top: 22px; }
.stamp { position: absolute; top: 18px; padding: 4px 12px; border: 3px solid; border-radius: 10px; font-weight: 800; font-size: 20px; letter-spacing: .04em; opacity: 0; pointer-events: none; background: var(--card); }
.stamp.know { left: 16px; color: var(--ok); border-color: var(--ok); transform: rotate(-10deg); }
.stamp.again { right: 16px; color: var(--bad); border-color: var(--bad); transform: rotate(10deg); }
.controls { min-height: 120px; }
.swipe-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.swipe-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; border: 0; border-radius: 20px; color: #fff; cursor: pointer; padding: 10px 14px; font-size: 17px; text-align: left; line-height: 1.15;
  box-shadow: 0 8px 18px -6px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.35); transition: transform .12s; }
.swipe-btn:active { transform: scale(.96); }
.swipe-btn b { display: block; font-size: 18px; } .swipe-btn small { display: block; opacity: .85; font-size: 12px; }
.swipe-btn.again { background: linear-gradient(135deg, #ff6b7a, #d6213a); justify-content: flex-start; }
.swipe-btn.know { background: linear-gradient(135deg, #3ddc84, #14933f); justify-content: flex-end; text-align: right; }
.swipe-btn svg { flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.swipe-btn.again svg { animation: hintL 1.4s ease-in-out 2; } .swipe-btn.know svg { animation: hintR 1.4s ease-in-out 2; }
@keyframes hintL { 0%,100% { transform: none; } 50% { transform: translateX(-7px); } }
@keyframes hintR { 0%,100% { transform: none; } 50% { transform: translateX(7px); } }
.swipe-tip { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
.swipe-tip .tip-l { color: var(--bad); font-weight: 800; } .swipe-tip .tip-r { color: var(--ok); font-weight: 800; }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } .drag.enter, .drag.nudge, .swipe-btn svg { animation: none; } }

@media (max-width: 420px) { .report-btn .tx { display: none; } .report-btn { width: 40px; padding: 0; } }
.big-num { margin: 2px 0 4px; } .big-num b { font-size: 40px; line-height: 1; } .big-num span { color: var(--muted); font-size: 16px; }
.card.mode .bar { margin-top: 8px; }
table.wt { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.wt th, table.wt td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.wt th { color: var(--muted); font-size: 12px; font-weight: 600; } table.wt .n { text-align: right; white-space: nowrap; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.legend span { margin-right: 10px; } .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 36px; display: flex; align-items: center; }

/* ---- my path ---- */
.card.hero { border-color: var(--accent); background: linear-gradient(160deg, var(--accent-soft), var(--card) 60%); }
.grade-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.grade-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 78px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); cursor: pointer; }
.grade-btn b { font-size: 28px; line-height: 1; } .grade-btn span { font-size: 12px; color: var(--muted); }
.grade-btn:active, .grade-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.tile-slots { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 16px 0 10px; }
.tile-word { display: inline-flex; gap: 5px; }
.slot-l { width: 34px; height: 44px; border-bottom: 3px solid var(--line); text-align: center; font-size: 26px; font-weight: 700; line-height: 44px; }
.slot-l.f { border-color: var(--accent); }
.tile-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 14px; }
.tile { width: 52px; height: 56px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-size: 24px; font-weight: 700; cursor: pointer; box-shadow: 0 2px 0 var(--line); }
.tile:active:not(:disabled) { transform: translateY(2px); box-shadow: none; } .tile:disabled { opacity: .25; }
