﻿:root {
  --bg-main: #0b1020;
  --bg-glass: rgba(17, 24, 39, 0.72);
  --gold: #aab4ff;
  --text: #e6e9f2;
  --border: rgba(255, 255, 255, 0.08);
  --bg: #0b1020;
  --card: #12182b;
  --accent: #7c8cff;
  --bg-soft: #0b1225;
  --surface: rgba(15, 23, 42, 0.62);
  --surface-strong: rgba(15, 23, 42, 0.86);
  --glass: rgba(148, 163, 184, 0.12);
  --primary: #7c8cff;
  --success: #22c55e;
  --warn: #7c8cff;
  --text: #e6e9f2;
  --muted: #94a3b8;
  --danger: #f43f5e;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow-lg: 0 20px 80px rgba(10, 14, 30, 0.45);
  --shadow-md: 0 14px 40px rgba(10, 14, 30, 0.35);
  --bg-shift-x: 0px;
  --bg-shift-y: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  color: var(--text);
  background: var(--bg);
  font-family: "Manrope", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

::selection {
  background: rgba(99, 102, 241, 0.42);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
}

.site-bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 20% 8%, rgba(99, 102, 241, 0.2), transparent 30%),
    radial-gradient(circle at 82% 82%, rgba(245, 201, 106, 0.12), transparent 28%),
    linear-gradient(160deg, var(--bg-main) 0%, #091224 48%, #04070d 100%);
}

.site-bg::before {
  content: none;
}

.site-bg-video {
  position: absolute;
  inset: -6%;
  width: 112%;
  height: 112%;
  object-fit: cover;
  opacity: 0.26;
  mix-blend-mode: screen;
  filter: saturate(1.18) contrast(1.04) blur(0.6px);
  z-index: 1;
  pointer-events: none;
  display: none;
}

.site-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(226, 232, 240, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(226, 232, 240, 0.02) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(5, 9, 20, 0.02), rgba(3, 7, 18, 0.82));
  background-size: 120px 120px, 120px 120px, 100% 100%;
  z-index: 2;
}

.app-cabinet .site-bg-video {
  opacity: 0.3;
  filter: saturate(1.2) contrast(1.06) blur(1.1px);
}

.particles {
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0;
  pointer-events: none;
  display: none;
}

.floating-blob {
  display: none;
}

.floating-blob.blob-1 {
  width: 340px;
  height: 340px;
  left: -120px;
  top: 90px;
  background: rgba(99, 102, 241, 0.42);
}

.floating-blob.blob-2 {
  width: 280px;
  height: 280px;
  right: -90px;
  top: 34%;
  animation-delay: 1.6s;
  background: rgba(34, 197, 94, 0.32);
}

.floating-blob.blob-3 {
  width: 230px;
  height: 230px;
  left: 48%;
  bottom: -90px;
  animation-delay: 3s;
  background: rgba(245, 158, 11, 0.26);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px) saturate(1.08);
  background: linear-gradient(180deg, rgba(8, 13, 30, 0.88), rgba(8, 13, 30, 0.68));
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.24);
}

.topbar-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 22px rgba(99, 102, 241, 0.55);
}

.brand span {
  color: var(--muted);
  font-size: 14px;
  margin-left: 4px;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-links a {
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: color 0.2s ease, background 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: rgba(99, 102, 241, 0.16);
}

.nav-actions {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  color: #f8fafc;
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
  position: relative;
}

button,
.btn,
a,
input,
select,
textarea,
.tree-person-trigger,
.auth-tab,
.analysis-tab-switch,
.action-choice-card,
.workspace-chip {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(99, 102, 241, 0.45);
}

.btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

.btn.secondary {
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.38);
  box-shadow: none;
}

.btn.warn {
  background: linear-gradient(135deg, #7c8cff 0%, #9f7cff 100%);
  color: #fff;
  box-shadow: 0 10px 30px rgba(124, 140, 255, 0.28);
}

.btn.success {
  background: linear-gradient(135deg, #22c55e 0%, #4ade80 100%);
  color: #052e16;
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.34);
}

.btn.danger {
  background: linear-gradient(135deg, #f43f5e 0%, #fb7185 100%);
}

.btn.glow::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(99, 102, 241, 0.6), rgba(34, 197, 94, 0.52));
  filter: blur(15px);
  z-index: -1;
}

.btn.glow {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.btn.gold {
  background: linear-gradient(135deg, #7c8cff, #9f7cff);
  color: #fff;
}

.btn.loading::after {
  content: "";
  width: 0.85em;
  height: 0.85em;
  margin-left: 8px;
  display: inline-block;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 0.75s linear infinite;
  vertical-align: -0.12em;
}

.field-error {
  margin-top: 6px;
  color: #fb7185;
  font-size: 12px;
}

[aria-invalid="true"] {
  border-color: rgba(251, 113, 133, 0.72) !important;
}

.hero {
  position: relative;
  padding: 72px 0 52px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 26px;
}

.kicker {
  font-size: 13px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  color: #a5b4fc;
  margin: 0 0 8px;
}

.hero h1 {
  margin: 0;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: clamp(36px, 7vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.8vw, 20px);
  max-width: 700px;
}

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

.hero-tags {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tag {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.45);
}

.glass {
  backdrop-filter: blur(16px);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.hero-card {
  position: relative;
  padding: 24px;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -90px -90px auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.34), transparent 72%);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.metric {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.62), rgba(2, 6, 23, 0.4));
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.metric b {
  display: block;
  font-size: 20px;
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.section {
  padding: 44px 0;
}

.section h2 {
  font-family: "Space Grotesk", "Manrope", sans-serif;
  margin: 0;
  font-size: clamp(28px, 4.4vw, 42px);
}

.section .lead {
  margin-top: 10px;
  color: var(--muted);
  max-width: 760px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  border-radius: var(--radius-sm);
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.54)),
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 34%);
  box-shadow: var(--shadow-md);
  transition: transform 0.24s ease, border-color 0.24s ease, box-shadow 0.24s ease;
  backdrop-filter: blur(16px) saturate(1.05);
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.38);
  box-shadow: 0 20px 46px rgba(99, 102, 241, 0.14);
}

.card h3,
.card h4 {
  margin: 0;
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

.card p {
  margin: 10px 0 0;
  color: var(--muted);
}

.icon-pill {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.46);
  color: #c7d2fe;
}

.feature-card {
  min-height: 170px;
  position: relative;
  overflow: hidden;
}

.feature-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -40px auto;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.24), transparent 70%);
}

.visual-shell {
  padding: 20px;
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(150deg, rgba(15, 23, 42, 0.82), rgba(30, 41, 59, 0.45));
}

.visual-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 14px;
}

.radial-chart {
  width: min(320px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background: conic-gradient(
    #6366f1 0deg 86deg,
    #22c55e 86deg 165deg,
    #7c8cff 165deg 238deg,
    #0ea5e9 238deg 310deg,
    #a78bfa 310deg 360deg
  );
  position: relative;
  box-shadow: 0 18px 50px rgba(99, 102, 241, 0.3);
}

.radial-chart::before {
  content: "Карта личности";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-weight: 700;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.32);
}

.tree-map {
  min-height: 310px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 14px;
  background: rgba(2, 6, 23, 0.36);
}

.tree-node {
  padding: 10px;
  border-radius: 10px;
  margin: 8px 0;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(99, 102, 241, 0.12);
  font-size: 14px;
}

.tree-node small {
  color: var(--muted);
  display: block;
}

.review {
  display: grid;
  gap: 10px;
}

.review-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.review-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.36), rgba(34, 197, 94, 0.36));
  display: grid;
  place-items: center;
  font-weight: 800;
}

.reviews-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.reviews-catalog {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.reviews-catalog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.review-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.review-form-wrap {
  margin-top: 18px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.34);
}

.review-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.review-form-wrap textarea {
  min-height: 120px;
  margin-top: 12px;
}

.review-empty {
  color: var(--muted);
}

.cta-band {
  margin-top: 16px;
  padding: 36px;
  border-radius: 24px;
  background: linear-gradient(130deg, rgba(99, 102, 241, 0.3), rgba(34, 197, 94, 0.26), rgba(245, 158, 11, 0.22));
  border: 1px solid rgba(148, 163, 184, 0.28);
  text-align: center;
}

.cta-band h3 {
  margin: 0;
  font-size: clamp(24px, 4vw, 36px);
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

.footer {
  margin-top: 50px;
  padding: 28px 0 50px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 16px;
}

.footer small,
.footer p,
.footer li {
  color: var(--muted);
}

.footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.page-hero {
  padding: 56px 0 24px;
}

.page-hero.page-hero-immersive {
  padding-top: 48px;
}

.page-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 22px;
  align-items: stretch;
}

.app-hero-card {
  position: relative;
  overflow: hidden;
  min-height: 100%;
}

.app-hero-card::before {
  content: "";
  position: absolute;
  inset: auto -80px -96px auto;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.18), transparent 70%);
}

.page-hero h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 52px);
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

.page-hero p {
  margin-top: 10px;
  color: var(--muted);
  max-width: 760px;
}

.content-stack {
  display: grid;
  gap: 14px;
}

.list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.list li {
  margin: 7px 0;
}

.auth-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background: rgba(2, 6, 23, 0.42);
  color: #cbd5e1;
  font-size: 13px;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.auth-chip.is-authenticated {
  border-color: rgba(34, 197, 94, 0.34);
  background: rgba(20, 83, 45, 0.2);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.08) inset;
}

.layout {
  display: grid;
  gap: 14px;
  padding-bottom: 40px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.row.compact {
  align-items: center;
}

.card hr {
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  margin: 16px 0;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 700;
}

.field-tip-btn {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 8px;
  border-radius: 50%;
  border: 1px solid rgba(99, 102, 241, 0.28);
  background: rgba(99, 102, 241, 0.14);
  color: #c7d2fe;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  vertical-align: middle;
}

.field-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.52);
  color: var(--text);
  padding: 11px 12px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.66);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.notice {
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.56), rgba(15, 23, 42, 0.42));
  color: #cbd5e1;
  margin-top: 10px;
}

.profile-wrap {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 14px;
}

.profile-quick-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
}

.profile-quick-main {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.profile-quick-avatar {
  width: 74px;
  height: 74px;
  border-radius: 24px;
  object-fit: cover;
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.32);
}

.profile-quick-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.profile-quick-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.profile-quick-kicker {
  color: #a5b4fc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-quick-meta strong {
  font-size: clamp(20px, 3vw, 28px);
  font-family: "Space Grotesk", "Manrope", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-quick-badge {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.profile-quick-actions {
  justify-content: flex-end;
  margin-top: 0;
}

.workspace-nav-shell {
  position: sticky;
  top: 84px;
  z-index: 24;
  margin-top: -2px;
}

.workspace-nav {
  display: flex;
  gap: 10px;
  overflow: auto;
  padding: 4px 2px 2px;
}

.workspace-nav::-webkit-scrollbar {
  display: none;
}

.workspace-chip {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(8, 13, 30, 0.84);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.workspace-chip:hover {
  background: rgba(30, 41, 59, 0.96);
  border-color: rgba(99, 102, 241, 0.46);
  transform: translateY(-1px);
}

.profile-modal-body,
.family-modal-body {
  display: grid;
  gap: 16px;
}

.modal-dialog-profile,
.modal-dialog-family {
  width: min(860px, calc(100% - 28px));
}

.avatar {
  width: 116px;
  height: 116px;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid rgba(148, 163, 184, 0.34);
}

.member-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.member-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 32%),
    rgba(2, 6, 23, 0.38);
}

.member-avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.member-card-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.member-card-body strong,
.tree-card-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-card-body span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.member-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tree-canvas-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background:
    radial-gradient(circle at 50% 18%, rgba(99, 102, 241, 0.16), transparent 24%),
    radial-gradient(circle at 78% 78%, rgba(34, 197, 94, 0.08), transparent 22%),
    linear-gradient(180deg, rgba(5, 11, 27, 0.92), rgba(4, 8, 18, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tree-fullscreen-dock {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.tree-canvas-wrap.fullscreen .tree-fullscreen-dock {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.tree-fullscreen-close {
  min-height: 44px;
  padding-inline: 16px;
  border-color: rgba(226, 232, 240, 0.26);
  background: rgba(5, 11, 27, 0.78);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 36px rgba(2, 6, 23, 0.35);
}

.tree-scene-video,
.tree-scene-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tree-scene-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.18;
  mix-blend-mode: screen;
  filter: saturate(1.18) contrast(1.04);
  display: none;
}

.tree-scene-overlay {
  background:
    radial-gradient(circle at 50% 18%, rgba(120, 119, 198, 0.26), transparent 26%),
    linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.02) 1px, transparent 1px),
    linear-gradient(180deg, rgba(15, 23, 42, 0.05), rgba(3, 7, 18, 0.8)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'%3E%3Cg fill='none' stroke='rgba(125,211,252,0.12)' stroke-width='3'%3E%3Cpath d='M600 760 V500'/%3E%3Cpath d='M600 520 L420 360'/%3E%3Cpath d='M600 520 L780 360'/%3E%3Cpath d='M420 360 L300 220'/%3E%3Cpath d='M780 360 L900 220'/%3E%3Cpath d='M420 360 L520 250'/%3E%3Cpath d='M780 360 L680 250'/%3E%3C/g%3E%3C/svg%3E") center/cover no-repeat;
  background-size: auto, 120px 120px, 120px 120px, auto, cover;
  opacity: 0.95;
  animation: tree-ambient 22s ease-in-out infinite;
}

#treeCanvas {
  min-height: 520px;
  position: relative;
  z-index: 2;
  border-radius: 20px;
  background: transparent;
  width: 100%;
  height: min(78vh, 920px);
  touch-action: none;
}

.tree-canvas-wrap.fullscreen {
  position: fixed;
  inset: 16px;
  z-index: 140;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  backdrop-filter: blur(14px);
  background: rgba(2, 6, 23, 0.98);
}

.tree-canvas-wrap.fullscreen #treeCanvas {
  height: calc(100vh - 72px);
}

.tree-preview {
  margin-top: 12px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  display: none;
  width: 100%;
  max-width: 100%;
}

.family-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 8px;
}

.family-form-panel {
  display: none;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.34);
}

.family-form-panel.active {
  display: block;
}

.family-summary-card {
  display: grid;
  gap: 10px;
}

.family-summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.family-summary-meta span {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.42);
  color: #cbd5e1;
  font-size: 12px;
}

.telegram-widget-note {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.34);
}

.telegram-widget-note p {
  margin: 0;
  color: var(--muted);
}

.profile-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 14px 12px;
}

.tree-people-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 14px;
}

.tree-people-help {
  margin: 0;
}

.tree-person-card {
  display: grid;
  justify-items: center;
}

.tree-person-trigger {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 10px;
  border: 0;
  padding: 8px 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 20px;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.tree-person-trigger:hover {
  background: rgba(15, 23, 42, 0.42);
  transform: translateY(-1px);
}

.tree-person-card.editing .tree-person-trigger {
  background: rgba(30, 41, 59, 0.58);
  box-shadow: 0 16px 30px rgba(59, 130, 246, 0.12);
}

.tree-person-avatar {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
}

.tree-person-card.editing .tree-person-avatar {
  border-color: rgba(99, 102, 241, 0.54);
  box-shadow: 0 18px 34px rgba(99, 102, 241, 0.18);
}

.tree-person-name {
  display: block;
  width: 100%;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.35;
  color: #e5e7eb;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 36px;
}

.modal-dialog-tree-profile {
  width: min(860px, calc(100% - 28px));
}

.tree-profile-hero {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin: 18px 0 18px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.36));
}

.tree-profile-avatar-btn {
  display: grid;
  gap: 10px;
  justify-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: center;
  padding: 0;
  cursor: pointer;
}

.tree-profile-avatar-btn.disabled {
  cursor: not-allowed;
}

.tree-profile-avatar {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.32);
}

.tree-profile-avatar-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tree-profile-utility {
  display: grid;
  gap: 10px;
  align-content: start;
}

.tree-profile-editor-body {
  display: grid;
  gap: 14px;
}

.tree-profile-editor-body .row {
  margin-top: 0;
}

.tree-profile-editor-body .btn {
  min-width: 0;
}

.question-list {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.question-card {
  padding: 10px;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.34);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.question-card p {
  margin: 0 0 8px;
  color: #cbd5e1;
}

.analysis-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(99, 102, 241, 0.24);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.76), rgba(15, 23, 42, 0.5)),
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 30%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.analysis-summary p {
  margin: 8px 0 0;
}

.analysis-summary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.analysis-tabs {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.analysis-tab-switch {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.52);
  color: #cbd5e1;
  font-weight: 700;
  cursor: pointer;
}

.analysis-tab-switch.active {
  color: #f8fafc;
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.18);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.16);
}

.analysis-tab-panels {
  display: grid;
}

.analysis-tab-panel {
  display: none;
  gap: 14px;
}

.analysis-tab-panel.active {
  display: grid;
}

.analysis-result {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  color: #cbd5e1;
}

.analysis-result-panel {
  align-content: start;
  min-height: 100%;
}

.analysis-result-hero {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(99, 102, 241, 0.24);
  background:
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.18), transparent 30%),
    linear-gradient(140deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.66));
}

.analysis-result-hero h4 {
  margin: 12px 0 0;
  font-size: clamp(26px, 4vw, 40px);
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

.analysis-result-hero p {
  margin: 10px 0 0;
  color: #cbd5e1;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.34);
  color: #c7d2fe;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.analysis-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.result-stat {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.36);
}

.result-stat span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.result-stat b {
  font-size: 18px;
  line-height: 1.25;
}

.analysis-note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.analysis-note-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.36);
}

.analysis-note-card p {
  margin: 8px 0 0;
}

.tarot-panel-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.tarot-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.tarot-actions {
  align-self: end;
  margin-top: 24px;
}

.tarot-result {
  display: grid;
  gap: 12px;
}

.tarot-result-hero {
  margin-top: 0;
}

.tarot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tarot-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.14), transparent 36%),
    rgba(2, 6, 23, 0.42);
}

.tarot-card span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tarot-card strong {
  font-size: 20px;
  line-height: 1.25;
}

.tarot-card b {
  color: #c7d2fe;
}

.tarot-card p {
  margin: 0;
  color: #cbd5e1;
}

.analysis-result ol {
  margin: 6px 0 0;
  padding-left: 20px;
}

.analysis-help {
  color: var(--muted);
  font-size: 14px;
  align-self: end;
}

.tree-form-note {
  margin: 10px 0 2px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.42);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.family-switch-box,
.tree-starter-box {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.28);
}

.family-switch-grid {
  align-items: end;
}

.tree-starter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.starter-slot {
  display: grid;
  gap: 6px;
  min-height: 84px;
  text-align: left;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(96, 165, 250, 0.22);
  background: rgba(15, 23, 42, 0.72);
  color: #e2e8f0;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.starter-slot:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(96, 165, 250, 0.45);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.18);
}

.starter-slot span {
  color: var(--muted);
  font-size: 12px;
}

.starter-slot.filled {
  border-color: rgba(34, 197, 94, 0.42);
  background: rgba(6, 78, 59, 0.32);
}

.starter-slot.locked {
  border-style: dashed;
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.36);
  color: #94a3b8;
  cursor: not-allowed;
}

.starter-slot:disabled {
  opacity: 0.75;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-shell.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-shell:not(.open) .modal-backdrop,
.modal-shell:not(.open) .modal-dialog {
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(14px);
}

.modal-dialog {
  position: relative;
  width: min(1040px, calc(100% - 28px));
  max-height: min(92vh, 980px);
  overflow: auto;
  padding: 24px;
  border-radius: 26px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background:
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.18), transparent 22%),
    linear-gradient(140deg, rgba(7, 12, 26, 0.97), rgba(10, 17, 34, 0.94));
  box-shadow: 0 30px 90px rgba(2, 6, 23, 0.58);
}

.modal-dialog h3 {
  margin: 4px 0 0;
  font-size: clamp(28px, 3vw, 38px);
}

.modal-dialog-auth {
  width: min(920px, calc(100% - 28px));
}

.modal-dialog-action {
  width: min(640px, calc(100% - 28px));
}

.modal-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.72);
  color: #e5e7eb;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-lead {
  max-width: 760px;
  color: var(--muted);
}

.auth-tabs {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 14px;
}

.auth-tab {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.52);
  color: #cbd5e1;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  color: #f8fafc;
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.18);
}

.auth-panels {
  display: grid;
  position: relative;
}

.auth-panel {
  display: none;
  gap: 14px;
  position: relative;
  z-index: 1;
  pointer-events: none;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.28);
}

.auth-panel.active {
  display: grid;
  z-index: 2;
  pointer-events: auto;
}

.auth-panel p {
  margin: 4px 0 0;
}

.analysis-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.96fr);
  gap: 16px;
}

.analysis-control-panel {
  display: grid;
  gap: 12px;
}

.analysis-dock {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  min-width: 214px;
  min-height: 64px;
  padding: 0 28px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 22px 42px rgba(15, 23, 42, 0.34);
}

.book-request-box {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.action-modal-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.action-choice-grid {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.action-choice-card,
.action-choice-link {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.6);
  color: #e5e7eb;
  text-align: left;
  padding: 16px 18px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.action-choice-card:hover,
.action-choice-link:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 102, 241, 0.45);
  background: rgba(30, 41, 59, 0.82);
}

.action-choice-card strong,
.action-choice-card span {
  display: block;
}

.action-choice-card strong {
  font-size: 16px;
}

.action-choice-card span,
.action-choice-link {
  color: var(--muted);
}

.action-choice-card span {
  margin-top: 6px;
  line-height: 1.55;
}

.action-choice-link {
  text-align: center;
  color: #e5e7eb;
}

body.modal-open {
  overflow: hidden;
}

body.tree-fullscreen-open {
  overflow: hidden;
}

.album-list {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.album-card {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  padding: 12px;
  background: rgba(2, 6, 23, 0.36);
  display: grid;
  gap: 10px;
}

.album-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.album-photo {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
}

.album-photo img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.album-photo figcaption {
  padding: 6px 8px 8px;
  color: var(--muted);
  font-size: 12px;
}

.album-photo-delete {
  position: absolute;
  right: 8px;
  bottom: 8px;
  backdrop-filter: blur(10px);
  background: rgba(2, 6, 23, 0.72);
}

.chat-composer {
  display: grid;
  gap: 8px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  margin: 0;
}

.inline-check input {
  width: auto;
}

.chat-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.chat-item {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  padding: 10px;
  background: rgba(2, 6, 23, 0.4);
}

.chat-item.urgent {
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.2) inset;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.chat-text {
  margin-top: 6px;
  white-space: pre-wrap;
  color: #e2e8f0;
}

.chat-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.book-shell {
  display: grid;
  gap: 14px;
  padding-bottom: 40px;
}

.book-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
}

.book-people {
  display: grid;
  gap: 10px;
}

.book-person {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 10px;
  background: rgba(2, 6, 23, 0.35);
}

.book-person .grid-3 {
  margin-top: 8px;
}

.status {
  position: fixed;
  bottom: 22px;
  right: 22px;
  max-width: min(440px, calc(100% - 30px));
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.24s ease, opacity 0.24s ease;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 12px;
  padding: 10px 12px;
  z-index: 90;
}

.status.error {
  border-color: rgba(244, 63, 94, 0.5);
}

.status.show {
  transform: translateY(0);
  opacity: 1;
}

.telegram-box {
  display: grid;
  gap: 12px;
}

.telegram-widget {
  min-height: 54px;
  display: flex;
  align-items: center;
}

.telegram-widget script,
.telegram-widget iframe {
  max-width: 100%;
}

.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  padding-bottom: 40px;
}

.admin-sidebar {
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 12px;
}

.admin-nav {
  display: grid;
  gap: 8px;
}

.admin-nav button {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 23, 0.45);
  color: #cbd5e1;
  padding: 10px;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.admin-nav button.active,
.admin-nav button:hover {
  border-color: rgba(99, 102, 241, 0.52);
  background: rgba(99, 102, 241, 0.2);
}

.admin-content {
  display: grid;
  gap: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(2, 6, 23, 0.42);
}

.kpi b {
  display: block;
  font-size: 22px;
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
}

th {
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.82);
  position: sticky;
  top: 0;
}

td {
  color: var(--muted);
}

.codebox {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(2, 6, 23, 0.5);
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .hero-grid,
  .page-hero-grid,
  .visual-grid,
  .analysis-modal-grid,
  .admin-layout,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 52px;
  }
}

@media (max-width: 860px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3,
  .grid-2,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .analysis-summary,
  .analysis-note-grid,
  .analysis-result-grid,
  .tarot-grid,
  .tarot-controls {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }

  .profile-wrap {
    grid-template-columns: 1fr;
  }

  .profile-quick-panel,
  .review-form-grid {
    grid-template-columns: 1fr;
  }

  .profile-quick-actions {
    justify-content: flex-start;
  }

  .member-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .member-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .tree-people-toolbar {
    grid-template-columns: 1fr;
  }

  .workspace-nav-shell {
    top: 74px;
  }

  .tree-profile-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  #treeCanvas {
    min-height: 460px;
    height: min(72vh, 760px);
  }

  .book-grid {
    grid-template-columns: 1fr;
  }

  .analysis-summary-actions {
    justify-content: flex-start;
  }

  .tarot-actions {
    margin-top: 0;
  }

  .modal-dialog {
    padding: 20px;
  }
}

@media (max-width: 540px) {
  .container {
    width: min(1200px, calc(100% - 24px));
  }

  .topbar-inner {
    min-height: 64px;
    gap: 8px;
  }

  .nav-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .profile-quick-main {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .profile-quick-avatar {
    width: 60px;
    height: 60px;
    border-radius: 18px;
  }

  .workspace-chip {
    padding: 9px 14px;
  }

  .hero h1 {
    font-size: clamp(32px, 10vw, 52px);
  }

  .cta-band {
    padding: 24px;
  }

  .tree-canvas-wrap.fullscreen {
    inset: 8px;
    padding: 10px;
  }

  .tree-canvas-wrap.fullscreen #treeCanvas {
    height: calc(100vh - 64px);
  }

  .tree-fullscreen-dock {
    top: 12px;
    right: 12px;
  }

  .tree-fullscreen-close {
    min-height: 40px;
    padding-inline: 14px;
    font-size: 13px;
  }

  .auth-chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .modal-dialog {
    width: calc(100% - 18px);
    padding: 18px 16px;
    border-radius: 22px;
  }

  .analysis-dock {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
  }

  .family-summary-meta,
  .reviews-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }

  .tree-person-avatar {
    width: 70px;
    height: 70px;
  }

  .tree-profile-avatar {
    width: 96px;
    height: 96px;
  }
}

body.landing-identity .site-bg {
  background:
    radial-gradient(circle at 16% 12%, rgba(14, 165, 233, 0.24), transparent 26%),
    radial-gradient(circle at 84% 14%, rgba(245, 158, 11, 0.2), transparent 24%),
    radial-gradient(circle at 80% 82%, rgba(16, 185, 129, 0.18), transparent 22%),
    radial-gradient(circle at 20% 82%, rgba(251, 191, 36, 0.12), transparent 24%),
    linear-gradient(160deg, #07111d 0%, #0a1c24 46%, #09111b 100%);
}

body.landing-identity .topbar {
  background: linear-gradient(180deg, rgba(7, 17, 29, 0.9), rgba(7, 17, 29, 0.68));
}

.identity-hero {
  padding-top: 72px;
}

.identity-side-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(45, 212, 191, 0.18);
  background:
    linear-gradient(135deg, rgba(8, 17, 31, 0.88), rgba(10, 24, 31, 0.66)),
    radial-gradient(circle at top right, rgba(251, 191, 36, 0.12), transparent 34%);
}

.identity-side-card::after {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.18), transparent 68%);
  filter: blur(18px);
}

.identity-metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.identity-grid .card {
  min-height: 220px;
  border-color: rgba(45, 212, 191, 0.14);
}

.identity-shell {
  border: 1px solid rgba(45, 212, 191, 0.18);
  background:
    linear-gradient(135deg, rgba(6, 14, 25, 0.88), rgba(11, 26, 30, 0.72)),
    radial-gradient(circle at top right, rgba(251, 191, 36, 0.1), transparent 28%);
}

.identity-chart-card {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.identity-ring {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 0 auto;
  background:
    conic-gradient(from 180deg, #22c55e, #38bdf8, #7c8cff, #22c55e);
  position: relative;
  box-shadow: 0 20px 44px rgba(2, 6, 23, 0.34);
}

.identity-ring::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: rgba(7, 17, 29, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.identity-chart-copy {
  display: grid;
  gap: 10px;
}

.identity-tree-map {
  align-content: start;
  border-color: rgba(251, 191, 36, 0.14);
}

.identity-cta {
  background:
    linear-gradient(135deg, rgba(10, 24, 31, 0.9), rgba(10, 16, 28, 0.84)),
    radial-gradient(circle at top center, rgba(45, 212, 191, 0.12), transparent 32%);
  border: 1px solid rgba(45, 212, 191, 0.18);
}

.educational-hero {
  border: 1px solid rgba(45, 212, 191, 0.16);
  background:
    linear-gradient(135deg, rgba(7, 17, 31, 0.82), rgba(12, 28, 38, 0.72)),
    radial-gradient(circle at top right, rgba(16, 185, 129, 0.14), transparent 32%);
}

.method-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.method-card {
  min-height: 138px;
  align-content: start;
}

.family-members-block {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.family-block-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}

.family-block-head span {
  color: var(--muted);
  font-size: 13px;
}

.family-members-stack {
  display: grid;
  gap: 12px;
}

.manual-relative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.manual-relative-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.34);
}

.manual-relative-main {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.tree-person-meta {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.tree-person-badges {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tree-person-chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.58);
  color: #dbe4ee;
  font-size: 11px;
  font-weight: 700;
}

.tree-person-chip.accent {
  border-color: rgba(99, 102, 241, 0.26);
  background: rgba(99, 102, 241, 0.16);
  color: #eef2ff;
}

.tree-profile-merge-box {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(34, 197, 94, 0.22);
  background:
    linear-gradient(135deg, rgba(6, 18, 22, 0.78), rgba(10, 22, 18, 0.62)),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.12), transparent 30%);
}

.tree-profile-merge-box p {
  margin: 0;
  color: var(--muted);
}

.tree-profile-merge-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.dream-panel-head p,
.pearson-card p,
.dream-symbol-item p,
.archetype-meter p {
  margin: 6px 0 0;
  color: var(--muted);
}

.dream-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dream-result,
.dream-symbol-list,
.archetype-map-list {
  display: grid;
  gap: 12px;
}

.dream-symbol-item,
.pearson-card,
.archetype-meter {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.34);
}

.pearson-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.pearson-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.pearson-card b {
  display: block;
  margin-top: 6px;
  color: #bfdbfe;
}

.archetype-meter-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}

.archetype-meter-head span {
  color: var(--muted);
  font-size: 12px;
}

.archetype-meter-bar {
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.82);
  overflow: hidden;
}

.archetype-meter-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #38bdf8, #818cf8);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.24);
}

.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (max-width: 1100px) {
  .identity-chart-card,
  .dream-panel-grid,
  .tree-profile-merge-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .identity-metric-grid,
  .method-card-grid {
    grid-template-columns: 1fr;
  }

  .manual-relative-main {
    grid-template-columns: 48px minmax(0, 1fr);
  }
}

@keyframes gradient-shift {
  0% {
    background-position: 0 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

@keyframes blob-float {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(14px, -18px) scale(1.08);
  }
}

@keyframes aurora-drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  35% {
    transform: translate3d(2%, -2%, 0) scale(1.04);
  }
  70% {
    transform: translate3d(-2%, 2%, 0) scale(1.02);
  }
}

@keyframes ambient-pan {
  0%,
  100% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 100% 100%;
  }
}

@keyframes tree-ambient {
  0%,
  100% {
    transform: scale(1) translate3d(0, 0, 0);
  }
  50% {
    transform: scale(1.03) translate3d(0, -1.2%, 0);
  }
}

body.app-cabinet {
  --bg: #110603;
  --bg-soft: #1a0904;
  --surface: rgba(43, 18, 8, 0.72);
  --surface-strong: rgba(28, 11, 4, 0.9);
  --glass: rgba(247, 177, 73, 0.09);
  --border: rgba(232, 169, 82, 0.24);
  --primary: #db8d23;
  --accent: #ffd786;
  --warn: #f0b34d;
  --text: #f8ead2;
  --muted: #d2b184;
  --danger: #f26b5b;
  --display-font: "Cormorant Garamond", Georgia, serif;
  --shadow-lg: 0 32px 90px rgba(0, 0, 0, 0.48);
  --shadow-md: 0 18px 46px rgba(0, 0, 0, 0.38);
  background: var(--bg);
}

.app-cabinet .site-bg {
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 186, 76, 0.28), transparent 26%),
    radial-gradient(circle at 82% 12%, rgba(197, 104, 29, 0.2), transparent 26%),
    radial-gradient(circle at 78% 84%, rgba(255, 210, 125, 0.14), transparent 24%),
    radial-gradient(circle at 12% 88%, rgba(190, 80, 10, 0.18), transparent 22%),
    linear-gradient(180deg, #060201 0%, #110603 34%, #180804 66%, #090302 100%);
}

.app-cabinet .site-bg::before {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 200, 108, 0.32), transparent 20%),
    radial-gradient(circle at 78% 20%, rgba(247, 150, 48, 0.18), transparent 20%),
    radial-gradient(circle at 74% 76%, rgba(196, 88, 18, 0.18), transparent 22%),
    radial-gradient(circle at 18% 82%, rgba(255, 215, 140, 0.15), transparent 22%);
  filter: blur(74px);
}

.app-cabinet .site-bg::after {
  background:
    radial-gradient(circle at center, rgba(255, 196, 95, 0.08), transparent 48%),
    linear-gradient(140deg, rgba(255, 184, 83, 0.07), rgba(86, 29, 6, 0.02), rgba(255, 208, 114, 0.05)),
    linear-gradient(rgba(255, 217, 155, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 217, 155, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 180% 180%, 120px 120px, 120px 120px;
}

.app-cabinet .floating-blob.blob-1 {
  background: rgba(255, 185, 84, 0.3);
}

.app-cabinet .floating-blob.blob-2 {
  background: rgba(182, 79, 16, 0.28);
}

.app-cabinet .floating-blob.blob-3 {
  background: rgba(255, 216, 132, 0.22);
}

.app-cabinet .topbar {
  background: linear-gradient(180deg, rgba(16, 6, 3, 0.94), rgba(22, 8, 3, 0.82));
  border-bottom: 1px solid rgba(232, 169, 82, 0.18);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

.app-cabinet .brand,
.app-cabinet .page-hero h1,
.app-cabinet .card h3,
.app-cabinet .card h4,
.app-cabinet .modal-dialog h3,
.app-cabinet .lineage-story-card strong,
.app-cabinet .heritage-card h4,
.app-cabinet .lineage-seal b,
.app-cabinet .value-node strong {
  font-family: var(--display-font);
}

.app-cabinet .brand {
  gap: 14px;
  font-size: clamp(28px, 2.8vw, 40px);
  line-height: 0.95;
  color: #fff1d4;
}

.app-cabinet .brand span {
  display: block;
  margin-left: 0;
  color: rgba(242, 198, 127, 0.76);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.app-cabinet .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 240, 195, 0.92), rgba(255, 197, 98, 0.88) 38%, rgba(128, 45, 8, 0.95) 100%);
  box-shadow:
    0 0 0 1px rgba(255, 221, 162, 0.26),
    0 0 30px rgba(255, 181, 61, 0.42);
}

.app-cabinet .nav-links a {
  color: #d8ba93;
}

.app-cabinet .nav-links a:hover,
.app-cabinet .nav-links a.active {
  color: #fff1d3;
  background: rgba(132, 56, 17, 0.34);
}

.app-cabinet .auth-chip {
  border-color: rgba(237, 181, 92, 0.28);
  background: rgba(54, 21, 9, 0.56);
  color: #f4d9ad;
}

.app-cabinet .auth-chip.is-authenticated {
  border-color: rgba(255, 205, 123, 0.44);
  background: rgba(97, 40, 14, 0.54);
  box-shadow: 0 0 0 1px rgba(255, 197, 100, 0.08) inset;
}

.app-cabinet .btn {
  color: #f8fafc;
  background: linear-gradient(135deg, #7c8cff, #9f7cff);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 40px rgba(124, 140, 255, 0.24);
}

.app-cabinet .btn:hover {
  box-shadow: 0 18px 42px rgba(124, 140, 255, 0.3);
}

.app-cabinet .btn.secondary,
.app-cabinet .btn.ghost {
  color: var(--text);
  box-shadow: none;
}

.app-cabinet .btn.secondary {
  background: rgba(63, 25, 10, 0.68);
  border: 1px solid rgba(226, 169, 86, 0.28);
}

.app-cabinet .btn.ghost {
  background: rgba(26, 10, 4, 0.28);
  border: 1px solid rgba(238, 182, 94, 0.32);
}

.app-cabinet .btn.warn {
  color: #2b1204;
  background: linear-gradient(135deg, #a24f0b 0%, #edab34 100%);
}

.app-cabinet .btn.success {
  color: #2b1204;
  background: linear-gradient(135deg, #956313 0%, #efbe59 100%);
}

.app-cabinet .btn.glow::before {
  background: linear-gradient(120deg, rgba(255, 178, 73, 0.72), rgba(255, 224, 159, 0.36));
  filter: blur(18px);
}

.app-cabinet .page-hero.page-hero-immersive {
  position: relative;
  overflow: hidden;
  padding: 38px;
  border-radius: 34px;
  border: 1px solid rgba(236, 181, 92, 0.18);
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 189, 84, 0.17), transparent 34%),
    linear-gradient(155deg, rgba(47, 17, 7, 0.92), rgba(18, 7, 3, 0.84));
  box-shadow: var(--shadow-lg);
}

.app-cabinet .page-hero.page-hero-immersive::before,
.app-cabinet .page-hero.page-hero-immersive::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 28px;
  pointer-events: none;
}

.app-cabinet .page-hero.page-hero-immersive::before {
  border: 1px solid rgba(255, 214, 149, 0.08);
}

.app-cabinet .page-hero.page-hero-immersive::after {
  inset: auto 46px 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 211, 138, 0.72), transparent);
}

.app-cabinet .page-hero-grid {
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
  gap: 28px;
  align-items: stretch;
}

.app-cabinet .page-hero h1 {
  font-size: clamp(46px, 7vw, 92px);
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: #fff0d0;
  max-width: 12ch;
  text-shadow: 0 0 24px rgba(255, 185, 70, 0.12);
}

.app-cabinet .page-hero p {
  color: #f0d4a7;
  max-width: 720px;
  font-size: clamp(16px, 1.8vw, 19px);
}

.app-cabinet .kicker {
  color: #f6c26f;
  letter-spacing: 0.2em;
}

.app-cabinet .tag {
  background: rgba(73, 27, 9, 0.52);
  border-color: rgba(241, 188, 100, 0.2);
  color: #fee7bd;
}

.app-cabinet .card,
.app-cabinet .glass,
.app-cabinet .modal-dialog {
  background:
    linear-gradient(155deg, rgba(43, 18, 8, 0.88), rgba(17, 7, 3, 0.82)),
    radial-gradient(circle at top, rgba(255, 190, 89, 0.08), transparent 48%);
  border: 1px solid rgba(236, 181, 92, 0.14);
  box-shadow: var(--shadow-md);
}

.app-cabinet .card:hover {
  border-color: rgba(255, 205, 123, 0.24);
}

.app-cabinet .notice,
.app-cabinet .analysis-note-card,
.app-cabinet .question-card,
.app-cabinet .method-card,
.app-cabinet .member-card,
.app-cabinet .manual-relative-card,
.app-cabinet .album-card,
.app-cabinet .chat-item,
.app-cabinet .pearson-card,
.app-cabinet .tarot-card,
.app-cabinet .action-choice-card,
.app-cabinet .family-summary-card {
  background: linear-gradient(160deg, rgba(65, 25, 10, 0.7), rgba(26, 10, 4, 0.62));
  border: 1px solid rgba(234, 176, 88, 0.14);
}

.app-cabinet label {
  color: #f3d9b0;
}

.app-cabinet input,
.app-cabinet select,
.app-cabinet textarea {
  background: rgba(27, 10, 4, 0.82);
  border-color: rgba(236, 181, 92, 0.16);
  color: #fff0d1;
  box-shadow: inset 0 1px 0 rgba(255, 218, 145, 0.04);
}

.app-cabinet input::placeholder,
.app-cabinet textarea::placeholder {
  color: rgba(234, 203, 157, 0.52);
}

.app-cabinet input:focus,
.app-cabinet select:focus,
.app-cabinet textarea:focus {
  border-color: rgba(255, 207, 126, 0.42);
  box-shadow: 0 0 0 3px rgba(223, 142, 37, 0.12);
}

.lineage-triptych,
.heritage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.lineage-triptych {
  margin-top: 24px;
}

.lineage-story-card,
.heritage-card,
.value-node {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
}

.lineage-story-card {
  padding: 20px;
  background:
    linear-gradient(155deg, rgba(72, 28, 10, 0.82), rgba(22, 8, 3, 0.72)),
    radial-gradient(circle at top, rgba(255, 193, 86, 0.12), transparent 48%);
  border: 1px solid rgba(242, 192, 111, 0.18);
}

.lineage-story-card::before,
.heritage-card::before,
.value-node::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 214, 149, 0.8), transparent);
}

.lineage-story-eyebrow,
.heritage-card-kicker,
.value-node span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lineage-story-card strong,
.heritage-card h4,
.value-node strong {
  display: block;
  margin-top: 10px;
  color: #fff0cf;
  font-size: clamp(28px, 3vw, 36px);
  line-height: 0.96;
}

.lineage-story-card p,
.heritage-card p,
.value-node p {
  margin: 10px 0 0;
  color: var(--muted);
}

.section-ornament {
  text-align: center;
  max-width: 860px;
  margin: 0 auto 24px;
}

.section-ornament h3 {
  margin: 0;
  color: #fff0cf;
  font-size: clamp(36px, 5vw, 58px);
  line-height: 0.96;
}

.value-orbit-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.value-node {
  padding: 22px;
  background:
    linear-gradient(155deg, rgba(66, 26, 10, 0.8), rgba(20, 8, 3, 0.7)),
    radial-gradient(circle at center, rgba(255, 193, 86, 0.08), transparent 50%);
  border: 1px solid rgba(241, 189, 108, 0.18);
}

.lineage-seal {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 24px;
  text-align: center;
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, rgba(255, 219, 148, 0.2), rgba(173, 78, 17, 0.22) 44%, rgba(30, 11, 4, 0.95) 100%);
  border: 1px solid rgba(248, 196, 115, 0.26);
  box-shadow:
    inset 0 0 40px rgba(255, 193, 86, 0.08),
    0 0 60px rgba(193, 87, 22, 0.18);
}

.lineage-seal::before,
.lineage-seal::after {
  content: "";
  position: absolute;
  border-radius: inherit;
  inset: -14px;
  border: 1px solid rgba(255, 216, 145, 0.12);
}

.lineage-seal::after {
  inset: -30px;
  border-color: rgba(255, 216, 145, 0.06);
}

.lineage-seal span,
.lineage-seal small {
  color: #f6c56d;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.lineage-seal b {
  color: #fff0cf;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 0.9;
}

.heritage-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.heritage-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.heritage-card h4 {
  color: #aab4ff;
}

.heritage-card p {
  flex: 1;
}

.app-cabinet .workspace-nav-shell {
  position: sticky;
  top: 92px;
  z-index: 18;
}

.app-cabinet .workspace-nav {
  padding: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(36, 14, 6, 0.92), rgba(25, 10, 4, 0.82));
  border: 1px solid rgba(236, 181, 92, 0.18);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.24);
}

.app-cabinet .workspace-chip {
  background: rgba(64, 25, 10, 0.68);
  border: 1px solid rgba(236, 181, 92, 0.16);
  color: #f5ddba;
}

.app-cabinet .workspace-chip:hover {
  background: rgba(111, 43, 14, 0.6);
  border-color: rgba(248, 204, 125, 0.28);
}

.lineage-orbit {
  position: relative;
  width: min(280px, 100%);
  aspect-ratio: 1;
  margin: 0 auto 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 230, 179, 0.18), rgba(122, 48, 11, 0.18) 42%, rgba(17, 7, 3, 0.9) 100%);
  border: 1px solid rgba(248, 203, 123, 0.2);
  box-shadow: inset 0 0 34px rgba(255, 193, 86, 0.08);
}

.lineage-orbit::before,
.lineage-orbit::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: inherit;
  border: 1px solid rgba(255, 211, 138, 0.1);
}

.lineage-orbit::after {
  inset: 42px;
}

.orbit-core,
.orbit-node {
  position: absolute;
  display: inline-grid;
  place-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(244, 193, 109, 0.18);
  background: rgba(62, 24, 10, 0.7);
  color: #ffe6bd;
  text-align: center;
}

.orbit-core {
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  min-width: 92px;
  min-height: 92px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 224, 159, 0.24), rgba(122, 48, 11, 0.72));
  font-family: var(--display-font);
  font-size: 36px;
}

.orbit-node-top {
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
}

.orbit-node-right {
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

.orbit-node-bottom {
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
}

.orbit-node-left {
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.lineage-card-copy {
  display: grid;
  gap: 12px;
}

.lineage-card-foot.secondary {
  color: #bb8b54;
}

.app-cabinet .analysis-tabs,
.app-cabinet .auth-tabs {
  background: rgba(30, 11, 4, 0.54);
  border: 1px solid rgba(236, 181, 92, 0.16);
}

.app-cabinet .analysis-tab-switch,
.app-cabinet .auth-tab {
  color: #e2c59b;
}

.app-cabinet .analysis-tab-switch.active,
.app-cabinet .auth-tab.active {
  background: linear-gradient(135deg, rgba(132, 55, 16, 0.92), rgba(224, 145, 34, 0.9));
  color: #2a1104;
}

.app-cabinet .tree-canvas-wrap {
  border: 1px solid rgba(236, 181, 92, 0.14);
  background:
    radial-gradient(circle at top, rgba(255, 197, 100, 0.12), transparent 32%),
    linear-gradient(160deg, rgba(42, 17, 7, 0.86), rgba(15, 6, 3, 0.76));
}

.app-cabinet .tree-scene-overlay {
  background:
    radial-gradient(circle at center, rgba(255, 205, 120, 0.1), transparent 38%),
    linear-gradient(180deg, rgba(11, 4, 2, 0.06), rgba(11, 4, 2, 0.58));
}

.app-cabinet .analysis-dock {
  color: #2b1204;
  background: linear-gradient(135deg, #a6520d 0%, #e29b2d 50%, #ffda8b 100%);
  box-shadow: 0 22px 48px rgba(145, 61, 13, 0.32);
}

.app-cabinet .status {
  background: rgba(33, 12, 5, 0.94);
  border: 1px solid rgba(236, 181, 92, 0.16);
  color: #ffe8c0;
}

.app-cabinet .status.error {
  background: rgba(66, 16, 9, 0.94);
}

.app-cabinet .modal-close {
  color: #f9ddb0;
}

.app-cabinet .layout {
  gap: 16px;
  padding-bottom: 120px;
}

@media (max-width: 1100px) {
  .app-cabinet .page-hero-grid,
  .lineage-triptych,
  .heritage-grid {
    grid-template-columns: 1fr;
  }

  .value-orbit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lineage-seal {
    grid-column: 1 / -1;
    max-width: 260px;
    margin: 0 auto;
  }
}

@media (max-width: 780px) {
  .app-cabinet .topbar-inner {
    min-height: auto;
    padding: 12px 0 16px;
    align-items: flex-start;
  }

  .app-cabinet .nav-links {
    display: none;
  }

  .app-cabinet .nav-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .app-cabinet .page-hero.page-hero-immersive {
    padding: 24px 20px;
    border-radius: 28px;
  }

  .app-cabinet .page-hero h1 {
    max-width: none;
    font-size: clamp(40px, 14vw, 62px);
  }

  .value-orbit-grid,
  .lineage-triptych,
  .heritage-grid {
    grid-template-columns: 1fr;
  }

  .lineage-seal {
    aspect-ratio: auto;
    border-radius: 28px;
  }

  .app-cabinet .workspace-nav-shell {
    top: auto;
    bottom: 88px;
  }

  .app-cabinet .workspace-nav {
    border-radius: 24px;
  }
}

/* codex-analysis-fixes-start */
#profileSection,
#familySection,
#treeSection,
#albumsSection,
#chatSection,
#bookSection,
#workspaceNav {
  scroll-margin-top: 108px;
}

.analysis-modal-grid {
  align-items: start;
}

.analysis-control-panel {
  min-width: 0;
  align-content: start;
}

.analysis-control-footer {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin-top: 0;
  padding-top: 14px;
  background: linear-gradient(180deg, rgba(7, 12, 26, 0), rgba(7, 12, 26, 0.94) 38%, rgba(7, 12, 26, 0.98));
}

.analysis-control-footer .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  width: min(100%, 420px);
  min-height: 58px;
  padding: 16px 24px;
  font-size: 17px;
  text-align: center;
}

.analysis-result-panel {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 0;
  max-height: min(76vh, 980px);
  overflow: auto;
  margin-top: 0;
  padding-right: 4px;
}

.analysis-dock {
  transition: opacity 0.22s ease, transform 0.22s ease;
}

body.modal-open .analysis-dock,
body.tree-fullscreen-open .analysis-dock {
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
}

.tree-canvas-wrap {
  isolation: isolate;
  overscroll-behavior: contain;
}

.tree-canvas-wrap canvas,
.tree-canvas-wrap .vis-network {
  touch-action: none;
}

.archetype-map-list {
  gap: 16px;
}

.archetype-chart-shell {
  display: grid;
  gap: 16px;
}

.archetype-chart-host {
  min-height: 420px;
  height: min(58vh, 520px);
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(2, 6, 23, 0.32);
}

.archetype-radar-chart {
  width: 100%;
  height: 100%;
}

.tree-page-layout {
  padding: 120px 0 64px;
}

.tree-page-head {
  max-width: 860px;
  margin-bottom: 22px;
}

.tree-page-head h1 {
  margin: 6px 0 10px;
}

.tree-page-head p:last-child {
  max-width: 720px;
  color: var(--muted);
}

.tree-page-card {
  width: 100%;
}

.tree-page-canvas {
  min-height: 68vh;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background:
    radial-gradient(circle at 20% 18%, rgba(20, 184, 166, 0.18), transparent 34%),
    radial-gradient(circle at 82% 16%, rgba(245, 201, 106, 0.14), transparent 36%),
    linear-gradient(180deg, rgba(2, 6, 23, 0.78), rgba(15, 23, 42, 0.94));
  overflow: hidden;
}

.archetype-chart-card {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(2, 6, 23, 0.3);
}

.archetype-chart-ring {
  position: relative;
  width: min(220px, 100%);
  aspect-ratio: 1;
  margin-inline: auto;
  border-radius: 50%;
  background: var(--chart-fill);
  box-shadow: 0 0 34px rgba(245, 158, 11, 0.18);
}

.archetype-chart-ring::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.98));
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}

.archetype-chart-center {
  position: absolute;
  inset: 22%;
  z-index: 1;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 4px;
  padding: 10px;
}

.archetype-chart-center span,
.archetype-chart-caption span,
.archetype-chart-item-head span {
  color: var(--muted);
  font-size: 12px;
}

.archetype-chart-center strong {
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1;
}

.archetype-chart-center small {
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.35;
}

.archetype-chart-caption {
  display: grid;
  gap: 8px;
}

.archetype-chart-caption strong {
  font-size: 18px;
}

.archetype-chart-caption p,
.archetype-chart-item p {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.6;
}

.archetype-chart-legend {
  display: grid;
  gap: 12px;
}

.archetype-chart-item {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.34);
}

.archetype-chart-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.archetype-chart-item-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.archetype-chart-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--swatch);
  box-shadow: 0 0 16px var(--swatch);
}

@media (max-width: 1100px) {
  .analysis-control-footer {
    position: static;
    padding-top: 0;
    background: none;
  }

  .analysis-result-panel {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .archetype-chart-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .analysis-dock {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .analysis-dock.btn {
    display: inline-flex;
    justify-content: center;
  }

  .analysis-control-footer .btn {
    width: 100%;
  }
}

.app-cabinet .card,
.app-cabinet .glass,
.app-cabinet .modal-dialog,
.app-cabinet .page-hero.page-hero-immersive,
.app-cabinet .notice,
.app-cabinet .analysis-note-card,
.app-cabinet .question-card,
.app-cabinet .method-card,
.app-cabinet .member-card,
.app-cabinet .manual-relative-card,
.app-cabinet .album-card,
.app-cabinet .chat-item,
.app-cabinet .pearson-card,
.app-cabinet .tarot-card,
.app-cabinet .action-choice-card,
.app-cabinet .family-summary-card {
  background: var(--bg-glass);
  border-color: var(--border);
}

.app-cabinet .btn {
  color: #f8fafc;
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 26px rgba(99, 102, 241, 0.26);
}

.app-cabinet .btn:hover {
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.32);
}

.app-cabinet .btn.secondary,
.app-cabinet .btn.ghost {
  color: var(--text);
  background: rgba(15, 23, 42, 0.42);
  border-color: var(--border);
}

.app-cabinet .brand-mark,
.app-cabinet .family-orb {
  box-shadow: none;
}

.app-cabinet .kicker,
.app-cabinet .lineage-story-eyebrow,
.app-cabinet .heritage-card-kicker,
.app-cabinet .value-node span {
  color: var(--gold);
}

.app-cabinet .page-hero h1,
.app-cabinet .lineage-story-card strong,
.app-cabinet .value-node strong {
  color: var(--text);
  text-shadow: none;
}

.app-cabinet .heritage-card h4 {
  color: var(--gold);
  text-shadow: none;
}

.app-cabinet .page-hero p,
.app-cabinet label {
  color: var(--muted);
}

.app-cabinet input,
.app-cabinet select,
.app-cabinet textarea {
  background: rgba(15, 23, 42, 0.72);
  border-color: var(--border);
  color: var(--text);
  box-shadow: none;
}

.app-cabinet .page-hero.page-hero-immersive::before,
.app-cabinet .page-hero.page-hero-immersive::after,
.lineage-story-card::before,
.heritage-card::before,
.value-node::before {
  content: none;
}

.app-cabinet .btn.glow {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.app-main #treeSection,
.app-main #treePeopleSection {
  display: none;
}

.app-cabinet .card,
.tree-page .card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.app-cabinet .btn,
.tree-page .btn,
.app-cabinet .btn.glow,
.tree-page .btn.glow {
  color: #f8fafc;
  background: linear-gradient(135deg, #7c8cff, #9f7cff);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 30px rgba(124, 140, 255, 0.26);
}

.app-cabinet .btn.secondary,
.app-cabinet .btn.ghost,
.tree-page .btn.secondary,
.tree-page .btn.ghost {
  color: var(--text);
  background: rgba(17, 24, 39, 0.78);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.tree-page-layout {
  padding-top: 116px;
}

.tree-onboarding {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.tree-onboarding div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(17, 24, 39, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.tree-onboarding span {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c8cff, #9f7cff);
  color: #fff;
  font-weight: 800;
}

.tree-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tree-side-panel {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 100px;
}

.tree-page-card {
  min-width: 0;
}

.tree-page #treeCanvas,
.tree-page-canvas {
  height: 80vh;
  width: 100%;
  min-height: 620px;
}

.tree-people-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.tree-person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  text-align: left;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.58);
  cursor: pointer;
}

.tree-person-row img {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  object-fit: cover;
}

.tree-person-row span {
  display: grid;
  gap: 2px;
}

.tree-person-row small {
  color: var(--muted);
}

.tree-profile-modal-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

@media (max-width: 980px) {
  .tree-workspace,
  .tree-onboarding {
    grid-template-columns: 1fr;
  }

  .tree-side-panel {
    position: static;
  }

  .tree-page #treeCanvas,
  .tree-page-canvas {
    min-height: 520px;
    height: 76vh;
  }
}
/* codex-analysis-fixes-end */

@media (max-width: 720px) {
  .analysis-dock {
    right: 12px;
    left: 12px;
    bottom: 12px;
    min-width: 0;
    width: auto;
    min-height: 58px;
    font-size: 17px;
  }

}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Code Rod Design System: shared product primitives. */
:root {
  --cr-bg: #100705;
  --cr-bg-deep: #080302;
  --cr-surface: rgba(40, 17, 8, 0.88);
  --cr-surface-raised: rgba(61, 26, 10, 0.92);
  --cr-surface-muted: rgba(31, 12, 6, 0.72);
  --cr-text: #fff0d1;
  --cr-text-muted: #d2b184;
  --cr-gold: #df9b35;
  --cr-gold-bright: #ffdaa0;
  --cr-line: rgba(236, 181, 92, 0.18);
  --cr-line-strong: rgba(255, 211, 138, 0.38);
  --cr-success: #78b88b;
  --cr-danger: #e37a69;
  --cr-radius-sm: 8px;
  --cr-radius-md: 12px;
  --cr-radius-lg: 18px;
  --cr-space-1: 4px;
  --cr-space-2: 8px;
  --cr-space-3: 12px;
  --cr-space-4: 16px;
  --cr-space-5: 20px;
  --cr-space-6: 24px;
  --cr-space-8: 32px;
  --cr-shadow-sm: 0 10px 26px rgba(0, 0, 0, 0.2);
  --cr-shadow-md: 0 20px 52px rgba(0, 0, 0, 0.3);
}

body,
body.app-cabinet,
body.tree-page {
  --bg: var(--cr-bg);
  --bg-main: var(--cr-bg);
  --bg-soft: var(--cr-bg-deep);
  --surface: var(--cr-surface);
  --surface-strong: var(--cr-surface-raised);
  --border: var(--cr-line);
  --primary: var(--cr-gold);
  --accent: var(--cr-gold-bright);
  --text: var(--cr-text);
  --muted: var(--cr-text-muted);
  --danger: var(--cr-danger);
  --radius: var(--cr-radius-md);
  --radius-sm: var(--cr-radius-sm);
  --shadow-md: var(--cr-shadow-sm);
  --shadow-lg: var(--cr-shadow-md);
  color: var(--cr-text);
  background: var(--cr-bg);
  font-family: "Manrope", "Segoe UI", Tahoma, sans-serif;
}

.topbar,
.app-cabinet .topbar,
.tree-page .topbar {
  min-height: 72px;
  background: rgba(16, 7, 5, 0.88);
  border-bottom-color: var(--cr-line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.topbar-inner {
  min-height: 72px;
}

.brand,
.app-cabinet .brand,
.tree-page .brand {
  color: var(--cr-text);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(25px, 2.2vw, 34px);
  font-weight: 700;
  letter-spacing: 0;
}

.brand span,
.app-cabinet .brand span,
.tree-page .brand span:last-child {
  color: var(--cr-text-muted);
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: 10px;
  letter-spacing: 0.14em;
}

.brand-mark,
.app-cabinet .brand-mark,
.tree-page .brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff0ca, var(--cr-gold) 42%, #743108 100%);
  box-shadow: 0 0 22px rgba(223, 155, 53, 0.34);
}

.nav-links {
  gap: var(--cr-space-1);
}

.nav-links a,
.app-cabinet .nav-links a,
.tree-page .nav-links a {
  padding: 9px 11px;
  border-radius: var(--cr-radius-sm);
  color: var(--cr-text-muted);
  font-size: 13px;
}

.nav-links a:hover,
.nav-links a.active,
.app-cabinet .nav-links a:hover,
.app-cabinet .nav-links a.active,
.tree-page .nav-links a:hover,
.tree-page .nav-links a.active {
  color: var(--cr-text);
  background: rgba(223, 155, 53, 0.13);
}

.btn,
.app-cabinet .btn,
.tree-page .btn {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--cr-radius-sm);
  color: #291104;
  background: linear-gradient(135deg, #bd7119, var(--cr-gold-bright));
  box-shadow: 0 10px 24px rgba(155, 83, 15, 0.22);
  font-size: 14px;
  font-weight: 800;
}

.btn:hover,
.app-cabinet .btn:hover,
.tree-page .btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 230, 175, 0.48);
  box-shadow: 0 14px 30px rgba(155, 83, 15, 0.3);
}

.btn.secondary,
.btn.ghost,
.app-cabinet .btn.secondary,
.app-cabinet .btn.ghost,
.tree-page .btn.secondary,
.tree-page .btn.ghost {
  color: var(--cr-text);
  background: rgba(43, 18, 8, 0.64);
  border-color: var(--cr-line);
  box-shadow: none;
}

.btn.ghost,
.app-cabinet .btn.ghost,
.tree-page .btn.ghost {
  background: transparent;
  color: var(--cr-text-muted);
}

.btn.success,
.app-cabinet .btn.success {
  color: #102116;
  background: linear-gradient(135deg, #6da77d, #a7d5a3);
}

.btn.warn,
.btn.glow,
.btn.gold,
.app-cabinet .btn.warn,
.app-cabinet .btn.glow,
.app-cabinet .btn.gold {
  color: #291104;
  background: linear-gradient(135deg, #bd7119, var(--cr-gold-bright));
}

.btn.danger,
.tree-page .btn.danger {
  color: #fff2ed;
  background: rgba(144, 44, 30, 0.75);
  border-color: rgba(227, 122, 105, 0.42);
}

.card,
.glass,
.panel,
.app-cabinet .card,
.app-cabinet .glass,
.app-cabinet .modal-dialog,
.tree-page .panel,
.tree-page .modal-dialog {
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-md);
  background: linear-gradient(155deg, var(--cr-surface), rgba(22, 8, 3, 0.9));
  box-shadow: var(--cr-shadow-sm);
}

.card,
.panel,
.tree-page .panel {
  padding: var(--cr-space-5);
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 211, 138, 0.28);
  box-shadow: var(--cr-shadow-md);
}

.card h3,
.card h4,
.panel h2,
.panel h3,
.modal-dialog h2,
.modal-dialog h3 {
  color: var(--cr-text);
  font-family: "Cormorant Garamond", Georgia, serif;
  letter-spacing: 0;
}

.card p,
.panel p,
.analysis-help,
.muted {
  color: var(--cr-text-muted);
}

label,
.app-cabinet label,
.tree-page .field label {
  color: var(--cr-text-muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea,
.app-cabinet input,
.app-cabinet select,
.app-cabinet textarea,
.tree-page input,
.tree-page select {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-sm);
  background: rgba(20, 8, 4, 0.8);
  color: var(--cr-text);
  box-shadow: inset 0 1px 0 rgba(255, 226, 165, 0.035);
}

textarea,
.app-cabinet textarea {
  min-height: 112px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgba(210, 177, 132, 0.58);
}

input:focus,
select:focus,
textarea:focus,
.app-cabinet input:focus,
.app-cabinet select:focus,
.app-cabinet textarea:focus,
.tree-page input:focus,
.tree-page select:focus {
  border-color: var(--cr-line-strong);
  box-shadow: 0 0 0 3px rgba(223, 155, 53, 0.14);
}

.notice,
.analysis-note-card,
.question-card,
.method-card,
.member-card,
.album-card,
.chat-item,
.tarot-card,
.pearson-card,
.action-choice-card,
.family-summary-card,
.tree-page .notice {
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-sm);
  background: var(--cr-surface-muted);
  color: var(--cr-text-muted);
}

.tag,
.badge,
.auth-chip,
.workspace-chip,
.tree-page .person-chip {
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-sm);
  background: rgba(83, 34, 11, 0.52);
  color: var(--cr-text);
}

.modal-backdrop,
.tree-page .modal-backdrop {
  background: rgba(8, 3, 1, 0.76);
  backdrop-filter: blur(8px);
}

.modal-dialog,
.tree-page .modal-dialog {
  border-radius: var(--cr-radius-md);
}

.modal-close,
.tree-page .modal-close {
  border-radius: var(--cr-radius-sm);
  color: var(--cr-text-muted);
}

table {
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-sm);
  overflow: hidden;
  background: var(--cr-surface-muted);
}

th {
  color: var(--cr-text);
  background: rgba(63, 25, 10, 0.9);
}

td {
  color: var(--cr-text-muted);
  border-bottom-color: rgba(236, 181, 92, 0.1);
}

.grid-2,
.grid-3,
.grid-4,
.analysis-modal-grid,
.book-grid,
.admin-layout {
  gap: var(--cr-space-4);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Shared premium transition for cabinet, tree, book and analysis routes. */
.page-transition {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  background: rgba(8, 3, 1, 0.1);
  transition: opacity 0.2s ease;
}

.page-transition-glow {
  position: absolute;
  inset: -18%;
  background: radial-gradient(ellipse at center, rgba(255, 206, 119, 0.48), rgba(177, 87, 15, 0.24) 34%, rgba(8, 3, 1, 0.96) 70%);
  opacity: 0;
  transform: scale(0.78);
}

.page-transition-roots {
  position: absolute;
  left: 50%;
  bottom: -24vh;
  width: min(1100px, 150vw);
  height: 82vh;
  transform: translateX(-50%);
}

.page-transition-roots::before,
.page-transition-roots::after,
.page-transition-roots span {
  position: absolute;
  bottom: 0;
  width: 2px;
  height: 100%;
  content: "";
  transform-origin: bottom center;
  background: linear-gradient(to top, rgba(104, 43, 8, 0), rgba(236, 172, 70, 0.92) 45%, rgba(255, 224, 156, 0));
  box-shadow: 0 0 14px rgba(249, 183, 76, 0.52);
}

.page-transition-roots::before { left: 40%; transform: rotate(-38deg); }
.page-transition-roots::after { left: 60%; transform: rotate(38deg); }
.page-transition-roots span:nth-child(1) { left: 50%; transform: rotate(-12deg); }
.page-transition-roots span:nth-child(2) { left: 48%; transform: rotate(15deg); }
.page-transition-roots span:nth-child(3) { left: 53%; transform: rotate(66deg); }

body.page-transition-leave .page-transition {
  opacity: 1;
}

body.page-transition-leave .page-transition-glow {
  animation: page-transition-glow 0.46s ease forwards;
}

body.page-transition-leave .page-transition-roots {
  animation: page-transition-roots 0.46s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
}

@keyframes page-transition-glow {
  to { opacity: 1; transform: scale(1); }
}

@keyframes page-transition-roots {
  from { opacity: 0; transform: translateX(-50%) translateY(24%) scale(0.72); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.analysis-page-layout {
  position: relative;
  z-index: 1;
  padding: 118px 0 72px;
}

.analysis-page-hero {
  max-width: 760px;
  margin: 0 auto 24px;
  text-align: center;
}

.analysis-page-hero h1 {
  margin: 8px 0 12px;
  font-family: var(--display-font);
  font-size: clamp(42px, 7vw, 72px);
  line-height: 0.95;
  color: #ffe0a3;
}

.analysis-page-hero p:last-child {
  max-width: 620px;
  margin: 0 auto;
  color: var(--muted);
}

.analysis-page-workspace {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(239, 183, 82, 0.32);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(47, 18, 5, 0.94), rgba(13, 5, 2, 0.92));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 233, 181, 0.12);
}

.analysis-page-workspace::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(ellipse at 18% 0%, rgba(255, 207, 118, 0.18), transparent 34%),
    repeating-radial-gradient(ellipse at 50% 118%, transparent 0 42px, rgba(210, 138, 47, 0.07) 43px 44px, transparent 45px 76px);
}

.analysis-page-workspace .modal-dialog-analysis {
  position: relative;
  width: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(20px, 4vw, 42px);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.analysis-page .analysis-tabs {
  position: relative;
  z-index: 1;
  padding: 0 clamp(20px, 4vw, 42px);
  margin: 0;
}

.analysis-page .analysis-tab-panels {
  position: relative;
  z-index: 1;
  padding: 24px clamp(20px, 4vw, 42px) clamp(20px, 4vw, 42px);
}

.analysis-page .analysis-tab-switch.active {
  color: #2a1004;
  border-color: rgba(255, 221, 145, 0.72);
  background: linear-gradient(135deg, #c8791c, #ffda91);
  box-shadow: 0 0 24px rgba(255, 183, 65, 0.3);
}

body.page-transition-enter .analysis-page-hero,
body.page-transition-enter .analysis-page-workspace {
  opacity: 0;
  transform: translateY(24px);
}

.analysis-page-hero,
.analysis-page-workspace {
  transition: opacity 0.58s ease, transform 0.58s ease;
}

@media (max-width: 720px) {
  .analysis-page-layout { padding-top: 96px; }
  .analysis-page-hero h1 { font-size: 46px; }
  .analysis-page .analysis-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
    overflow: visible;
    padding: 0 0 8px;
  }
  .analysis-page .analysis-tab-switch {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    line-height: 1.25;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-transition,
  .analysis-page-hero,
  .analysis-page-workspace { transition: none; }
  body.page-transition-leave .page-transition-glow,
  body.page-transition-leave .page-transition-roots { animation: none; }
}

/* Tree page layout, moved from static/tree.html into the shared system. */
.tree-page .site-bg {
  background:
    radial-gradient(circle at 50% -20%, rgba(223, 155, 53, 0.17), transparent 34%),
    linear-gradient(180deg, var(--cr-bg), var(--cr-bg-deep));
}

.tree-page .tree-shell {
  position: relative;
  padding: var(--cr-space-8) 0 56px;
}

.tree-page .tree-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--cr-space-5);
  margin-bottom: var(--cr-space-5);
}

.tree-page .tree-hero h1 {
  margin: 0;
  color: var(--cr-text);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 0.95;
}

.tree-page .tree-hero p {
  max-width: 720px;
  margin: var(--cr-space-2) 0 0;
  color: var(--cr-text-muted);
}

.tree-page .tree-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: var(--cr-space-4);
  align-items: start;
}

.tree-page .field {
  display: grid;
  gap: 7px;
  margin: var(--cr-space-3) 0;
}

.tree-page .tree-canvas {
  height: min(68vh, 680px);
  min-height: 480px;
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-md);
  background: rgba(13, 5, 2, 0.8);
  overflow: hidden;
}

.tree-page .levels {
  display: grid;
  gap: var(--cr-space-3);
  margin-top: var(--cr-space-4);
}

.tree-page .level-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: var(--cr-space-3);
  align-items: stretch;
  padding: var(--cr-space-3);
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-sm);
  background: var(--cr-surface-muted);
}

.tree-page .level-title b,
.tree-page .person-chip small {
  display: block;
}

.tree-page .level-title small,
.tree-page .person-chip small {
  color: var(--cr-text-muted);
}

.tree-page .level-actions,
.tree-page .person-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-2);
}

.tree-page .level-actions { margin: var(--cr-space-3) 0; }
.tree-page .person-chips { align-content: center; min-height: 40px; }

.tree-page .person-chip {
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
}

.tree-page .loader {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  background: rgba(8, 3, 1, 0.72);
  backdrop-filter: blur(6px);
}

.tree-page .loader.open { display: grid; }

.tree-page .spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 218, 160, 0.18);
  border-top-color: var(--cr-gold-bright);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.tree-page .toast-wrap {
  position: fixed;
  right: var(--cr-space-4);
  bottom: var(--cr-space-4);
  z-index: 80;
  display: grid;
  gap: var(--cr-space-2);
}

.tree-page .toast {
  width: min(360px, calc(100vw - 32px));
  padding: var(--cr-space-3);
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-sm);
  color: var(--cr-text);
  background: var(--cr-surface-raised);
  box-shadow: var(--cr-shadow-md);
  animation: toast-in 0.2s ease-out;
}

.tree-page .toast.error { border-color: rgba(227, 122, 105, 0.46); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.tree-page .modal-dialog {
  position: relative;
  width: min(520px, 100%);
  padding: var(--cr-space-5);
}

.product-page .site-bg {
  background:
    radial-gradient(circle at 18% 14%, rgba(223, 155, 53, 0.17), transparent 26%),
    radial-gradient(circle at 82% 82%, rgba(136, 57, 13, 0.13), transparent 28%),
    linear-gradient(180deg, var(--cr-bg), var(--cr-bg-deep));
}

.product-page .layout,
.product-page .book-shell {
  padding-top: var(--cr-space-8);
  padding-bottom: 72px;
}

.product-page .page-hero {
  max-width: 760px;
  margin-bottom: var(--cr-space-6);
}

.product-page .page-hero h1 {
  margin: 0;
  color: var(--cr-text);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(42px, 6vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
}

.product-page .page-hero p {
  margin-top: var(--cr-space-3);
  color: var(--cr-text-muted);
  font-size: 16px;
}

.admin-nav button {
  border-color: var(--cr-line);
  border-radius: var(--cr-radius-sm);
  background: transparent;
  color: var(--cr-text-muted);
}

.admin-nav button.active,
.admin-nav button:hover {
  border-color: var(--cr-line-strong);
  background: rgba(223, 155, 53, 0.14);
  color: var(--cr-text);
}

.info-disclosure {
  display: grid;
  gap: var(--cr-space-3);
}

.info-disclosure summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--cr-space-3);
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-sm);
  color: var(--cr-text);
  background: var(--cr-surface-muted);
  cursor: pointer;
  font-weight: 800;
}

.info-disclosure[open] summary {
  border-color: var(--cr-line-strong);
}

.admin-scope-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-2);
  margin-top: var(--cr-space-3);
}

/* Quiet family-line atmosphere. Decorative layers never receive interaction. */
.code-roots .site-bg::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  content: "";
  pointer-events: none;
  opacity: 0.62;
  background:
    radial-gradient(ellipse 88% 46% at 50% 116%, transparent 0 48%, rgba(255, 216, 145, 0.085) 48.15% 48.42%, transparent 48.7% 60%),
    radial-gradient(ellipse 64% 36% at 12% 112%, transparent 0 51%, rgba(223, 155, 53, 0.06) 51.2% 51.45%, transparent 51.8% 64%),
    radial-gradient(ellipse 64% 36% at 88% 112%, transparent 0 51%, rgba(223, 155, 53, 0.06) 51.2% 51.45%, transparent 51.8% 64%);
  transform-origin: 50% 100%;
  animation: roots-breathe 12s ease-in-out infinite;
}

.code-roots .site-bg::after {
  background:
    radial-gradient(circle at 52% 8%, rgba(255, 220, 157, 0.09), transparent 26%),
    radial-gradient(circle at 50% 104%, rgba(223, 155, 53, 0.1), transparent 38%),
    linear-gradient(180deg, rgba(255, 215, 142, 0.018), transparent 26%);
  background-size: 100% 100%;
  animation: ambient-glow 10s ease-in-out infinite;
}

.atmospheric-particles .particles {
  z-index: -1;
  display: block;
  opacity: 0.24;
}

@keyframes roots-breathe {
  0%, 100% { opacity: 0.44; transform: scale(1); }
  50% { opacity: 0.68; transform: scale(1.025); }
}

@keyframes ambient-glow {
  0%, 100% { opacity: 0.7; transform: translate3d(0, 0, 0); }
  50% { opacity: 1; transform: translate3d(0, -0.6%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .atmospheric-particles .particles { display: none; }
  .code-roots .site-bg::before,
  .code-roots .site-bg::after { animation: none; }
}

@media (max-width: 920px) {
  .tree-page .tree-grid,
  .tree-page .level-row { grid-template-columns: 1fr; }
  .tree-page .tree-hero { display: grid; }
}

/* TASK_020: final shared interaction and narrow-screen safeguards. */
html { background: var(--cr-bg-deep); }
body { overflow-x: hidden; }

/* The analysis page is a document, not a constrained modal: its full result must be reachable by page scrolling. */
.analysis-page {
  overflow-y: auto;
}

.analysis-page .analysis-page-workspace {
  overflow: visible;
}

.analysis-page .analysis-result-panel {
  position: static;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

/* A life profile is deliberately longer than a compact person card. */
.tree-page #personModal .modal-dialog {
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.person-life-section {
  margin-top: var(--cr-space-4);
  padding-top: var(--cr-space-3);
  border-top: 1px solid var(--cr-line);
}

.person-life-section h3 {
  margin: 0;
  color: var(--cr-text);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 24px;
}

.person-life-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--cr-space-3);
}

.family-calendar {
  margin-top: var(--cr-space-5);
  padding-top: var(--cr-space-4);
  border-top: 1px solid var(--cr-line);
}

.calendar-items,
.person-timeline {
  display: grid;
  gap: var(--cr-space-2);
}

.calendar-item,
.timeline-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--cr-space-3);
  align-items: start;
  padding: var(--cr-space-3);
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius-sm);
  background: var(--cr-surface-muted);
}

.calendar-item > span { font-size: 22px; }
.calendar-item p,
.timeline-event p { margin: 4px 0 0; color: var(--cr-text-muted); }
.timeline-event small { display: block; margin-top: 8px; color: var(--cr-gold-bright); }
.timeline-event time { min-width: 48px; color: var(--cr-gold-bright); font-weight: 800; }
.event-editor { margin-top: var(--cr-space-3); }

.reminder-editor {
  display: grid;
  gap: var(--cr-space-2);
  margin-top: var(--cr-space-4);
  padding-top: var(--cr-space-3);
  border-top: 1px solid var(--cr-line);
}

.reminder-choice { color: var(--cr-text-muted); }

@media (max-width: 620px) {
  .tree-page #personModal .modal-dialog {
    width: calc(100% - 20px);
    max-height: calc(100vh - 20px);
    padding: var(--cr-space-4);
  }

  .person-life-grid { grid-template-columns: 1fr; }
}

:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--cr-gold-bright);
  outline-offset: 3px;
}

.btn,
.btn.secondary,
.btn.ghost,
.btn.success,
.btn.danger,
.btn.warn,
.btn.glow,
.btn.gold {
  min-height: 44px;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.56; transform: none; box-shadow: none; }

input,
select,
textarea {
  min-height: 44px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

textarea { min-height: 96px; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cr-line-strong);
  box-shadow: 0 0 0 3px rgba(223, 155, 53, 0.15);
}

.status,
.toast,
.notice { border-radius: var(--cr-radius-sm); }

.topbar,
.unified-header { backdrop-filter: blur(18px); }

.product-page .topbar,
.tree-page .topbar,
.app-cabinet .topbar { border-bottom-color: var(--cr-line); }

.tree-page .tree-canvas { box-shadow: inset 0 1px 0 rgba(255, 218, 160, 0.06); }

@media (max-width: 860px) {
  .app-cabinet .layout { grid-template-columns: minmax(0, 1fr); }

  .topbar-inner { align-items: flex-start; }
  .nav-actions { flex-wrap: wrap; gap: var(--cr-space-2); }
  .nav-actions .auth-chip { max-width: 100%; }
  .page-hero,
  .product-page .page-hero { padding-top: var(--cr-space-6); }

  .app-cabinet .page-hero-grid,
  .app-cabinet .lineage-hero-copy,
  .app-cabinet .app-hero-card,
  .app-cabinet .lineage-card-copy,
  .app-cabinet .lineage-method-grid,
  .app-cabinet .method-card { min-width: 0; max-width: 100%; }

  .app-cabinet .page-hero-grid,
  .app-cabinet .method-card-grid { grid-template-columns: minmax(0, 1fr); }

  .app-cabinet .lineage-card-copy,
  .app-cabinet .method-card,
  .app-cabinet .lineage-card-foot { overflow-wrap: anywhere; }
}

@media (max-width: 540px) {
  .btn { width: auto; max-width: 100%; }
  .row { align-items: stretch; }
  .row .btn,
  .hero-actions .btn { flex: 1 1 100%; }
  .tree-page .tree-canvas { min-height: 420px; height: 62vh; }
  .tree-page .toast-wrap { right: var(--cr-space-3); bottom: var(--cr-space-3); }
}

/* TASK_021: mobile app shell and compact life card. */
.mobile-bottom-nav { display: none; }
.person-mobile-summary,
.person-mobile-tabs { display: none; }

@media (max-width: 780px) {
  body.app-cabinet,
  body.tree-page { padding-bottom: 82px; }

  .topbar-inner { min-height: 60px; }
  .brand span:last-child,
  .nav-actions { display: none; }
  .tree-page .tree-hero { gap: var(--cr-space-3); padding-top: var(--cr-space-4); }
  .tree-page .tree-hero h1 { font-size: 36px; }
  .tree-page .tree-hero p { font-size: 14px; }
  .tree-page .tree-grid { gap: var(--cr-space-3); }
  .tree-page .panel { padding: var(--cr-space-4); }
  .tree-page .tree-canvas { min-height: 360px; height: 56vh; touch-action: none; }
  .tree-page .tree-canvas canvas { touch-action: none; }
  .tree-page .tree-grid > aside { display: none; }
  .tree-page .tree-grid > section > .row:first-child { display: grid; grid-template-columns: 1fr 1fr; }
  .tree-page .tree-grid > section > .row:first-child > .row { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .tree-page #addPersonBtn { grid-column: 1 / -1; min-height: 52px; font-size: 16px; }
  .tree-page .level-row { grid-template-columns: 1fr; }
  .tree-page .level-actions .btn { flex: 1 1 auto; }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 90;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    min-height: 70px;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--cr-line);
    background: rgba(16, 7, 5, 0.96);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(16px);
  }
  .mobile-bottom-nav a { display: grid; place-items: center; gap: 2px; min-height: 54px; color: var(--cr-text-muted); font-size: 18px; }
  .mobile-bottom-nav a small { font-size: 9px; line-height: 1; white-space: nowrap; }
  .mobile-bottom-nav a.active { color: var(--cr-gold-bright); }

  .tree-page #personModal .person-mobile-dialog { width: 100%; max-height: 100dvh; padding: 16px; border-radius: 16px 16px 0 0; }
  .person-mobile-summary { align-items: center; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; margin: 12px 0; padding: 12px; border: 1px solid var(--cr-line); border-radius: var(--cr-radius-sm); background: var(--cr-surface-muted); }
  .person-mobile-summary:not(.hidden) { display: grid; }
  .person-mobile-summary img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; }
  .person-mobile-summary strong,
  .person-mobile-summary span { display: block; }
  .person-mobile-summary span { margin-top: 3px; color: var(--cr-text-muted); font-size: 13px; }
  .person-mobile-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 8px; padding: 0 16px 8px; scrollbar-width: none; }
  .person-mobile-tabs button { flex: 0 0 auto; min-height: 38px; padding: 7px 10px; border: 1px solid var(--cr-line); border-radius: var(--cr-radius-sm); color: var(--cr-text-muted); background: var(--cr-surface-muted); font: inherit; font-size: 12px; font-weight: 700; }
  .person-mobile-tabs button[aria-selected="true"] { border-color: var(--cr-line-strong); color: var(--cr-text); background: rgba(223, 155, 53, 0.17); }
  .person-mobile-section { display: none; margin-top: 12px; }
  .person-mobile-section.mobile-section-active { display: block; }
  .person-mobile-section[data-person-section="main"] { display: block; }
  .person-mobile-dialog:has(.person-mobile-tabs button[aria-selected="true"][data-person-tab="life"]) .person-mobile-section[data-person-section="main"],
  .person-mobile-dialog:has(.person-mobile-tabs button[aria-selected="true"][data-person-tab="timeline"]) .person-mobile-section[data-person-section="main"],
  .person-mobile-dialog:has(.person-mobile-tabs button[aria-selected="true"][data-person-tab="memories"]) .person-mobile-section[data-person-section="main"],
  .person-mobile-dialog:has(.person-mobile-tabs button[aria-selected="true"][data-person-tab="memory"]) .person-mobile-section[data-person-section="main"],
  .person-mobile-dialog:has(.person-mobile-tabs button[aria-selected="true"][data-person-tab="legacy"]) .person-mobile-section[data-person-section="main"] { display: none; }
}
