/* Медитации собственным голосом — светлая тёплая палитра, малина и воздух */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* Телефон: касание без синей вспышки, длинные слова не распирают экран */
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
img, svg, audio { max-width: 100%; }

:root {
  --bg: #fdf6f4;
  --bg-glow: #fbedf0;
  --surface: #ffffff;
  --surface-2: #f7e6ea;
  --text: #4a323e;
  --text-dim: #a58a96;
  --accent: #c94f7c;      /* тёплая малина */
  --accent-soft: #d66590;
  --accent-text: #ffffff;
  --danger: #c0605e;
  --radius: 20px;
  --shadow: 0 8px 28px rgba(201, 79, 124, 0.08);
}

html { background: var(--bg); }

body {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-glow) 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  overflow-wrap: anywhere;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 28px 96px;
}

header h1 {
  font-family: "Palatino", "Georgia", serif;
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

header p.tagline {
  color: var(--text-dim);
  margin-top: 6px;
  font-size: 1rem;
  font-style: italic;
}

nav {
  display: flex;
  gap: 14px;
  margin: 36px 0 48px;
  flex-wrap: wrap;
}

nav a {
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 13px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: background 0.25s, color 0.25s;
}

nav a:hover { background: var(--surface-2); color: var(--accent); }

h2 {
  font-family: "Palatino", "Georgia", serif;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 1.05rem;
  padding: 14px 28px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.25s, transform 0.15s;
}

.btn:hover { background: #f2d9e0; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-soft); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  padding: 8px 14px;
  font-size: 0.9rem;
}

/* Пустая библиотека: два шага */
.empty-steps { display: grid; gap: 20px; }

.step {
  display: flex;
  align-items: center;
  gap: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 28px;
}

.step .num {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.step h3 { font-weight: 500; font-size: 1.1rem; }
.step p { color: var(--text-dim); font-size: 0.92rem; }
.step .btn { margin-left: auto; flex-shrink: 0; }

/* Карточки библиотеки */
.med-list { display: grid; gap: 18px; }

.med-card {
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.med-card .info { flex: 1; min-width: 0; }
.med-card h3 { font-weight: 500; font-size: 1.05rem; }

.med-card .meta {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 2px;
}

.status-pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.status-pill.ready { color: var(--accent); }
.status-pill.error { color: var(--danger); }

/* Выбор темы */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.topic-card {
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 26px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.25s, background 0.25s;
}

.topic-card:hover { border-color: var(--accent); }
.topic-card h3 { font-weight: 500; font-family: "Palatino", "Georgia", serif; }
.topic-card p { color: var(--text-dim); font-size: 0.88rem; margin-top: 6px; }

.script-view {
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 34px;
}

.script-view h3 { font-weight: 500; margin-bottom: 14px; font-family: "Palatino", "Georgia", serif; }

.script-view .text {
  color: var(--text);
  white-space: pre-wrap;
  font-size: 1.02rem;
  line-height: 2;
}

.actions { display: flex; gap: 14px; margin-top: 28px; flex-wrap: wrap; }

.hidden { display: none !important; }

section + section { margin-top: 56px; }

/* Имя для режима аватара (главная) */
.name-step {
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 28px;
}

.name-step h3 { font-weight: 500; font-size: 1.1rem; }
.name-note { color: var(--text-dim); font-size: 0.92rem; margin-top: 4px; }

.name-form { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 16px; }

.name-form input {
  flex: 1;
  min-width: 200px;
  font: inherit;
  padding: 13px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
}

.name-form input:focus { outline: 1px solid var(--accent); }

/* Род обращения: «…ты спокоен» / «…ты спокойна» — пилюли-радио */
.name-gender { border: none; width: 100%; }
.name-gender legend { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 8px; }

.name-gender label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-right: 10px;
  cursor: pointer;
}

.name-gender input { accent-color: var(--accent); }

.name-error { color: var(--danger); font-size: 0.9rem; margin-top: 10px; }

.name-quiet { color: var(--text-dim); font-size: 0.92rem; }
.name-quiet a { color: var(--accent); }

/* Вход и регистрация (login.html) */
.auth-card {
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 440px;
}

.auth-tabs { display: flex; gap: 10px; margin-bottom: 24px; }

.auth-tab {
  flex: 1;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 12px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
}

.auth-tab.active { background: var(--surface-2); color: var(--accent); font-weight: 600; }

.auth-form { display: grid; gap: 14px; }

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100%;
  font: inherit;
  padding: 13px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
}

.auth-form input:focus { outline: 1px solid var(--accent); }

.auth-gender { border: none; display: grid; gap: 8px; font-size: 0.95rem; }
.auth-gender legend { color: var(--text-dim); margin-bottom: 6px; }
.auth-gender label { display: flex; align-items: center; gap: 10px; cursor: pointer; }

.auth-error { color: var(--danger); font-size: 0.9rem; margin-top: 14px; }

/* Выход (шапка главной) — тихая ссылка */
.logout-link {
  float: right;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-decoration: none;
  margin-top: 6px;
}

.logout-link:hover { color: var(--accent); }

/* ---------- Телефон (≤480px): одна колонка, крупные касабельные элементы ---------- */
@media (max-width: 480px) {
  .wrap { padding: 24px 16px 72px; }

  header h1 { font-size: 1.45rem; line-height: 1.35; }
  header p.tagline { font-size: 0.92rem; }

  /* Навигация: компактные пилюли в ряд, скроллятся внутри себя —
     страница горизонтально не едет */
  nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 10px;
    margin: 22px 0 30px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 12px 18px;
    font-size: 0.95rem;
  }

  section + section { margin-top: 36px; }

  /* Кнопки: во всю ширину, палец не промахивается */
  .btn {
    display: block;
    width: 100%;
    min-height: 48px;
    text-align: center;
  }
  .btn-danger { padding: 12px 14px; }
  .actions { flex-direction: column; gap: 10px; margin-top: 22px; }

  /* Шаги пустой библиотеки — в столбик */
  .step { flex-direction: column; align-items: stretch; gap: 14px; padding: 20px; }
  .step .num { width: 40px; height: 40px; font-size: 1.05rem; }
  .step .btn { margin-left: 0; }

  /* Карточки медитаций: заголовок сверху, кнопки стопкой — не сжимаются в кашу */
  .med-card { flex-direction: column; align-items: stretch; gap: 12px; padding: 18px; }

  /* Темы — одна колонка */
  .topics-grid { grid-template-columns: 1fr; gap: 14px; }
  .topic-card { padding: 20px; }

  .script-view { padding: 22px 18px; }
  .script-view .text { font-size: 1rem; }

  /* Имя: поле и кнопка в столбик, пилюли рода — во всю ширину;
     «Сохранить» — в конец, после пилюль (в разметке кнопка раньше fieldset) */
  .name-step { padding: 20px 18px; }
  .name-form { flex-direction: column; gap: 10px; }
  .name-form .btn { order: 1; }
  .name-form input { min-width: 0; width: 100%; min-height: 48px; }
  .name-gender label {
    display: flex;
    width: 100%;
    min-height: 48px;
    margin: 0 0 8px;
  }

  /* Вход и регистрация */
  .auth-card { padding: 24px 18px; }
  .auth-tab { min-height: 48px; }
  .auth-form input[type="text"],
  .auth-form input[type="email"],
  .auth-form input[type="password"] { min-height: 48px; }
  .auth-gender label { min-height: 48px; }
}
