/* Тала — вариант C «Светлое утро». Цвета сняты с макетов bRrBT / p5I8q / lUxJB. */

:root {
  --bg: #faf5ec; /* кремовый фон всего приложения */
  --surface: #ffffff; /* карточки и строки */
  --ink: #33281d; /* основной текст */
  --muted: #8d8478; /* вторичный текст */
  --line: #ece4d5; /* разделители и рамки */
  --accent: #e8622c; /* терракота: главные кнопки, активная вкладка */
  --accent-press: #d23a12; /* нажатое состояние */
  --accent-soft: #fbe7dc; /* заливка под терракотовым акцентом */
  --dark: #33281d; /* тёмная карточка */
  --gold: #bf8f43; /* мелкие пилюли вроде «60 мин» */
  --gold-soft: #f6eddd;
  --danger: #c0392b;

  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --t-12: 0.75rem;
  --t-14: 0.875rem;
  --t-17: 1.0625rem;
  --t-20: 1.25rem;
  --t-24: 1.5rem;
  --t-30: 1.875rem;
  --t-34: 2.125rem;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(51, 40, 29, 0.04), 0 8px 24px rgba(51, 40, 29, 0.05);
  --shadow-lift: 0 2px 4px rgba(51, 40, 29, 0.06), 0 12px 28px rgba(51, 40, 29, 0.08);

  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);
  --dur: 180ms;

  --tabbar-h: 64px;
  --tabbar-gap: 10px;
  --saydock-h: 60px; /* уточняется из JS по реальной высоте строки ввода */
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-17);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
}
.skip:focus {
  left: 8px;
  top: 8px;
}

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

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
}

.screen {
  flex: 1;
  padding: 0 20px calc(var(--tabbar-gap) + var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* снизу висит строка ввода — отдаём ей место в потоке */
.screen--hasSay {
  padding-bottom: calc(
    var(--tabbar-gap) + var(--tabbar-h) + var(--saydock-h) + 28px + env(safe-area-inset-bottom)
  );
}

/* ---------- шапка «моя большая игра» ---------- */

.bigGame {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
}

.bigGame__label {
  display: block;
  font-size: var(--t-12);
  color: var(--muted);
}

.bigGame__text {
  display: block;
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--t-34);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin-top: 4px;
}

.bigGame__text--m {
  font-size: var(--t-30);
}

.bigGame__text--s {
  font-size: var(--t-24);
}

.topbar--compact .bigGame__text {
  font-size: var(--t-20);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* без min-width:0 длинная игра в одну строку выталкивает кнопку паспорта за экран */
.topbar__row .bigGame {
  flex: 1;
  width: auto;
  min-width: 0;
  overflow: hidden;
}

.topbar__passport {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  display: grid;
  place-items: center;
  transition: background var(--dur) var(--ease);
}

.topbar__passport:hover {
  background: var(--gold-soft);
}

/* ---------- общее ---------- */

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section__title {
  font-family: var(--sans);
  font-size: var(--t-14);
  font-weight: 600;
  color: var(--muted);
}

.screenTitle {
  font-size: var(--t-30);
}

.note {
  font-size: var(--t-14);
  color: var(--muted);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* строки-карточки: на макетах каждый пункт — отдельная белая плашка */
.list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list > li {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.list__main {
  display: block;
  min-width: 0;
  flex: 1;
}

.list__name {
  display: block;
  font-size: var(--t-17);
  font-weight: 600;
}

.list__note {
  display: block;
  font-size: var(--t-14);
  color: var(--muted);
}

.pill {
  flex: none;
  font-size: var(--t-12);
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.pill--gold {
  background: var(--gold-soft);
  border-color: transparent;
  color: var(--ink);
}

.pill--accent {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-press);
}

.tag--mock {
  align-self: flex-start;
  font-size: var(--t-12);
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-17);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.btn:hover {
  background: var(--gold-soft);
}
.btn:active {
  transform: scale(0.99);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--accent:hover {
  background: var(--accent-press);
  border-color: var(--accent-press);
}

.btn--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 500;
}
.btn--quiet:hover {
  background: var(--surface);
  color: var(--ink);
}

.error {
  font-size: var(--t-14);
  color: var(--danger);
}

/* ---------- скелетоны ---------- */

.skeleton {
  background: #f1e9dc;
  border-radius: var(--radius-sm);
  height: 16px;
  animation: pulse 1.4s var(--ease) infinite;
}
.skeleton--title {
  height: 32px;
  width: 70%;
}
.skeleton--row {
  height: 88px;
}
.skeleton--wide {
  height: 104px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ---------- показатели: три колонки ---------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric__icon {
  color: var(--gold);
  margin-bottom: 4px;
}

.metric__value {
  font-size: var(--t-30);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.metric__name {
  font-size: var(--t-14);
  font-weight: 600;
}

.metric__caption {
  font-size: var(--t-12);
  color: var(--muted);
}

/* ---------- тёмная карточка входа в разговор ---------- */

.talkCard {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--dark);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: #fff;
  box-shadow: var(--shadow-lift);
  transition: transform var(--dur) var(--ease);
}

.talkCard:hover {
  transform: translateY(-1px);
}
.talkCard:active {
  transform: scale(0.995);
}

.talkCard__mark {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
}

.talkCard__body {
  flex: 1;
  min-width: 0;
}

.talkCard__title {
  display: block;
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--t-20);
}

.talkCard__note {
  display: block;
  font-size: var(--t-14);
  color: #b9ae9f;
}

.talkCard__go {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
}

.talkCard:hover .talkCard__go {
  background: var(--accent-press);
}

/* ---------- задача дня ---------- */

.task__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.task__text {
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--t-20);
  line-height: 1.2;
}

/* ---------- лента разговора ---------- */

.talk {
  gap: 14px;
}

.talkHint {
  font-size: var(--t-14);
  color: var(--muted);
  text-align: center;
  max-width: 34ch;
  align-self: center;
  padding: 24px 0;
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.turn {
  max-width: 88%;
  padding: 12px 15px;
  border-radius: var(--radius);
  font-size: var(--t-17);
}

.turn--tala {
  align-self: flex-start;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 6px;
}

.turn--human {
  align-self: flex-end;
  background: var(--accent-soft);
  border-bottom-right-radius: 6px;
}

.turn__who {
  display: block;
  font-size: var(--t-12);
  color: var(--muted);
  margin-bottom: 2px;
}

.turn__text {
  display: block;
}

.turn__note {
  display: block;
  font-size: var(--t-12);
  color: var(--muted);
  margin-top: 4px;
}

.turn--failed {
  background: #fbe6e3;
}

.turn--failed .turn__note {
  color: var(--danger);
}

.turn__retry {
  margin-top: 6px;
  min-height: 34px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--t-14);
  font-weight: 600;
  transition: background var(--dur) var(--ease);
}

.turn__retry:hover {
  background: var(--gold-soft);
}

.turn--waiting {
  min-width: 88px;
}

.dots {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 20px;
}

.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.35;
  animation: dot 1.2s var(--ease) infinite;
}

.dots i:nth-child(2) {
  animation-delay: 0.18s;
}
.dots i:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
  }
  30% {
    opacity: 1;
  }
}

/* ---------- карточка подтверждения ---------- */

.confirm {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm__title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--t-20);
  line-height: 1.2;
}

.confirm__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--t-14);
}

.confirm__kind {
  color: var(--muted);
}

.confirm__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.confirm__actions .btn {
  min-height: 44px;
  padding: 10px 18px;
  font-size: var(--t-14);
}

/* ---------- строка ввода «Скажи Тале…» с диктовкой ---------- */

.sayDock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-gap) + var(--tabbar-h) + 8px + env(safe-area-inset-bottom));
  z-index: 3;
  width: calc(100% - 24px);
  max-width: 456px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sayDock__note {
  align-self: center;
  font-size: var(--t-12);
  color: var(--muted);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  box-shadow: var(--shadow);
}

.sayDock__note--error {
  color: var(--danger);
}

.sayRow {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: var(--shadow-lift);
  padding: 6px 6px 6px 8px;
}

.sayRow__mic {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.sayRow__mic:hover {
  background: var(--gold-soft);
  color: var(--ink);
}

.sayRow__mic:disabled {
  opacity: 0.4;
  cursor: default;
}

/* идёт запись — микрофон терракотовый и пульсирует */
.sayRow--recording .sayRow__mic {
  background: var(--accent);
  color: #fff;
  animation: recording 1.4s var(--ease) infinite;
}

@keyframes recording {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(232, 98, 44, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(232, 98, 44, 0);
  }
}

.sayRow__timer {
  flex: none;
  font-size: var(--t-14);
  font-weight: 600;
  color: var(--accent-press);
  font-variant-numeric: tabular-nums;
}

.sayRow__input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 8px 4px;
  font-size: var(--t-17);
  background: transparent;
  border: 0;
}

.sayRow__input::placeholder {
  color: var(--muted);
}

.sayRow__input:focus {
  outline: none;
}

.sayRow__input:disabled {
  opacity: 0.6;
}

.sayRow__send {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.sayRow__send:hover {
  background: var(--accent-press);
}

.sayRow__send:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---------- нижняя навигация ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-gap) + env(safe-area-inset-bottom));
  z-index: 4;
  width: calc(100% - 24px);
  max-width: 456px;
  margin: 0 auto;
  height: var(--tabbar-h);
  background: var(--surface);
  border-radius: 26px;
  box-shadow: var(--shadow-lift);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

/* класс сильнее правила [hidden] из браузера — гасим явно */
.tabbar[hidden] {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: var(--t-12);
  color: var(--muted);
  text-decoration: none;
  border-radius: 22px;
  transition: color var(--dur) var(--ease);
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-current="page"] {
  color: var(--accent);
}

/* ---------- паспорт ---------- */

.mastery {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-12);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mastery__bar {
  width: 54px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.mastery__fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

.manifest {
  font-family: var(--serif);
  font-size: var(--t-20);
  line-height: 1.4;
  white-space: pre-wrap;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* ---------- путь: вертикальный таймлайн ---------- */

.steps {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 18px;
  position: relative;
}

.step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 19px;
  top: 44px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.step__dot {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  display: grid;
  place-items: center;
}

.step--done .step__dot {
  color: var(--gold);
  border-color: var(--gold);
}

.step--now .step__dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.step__body {
  flex: 1;
  min-width: 0;
  padding-top: 3px;
}

/* текущий шаг — белая карточка, как на макете */
.step--now .step__body {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step__name {
  display: block;
  font-size: var(--t-17);
  font-weight: 600;
}

.step__note {
  display: block;
  font-size: var(--t-14);
  color: var(--muted);
}

.step__go {
  flex: none;
  color: var(--muted);
}

/* ---------- люди ---------- */

.avatar {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-size: var(--t-17);
  font-weight: 700;
}

/* ---------- вход по коду ---------- */

.login {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding-bottom: 12dvh;
}

.login__title {
  font-size: var(--t-30);
}

.login .note {
  max-width: 30ch;
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 260px;
  margin-top: 6px;
}

.login__code {
  min-height: 56px;
  padding: 10px 12px;
  font-size: var(--t-24);
  text-align: center;
  letter-spacing: 0.3em;
  text-indent: 0.3em; /* компенсация трекинга, чтобы код стоял по центру */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login__code:focus {
  border-color: var(--accent);
}

.login__error {
  font-size: var(--t-14);
  color: var(--danger);
  min-height: 1.45em;
}

/* ---------- уважение к настройкам движения ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
