:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c2129;
  --border: #262d38;
  --text: #e6edf3;
  --muted: #8b949e;
  --gold: #f0b429;
  --gold-dim: #7a5a12;
  --green-1: #1a7f37;
  --green-2: #2ea043;
  --green-3: #4ae168;
  --empty: #21262d;
  --red: #f85149;
  --blue: #4493f8;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { font-size: 12px; line-height: 1.4; margin-top: 8px; }
.small { font-size: 12px; }

.label {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ---------- вход ---------- */

.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
}

.login-mark { font-size: 34px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { font-size: 13px; margin-bottom: 20px; }

.login-card input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}

.login-card input:focus { outline: none; border-color: var(--blue); }

.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--gold);
  color: #14100a;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }

.shake { animation: shake .4s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ---------- каркас ---------- */

.screen { max-width: 1180px; margin: 0 auto; padding: 24px; }
#home { max-width: 720px; }

.grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.back {
  display: inline-block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.back:hover { color: var(--text); }

.panel-stack {
  position: sticky;
  top: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ---------- MMR ---------- */

.mmr-label {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.mmr-value {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.05;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.mmr-value.bump { animation: bump .45s cubic-bezier(.2, 1.6, .4, 1); }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); text-shadow: 0 0 24px rgba(240, 180, 41, .55); }
  100% { transform: scale(1); }
}

.mmr-split { font-size: 12px; margin-top: 2px; }

.home-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.home-level { flex: 1; max-width: 340px; }
.home-label { margin-top: 28px; }

.level-block, .track-progress, .heat {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.level-badge {
  background: var(--gold);
  color: #14100a;
  font-weight: 800;
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 999px;
}

.form-title { font-size: 13px; font-weight: 600; }

.bar {
  height: 8px;
  background: var(--empty);
  border-radius: 999px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width .5s cubic-bezier(.2, .8, .3, 1);
}

/* ---------- форма ---------- */

.pips { display: flex; gap: 4px; margin-bottom: 12px; }

.pips i {
  flex: 1;
  height: 10px;
  border-radius: 3px;
  background: var(--empty);
  transition: background .3s;
}

.pips i.on { background: var(--green-2); }
.pips i.fresh { animation: pip .5s; }

@keyframes pip {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(1.9); background: var(--green-3); }
  100% { transform: scaleY(1); }
}

.review-btn {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--green-1);
  border-radius: 10px;
  background: rgba(46, 160, 67, .14);
  color: var(--green-3);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.review-btn.done {
  background: var(--green-1);
  color: #eafff0;
  cursor: default;
}

/* ---------- карточки треков ---------- */

.track-card {
  display: block;
  margin-bottom: 12px;
  transition: border-color .15s, transform .1s;
}

.track-card:hover { border-color: var(--gold-dim); }
.track-card:active { transform: scale(.995); }

.track-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.track-card-title { font-size: 17px; font-weight: 700; }

.track-card-mmr {
  color: var(--gold);
  font-weight: 800;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.track-card .bar { margin: 10px 0; }
.track-card-next { margin-top: 10px; }

/* ---------- «круче N% такой-то аудитории» ---------- */

.pcts { margin-top: 12px; }

.pct {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 3px 0;
}

.pct b {
  color: var(--green-3);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.pct .one-in {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.track-card .pcts { margin-top: 10px; }

/* ---------- календарь занятий ---------- */

.streak-card { margin-bottom: 8px; }

.streak-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.streak-value {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: var(--green-3);
  font-variant-numeric: tabular-nums;
}

.streak-value.cold { color: var(--muted); }
.streak-side { text-align: right; line-height: 1.7; }
.streak-side b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Полгода недель в 375 px не влезают, поэтому календарь прокручивается вбок
   и прижат к правому краю: свежие дни важнее старых. */
.cal-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
}

.cal {
  display: flex;
  gap: 3px;
  width: max-content;
  margin-left: auto;
}

.cal-col { display: flex; flex-direction: column; gap: 3px; }

.cal-month {
  font-size: 9px;
  color: var(--muted);
  height: 12px;
  line-height: 12px;
  white-space: nowrap;
}

.cal-day {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--empty);
}

.cal-day.l1 { background: var(--green-1); }
.cal-day.l2 { background: var(--green-2); }
.cal-day.l3 { background: var(--green-3); }
.cal-day.today { box-shadow: 0 0 0 1.5px var(--gold); }
.cal-day.future { background: transparent; }

/* ---------- книги ---------- */

.select {
  width: 100%;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.book-form { margin-bottom: 16px; }

.book-form input {
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.book-form input:focus { outline: none; border-color: var(--blue); }

.book-form-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.book-form-row input { flex: 1; min-width: 0; }

.book-form-row button {
  flex: 0 0 auto;
  padding: 11px 20px;
  background: var(--gold);
  color: #14100a;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.book-year {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}

.book {
  display: flex;
  align-items: baseline;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.book-main { flex: 1; min-width: 0; }
.book-title { font-weight: 600; }
.book-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.book-drop {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: #4d5665;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.book-drop:hover { color: var(--red); }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 32px 16px;
}

.mini-heat { display: flex; flex-wrap: wrap; gap: 2px; }

.mini-heat i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--empty);
  display: block;
}

.mini-heat i.w1.on { background: var(--green-1); }
.mini-heat i.w2.on { background: var(--green-2); }
.mini-heat i.w3.on, .mini-heat i.w10.on { background: var(--green-3); }

/* ---------- хитмап ---------- */

.heat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }

.heat-name {
  width: 92px;
  flex: 0 0 92px;
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat-cells { display: flex; flex-wrap: wrap; gap: 3px; }

.cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--empty);
  border: none;
  padding: 0;
  cursor: pointer;
}

.cell.w1.on { background: var(--green-1); }
.cell.w2.on { background: var(--green-2); }
.cell.w3.on, .cell.w10.on { background: var(--green-3); }
.cell.pulse { animation: pulse .6s; }

@keyframes pulse {
  0% { transform: scale(1); }
  45% { transform: scale(2.1); box-shadow: 0 0 12px rgba(74, 225, 104, .8); }
  100% { transform: scale(1); }
}

/* ---------- контент трека ---------- */

.content-head { margin-bottom: 20px; }
.content-head h1 { font-size: 22px; line-height: 1.25; margin-bottom: 6px; }
.content-head p { font-size: 13px; }
.src { font-size: 12px; text-decoration: underline; display: inline-block; margin-top: 6px; }

.section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.section.next { border-color: var(--gold-dim); }

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.section-head:hover { background: var(--panel-2); }
.section-title { font-weight: 600; flex: 1; min-width: 0; }

.badge {
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #14100a;
  background: var(--gold);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.section-count {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chev { color: var(--muted); transition: transform .2s; }
.section.open .chev { transform: rotate(90deg); }
.section-body { display: none; padding: 0 16px 10px; }
.section.open .section-body { display: block; }

.atom {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.atom:hover { background: var(--panel-2); }
.atom.flash { animation: flash 1.2s; }

@keyframes flash {
  0% { background: rgba(240, 180, 41, .22); }
  100% { background: transparent; }
}

.box {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 2px solid #3d4552;
  border-radius: 6px;
  position: relative;
  transition: background .18s, border-color .18s;
}

.atom.on .box { background: var(--green-2); border-color: var(--green-2); }

.box svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.box path {
  fill: none;
  stroke: #fff;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 22;
  stroke-dashoffset: 22;
}

.atom.on .box path { stroke-dashoffset: 0; transition: stroke-dashoffset .28s ease-out .04s; }

.atom-text { flex: 1; font-size: 14px; }
.atom.on .atom-text { color: var(--muted); }

.atom-meta {
  flex: 0 0 auto;
  font-size: 11px;
  color: #4d5665;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.atom.on .atom-meta { color: var(--green-2); }

.content-foot { font-size: 12px; padding: 12px 4px 40px; }

/* ---------- всплывающие числа, тост, левелап ---------- */

.floats { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

.float {
  position: absolute;
  font-weight: 800;
  font-size: 20px;
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
  animation: floatUp 1.1s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 0; transform: translateY(0) scale(.8); }
  15% { opacity: 1; transform: translateY(-6px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-56px) scale(1); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  max-width: min(520px, calc(100vw - 32px));
  font-size: 14px;
  z-index: 60;
  animation: toastIn .3s;
  text-align: center;
}

.toast.err { border-color: var(--red); color: #ffb4b0; }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.levelup {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(240, 180, 41, .22), rgba(14, 17, 22, .92) 62%);
  animation: fadeIn .25s;
  pointer-events: none;
}

.levelup-inner { text-align: center; animation: popIn .6s cubic-bezier(.2, 1.6, .4, 1); }

.levelup-word {
  font-size: 15px;
  letter-spacing: .4em;
  text-transform: uppercase;
  color: var(--gold);
}

.levelup-num {
  font-size: 108px;
  font-weight: 900;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 60px rgba(240, 180, 41, .7);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.confetti { position: absolute; inset: 0; overflow: hidden; }

.confetti i {
  position: absolute;
  top: -14px;
  width: 8px;
  height: 14px;
  opacity: .95;
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* ---------- мобильный layout ---------- */

@media (max-width: 760px) {
  .screen { padding: 0; max-width: none; }
  #home { padding: 16px 16px 40px; }

  .home-head { display: block; margin-bottom: 18px; }
  .mmr-label { font-size: 10px; letter-spacing: .12em; }
  .mmr-value { font-size: 34px; display: inline-block; }
  .mmr-split { display: inline-block; margin-left: 8px; }
  .home-level { max-width: none; margin-top: 10px; }

  .grid { display: block; }
  .back { padding: 14px 16px 0; margin-bottom: 8px; }

  .panel-stack {
    position: static;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
  }

  /* Липкой остаётся только строка рейтинга: она должна быть видна всегда,
     а прогресс трека и хитмап уезжают в обычный поток над списком тем. */
  .panel-inner {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 14px;
    background: rgba(22, 27, 34, .96);
    backdrop-filter: blur(8px);
  }

  .panel-inner .mmr-value { font-size: 32px; }
  .panel-inner .level-block { margin-top: 10px; padding-top: 10px; }
  .panel-inner .level-block .level-row { margin-bottom: 6px; }

  .panel-rest { padding: 16px 16px 0; }
  .track-progress { margin-top: 0; padding-top: 0; border-top: none; }
  .heat-name { width: 74px; flex: 0 0 74px; font-size: 9px; }

  .content { padding: 16px; }
  .content-head h1 { font-size: 18px; }

  /* Пилюля «начни отсюда» рядом с названием и счётчиком в 375 px не влезает,
     поэтому на телефоне она переезжает отдельной строкой-подписью. */
  .section-head { padding: 16px; flex-wrap: wrap; }
  .section-count { order: 3; }

  .badge {
    order: 4;
    width: 100%;
    margin: 2px 0 0 26px;
    padding: 0;
    background: none;
    color: var(--gold);
    letter-spacing: .06em;
  }

  .atom { padding: 13px 6px; gap: 14px; }
  .atom-text { font-size: 15px; }
  .box { width: 24px; height: 24px; }
  .atom-meta { display: none; }

  .review-btn { padding: 16px; font-size: 15px; }
  .toast { bottom: 20px; }
  .levelup-num { font-size: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
