/* Семейная летопись — светлый современный стиль: холодный фон, белые карточки,
   градиент индиго → фиолетовый, коралл для записи голоса. */
:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --ink: #16172b;
  --muted: #6b6f86;
  --line: #e3e5f0;
  --primary: #6d5efc;
  --primary-ink: #ffffff;
  --grad: linear-gradient(135deg, #6d5efc 0%, #9b5cf6 100%);
  --coral: #ff6b57;
  --shadow: 0 10px 30px rgba(38, 32, 110, 0.08), 0 2px 6px rgba(38, 32, 110, 0.05);
  --shadow-strong: 0 14px 34px rgba(109, 94, 252, 0.35);
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Inter", sans-serif;
  --tone-0: #ece9ff; --tone-1: #ffe9e4; --tone-2: #e2f6ee; --tone-3: #fff3d6; --tone-4: #e3f1ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1020; --surface: #1a1b31; --surface-2: #23254a; --ink: #eef0ff; --muted: #a2a6c4;
    --line: #2c2e52; --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --tone-0: #2d2a5c; --tone-1: #4a2c2a; --tone-2: #1f3d33; --tone-3: #45391d; --tone-4: #1e3450;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Атрибут hidden должен побеждать display у классов (.tabs, .big и т.п.). */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 var(--font);
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
button { cursor: pointer; font-family: var(--font); }
button:disabled { opacity: .55; cursor: default; }

/* --- шапка и вкладки --- */
.top { display: flex; align-items: center; gap: 12px; padding: 18px 16px 8px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px; background: var(--grad);
  display: grid; place-items: center; font-size: 22px; box-shadow: var(--shadow-strong);
}
h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.brand-sub { margin: 0; color: var(--muted); font-size: 13px; }
.narrator {
  font: 15px var(--font); padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 12px; scrollbar-width: none;
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  font-size: 15px; font-weight: 600; border: none; background: var(--surface); color: var(--muted);
  padding: 9px 16px; border-radius: 999px; white-space: nowrap; box-shadow: var(--shadow);
  transition: background .2s, color .2s, transform .1s;
}
.tabs button:active { transform: scale(.96); }
.tabs button.active { background: var(--grad); color: var(--primary-ink); box-shadow: var(--shadow-strong); }

main { padding: 8px 16px 16px; max-width: 720px; margin: 0 auto; }

/* --- общие блоки --- */
.card {
  background: var(--surface); border-radius: var(--r-lg); padding: 18px;
  margin-bottom: 14px; box-shadow: var(--shadow);
}
.status {
  background: var(--surface); border-radius: var(--r-md); padding: 12px 16px;
  box-shadow: var(--shadow); border-left: 4px solid var(--primary); font-size: 15px;
}
.screen-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0 6px; }
.hint-muted { color: var(--muted); margin: 0 0 18px; }
.empty { color: var(--muted); text-align: center; padding: 36px 12px; font-size: 15px; }
.topic {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--primary); background: var(--tone-0);
  padding: 4px 10px; border-radius: 999px;
}
.topic:empty { display: none; }

/* --- кнопки --- */
.big {
  display: block; width: 100%; font-size: 17px; font-weight: 700; padding: 16px;
  border-radius: var(--r-md); border: none; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); margin-bottom: 12px; text-align: center;
  transition: transform .1s, box-shadow .2s;
}
.big:active { transform: scale(.98); }
.primary { background: var(--grad); color: var(--primary-ink); box-shadow: var(--shadow-strong); }
.ghost {
  font-size: 15px; font-weight: 600; background: none; border: none; color: var(--muted);
  padding: 12px 8px;
}
.row { display: flex; gap: 10px; align-items: center; }
.row .big { flex: 1; margin-bottom: 0; }

/* --- плитки ролей и родных --- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 22px; }
.tile-btn {
  display: flex; align-items: center; gap: 12px; padding: 14px; border: none;
  border-radius: var(--r-md); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); font-size: 17px; font-weight: 700; text-align: left;
  transition: transform .1s, box-shadow .2s;
}
.tile-btn:active { transform: scale(.97); box-shadow: var(--shadow-strong); }
.tile-icon {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  font-size: 24px; flex: none;
}
.tone-0 { background: var(--tone-0); } .tone-1 { background: var(--tone-1); }
.tone-2 { background: var(--tone-2); } .tone-3 { background: var(--tone-3); }
.tone-4 { background: var(--tone-4); }

.role-line {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border-radius: var(--r-md); padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.role-line b { color: var(--primary); }
.relatives { display: grid; gap: 12px; margin-bottom: 18px; }
.relative { display: flex; gap: 14px; align-items: center; margin-bottom: 0; }
.relative img, .relative .avatar {
  width: 60px; height: 60px; border-radius: 18px; object-fit: cover; flex: none;
  background: var(--surface-2); display: grid; place-items: center; font-size: 28px;
}
.relative .kin { color: var(--muted); font-size: 13px; font-weight: 600; }
.relative .name { font-weight: 700; }

/* --- анкета --- */
.field { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
textarea, input[type=text], input[type=date] {
  width: 100%; font: 17px var(--font); padding: 14px 16px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink);
  margin: 6px 0 14px; outline: none; transition: border-color .2s, background .2s;
  -webkit-appearance: none; appearance: none;
}
textarea:focus, input:focus { border-color: var(--primary); background: var(--surface); }
.file-label {
  cursor: pointer; background: var(--surface-2); box-shadow: none; color: var(--primary);
  border: 1.5px dashed color-mix(in srgb, var(--primary) 45%, transparent);
}
.preview {
  width: 120px; height: 120px; object-fit: cover; border-radius: 28px; display: block;
  margin: 0 auto 14px; box-shadow: var(--shadow);
}

/* --- беседа --- */
.question { background: var(--grad); color: var(--primary-ink); box-shadow: var(--shadow-strong); }
.question .topic { background: rgba(255, 255, 255, .2); color: #fff; }
.q-text { font-size: 22px; font-weight: 700; line-height: 1.35; margin: 12px 0 2px; }
.heard {
  color: var(--muted); font-style: italic; background: var(--surface); padding: 12px 16px;
  border-radius: var(--r-md);
}
.mic-wrap { display: flex; flex-direction: column; align-items: center; margin: 22px 0 10px; }
.mic {
  width: 96px; height: 96px; border-radius: 50%; border: none; font-size: 40px;
  background: var(--grad); color: #fff; box-shadow: var(--shadow-strong);
  display: grid; place-items: center; transition: transform .15s;
}
.mic:active { transform: scale(.94); }
.mic.recording { background: var(--coral); animation: pulse 1.4s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 107, 87, .55); }
  100% { box-shadow: 0 0 0 26px rgba(255, 107, 87, 0); }
}
.mic-label { margin: 12px 0 0; font-weight: 600; color: var(--muted); }
.hint { color: var(--coral); text-align: center; margin: 4px 0 12px; font-weight: 600; font-size: 15px; }

/* --- рассказы и лента --- */
.story h3, .event h3 { margin: 10px 0 6px; font-size: 18px; }
.story .answer { margin: 8px 0 0; white-space: pre-wrap; }
.event { position: relative; padding-left: 26px; }
.event::before {
  content: ""; position: absolute; left: 12px; top: 18px; bottom: 18px; width: 4px;
  border-radius: 4px; background: var(--grad);
}
.year {
  font-size: 22px; font-weight: 800; background: var(--grad); -webkit-background-clip: text;
  background-clip: text; color: transparent;
}
.place { color: var(--muted); font-size: 14px; }

/* --- древо --- */
.generation { margin-bottom: 20px; }
.generation h3 {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--muted);
  text-transform: uppercase; margin: 0 0 10px;
}
.people { display: flex; flex-wrap: wrap; gap: 10px; }
.person {
  background: var(--surface); border-radius: var(--r-md); padding: 12px 16px; min-width: 140px;
  box-shadow: var(--shadow);
}
.person.me { background: var(--grad); color: #fff; box-shadow: var(--shadow-strong); }
.person .name { font-weight: 700; }
.person .rel { color: var(--muted); font-size: 13px; }
.person.me .rel { color: rgba(255, 255, 255, .8); }
.person .years { font-size: 13px; }

/* --- книга: читается лучше с засечками --- */
#book-body {
  background: var(--surface); border-radius: var(--r-lg); padding: 6px 22px 18px;
  box-shadow: var(--shadow); font-family: Georgia, "PT Serif", serif; font-size: 18px;
}
#book-body:empty { display: none; }
#book-body h2 { font-size: 26px; text-align: center; margin: 22px 0; }
#book-body h3 { font-size: 21px; margin-top: 28px; color: var(--primary); }
#book-body p { text-indent: 1.5em; margin: 0 0 .8em; }

/* --- архив --- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface); border-radius: var(--r-md); overflow: hidden; font-size: 14px;
  box-shadow: var(--shadow);
}
.tile img { width: 100%; height: 150px; object-fit: cover; display: block; }
.tile .cap { display: block; padding: 8px 10px; color: var(--ink); text-decoration: none; }

@media print {
  .top, .tabs, .no-print, #status { display: none !important; }
  body { background: #fff; color: #000; font-size: 13pt; }
  main { max-width: none; padding: 0; }
  .panel:not(#book) { display: none !important; }
  #book-body { box-shadow: none; padding: 0; }
  #book-body h3 { page-break-before: always; color: #000; }
}
