/* ============================================================
   ПОТРАЧЕНО — Design System
   Material 3 · Dark Theme · Gold Accent
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  /* Colors */
  --clr-bg:          #0D0D0D;
  --clr-surface:     #1A1A1A;
  --clr-surface-2:   #222222;
  --clr-surface-var: #252525;
  --clr-primary:     #D4AF37;
  --clr-primary-dim: #B8942A;
  --clr-on-primary:  #000000;
  --clr-on-bg:       #F0EDE8;
  --clr-on-surface:  #F0EDE8;
  --clr-muted:       #A09C96;
  --clr-outline:     #3A3530;
  --clr-outline-dim: #242018;
  --clr-error:       #CF6679;
  --clr-overlay:     rgba(0,0,0,0.65);

  /* Shape */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 999px;

  /* Spacing */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  32px;
  --sp-2xl: 48px;

  /* Elevation */
  --shadow-1: 0 1px 4px rgba(0,0,0,.5);
  --shadow-2: 0 2px 10px rgba(0,0,0,.55);
  --shadow-3: 0 6px 24px rgba(0,0,0,.6);

  /* Gold glow */
  --glow-primary: 0 0 20px rgba(212,175,55,.12);

  /* Fonts */
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--clr-bg);
  color: var(--clr-on-surface);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Typography scale ────────────────────────────────────── */
.t-display {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 10vw, 4.5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.03em;
}
.t-h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  font-weight: 600;
  line-height: 1.15;
}
.t-h2 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.25;
}
.t-h3 {
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.35;
}
.t-body { font-size: .9375rem; font-weight: 400; line-height: 1.6; }
.t-body-sm { font-size: .8125rem; font-weight: 400; line-height: 1.5; }
.t-label { font-size: .8125rem; font-weight: 600; letter-spacing: .04em; }
.t-overline {
  font-size: .6875rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--clr-muted);
}

/* ── Color utilities ─────────────────────────────────────── */
.gold   { color: var(--clr-primary); }
.muted  { color: var(--clr-muted); }
.error  { color: var(--clr-error); }

/* ── App Shell ───────────────────────────────────────────── */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Top App Bar ─────────────────────────────────────────── */
.top-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: var(--sp-md);
  min-height: 64px;
  background: var(--clr-bg);
  border-bottom: 1px solid var(--clr-outline-dim);
}
.top-bar-title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 50%;
  color: var(--clr-muted); cursor: pointer; font-size: 1.25rem;
  transition: background .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(240,237,232,.07); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Bottom Navigation ───────────────────────────────────── */
.bottom-nav {
  position: sticky; bottom: 0; z-index: 20;
  display: flex;
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-outline-dim);
  padding-bottom: max(var(--sp-sm), env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: var(--sp-sm) var(--sp-xs) 4px;
  cursor: pointer; text-decoration: none;
  color: var(--clr-muted); font-size: .6875rem; font-weight: 500;
  transition: color .2s;
}
.nav-item.active { color: var(--clr-primary); }
.nav-pill {
  width: 64px; height: 32px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.nav-item.active .nav-pill { background: rgba(212,175,55,.15); }
.nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Scroll Content ──────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-md);
  width: 100%;
  display: flex; flex-direction: column; gap: var(--sp-md);
}
.content::-webkit-scrollbar { width: 3px; }
.content::-webkit-scrollbar-thumb { background: var(--clr-outline); border-radius: 2px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--clr-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--clr-outline-dim);
  padding: var(--sp-lg);
}
.card-outlined {
  background: transparent;
  border: 1px solid var(--clr-outline);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
}
.card-hero {
  background: var(--clr-surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--clr-primary);
  padding: var(--sp-lg) var(--sp-xl);
  box-shadow: var(--glow-primary), var(--shadow-2);
}

/* ── Person Card ─────────────────────────────────────────── */
.person-card {
  background: var(--clr-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--clr-outline-dim);
  padding: var(--sp-md);
  display: flex; flex-direction: column; gap: var(--sp-sm);
  cursor: pointer; transition: border-color .2s, box-shadow .2s;
  text-decoration: none; color: inherit;
}
.person-card:hover {
  border-color: var(--clr-primary);
  box-shadow: 0 0 14px rgba(212,175,55,.13);
}

.person-header {
  display: flex; gap: var(--sp-md); align-items: center;
}

.avatar {
  width: 52px; height: 52px; flex-shrink: 0;
  border-radius: var(--r-md);
  background: var(--clr-surface-var);
  border: 1px solid var(--clr-outline);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 700;
  color: var(--clr-primary);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.has-image {
  background: var(--clr-surface);
  color: transparent;
}
.avatar-lg {
  width: 64px; height: 64px;
  font-size: 1.35rem;
  border-radius: var(--r-lg);
}

.person-info { flex: 1; min-width: 0; }
.person-name {
  font-weight: 600; font-size: .9375rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.person-years { color: var(--clr-primary); font-size: .8125rem; font-weight: 500; }
.person-meta { color: var(--clr-muted); font-size: .75rem; margin-top: 2px; }
.person-quote {
  font-style: italic; font-size: .8125rem; line-height: 1.55;
  color: var(--clr-muted);
  border-left: 2px solid var(--clr-primary);
  padding-left: var(--sp-sm);
}

/* ── Progress Bar ────────────────────────────────────────── */
.progress-track {
  height: 5px; background: var(--clr-surface-var);
  border-radius: 3px; overflow: hidden;
  margin: var(--sp-sm) 0;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--clr-primary-dim) 0%, var(--clr-primary) 60%, #F0D060 100%);
  transition: width 1.2s cubic-bezier(.16,1,.3,1);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-sm);
  height: 48px; padding: 0 var(--sp-lg);
  border-radius: var(--r-full); border: none;
  font-family: var(--font-body); font-size: .9375rem; font-weight: 600;
  letter-spacing: .01em; cursor: pointer; white-space: nowrap;
  transition: opacity .2s, box-shadow .2s, background .2s;
  text-decoration: none;
}
.btn-filled {
  background: var(--clr-primary); color: var(--clr-on-primary);
}
.btn-filled:hover { opacity: .9; box-shadow: 0 2px 12px rgba(212,175,55,.35); }

.btn-outlined {
  background: transparent; color: var(--clr-primary);
  border: 1.5px solid var(--clr-primary);
}
.btn-outlined:hover { background: rgba(212,175,55,.08); }

.btn-text {
  background: transparent; color: var(--clr-primary);
  height: 40px; padding: 0 var(--sp-md);
}
.btn-text:hover { background: rgba(212,175,55,.08); }

.btn-full { width: 100%; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── FAB ─────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--sp-xl) + 64px);
  right: var(--sp-md);
  width: 56px; height: 56px;
  border-radius: var(--r-lg);
  background: var(--clr-primary);
  color: var(--clr-on-primary);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-3);
  font-size: 1.5rem; transition: box-shadow .2s;
  z-index: 10;
}
.fab:hover { box-shadow: 0 6px 24px rgba(212,175,55,.4); }

/* ── Chips ───────────────────────────────────────────────── */
.chips-row {
  display: flex; gap: var(--sp-sm);
  overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none;
}
.chips-row::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 var(--sp-md);
  border-radius: 16px; border: 1px solid var(--clr-outline);
  background: transparent; color: var(--clr-muted);
  font-size: .8125rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: all .2s;
  font-family: var(--font-body);
}
.chip.active {
  background: rgba(212,175,55,.14);
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}
.chip:hover:not(.active) { background: rgba(240,237,232,.05); }

/* ── Section label ───────────────────────────────────────── */
.section-label {
  font-size: .6875rem; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--clr-muted); margin-bottom: var(--sp-sm);
}

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  height: 1px; background: var(--clr-outline-dim);
  margin: var(--sp-sm) 0;
}

/* ── Wiki link ───────────────────────────────────────────── */
.wiki-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--clr-primary); font-size: .8rem; font-weight: 500;
  transition: opacity .15s;
}
.wiki-link:hover { opacity: .7; }

/* ── Bottom Sheet ────────────────────────────────────────── */
.sheet-overlay {
  position: fixed; inset: 0;
  background: var(--clr-overlay);
  z-index: 100; display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.sheet-overlay.open { opacity: 1; pointer-events: all; }
.sheet-overlay.open .sheet { transform: translateY(0); }

.sheet {
  width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--clr-surface);
  border-radius: 28px 28px 0 0;
  padding: var(--sp-lg);
  padding-bottom: max(var(--sp-2xl), env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.16,1,.3,1);
  display: flex; flex-direction: column; gap: var(--sp-md);
}
.sheet-handle {
  width: 36px; height: 4px; background: var(--clr-outline);
  border-radius: 2px; margin: 0 auto var(--sp-sm);
}

/* ── Date Input ──────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .75rem; font-weight: 600; color: var(--clr-primary); letter-spacing: .04em; }
.field input {
  height: 56px; background: var(--clr-surface);
  border: 1px solid var(--clr-outline); border-radius: var(--r-md);
  color: var(--clr-on-surface); font-family: var(--font-body); font-size: 1rem;
  padding: 0 var(--sp-md); outline: none; transition: border-color .2s, box-shadow .2s;
  color-scheme: dark; width: 100%;
}
.field input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(212,175,55,.18);
}

/* ── Ornament ────────────────────────────────────────────── */
.ornament {
  color: var(--clr-primary); opacity: .6; letter-spacing: .2em;
  font-size: .875rem; text-align: center;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulseGold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,175,55,.35); }
  50%       { box-shadow: 0 0 0 8px rgba(212,175,55,0); }
}

.anim-up      { animation: fadeUp .5s cubic-bezier(.16,1,.3,1) both; }
.anim-up-1    { animation: fadeUp .5s .1s cubic-bezier(.16,1,.3,1) both; }
.anim-up-2    { animation: fadeUp .5s .2s cubic-bezier(.16,1,.3,1) both; }
.anim-up-3    { animation: fadeUp .5s .3s cubic-bezier(.16,1,.3,1) both; }
.anim-fade    { animation: fadeIn .4s ease both; }

/* Nav rail hidden by default (mobile); media query below overrides for tablet+ */
.nav-rail { display: none; }
.rail-brand { display: none; }
.rail-brand img { display: block; width: 100%; height: auto; }

/* ── Responsive (Tablet 768+) ────────────────────────────── */
@media (min-width: 768px) {
  body { background: #080808; }

  .app-wrapper {
    display: flex; min-height: 100vh; width: 100%;
  }

  .nav-rail {
    width: 88px; flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center;
    padding: var(--sp-md) var(--sp-xs) var(--sp-lg);
    background: var(--clr-surface);
    border-right: 1px solid var(--clr-outline-dim);
    position: sticky; top: 0; height: 100vh; gap: var(--sp-sm);
  }
  .rail-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    width: 72px; padding: var(--sp-sm); border-radius: var(--r-lg);
    cursor: pointer; color: var(--clr-muted); font-size: .625rem; font-weight: 600;
    text-decoration: none; transition: background .15s, color .15s;
    letter-spacing: .04em; text-transform: uppercase;
  }
  .rail-item.active { color: var(--clr-primary); background: rgba(212,175,55,.1); }
  .rail-pill {
    width: 56px; height: 32px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
  }
  .rail-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  .app { max-width: none; flex: 1; min-width: 0; }
  .bottom-nav { display: none; }
  .fab { right: var(--sp-xl); }

  /* Ограничиваем ширину контентной области для читаемости */
  .content {
    padding: var(--sp-lg);
  }

  .content > * {
    max-width: 1040px;
    width: 100%;
  }

  .feed-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-md);
  }
}

@media (min-width: 1200px) {
  /* Nav Drawer — раскрываем rail в полноценное меню */
  .nav-rail {
    width: 240px; align-items: flex-start;
    padding: var(--sp-md) var(--sp-md) var(--sp-lg);
  }
  .rail-brand {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 64px;
    padding: 0 var(--sp-sm);
    margin-bottom: var(--sp-sm);
    opacity: .9;
  }
  .rail-brand:hover { opacity: 1; }
  .rail-brand img {
    width: 148px;
    transform: rotate(-3deg);
  }
  .rail-item {
    flex-direction: row; width: 100%; gap: var(--sp-md);
    font-size: .875rem; text-transform: none; letter-spacing: 0;
    padding: var(--sp-sm) var(--sp-md);
  }
  .rail-pill { width: 40px; height: 40px; border-radius: var(--r-md); flex-shrink: 0; }
  .rail-item.active .rail-pill { background: rgba(212,175,55,.15); }
  .rail-item svg { width: 20px; height: 20px; }

  /* Контент чуть шире на десктопе */
  .content {
    padding: var(--sp-xl);
  }

  .content > * { max-width: 1320px; }

  .feed-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-lg); align-items: start;
  }
  .dashboard-cols .card-hero { grid-column: 1 / -1; }
}

/* ── Utilities ───────────────────────────────────────────── */
.flex-row    { display: flex; flex-direction: row; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: var(--sp-sm); }
.gap-md { gap: var(--sp-md); }
.mt-sm  { margin-top: var(--sp-sm); }
.mt-md  { margin-top: var(--sp-md); }
.mt-lg  { margin-top: var(--sp-lg); }
.text-center { text-align: center; }
