/* Палітра з Theme.kt — веб і застосунок мають бути очевидно одним продуктом. */
:root {
  --bg: #121212;
  --surface: #1E1E1E;
  --elevated: #2A2A2A;
  --text: #FFFFFF;
  --dim: #9E9E9E;
  --faint: #6E6E6E;
  --rule: #2E2E2E;
  --purple: #9C27B0;
  --purple-lt: #C24DD8;
  --blue: #29B6F6;
  --green: #16A34A;
  --red: #DC2626;
  --amber: #E0A030;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.02em; line-height: 1.18; text-wrap: balance; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; font-weight: 600; }
p { margin: 0 0 1rem; }

button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}

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

#bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .7rem;
  padding: max(.7rem, env(safe-area-inset-top)) 1rem .7rem;
  background: rgba(18, 18, 18, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
#bar .logo { width: 28px; height: 28px; flex: none; }
#bar-title { font-weight: 800; letter-spacing: -.02em; }

.icon-btn {
  background: transparent; border: 0; color: var(--text);
  font-size: 1.3rem; line-height: 1; padding: .3rem .5rem;
  border-radius: 9px;
}
.icon-btn:hover { background: var(--elevated); }

#app {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(3rem + env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------- елементи */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.35rem; border: 1px solid transparent; border-radius: 12px;
  background: var(--purple); color: #fff; font-weight: 600;
  transition: background .14s ease, transform .1s ease;
}
.btn:hover:not(:disabled) { background: var(--purple-lt); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; border-color: var(--rule); color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: var(--elevated); }
.btn.blue { background: var(--blue); color: #062634; }
.btn.blue:hover:not(:disabled) { background: #4FC5F8; }

input[type="text"], textarea, select {
  width: 100%; padding: .8rem .9rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--rule); border-radius: 12px;
  font: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--dim); margin: 0 0 .4rem; }
.field { margin-bottom: 1.15rem; }

.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.stack { display: grid; gap: .75rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.dim { color: var(--dim); }
.small { font-size: .87rem; }
.center { text-align: center; }

/* ---------------------------------------------------------------- курси */

.course {
  display: flex; align-items: center; gap: .9rem;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: .9rem 1rem;
  width: 100%; text-align: left; color: var(--text);
}
.course:hover { background: var(--elevated); }
.course .ring {
  width: 46px; height: 46px; flex: none; position: relative;
  display: grid; place-items: center;
  font-size: .74rem; font-weight: 700;
}
.course .ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.course .meta { min-width: 0; }
.course .name { font-weight: 600; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- шлях */

.section-title {
  display: flex; align-items: center; gap: .6rem;
  margin: 1.6rem 0 .8rem; color: var(--dim);
  font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 600;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.step {
  display: flex; align-items: center; gap: .9rem;
  width: 100%; text-align: left; color: var(--text);
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: .8rem .95rem; margin-bottom: .6rem;
}
.step:hover:not(:disabled) { background: var(--elevated); }
.step:disabled { opacity: .55; cursor: default; }
.step .num {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
  background: var(--elevated); color: var(--dim);
}
.step.done .num { background: var(--green); color: #fff; }
.step.next .num { background: var(--purple); color: #fff; }
.step .topic { overflow-wrap: anywhere; }

/* ------------------------------------------------------- перший візит */

.hero { padding: 2.5rem 0 1rem; text-align: center; }
.hero-title { font-size: clamp(1.9rem, 7vw, 2.7rem); }
.hero-title.accent { color: var(--purple-lt); }
.hero-sub {
  margin: 1.1rem auto 0; max-width: 32rem;
  color: var(--dim); font-size: 1.02rem;
}

.points { display: grid; gap: .8rem; margin-top: 3rem; }
@media (min-width: 46rem) { .points { grid-template-columns: repeat(3, 1fr); } }
.point {
  display: flex; gap: .9rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.point-ico { font-size: 1.4rem; line-height: 1.2; flex: none; }
.point h3 { margin-bottom: .25rem; }
.point p { margin: 0; }

/* ---------------------------------------------------------------- стрік, XP */

.stats { display: flex; gap: .55rem; margin-top: 1rem; }
.stats .stat {
  flex: 1; text-align: center;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 12px; padding: .6rem .4rem;
}
.stats .stat b { display: block; font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; }
.stats .stat span { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.stats .goal.hit { border-color: var(--green); }
.stats .goal.hit b { color: var(--green); }

.hearts { display: inline-flex; gap: .2rem; font-size: 1rem; }
.heart { color: var(--red); transition: opacity .2s ease, transform .2s ease; }
.heart.gone { opacity: .22; transform: scale(.85); }

.xp-pill {
  display: inline-block; padding: .4rem 1rem; border-radius: 999px;
  background: rgba(224, 160, 48, .18); border: 1px solid var(--amber);
  color: var(--amber); font-weight: 800; letter-spacing: .02em;
}
.card.win { border-color: var(--green); }

/* ---------------------------------------------------------------- мапа шляху */

.unit {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: .8rem 1.1rem;
  margin: 2.2rem 0 .5rem;
}
.unit-label { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--blue); font-weight: 600; }
.unit-name { font-weight: 700; letter-spacing: -.015em; }
.unit-count { margin-left: auto; color: var(--dim); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Вузли гуляють вбік — це і робить зі списку дорогу. Ширину лишаємо вужчою
   за контейнер, щоб зсув нікуди не виштовхував підпис. */
.map { display: flex; flex-direction: column; align-items: center; padding: .6rem 0; }

.node {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: .45rem;
  width: 34%; min-width: 8.5rem; max-width: 12rem;
  background: transparent; border: 0; color: var(--text);
  padding: .55rem 0 1.5rem;
}
/* З'єднувальна лінія між вузлами — малюємо як хвіст під кожним, крім останнього. */
.node::after {
  content: ""; position: absolute; left: 50%; bottom: .15rem;
  width: 3px; height: 1.3rem; transform: translateX(-50%);
  background: var(--elevated); border-radius: 2px;
}
.node:last-child::after { display: none; }
.node.done::after { background: rgba(22, 163, 74, .55); }

.node .disc {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.35rem;
  background: var(--elevated); color: var(--dim);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .45);
  transition: transform .12s ease, box-shadow .12s ease;
}
.node .cap {
  font-size: .78rem; line-height: 1.35; color: var(--dim);
  text-align: center; overflow-wrap: anywhere;
}

.node.done .disc { background: var(--green); color: #fff; }
.node.done .cap { color: var(--text); }

.node.next .disc {
  background: var(--purple); color: #fff;
  box-shadow: 0 5px 0 #6A1B9A, 0 0 0 6px rgba(156, 39, 176, .22);
}
.node.next .cap { color: var(--text); font-weight: 600; }

.node:not(:disabled):hover .disc { transform: translateY(-2px); }
.node:not(:disabled):active .disc { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .45); }
.node.locked { cursor: default; }
.node.locked .disc { font-size: 1.05rem; }

/* ---------------------------------------------------------------- урок */

.lesson-hero {
  background: linear-gradient(135deg, var(--purple), #6A1B9A);
  border-radius: var(--radius); padding: 1.2rem 1.2rem 1.3rem; margin-bottom: 1.1rem;
}
.lesson-hero .day {
  display: inline-block; font-size: .74rem; font-weight: 600;
  background: rgba(0, 0, 0, .28); padding: .25rem .6rem; border-radius: 999px; margin-bottom: .6rem;
}
.lesson-body p { line-height: 1.75; }
.lesson-body .hl { background: rgba(41, 182, 246, .28); border-radius: 3px; }

.keypoints { border-left: 3px solid var(--blue); }
.keypoints ul { margin: .5rem 0 0; padding-left: 1.1rem; }
.keypoints li { margin: .35rem 0; color: var(--dim); }
.keypoints li b { color: var(--text); font-weight: 500; }

figure { margin: 1.1rem 0; }
figure img {
  width: 100%; height: auto; display: block;
  border-radius: var(--radius); border: 1px solid var(--rule);
  background: var(--surface);
}
figcaption { margin-top: .45rem; font-size: .84rem; color: var(--faint); }

.rates { display: flex; gap: .1rem; }
.rate {
  background: transparent; border: 0; color: var(--dim);
  padding: .3rem .5rem; border-radius: 8px; font-size: .84rem; font-weight: 600;
}
.rate[aria-pressed="true"] { color: var(--blue); background: var(--elevated); }

/* ---------------------------------------------------------------- тест */

.progress { height: 5px; background: var(--elevated); border-radius: 99px; overflow: hidden; margin: .2rem 0 1.2rem; }
.progress i { display: block; height: 100%; background: var(--purple); transition: width .25s ease; }

.opt {
  display: block; width: 100%; text-align: left;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--rule); border-radius: 12px;
  padding: .85rem 1rem; margin-bottom: .55rem;
}
.opt:hover:not(:disabled) { background: var(--elevated); }
.opt.correct { border-color: var(--green); background: rgba(22, 163, 74, .14); }
.opt.wrong { border-color: var(--red); background: rgba(220, 38, 38, .14); }
.opt:disabled { cursor: default; }

.verdict { border-radius: 12px; padding: .9rem 1rem; margin-top: .9rem; font-size: .94rem; }
.verdict.ok { background: rgba(22, 163, 74, .14); border: 1px solid var(--green); }
.verdict.no { background: rgba(220, 38, 38, .14); border: 1px solid var(--red); }

.tag {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; padding: .25rem .55rem; border-radius: 7px;
  background: var(--elevated); color: var(--amber); margin-bottom: .7rem;
}

.note-target {
  background: var(--elevated); border-radius: 12px; padding: 1.4rem; text-align: center; margin: .8rem 0;
}
.note-target .letter { font-size: 3rem; font-weight: 800; color: var(--amber); line-height: 1; }
.note-target .hz { color: var(--dim); font-size: .85rem; }
.note-heard { font-size: .9rem; color: var(--dim); min-height: 1.4em; }

/* ---------------------------------------------------------------- стани */

.spinner {
  width: 34px; height: 34px; margin: 0 auto .9rem;
  border: 3px solid var(--elevated); border-top-color: var(--purple);
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }

.empty { text-align: center; padding: 3rem 1rem; color: var(--dim); }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--elevated); color: var(--text);
  border: 1px solid var(--rule); border-radius: 12px;
  padding: .7rem 1.1rem; font-size: .9rem; z-index: 50;
  max-width: calc(100vw - 2rem);
}

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