/* ==========================================================
   Speek — общий стиль
   Белый / ледяной голубой + немного чёрного и серебра
   ========================================================== */

:root {
  /* поверхности */
  --bg: #F3F7FE;
  --bg2: #FFFFFF;
  --path: #E8F0FD;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.9);

  /* акценты */
  --blue: #2563FF;
  --blue-deep: #1639B8;
  --sky: #5AA9FF;
  --cyan: #22D3EE;
  --amber: #2563FF;
  --mint: #1D6FFF;
  --red: #FF5C7A;

  /* чёрный и серебро */
  --ink: #0A0F1C;
  --graphite: #161D2E;
  --graphite-2: #232C42;
  --silver: #C6CFDD;
  --silver-light: #E3E9F2;
  --chrome: linear-gradient(145deg, #FFFFFF 0%, #D5DCE8 45%, #F4F7FB 55%, #AEB8C9 100%);

  /* текст */
  --text: #0C1424;
  --text-dim: #5C6C84;
  --locked: #D3DAE6;

  --radius: 18px;
  --shadow-soft: 0 10px 30px rgba(30, 64, 140, 0.10), 0 2px 6px rgba(30, 64, 140, 0.06);
  --shadow-glow: 0 8px 28px rgba(37, 99, 255, 0.35);
  --ease: cubic-bezier(.2, .8, .2, 1);

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  background: var(--bg);
  scroll-padding-top: env(safe-area-inset-top, 0px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: 'Manrope', system-ui, sans-serif;
  background: transparent;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.home { min-height: 100%; }
body.lesson { height: 100%; display: flex; flex-direction: column; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(60% 45% at 85% -5%, rgba(90, 169, 255, 0.40) 0%, transparent 70%),
    radial-gradient(50% 40% at 0% 20%, rgba(34, 211, 238, 0.22) 0%, transparent 70%),
    radial-gradient(70% 50% at 50% 115%, rgba(37, 99, 255, 0.16) 0%, transparent 70%),
    linear-gradient(180deg, #FFFFFF 0%, #EEF4FF 100%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(37, 99, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 255, 0.07) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 20%, #000 0%, transparent 75%);
          mask-image: radial-gradient(ellipse at 50% 20%, #000 0%, transparent 75%);
}

h1, h2, h3, .display { font-family: 'Sora', system-ui, sans-serif; letter-spacing: -0.02em; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 10px;
}

header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
          backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid rgba(198, 207, 221, 0.7);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 8px 24px rgba(30, 64, 140, 0.06);
}
body.home header { justify-content: space-between; padding: 14px 20px; }

.brand { display: flex; align-items: center; gap: 11px; }

.brand .mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif; font-weight: 800; font-size: 17px;
  color: #EAF1FF;
  background: linear-gradient(145deg, #2B3550 0%, var(--ink) 60%);
  box-shadow:
    0 0 0 1px rgba(198, 207, 221, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 6px 16px rgba(10, 15, 28, 0.28);
  position: relative;
}
.brand .mark::after {
  content: "";
  position: absolute; right: 5px; top: 5px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}
.brand .name { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }

.streak {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: 100px;
  font-weight: 800; font-size: 14px;
  color: #EAF1FF;
  background: linear-gradient(145deg, var(--graphite-2), var(--ink));
  box-shadow: 0 0 0 1px rgba(198, 207, 221, 0.8), 0 6px 14px rgba(10, 15, 28, 0.22);
}

.exit {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--silver-light);
  background: var(--glass-strong);
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  transition: transform .2s var(--ease), color .2s, box-shadow .2s;
}
.exit:hover { color: var(--blue); box-shadow: var(--shadow-soft); transform: translateY(-1px); }

.htitle { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.hsub { color: var(--text-dim); font-size: 12px; margin-top: 1px; }

main { position: relative; }
body.home main { max-width: 520px; margin: 0 auto; padding: 40px 20px 100px; }

.intro { margin-bottom: 40px; }
.intro h1 {
  font-size: 30px; font-weight: 800; line-height: 1.15;
  margin: 0 0 12px;
  background: linear-gradient(120deg, var(--ink) 0%, #1A2C66 55%, var(--blue) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.intro p { color: var(--text-dim); font-size: 15px; line-height: 1.65; margin: 0; max-width: 38ch; }

.unit-tag {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--glass-strong);
  border: 1px solid var(--silver);
  padding: 8px 15px; border-radius: 100px;
  font-size: 13px; color: var(--text-dim); font-weight: 500;
  margin-bottom: 44px;
  box-shadow: var(--shadow-soft);
}
.unit-tag::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 10px var(--cyan);
}
.unit-tag b { color: var(--ink); font-weight: 800; }

.path { position: relative; }
.path svg.connector { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

.node-row { position: relative; display: flex; margin-bottom: 38px; min-height: 82px; }
.node-row[data-align="center"] { justify-content: center; }
.node-row[data-align="left"]   { justify-content: flex-start; padding-left: 8%; }
.node-row[data-align="right"]  { justify-content: flex-end;   padding-right: 8%; }

.node {
  position: relative;
  width: 78px; height: 78px; border-radius: 50%;
  border: none; cursor: default;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  z-index: 2;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}

.node.unlocked {
  color: #fff;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.65) 0%, transparent 38%),
    linear-gradient(160deg, var(--sky) 0%, var(--blue) 55%, var(--blue-deep) 100%);
  box-shadow:
    0 6px 0 #14308F,
    0 14px 30px rgba(37, 99, 255, 0.40),
    inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  cursor: pointer;
  text-shadow: 0 2px 8px rgba(10, 30, 120, 0.45);
}
.node.unlocked:hover { transform: translateY(-2px); }
.node.unlocked:active { transform: translateY(5px); box-shadow: 0 1px 0 #14308F, 0 6px 16px rgba(37, 99, 255, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.35); }

.node.locked {
  color: #7C8BA3;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.95) 0%, transparent 45%),
    var(--chrome);
  box-shadow: 0 6px 0 #AAB4C5, 0 12px 22px rgba(30, 64, 140, 0.10), inset 0 0 0 2px rgba(255, 255, 255, 0.8);
  cursor: not-allowed;
  filter: saturate(0.8);
}

.node .pulse {
  position: absolute; inset: -10px; border-radius: 50%;
  border: 2px solid var(--cyan);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.node-label {
  position: absolute; top: 92px; left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 700; color: var(--text-dim);
  white-space: nowrap;
}
.node.unlocked + .node-label { color: var(--ink); }

.start-badge {
  position: absolute; top: -46px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px;
  background: linear-gradient(145deg, var(--graphite-2), var(--ink));
  color: #fff;
  font-family: 'Sora', sans-serif; font-weight: 700; font-size: 12px;
  padding: 7px 14px; border-radius: 100px;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(198, 207, 221, 0.7), 0 8px 18px rgba(10, 15, 28, 0.28);
}
.start-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan);
}
.start-badge::after {
  content: ""; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--ink); border-bottom: 0;
}

.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 18, 40, 0.38);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: none; align-items: flex-end; justify-content: center;
  z-index: 50;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
}
.overlay.open { display: flex; }

.sheet {
  width: 100%; max-width: 520px;
  background: var(--glass-strong);
  border-radius: 28px 28px 0 0;
  padding: 30px 24px calc(28px + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--silver-light);
  border-bottom: none;
  box-shadow: 0 -20px 60px rgba(30, 64, 140, 0.20);
  animation: sheet-up .35s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet::before {
  content: ""; display: block; width: 44px; height: 4px; border-radius: 4px;
  background: var(--silver); margin: -14px auto 20px;
}
.sheet h2 { font-size: 21px; margin: 0 0 8px; font-weight: 800; }
.sheet p { color: var(--text-dim); font-size: 14px; line-height: 1.6; margin: 0 0 22px; }
.sheet button {
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  background: linear-gradient(145deg, var(--graphite-2), var(--ink));
  color: #fff;
  font-family: 'Sora', sans-serif; font-weight: 700; font-size: 15px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(10, 15, 28, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform .15s var(--ease);
}
.sheet button:active { transform: scale(0.98); }
.sheet .close { background: none; color: var(--text-dim); box-shadow: none; margin-top: 10px; font-weight: 600; }

#chat {
  flex: 1;
  min-height: 100px;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--silver) transparent;
}
#chat::-webkit-scrollbar { width: 6px; }
#chat::-webkit-scrollbar-thumb { background: var(--silver); border-radius: 6px; }

.msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 15px; line-height: 1.55;
  overflow-wrap: anywhere;
  animation: msg-in .28s var(--ease);
}
@keyframes msg-in { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

.msg.ai {
  align-self: flex-start;
  background: var(--glass-strong);
  border: 1px solid var(--silver-light);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-soft);
}
.msg.user {
  align-self: flex-end;
  color: #fff; font-weight: 500;
  background: linear-gradient(145deg, var(--sky) 0%, var(--blue) 60%, var(--blue-deep) 100%);
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.msg.typing { color: var(--text-dim); font-style: italic; }

.msg .speak, .msg .retry {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px; padding: 5px 11px;
  border: 1px solid rgba(37, 99, 255, 0.25);
  border-radius: 100px;
  background: rgba(37, 99, 255, 0.07);
  color: var(--blue);
  font: 700 12px 'Manrope', system-ui, sans-serif;
  cursor: pointer;
  transition: background .2s, transform .15s var(--ease);
}
.msg .speak:hover, .msg .retry:hover { background: rgba(37, 99, 255, 0.14); }
.msg .speak:active, .msg .retry:active { transform: scale(0.96); }
.msg .retry:disabled { opacity: 0.5; }

#composer {
  flex-shrink: 0;
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
          backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid rgba(198, 207, 221, 0.8);
  box-shadow: 0 -8px 24px rgba(30, 64, 140, 0.06);
}

#textInput {
  flex: 1; min-width: 0;
  padding: 13px 18px;
  border-radius: 100px;
  border: 1px solid var(--silver);
  background: #fff;
  color: var(--text);
  font-size: 15px; font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#textInput::placeholder { color: #8E9BB1; }
#textInput:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(37, 99, 255, 0.14); }
#textInput:disabled { background: var(--path); }

#micBtn, #sendBtn {
  flex-shrink: 0;
  width: 46px; height: 46px; border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  transition: transform .15s var(--ease), box-shadow .2s;
}
#micBtn:active, #sendBtn:active { transform: scale(0.92); }

#micBtn {
  background: var(--chrome);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--silver), 0 4px 12px rgba(30, 64, 140, 0.12);
}
#micBtn.listening {
  background: linear-gradient(145deg, var(--cyan), var(--blue));
  color: #fff;
  animation: listen 1.2s ease-in-out infinite;
}
@keyframes listen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.55); }
  50%      { box-shadow: 0 0 0 10px rgba(34, 211, 238, 0); }
}

#sendBtn {
  background: linear-gradient(145deg, var(--sky), var(--blue) 60%, var(--blue-deep));
  color: #fff;
  box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
#sendBtn:disabled, #micBtn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.notice { color: var(--text-dim); font-size: 12px; text-align: center; padding: 6px 16px; }
.notice:empty { display: none; }

#progress {
  flex-shrink: 0;
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  padding: 8px 16px 4px;
}
#progress:empty { display: none; }

.chip {
  font-size: 12px; font-weight: 700;
  padding: 6px 12px; border-radius: 100px;
  background: var(--glass-strong);
  color: var(--text-dim);
  border: 1px solid var(--silver-light);
  transition: all .3s var(--ease);
}
.chip.done {
  color: #fff;
  background: linear-gradient(145deg, var(--sky), var(--blue));
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(37, 99, 255, 0.35);
}

.done-card {
  align-self: center; text-align: center;
  max-width: 90%;
  padding: 22px 24px;
  border-radius: 22px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(37, 99, 255, 0.45) 0%, transparent 60%),
    linear-gradient(160deg, var(--graphite-2), var(--ink));
  border: 1px solid rgba(198, 207, 221, 0.55);
  box-shadow: 0 18px 40px rgba(10, 15, 28, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  animation: msg-in .45s var(--ease);
}
.done-card h2 { margin: 0 0 6px; font-size: 19px; font-weight: 800; }
.done-card p { margin: 0 0 16px; color: #B4C0D6; font-size: 14px; }
.done-card button, .done-card a {
  display: inline-block;
  padding: 12px 24px; border: none; border-radius: 12px;
  color: var(--ink);
  background: var(--chrome);
  font-family: 'Sora', sans-serif; font-weight: 700; font-size: 14px;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  transition: transform .15s var(--ease);
}
.done-card button:active, .done-card a:active { transform: scale(0.97); }

body.lesson main {
  width: 100%; max-width: 760px;
  min-height: 0; flex: 1;
  margin: 0 auto;
  display: flex; flex-direction: column;
  padding: 18px 16px 0;
}
body.lesson main #chat { padding: 12px 2px; }
body.lesson main #composer { margin: 0 -16px; }

.review-heading { flex-shrink: 0; padding: 0 2px 12px; }
.review-heading h1 {
  margin: 0 0 7px; font-size: 22px; line-height: 1.25; font-weight: 800;
  background: linear-gradient(120deg, var(--ink), var(--blue));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.review-heading p { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.55; }

.question-meta {
  display: flex; justify-content: space-between; gap: 12px;
  margin: 12px 2px 8px;
  color: var(--text-dim); font-size: 12px; font-weight: 700;
}

.track {
  height: 7px; margin: 0 2px 8px;
  border-radius: 10px;
  background: var(--silver-light);
  box-shadow: inset 0 1px 2px rgba(30, 64, 140, 0.15);
  overflow: hidden;
}
.track-fill {
  height: 100%; width: 0;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.7);
  transition: width .35s var(--ease);
}

@media (max-width: 420px) {
  .msg { max-width: 90%; }
  .intro h1 { font-size: 26px; }
}

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