/* Таро — справочник. Один гротеск (Manrope), два тона: холодная бумага и ночь.
   Нет карточек-плиток с тенями: иерархия задаётся размером и весом шрифта. */
:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --ink: #1A1D24;
  --muted: #6B7280;
  --line: #DADDE3;
  --accent: #1F5F63;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCE9E8;
  --danger: #8F2D2D;
  --radius: 10px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121419; --surface: #1B1E26; --ink: #E8E9EC; --muted: #9AA0AA; --line: #2B2F3A;
    --accent: #7CC4C3; --accent-ink: #0F1A1A; --accent-soft: #1F3435; --danger: #E08A8A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121419; --surface: #1B1E26; --ink: #E8E9EC; --muted: #9AA0AA; --line: #2B2F3A;
  --accent: #7CC4C3; --accent-ink: #0F1A1A; --accent-soft: #1F3435; --danger: #E08A8A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Шапка */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  display: flex; align-items: baseline; gap: 18px; padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line); overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.top::-webkit-scrollbar { display: none; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -0.01em; }
.tabs { display: flex; gap: 16px; font-weight: 600; color: var(--muted); }
.tabs a { padding: 4px 0 6px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom: 2px solid var(--accent); }

.view { max-width: 760px; margin: 0 auto; padding: 16px; }

/* Поиск */
.search { position: relative; margin: 4px 0 20px; }
.search input {
  width: 100%; padding: 14px 16px; font: inherit; font-size: 17px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
.search input::placeholder { color: var(--muted); }
.search-hint { color: var(--muted); font-size: 13px; margin: 6px 2px 0; }

/* Ветка колоды */
.branch { margin: 0 0 28px; }
.branch h2 { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.branch p.lead { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.deck { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 480px) { .deck { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 640px) { .deck { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 780px) { .deck { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 100px; min-width: 0;
  padding: 10px 10px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); position: relative; -webkit-tap-highlight-color: transparent;
}
.tile:active { background: var(--accent-soft); }
.tile .glyph { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; padding-right: 36px; }
.tile .name { font-size: 12.5px; font-weight: 600; line-height: 1.2; margin-top: 10px; overflow-wrap: anywhere; hyphens: auto; }
.tile.empty .glyph { color: var(--muted); font-weight: 600; }
.tile.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile .pick {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); font-size: 18px; line-height: 1; cursor: pointer;
}
.tile.selected .pick { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tile .dot { position: absolute; right: 12px; bottom: 12px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* Страница карты */
.card-head { margin: 4px 0 18px; }
.card-head .num { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.card-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 6px; line-height: 1.1; }
.card-head .meta { color: var(--muted); font-size: 14px; }
.card-head .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.card-head .actions .btn-block { grid-column: 1 / -1; }
.section { margin: 22px 0; }
.section h2 { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.section { max-width: 64ch; }
.section p { margin: 0 0 10px; }
.section ul { padding-left: 20px; margin: 0 0 10px; }
.section li { margin: 0 0 10px; }
.section .md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.section .empty { color: var(--muted); }
.classic { display: grid; grid-template-columns: 1fr; gap: 6px 16px; }
.classic div span { color: var(--muted); }
@media (min-width: 520px) { .classic { grid-template-columns: 1fr 1fr; } }
.murli { border-left: 3px solid var(--accent); padding-left: 14px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 0;
  padding: 10px 16px; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; text-align: center;
}
.btn-nav { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.btn-block { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 .btn { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 14px; }

/* Нижняя полоса выбора */
.tray { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.tray-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.tray-inner span { flex: 1; font-weight: 600; }

/* Расклад */
.spread-form label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
.spread-form input, .spread-form textarea {
  width: 100%; padding: 10px 12px; font: inherit; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
.spread-form textarea { min-height: 64px; resize: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row .btn { flex: 1 1 140px; }
.pos-list { list-style: none; padding: 0; margin: 12px 0; }
.pos-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pos-list .idx { width: 24px; color: var(--muted); font-weight: 700; }
.pos-list .ttl { flex: 1; font-weight: 600; }
.pos-list .pos-input { width: 34%; min-width: 96px; padding: 6px 8px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.pos-list .rm { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 22px; width: 40px; height: 40px; }
.spread-cards { margin-top: 24px; }
.spread-card { padding: 16px 0; border-top: 1px solid var(--line); }
.spread-card h3 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.spread-card .pos { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.spread-card details { margin-top: 8px; }
.spread-card summary { cursor: pointer; font-weight: 600; }
.notice { padding: 12px 14px; border-radius: var(--radius); background: var(--accent-soft); margin: 12px 0; font-size: 14px; }
.notice.err { background: transparent; border: 1px solid var(--danger); color: var(--danger); }

/* Фото */
.photo-box { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; text-align: center; margin: 12px 0; }
.photo-box .btn { white-space: normal; line-height: 1.2; }
.photo-box input { display: none; }
.photo-preview { max-width: 100%; max-height: 260px; border-radius: 8px; margin: 10px auto 0; display: block; }
.recog-list { list-style: none; padding: 0; margin: 12px 0; }
.recog-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.recog-list .conf { color: var(--muted); font-size: 13px; }

/* Сохранённые */
.saved-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.saved-item .q { font-weight: 700; }
.saved-item .d { color: var(--muted); font-size: 14px; }
.saved-item .c { margin-top: 6px; font-size: 14px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
h1.page { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 14px; }

/* Разбор по вопросу */
.reading h2 { font-size: 20px; margin: 18px 0 8px; }
.reading .md p strong { font-weight: 700; }
.md h2, .md p > strong:only-child { font-size: 17px; }
