/* Ночная тема в цветах аватарки Соньки: глубокий синий, лунный жёлтый, кремовая книжка. */
:root {
  --bg: #15173f;
  --bg-2: #1b1d4f;
  --card: #23266a;
  --card-2: #2b2f7a;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f1ff;
  --muted: #b9b8dc;
  --moon: #f7d98b;
  --moon-2: #ffe9b0;
  --ink: #1b1d4f;
  --page: #f6ecd2;
  --page-ink: #2a2440;
  --danger: #ff8f8f;
  --ok: #9be3b4;
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 60% at 50% 0%, #2a2d7d 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
a { color: var(--moon); }
img { display: block; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(21, 23, 63, 0.88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 19px; }
.brand img { border-radius: 50%; }
.inbox-link { position: relative; font-size: 22px; text-decoration: none; padding: 4px; }
.badge {
  position: absolute; top: -2px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--moon); color: var(--ink); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

main { max-width: 640px; margin: 0 auto; padding: 16px; outline: none; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(21, 23, 63, 0.95);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px;
}
.tabs a span { font-size: 22px; line-height: 1; }
.tabs a.on { color: var(--moon); }

h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 14px; }
h2 { font-size: 20px; margin: 22px 0 10px; }
h3 { font-size: 17px; margin: 16px 0 8px; color: var(--muted); font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: 10px; }
.spacer { height: 8px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 0 0 12px;
}
.card.hero { background: linear-gradient(135deg, #2c3088, #23266a); }
.card.warn { background: #3a2f62; border-color: rgba(247, 217, 139, 0.35); }
.card.note { white-space: pre-line; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--moon); border-color: var(--moon); color: var(--ink); }
.btn.primary:active { background: var(--moon-2); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(255, 143, 143, 0.4); }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 58px; font-size: 19px; }
.btn[disabled] { opacity: 0.5; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 42px; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip.on { background: var(--moon); color: var(--ink); border-color: var(--moon); font-weight: 600; }

label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 15px; }
input[type=email], input[type=text], input[type=number], textarea, select {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: #11133a; color: var(--text);
  font: inherit; font-size: 17px; /* 16px+ — iPhone не увеличивает страницу при вводе */
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--moon); outline-offset: 2px;
}
input.code { letter-spacing: 0.4em; text-align: center; font-size: 26px; font-weight: 700; }
.check { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 16px; font-size: 15px; color: var(--muted); }
.check input { width: 24px; height: 24px; flex: none; margin: 1px 0 0; accent-color: var(--moon); }
.error { color: var(--danger); margin: 0 0 12px; }
.ok { color: var(--ok); }

.login-logo { width: 120px; height: 120px; border-radius: 50%; margin: 18px auto 10px; box-shadow: 0 0 60px rgba(247, 217, 139, 0.25); }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.list a {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 4px; color: var(--text); text-decoration: none;
}
.list .meta { color: var(--muted); font-size: 14px; white-space: nowrap; }

details.group { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin: 0 0 10px; }
details.group summary { padding: 14px 16px; font-weight: 600; cursor: pointer; list-style: none; }
details.group summary::-webkit-details-marker { display: none; }
details.group summary::after { content: "›"; float: right; color: var(--muted); transition: transform .2s; }
details.group[open] summary::after { transform: rotate(90deg); }
details.group .chips { padding: 0 12px 14px; }

/* Сказка — как страница книжки: светлая, крупный шрифт с засечками */
.page {
  background: var(--page); color: var(--page-ink); border-radius: 18px; padding: 22px 20px 10px;
  font: 19px/1.65 Georgia, "Times New Roman", serif; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.page h1 { font: 700 24px/1.25 Georgia, "Times New Roman", serif; color: #3b2f6b; margin: 0 0 16px; }
.page p { margin: 0 0 14px; }

.player { margin: 14px 0; }
.player audio { width: 100%; margin-top: 10px; }

.loading { text-align: center; padding: 40px 10px; }
.moon {
  width: 96px; height: 96px; margin: 0 auto 20px; border-radius: 50%;
  box-shadow: -22px 10px 0 0 var(--moon); transform: rotate(-20deg);
  animation: sway 3s ease-in-out infinite;
}
@keyframes sway { 50% { transform: rotate(-5deg) translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .moon { animation: none; } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom));
  max-width: 600px; margin: 0 auto; z-index: 10;
  background: var(--moon); color: var(--ink); padding: 12px 16px; border-radius: 14px; font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.msg { white-space: pre-line; }
.msg .meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
