/* ===== Variables ===== */
:root {
  --bg: #f0fdf4;
  --card: #ffffff;
  --ink: #0f291e;
  --muted: #5a7a6b;
  --line: #d1f0db;
  --green: #059669;
  --green-bright: #10b981;
  --green-soft: #d1fae5;
  --green-glow: rgba(16, 185, 129, 0.15);
  --shadow: 0 20px 60px rgba(15, 41, 30, 0.12);
  --shadow-sm: 0 4px 20px rgba(15, 41, 30, 0.06);
  --bottom-nav-height: 84px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  /* Generation Colors */
  --gen1-primary: #d97706;
  --gen1-soft: #fef3c7;
  --gen1-glow: rgba(217, 119, 6, 0.15);
  --gen1-ink: #78350f;

  --gen2-primary: #2563eb;
  --gen2-soft: #dbeafe;
  --gen2-glow: rgba(37, 99, 235, 0.15);
  --gen2-ink: #1e3a8a;

  --gen3-primary: #059669;
  --gen3-soft: #d1fae5;
  --gen3-glow: rgba(5, 150, 105, 0.15);
  --gen3-ink: #064e3b;

  --gen4-primary: #7c3aed;
  --gen4-soft: #ede9fe;
  --gen4-glow: rgba(124, 58, 237, 0.15);
  --gen4-ink: #4c1d95;
}

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* ===== Layout ===== */
.app-shell {
  min-height: 100vh;
  padding-bottom: calc(160px + env(safe-area-inset-bottom));
}

.app-main {
  min-width: 0;
}

.tree-only-body .app-shell {
  display: block;
  max-width: none;
  margin: 0 auto;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.desktop-side,
.desktop-panel {
  display: none;
}

/* ===== Sticky Header ===== */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(240, 253, 244, 0.92);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid rgba(209, 240, 219, 0.6);
  box-shadow: 0 8px 24px rgba(15, 41, 30, 0.055);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--green), var(--green-bright));
  color: #fff;
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3);
  flex-shrink: 0;
}

.brand-mark i {
  width: 22px;
  height: 22px;
}

.brand-text {
  min-width: 0;
  line-height: 1.05;
}

.brand-text strong {
  display: block;
  font-size: 1.04rem;
  letter-spacing: -0.045em;
  font-weight: 800;
}

.brand-text span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 12px rgba(15, 41, 30, 0.06);
  display: grid;
  place-items: center;
  color: var(--ink);
  flex-shrink: 0;
}

.icon-btn i {
  width: 18px;
  height: 18px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 16px;
  padding: 13px 14px;
  font-weight: 800;
  font-size: 0.9rem;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.96);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--green), var(--green-bright));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.35);
}

.btn.soft {
  background: var(--green-soft);
  color: var(--green);
  border-color: #a7f3d0;
}

.link-btn {
  color: var(--green);
  border: 0;
  background: transparent;
  font-weight: 800;
  white-space: nowrap;
  padding: 0;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  cursor: pointer;
}

.link-btn i {
  width: 14px;
  height: 14px;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(231, 247, 238, 0.88)), var(--card);
  border-radius: 28px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  right: -74px;
  top: -74px;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.10);
}

.pill {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(16, 185, 129, 0.13);
  color: var(--green);
  font-weight: 800;
  font-size: 0.78rem;
}

.pill i {
  width: 14px;
  height: 14px;
}

.hero h1 {
  position: relative;
  z-index: 1;
  margin: 14px 0 8px;
  font-size: clamp(2.15rem, 11vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.08em;
  color: var(--ink);
  font-weight: 900;
}

.hero > p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  max-width: 720px;
  font-size: 0.96rem;
  font-weight: 500;
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 18px;
}

.quick-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 14px;
}

.stat {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 11px 8px;
  text-align: center;
  box-shadow: 0 8px 18px rgba(15, 41, 30, 0.04);
}

.stat strong {
  display: block;
  font-size: 1.08rem;
  letter-spacing: -0.04em;
  color: var(--ink);
  font-weight: 800;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 2px;
  font-weight: 700;
}

/* ===== Section heads ===== */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 24px 2px 12px;
  scroll-margin-top: 90px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.28rem;
  letter-spacing: -0.045em;
  color: var(--ink);
  font-weight: 800;
}

.section-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ===== Today cards ===== */
.today-grid {
  display: grid;
  gap: 11px;
}

.today-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 13px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.today-card:active {
  transform: scale(0.98);
}

.today-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.today-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.today-icon i {
  width: 22px;
  height: 22px;
}

.today-card:nth-child(1) .today-icon { background: #fef3c7; color: #d97706; }
.today-card:nth-child(2) .today-icon { background: #dbeafe; color: #2563eb; }
.today-card:nth-child(3) .today-icon { background: #ffe4e6; color: #f43f5e; }

.today-card strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-weight: 700;
}

.today-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
  font-weight: 500;
}

.today-card .arrow {
  color: var(--muted);
  opacity: 0.5;
}

.today-card .arrow i {
  width: 18px;
  height: 18px;
}

/* ===== Tree - Generation Bands ===== */
.gen-band {
  border-radius: 24px;
  padding: 20px 16px;
  margin-bottom: 16px;
  border: 1px solid;
  position: relative;
  overflow: hidden;
}

.gen-band::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  opacity: 0.06;
}

.gen-band[data-gen="1"] {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fde68a;
}
.gen-band[data-gen="1"]::before { background: radial-gradient(circle, var(--gen1-primary), transparent); }

.gen-band[data-gen="2"] {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #bfdbfe;
}
.gen-band[data-gen="2"]::before { background: radial-gradient(circle, var(--gen2-primary), transparent); }

.gen-band[data-gen="3"] {
  background: linear-gradient(135deg, #f0fdf4 0%, #d1fae5 100%);
  border-color: #a7f3d0;
}
.gen-band[data-gen="3"]::before { background: radial-gradient(circle, var(--gen3-primary), transparent); }

.gen-band[data-gen="4"] {
  background: linear-gradient(135deg, #faf5ff 0%, #ede9fe 100%);
  border-color: #ddd6fe;
}
.gen-band[data-gen="4"]::before { background: radial-gradient(circle, var(--gen4-primary), transparent); }

.gen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.gen-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.gen-badge i {
  width: 14px;
  height: 14px;
}

.gen-band[data-gen="1"] .gen-badge { background: var(--gen1-soft); color: var(--gen1-primary); }
.gen-band[data-gen="2"] .gen-badge { background: var(--gen2-soft); color: var(--gen2-primary); }
.gen-band[data-gen="3"] .gen-badge { background: var(--gen3-soft); color: var(--gen3-primary); }
.gen-band[data-gen="4"] .gen-badge { background: var(--gen4-soft); color: var(--gen4-primary); }

.gen-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  flex: 1;
  position: relative;
  z-index: 1;
}

.gen-band[data-gen="1"] .gen-title { color: var(--gen1-ink); }
.gen-band[data-gen="2"] .gen-title { color: var(--gen2-ink); }
.gen-band[data-gen="3"] .gen-title { color: var(--gen3-ink); }
.gen-band[data-gen="4"] .gen-title { color: var(--gen4-ink); }

.gen-count {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

/* ===== Horizontal Scroll Container ===== */
.scroll-container {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 0 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
  z-index: 1;
}

.scroll-container::-webkit-scrollbar { display: none; }

/* ===== Person Card (Horizontal) ===== */
.person-card {
  flex: 0 0 auto;
  width: 160px;
  background: #fff;
  border-radius: 24px;
  padding: 16px 14px 14px;
  border: 2px solid transparent;
  box-shadow: 0 4px 16px rgba(15, 41, 30, 0.06);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  scroll-snap-align: start;
}

.person-card:active { transform: scale(0.96); }
.person-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15, 41, 30, 0.1); }

.gen-band[data-gen="1"] .person-card { border-color: #fde68a; }
.gen-band[data-gen="1"] .person-card.active { border-color: var(--gen1-primary); box-shadow: 0 0 0 4px var(--gen1-glow), 0 8px 24px rgba(217,119,6,0.15); }

.gen-band[data-gen="2"] .person-card { border-color: #bfdbfe; }
.gen-band[data-gen="2"] .person-card.active { border-color: var(--gen2-primary); box-shadow: 0 0 0 4px var(--gen2-glow), 0 8px 24px rgba(37,99,235,0.15); }

.gen-band[data-gen="3"] .person-card { border-color: #a7f3d0; }
.gen-band[data-gen="3"] .person-card.active { border-color: var(--gen3-primary); box-shadow: 0 0 0 4px var(--gen3-glow), 0 8px 24px rgba(5,150,105,0.15); }

.gen-band[data-gen="4"] .person-card { border-color: #ddd6fe; }
.gen-band[data-gen="4"] .person-card.active { border-color: var(--gen4-primary); box-shadow: 0 0 0 4px var(--gen4-glow), 0 8px 24px rgba(124,58,237,0.15); }

.card-avatar {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
  margin-bottom: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  position: relative;
  flex-shrink: 0;
}

.card-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  z-index: 1;
}

.card-avatar-fallback {
  position: relative;
  z-index: 0;
}

.card-avatar .spouse-indicator {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid;
  display: grid;
  place-items: center;
}

.card-avatar .spouse-indicator i {
  width: 10px;
  height: 10px;
}

.gen-band[data-gen="1"] .card-avatar .spouse-indicator { border-color: var(--gen1-primary); color: var(--gen1-primary); }
.gen-band[data-gen="2"] .card-avatar .spouse-indicator { border-color: var(--gen2-primary); color: var(--gen2-primary); }
.gen-band[data-gen="3"] .card-avatar .spouse-indicator { border-color: var(--gen3-primary); color: var(--gen3-primary); }
.gen-band[data-gen="4"] .card-avatar .spouse-indicator { border-color: var(--gen4-primary); color: var(--gen4-primary); }

.card-name {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 3px;
  color: var(--ink);
}

.card-role {
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.gen-band[data-gen="1"] .card-role { color: var(--gen1-primary); }
.gen-band[data-gen="2"] .card-role { color: var(--gen2-primary); }
.gen-band[data-gen="3"] .card-role { color: var(--gen3-primary); }
.gen-band[data-gen="4"] .card-role { color: var(--gen4-primary); }

.card-dates {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 10px;
}

.card-actions {
  display: flex;
  gap: 6px;
  width: 100%;
}

.card-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 10px;
  padding: 7px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  font-family: inherit;
  color: var(--ink);
}

.card-btn:active { transform: scale(0.95); }
.card-btn i { width: 12px; height: 12px; }

.gen-band[data-gen="1"] .card-btn { border-color: #fde68a; }
.gen-band[data-gen="1"] .card-btn:hover { background: var(--gen1-soft); }
.gen-band[data-gen="2"] .card-btn { border-color: #bfdbfe; }
.gen-band[data-gen="2"] .card-btn:hover { background: var(--gen2-soft); }
.gen-band[data-gen="3"] .card-btn { border-color: #a7f3d0; }
.gen-band[data-gen="3"] .card-btn:hover { background: var(--gen3-soft); }
.gen-band[data-gen="4"] .card-btn { border-color: #ddd6fe; }
.gen-band[data-gen="4"] .card-btn:hover { background: var(--gen4-soft); }

/* ===== Connector between generations ===== */
.gen-connector {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 40px;
  position: relative;
  margin: -8px 0;
  z-index: 0;
}

.gen-connector-line {
  width: 2px;
  height: 100%;
  background: linear-gradient(to bottom, var(--line), var(--green-bright));
  position: relative;
}

.gen-connector-line::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-bright);
  box-shadow: 0 0 0 3px var(--green-glow);
}

/* ===== Tree Legacy (for compatibility) ===== */
.tree-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tree-top {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}

.tree-top::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip.active {
  background: var(--green-soft);
  color: var(--green);
  border-color: #a7f3d0;
}

.tree-scroll {
  overflow: visible;
  margin: 0 -14px;
  padding: 4px 14px 12px;
}

.tree {
  width: 100%;
  min-width: 0;
  padding: 4px 0 6px;
}

.generation {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
  margin: 18px 0;
}

.generation.hidden { display: none; }

.generation.revealed {
  animation: reveal 0.24s ease-out;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.generation-label {
  color: #8a9890;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  line-height: 1.35;
  font-weight: 900;
}

.people-row {
  display: flex;
  gap: 18px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-inline: 4px;
  scroll-padding-inline: 50%;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.people-row::-webkit-scrollbar { display: none; }

.people-row::before,
.people-row::after {
  content: "";
  flex: 0 0 max(16px, calc(50% - 84px));
}

.people-row.compact {
  justify-content: center;
  padding-inline: 16px;
  scroll-padding-inline: 16px;
}

@supports (justify-content: safe center) {
  .people-row.compact { justify-content: safe center; }
}

.people-row.compact::before,
.people-row.compact::after { display: none; }

/* Legacy person-card (for tree_preview.html) */
.person-card-legacy {
  flex: 0 0 auto;
  width: 168px;
  display: grid;
  grid-template-columns: 45px 1fr 28px;
  gap: 9px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 19px;
  padding: 10px;
  box-shadow: 0 10px 24px rgba(19, 32, 25, 0.08);
  transition: 0.18s ease;
  cursor: pointer;
  scroll-snap-align: center;
}

.person-card-legacy:hover,
.person-card-legacy.selected {
  border-color: var(--green);
  box-shadow: 0 16px 32px rgba(8, 124, 61, 0.15);
  transform: translateY(-2px);
}

.avatar {
  width: 45px;
  height: 45px;
  border-radius: 16px;
  background: var(--blue-soft);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.person-meta {
  min-width: 0;
}

.person-meta b {
  display: block;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-weight: 700;
}

.person-meta small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.expand-dot {
  width: 28px;
  height: 28px;
  border-radius: 11px;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 950;
  font-size: 1rem;
  cursor: pointer;
}

@media (max-width: 620px) {
  .generation {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .generation-label {
    padding-inline: 2px;
  }
}

/* ===== Prompt ===== */
.prompt-card {
  border: 1px solid #ead7ad;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(255, 244, 216, 0.94));
  border-radius: 28px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.prompt-card::before {
  content: "";
  position: absolute;
  top: -30px;
  right: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,158,11,0.08) 0%, transparent 70%);
}

.prompt-card .mini {
  color: #b45309;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.prompt-card h3 {
  margin: 8px 0 14px;
  font-size: 1.2rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 800;
  position: relative;
  z-index: 1;
  color: var(--ink);
}

.prompt-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  position: relative;
  z-index: 1;
}

/* ===== Memories ===== */
.memory-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 78%;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.memory-strip::-webkit-scrollbar { display: none; }

.memory-card {
  min-height: 210px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background:
    linear-gradient(to top, rgba(8, 28, 17, 0.70), rgba(8, 28, 17, 0.08)),
    linear-gradient(135deg, #b8d9c4, #457c5b);
  color: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  box-shadow: var(--shadow);
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform 0.15s ease;
  position: relative;
  overflow: hidden;
}

.memory-card:hover { transform: translateY(-2px); }

.memory-card:nth-child(2) {
  background:
    linear-gradient(to top, rgba(8, 28, 17, 0.72), rgba(8, 28, 17, 0.06)),
    linear-gradient(135deg, #b7cae9, #536d9a);
}

.memory-card:nth-child(3) {
  background:
    linear-gradient(to top, rgba(8, 28, 17, 0.72), rgba(8, 28, 17, 0.06)),
    linear-gradient(135deg, #e5c79d, #865d31);
}

.memory-card .label {
  align-self: start;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
  margin-bottom: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.memory-card .label i {
  width: 12px;
  height: 12px;
}

.memory-card h3 {
  margin: 0 0 6px;
  letter-spacing: -0.04em;
  font-size: 1.24rem;
  font-weight: 800;
}

.memory-card p {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.86rem;
  line-height: 1.42;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.memory-meta {
  display: flex;
  gap: 10px;
  font-weight: 800;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.88);
}

.memory-meta i {
  width: 14px;
  height: 14px;
}

/* ===== Activity ===== */
.activity-list {
  display: grid;
  gap: 10px;
}

.activity {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 20px;
  padding: 13px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  cursor: pointer;
}

.activity:active { transform: scale(0.98); }

.activity-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.activity-icon i {
  width: 20px;
  height: 20px;
}

.activity b {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.activity p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  font-weight: 500;
}

/* ===== Champions ===== */
.champion {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 20px;
  padding: 13px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.champion-rank {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.85rem;
}

.champion-rank.gold { background: #fef3c7; color: #d97706; }
.champion-rank.silver { background: #f3f4f6; color: #6b7280; }
.champion-rank.bronze { background: #ffedd5; color: #f97316; }

.champion-info b { font-size: 0.9rem; font-weight: 700; color: var(--ink); }
.champion-info p { margin: 2px 0 0; color: var(--muted); font-size: 0.75rem; font-weight: 600; }

.champion-points {
  background: var(--green-soft);
  color: var(--green);
  padding: 6px 12px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* ===== Feed Columns ===== */
.feed-columns {
  display: grid;
  gap: 16px;
}

/* ===== Bottom Nav (Floating) ===== */
.bottom-nav-wrapper {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 0 16px calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
}

.bottom-nav {
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid rgba(209, 240, 219, 0.7);
  border-radius: 28px;
  box-shadow: 0 12px 40px rgba(15, 41, 30, 0.15), 0 0 0 1px rgba(255,255,255,0.5) inset;
  max-width: 420px;
  margin: 0 auto;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.bottom-nav a,
.bottom-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0;
  border-radius: 18px;
  font-size: 0.65rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  font-family: inherit;
}

.bottom-nav a.active,
.bottom-nav button.active {
  background: var(--green-soft);
  color: var(--green);
}

.bottom-nav a i,
.bottom-nav button i {
  width: 22px;
  height: 22px;
}

.bottom-nav .add-main {
  background: linear-gradient(135deg, var(--green), var(--green-bright));
  color: #fff;
  transform: translateY(-10px);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.4);
  border: 2px solid rgba(255,255,255,0.3);
}

.bottom-nav .add-main i {
  width: 24px;
  height: 24px;
}

.bottom-nav.hidden-for-keyboard {
  transform: translateY(140%);
  opacity: 0;
  pointer-events: none;
}

/* ===== Person Drawer ===== */
.person-drawer {
  position: fixed;
  z-index: 1200;
  left: 10px;
  right: 10px;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translateY(calc(100% + 140px));
  transition: transform 0.24s ease;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 30px 30px 24px 24px;
  box-shadow: 0 -18px 60px rgba(15, 41, 30, 0.24);
  padding: 14px;
}

.person-drawer.show {
  transform: translateY(0);
}

.drawer-handle {
  width: 50px;
  height: 5px;
  border-radius: 999px;
  background: #d5ded8;
  margin: 0 auto 12px;
}

.drawer-main {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.drawer-avatar {
  width: 54px;
  height: 54px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--green);
  overflow: hidden;
}

.drawer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.drawer-main b {
  display: block;
  font-size: 1.02rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-weight: 800;
}

.drawer-main span {
  display: block;
  color: var(--muted);
  font-size: 0.81rem;
  font-weight: 600;
}

.drawer-close {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  width: 38px;
  height: 38px;
  font-weight: 900;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.drawer-close i {
  width: 16px;
  height: 16px;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ===== Bottom Sheet (New) ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(15, 41, 30, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.sheet-overlay.show { opacity: 1; pointer-events: auto; }

.detail-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1110;
  background: #fff;
  border-radius: 32px 32px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(15, 41, 30, 0.2);
  transform: translateY(110%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: 500px;
  margin: 0 auto;
}

.detail-sheet.show { transform: translateY(0); }

.sheet-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  position: relative;
}

.sheet-avatar {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: white;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  flex-shrink: 0;
  overflow: hidden;
}

.sheet-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sheet-title h3 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.sheet-title p {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 2px;
}

.sheet-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.sheet-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.sheet-action:active { transform: scale(0.95); background: var(--green-soft); }
.sheet-action i { width: 20px; height: 20px; color: var(--green); }

.sheet-section { margin-bottom: 16px; }
.sheet-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 800;
}

.sheet-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.sheet-info-row span:first-child { color: var(--muted); font-weight: 600; }
.sheet-info-row span:last-child { font-weight: 700; color: var(--ink); }

.sheet-close {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sheet-close i { width: 16px; height: 16px; }

/* ===== Global Sheet ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 41, 30, 0.35);
  z-index: 1300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.sheet-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.global-sheet {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 1310;
  transform: translateY(calc(100% + 160px));
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 30px 30px 24px 24px;
  box-shadow: 0 -18px 60px rgba(15, 41, 30, 0.24);
  padding: 14px;
  max-height: 80vh;
  overflow-y: auto;
}

.global-sheet.show {
  transform: translateY(0);
}

/* ===== Account Sheet ===== */
body.account-sheet-open {
  overflow: hidden;
}

.account-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1320;
  background: rgba(15, 41, 30, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.account-sheet-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.account-sheet {
  position: fixed;
  z-index: 1330;
  left: 10px;
  right: 10px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  max-width: 420px;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 30px 30px 24px 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -18px 60px rgba(15, 41, 30, 0.24);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(calc(100% + 150px));
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.22s ease, visibility 0.22s ease;
}

.account-sheet.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.account-sheet-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 12px;
  align-items: start;
}

.account-sheet-head p {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.account-sheet-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.18rem;
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.045em;
}

.account-sheet-head span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
  font-weight: 600;
}

.account-sheet-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 9px;
  margin-top: 14px;
}

.account-sheet-actions .btn {
  min-width: 0;
  min-height: 48px;
  border-radius: 17px;
  padding-inline: 12px;
}

.bottom-nav .add-main[aria-expanded="true"],
.side-link[aria-expanded="true"],
.icon-btn[aria-expanded="true"] {
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-bright));
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.28);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  z-index: 1400;
  left: 20px;
  right: 20px;
  top: calc(70px + env(safe-area-inset-top));
  transform: translateY(-200%);
  opacity: 0;
  visibility: hidden;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 20px;
  background: var(--ink);
  color: #fff;
  padding: 14px 18px;
  box-shadow: 0 16px 40px rgba(15, 41, 30, 0.25);
  font-weight: 700;
  font-size: 0.88rem;
  text-align: center;
  pointer-events: none;
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.toast i {
  width: 18px;
  height: 18px;
}

/* ===== Empty states ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.empty-state h1 {
  font-size: 1.5rem;
  color: var(--ink);
  margin-bottom: 8px;
  font-weight: 800;
}

.empty-state p {
  margin-bottom: 16px;
  font-weight: 500;
}

.empty-state code {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 12px;
  font-size: 0.85rem;
}

/* ===== Form / sheet compatibility ===== */
.sheet-content {
  padding-top: 4px;
}

.sheet-handle {
  width: 50px;
  height: 5px;
  border-radius: 999px;
  background: #d5ded8;
  margin: 0 auto 16px;
}

.sheet-title {
  font-size: 1.15rem;
  margin: 0 0 14px;
  color: var(--ink);
  font-weight: 800;
}

.person-form {
  display: grid;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.92rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
}

.form-actions {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

/* ===== Auth Forms ===== */
.auth-card {
  position: relative;
  max-width: 560px;
  margin: 16px auto 0;
  padding: 18px 14px;
}

.auth-card .section-head {
  margin-bottom: 16px;
}

.auth-form {
  gap: 13px;
}

.auth-field,
.auth-form > p {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
}

.auth-label,
.auth-form > p > label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.auth-field input,
.auth-form > p > input,
.auth-form > p > select,
.auth-form > p > textarea {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  border: 1px solid rgba(209, 240, 219, 0.95);
  border-radius: 18px;
  padding: 13px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 5px 18px rgba(15, 41, 30, 0.05);
  font-size: 1rem;
  font-weight: 700;
  outline: 0;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.auth-field input:focus,
.auth-form > p > input:focus,
.auth-form > p > select:focus,
.auth-form > p > textarea:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.13), 0 8px 24px rgba(15, 41, 30, 0.08);
}

.auth-field input::placeholder,
.auth-form > p > input::placeholder {
  color: rgba(90, 122, 107, 0.66);
}

.auth-field input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  box-shadow: 0 0 0 1000px #fff inset;
}

.auth-field small,
.auth-form .helptext {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  font-weight: 650;
}

.auth-field small ul,
.auth-form .helptext ul {
  display: grid;
  gap: 4px;
  margin: 4px 0 0;
  padding-left: 18px;
}

.auth-field em,
.auth-form .errorlist {
  color: #9a3412;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
}

.auth-form .errorlist {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.auth-form .form-errors,
.form-errors {
  border: 1px solid rgba(217, 119, 6, 0.24);
  border-radius: 18px;
  padding: 11px 12px;
  color: #78350f;
  background: #fef3c7;
  font-size: 0.84rem;
  font-weight: 800;
}

.auth-form input[type="hidden"] {
  display: none;
}

.auth-form .form-actions {
  margin-top: 2px;
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

/* ===== Story / Activity / Comment / Reaction cards ===== */
.section {
  margin-bottom: 14px;
}

.story-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  transition: transform 0.15s ease;
}

.story-card:active { transform: scale(0.98); }

.story-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.story-card-title {
  font-size: 1.05rem;
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.story-featured-badge {
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.story-featured-badge i {
  width: 10px;
  height: 10px;
}

.story-card-excerpt {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0 0 10px;
  font-weight: 500;
}

.story-card-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 12px;
  font-weight: 600;
}

.activity-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
  transition: transform 0.15s ease;
  cursor: pointer;
}

.activity-card:active { transform: scale(0.98); }

.activity-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: var(--green-soft);
  color: var(--green);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  overflow: hidden;
  flex-shrink: 0;
}

.activity-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.activity-card-message {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink);
  font-weight: 700;
}

.activity-card-time {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
  font-weight: 500;
}

.activity-card-badge {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: var(--blue-soft);
  display: grid;
  place-items: center;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}

.activity-card-badge i {
  width: 16px;
  height: 16px;
}

.reaction-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.react-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.react-btn:active { transform: scale(0.95); }

.react-btn.active {
  background: var(--green-soft);
  color: var(--green);
  border-color: #a7f3d0;
}

.comment-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.comment-heading {
  font-size: 0.9rem;
  margin: 0 0 10px;
  color: var(--ink);
  font-weight: 800;
}

.comment-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: var(--purple-soft);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  flex-shrink: 0;
}

.comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.comment-text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink);
  font-weight: 500;
}

.comment-time {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 500;
}

.comment-empty {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 10px;
  font-weight: 500;
}

.comment-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.comment-input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
}

.comment-input:focus {
  outline: none;
  border-color: var(--green);
}

.btn-sm {
  padding: 9px 12px;
  font-size: 0.82rem;
}

/* ===== Memory card inner ===== */
.memory-card-inner {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  align-items: center;
}

.memory-thumb-large {
  width: 100px;
  height: 100px;
  border-radius: 18px;
  background: linear-gradient(135deg, #40916c, #52b788);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.8rem;
  text-align: center;
  padding: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.memory-thumb-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.memory-thumb-placeholder {
  background: var(--green-soft);
  color: var(--green);
}

.memory-card-info {
  min-width: 0;
}

/* ===== Prompt answers ===== */
.prompt-question {
  margin: 8px 0 14px;
  font-size: 1.32rem;
  line-height: 1.2;
  letter-spacing: -0.04em;
  color: var(--ink);
  font-weight: 800;
}

.prompt-answers {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.prompt-answer-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  border: 1px solid rgba(152, 113, 42, 0.12);
}

.prompt-answer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--green);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  overflow: hidden;
  flex-shrink: 0;
}

.prompt-answer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.prompt-answer-text {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
  font-weight: 500;
}

.prompt-answer-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
  font-weight: 500;
}

/* ===== Empty card ===== */
.empty-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  color: var(--muted);
}

.empty-card-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.empty-card p {
  margin: 0;
  line-height: 1.5;
  font-weight: 500;
}

/* ===== Legend ===== */
.tree-legend {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 0 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ===== Animations ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeUp 0.5s ease forwards;
  opacity: 0;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

/* ===== Tablet ===== */
@media (min-width: 760px) {
  .today-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .memory-strip {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-flow: initial;
    grid-auto-columns: initial;
    overflow: visible;
  }

  .feed-columns {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 16px;
  }

  .bottom-nav-wrapper {
    padding: 0 24px calc(12px + env(safe-area-inset-bottom));
  }

  .bottom-nav {
    max-width: 460px;
  }

  .person-drawer {
    left: auto;
    right: 20px;
    width: 380px;
    bottom: 120px;
  }

  .global-sheet {
    left: auto;
    right: 20px;
    width: 420px;
  }

  .account-sheet {
    left: auto;
    right: 20px;
    bottom: 104px;
    width: 420px;
    margin: 0;
  }

  .detail-sheet {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(110%);
  }

  .detail-sheet.show {
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== Desktop ===== */
@media (min-width: 1040px) {
  .app-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 16px;
  }

  .app-main {
    min-width: 0;
  }

  .page {
    padding: 20px 0;
  }

  .bottom-nav-wrapper {
    display: none;
  }

  .sticky-header {
    position: static;
    border-radius: 24px;
    margin-bottom: 12px;
    border: 1px solid rgba(209, 240, 219, 0.6);
  }

  .desktop-side {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-top: 8px;
  }

  .desktop-panel {
    display: none;
  }

  .desk-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--ink);
    padding-left: 6px;
  }

  .desk-logo i {
    width: 24px;
    height: 24px;
    color: var(--green);
  }

  .side-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 8px;
    padding-left: 10px;
  }

  .side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 14px;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    transition: background 0.15s;
  }

  .side-link:hover {
    background: rgba(255, 255, 255, 0.6);
  }

  .side-link.active {
    background: var(--green-soft);
    color: var(--green);
  }

  .side-link i {
    width: 18px;
    height: 18px;
  }

  .side-memory {
    margin-top: auto;
    padding: 14px;
    border-radius: 20px;
    background: var(--gen1-soft);
    border: 1px solid #fde68a;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--ink);
  }

  .side-memory b {
    display: block;
    margin-bottom: 4px;
    font-size: 0.9rem;
  }

  .person-drawer {
    left: auto;
    right: 40px;
    width: 380px;
  }

  .global-sheet {
    left: auto;
    right: 40px;
    width: 420px;
  }

  .account-sheet {
    right: 40px;
    bottom: 40px;
  }
}

@media (min-width: 1200px) {
  .app-shell {
    grid-template-columns: 220px 1fr 260px;
  }

  .desktop-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 8px;
  }

  .desktop-search {
    padding: 12px 14px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.88rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .desktop-search i {
    width: 16px;
    height: 16px;
  }

  .profile-panel {
    padding: 18px;
    border-radius: 24px;
    background: #fff;
    border: 1px solid var(--line);
    text-align: center;
    box-shadow: var(--shadow-sm);
  }

  .profile-big {
    width: 72px;
    height: 72px;
    border-radius: 24px;
    background: var(--green-soft);
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--green);
    margin: 0 auto 10px;
    overflow: hidden;
  }

  .profile-big img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .profile-panel h3 {
    font-size: 1.05rem;
    margin-bottom: 2px;
    font-weight: 800;
  }

  .profile-panel p {
    color: var(--green);
    font-weight: 700;
    font-size: 0.82rem;
    margin-bottom: 12px;
  }

  .widget {
    padding: 16px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
  }

  .widget h3 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    font-weight: 800;
  }

  .widget p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
    font-weight: 500;
  }

  .widget strong {
    color: var(--green);
  }
}

@media (max-width: 390px) {
  .brand-text span {
    max-width: 160px;
  }

  .bottom-nav-wrapper {
    padding: 0 10px calc(12px + env(safe-area-inset-bottom));
  }

  .person-card {
    width: 140px;
    padding: 12px 10px 10px;
  }

  .card-avatar {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    font-size: 1.1rem;
  }
}

/* ===== Uploaded media support ===== */
.avatar,
.person-card-avatar,
.drawer-avatar,
.activity-card-avatar,
.memory-thumb-large,
.card-avatar,
.sheet-avatar,
.profile-big,
.comment-avatar,
.prompt-answer-avatar {
  overflow: hidden;
}

.avatar img,
.person-card-avatar img,
.drawer-avatar img,
.activity-card-avatar img,
.memory-thumb-large.has-image img,
.card-avatar img,
.sheet-avatar img,
.profile-big img,
.comment-avatar img,
.prompt-answer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.memory-card.has-image {
  position: relative;
  overflow: hidden;
}

.memory-card.has-image > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.memory-card.has-image::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(8, 28, 17, 0.72), rgba(8, 28, 17, 0.12));
  z-index: 1;
  pointer-events: none;
}

.memory-card.has-image > *:not(img) {
  position: relative;
  z-index: 2;
}

.memory-thumb-large.has-image {
  padding: 0;
  background: #fff;
}
