/* ================================================
   Design System — Arsip Silsilah Keluarga & Kucing
   Dark Warm Theme | v1.0
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Inter:wght@300;400;500;600;700&display=swap');

/* ================================================
   CSS Custom Properties
   ================================================ */
:root {
  /* === Color Palette === */
  --color-bg:         #0f0d0b;
  --color-surface:    #1c1814;
  --color-surface-2:  #272019;
  --color-surface-3:  #332a1d;
  --color-border:     #3a2f22;
  --color-border-2:   #4a3d2c;

  /* Amber — Family theme */
  --color-amber:        #f59e0b;
  --color-amber-dark:   #d97706;
  --color-amber-light:  #fcd34d;
  --color-amber-glow:   rgba(245, 158, 11, 0.12);
  --color-amber-glow-2: rgba(245, 158, 11, 0.25);

  /* Rose — Cats / Memorial */
  --color-rose:        #f43f5e;
  --color-rose-dark:   #e11d48;
  --color-rose-light:  #fb7185;
  --color-rose-glow:   rgba(244, 63, 94, 0.12);
  --color-rose-glow-2: rgba(244, 63, 94, 0.25);

  /* Emerald — Active / Health */
  --color-green:      #10b981;
  --color-green-dark: #059669;
  --color-green-glow: rgba(16, 185, 129, 0.12);

  /* Blue — Info */
  --color-blue:      #3b82f6;
  --color-blue-glow: rgba(59, 130, 246, 0.12);

  /* Purple — Moved */
  --color-purple:      #8b5cf6;
  --color-purple-glow: rgba(139, 92, 246, 0.12);

  /* Text */
  --color-text:           #f5f0e8;
  --color-text-secondary: #c4b49e;
  --color-muted:          #8a7a68;
  --color-muted-2:        #5a4d3e;

  /* === Spacing === */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* === Border Radius === */
  --radius-sm:   0.375rem;
  --radius:      0.75rem;
  --radius-lg:   1rem;
  --radius-xl:   1.5rem;
  --radius-2xl:  2rem;
  --radius-full: 9999px;

  /* === Shadows === */
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.4);
  --shadow:       0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:    0 12px 48px rgba(0,0,0,0.6);
  --shadow-amber: 0 4px 24px rgba(245, 158, 11, 0.25);
  --shadow-rose:  0 4px 24px rgba(244, 63, 94, 0.25);

  /* === Layout === */
  --sidebar-width:      260px;
  --bottom-nav-height:  70px;

  /* === Transitions === */
  --t:      180ms ease;
  --t-slow: 350ms ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: 'Playfair Display', serif;
  line-height: 1.25;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ================================================
   App Layout
   ================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--sp-8);
  min-height: 100vh;
  animation: fadeIn 0.3s ease;
}

/* Wrapper div variant (flex column with top-bar + content + bottom-nav) */
.app-main-wrap {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--t-slow);
}

/* ================================================
   Sidebar
   ================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform var(--t-slow);
}

.sidebar-header {
  padding: var(--sp-6) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--color-amber);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  line-height: 1.3;
}

.sidebar-logo .logo-emoji {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.sidebar-logo .logo-sub {
  font-size: 0.6875rem;
  color: var(--color-muted);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  display: block;
  margin-top: 1px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--color-amber-glow-2);
  border: 2px solid var(--color-amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-amber);
  flex-shrink: 0;
}

.sidebar-user-name { font-size: 0.875rem; font-weight: 600; color: var(--color-text); }
.sidebar-user-role { font-size: 0.6875rem; color: var(--color-muted); }

.sidebar-nav {
  flex: 1;
  padding: var(--sp-4) var(--sp-3);
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted-2);
  padding: var(--sp-5) var(--sp-3) var(--sp-2);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius);
  color: var(--color-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--t), color var(--t);
  margin-bottom: 2px;
  position: relative;
}

.sidebar-nav a:hover {
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
}

.sidebar-nav a.active {
  background: var(--color-amber-glow);
  color: var(--color-amber);
  font-weight: 600;
}

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--color-amber);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-icon {
  font-size: 1.125rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--color-border);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  backdrop-filter: blur(2px);
}

/* ================================================
   Top Bar (Mobile)
   ================================================ */
.top-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.top-bar-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-amber);
}

/* ================================================
   Bottom Navigation (Mobile)
   ================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(28, 24, 20, 0.97);
  border-top: 1px solid var(--color-border);
  z-index: 100;
  backdrop-filter: blur(16px);
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  padding: 0 var(--sp-2);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--color-muted);
  font-size: 0.625rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--t);
  flex: 1;
  padding: var(--sp-2) var(--sp-1);
}

.bottom-nav-item .nav-icon {
  font-size: 1.375rem;
  transition: transform var(--t);
}

.bottom-nav-item.active {
  color: var(--color-amber);
}

.bottom-nav-item.active .nav-icon {
  transform: translateY(-2px);
}

/* ================================================
   Cards
   ================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
}

.card:hover {
  border-color: var(--color-border-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-link:hover .card {
  border-color: var(--color-amber);
  box-shadow: var(--shadow-amber);
}

.card-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: var(--sp-4);
  background: var(--color-surface-2);
}

/* ================================================
   Cat Cards
   ================================================ */
.cat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
  cursor: pointer;
}

.cat-card:hover {
  border-color: var(--color-amber);
  transform: translateY(-3px);
  box-shadow: var(--shadow-amber);
}

.cat-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}

.cat-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cat-card-body {
  padding: var(--sp-4);
}

.cat-card.memorial {
  border-color: var(--color-rose);
}

.cat-card.memorial:hover {
  box-shadow: var(--shadow-rose);
}

/* ================================================
   Buttons
   ================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--t), transform var(--t), box-shadow var(--t), color var(--t);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--color-amber);
  color: #1a1000;
}
.btn-primary:hover {
  background: var(--color-amber-light);
  box-shadow: var(--shadow-amber);
}

.btn-rose {
  background: var(--color-rose-glow-2);
  color: var(--color-rose-light);
  border: 1px solid rgba(244, 63, 94, 0.4);
}
.btn-rose:hover {
  background: var(--color-rose);
  color: white;
}

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-3); }

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-rose-glow);
  color: var(--color-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
  background: var(--color-rose);
  color: white;
}

.btn-sm { padding: var(--sp-2) var(--sp-3); font-size: 0.8125rem; }
.btn-lg { padding: var(--sp-4) var(--sp-8); font-size: 1rem; }

.btn-icon {
  padding: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  justify-content: center;
  font-size: 1.125rem;
}

.btn-icon-sm {
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  justify-content: center;
  font-size: 0.875rem;
}

/* ================================================
   Badges
   ================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before { content: '●'; font-size: 0.5rem; }

.badge-green  { background: var(--color-green-glow); color: var(--color-green); border: 1px solid rgba(16,185,129,0.25); }
.badge-rose   { background: var(--color-rose-glow);  color: var(--color-rose);  border: 1px solid rgba(244,63,94,0.25); }
.badge-amber  { background: var(--color-amber-glow); color: var(--color-amber); border: 1px solid rgba(245,158,11,0.25); }
.badge-purple { background: var(--color-purple-glow);color: var(--color-purple);border: 1px solid rgba(139,92,246,0.25); }
.badge-muted  { background: rgba(58,47,34,0.5); color: var(--color-muted); border: 1px solid var(--color-border); }

/* ================================================
   Forms
   ================================================ */
.form-group { margin-bottom: var(--sp-5); }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--sp-2);
}

.form-label .required {
  color: var(--color-rose);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 0.9375rem;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-amber);
  box-shadow: 0 0 0 3px var(--color-amber-glow);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--color-muted-2); }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a7a68' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-hint  { font-size: 0.8125rem; color: var(--color-muted); margin-top: var(--sp-1); }
.form-error { font-size: 0.8125rem; color: var(--color-rose); margin-top: var(--sp-1); display: none; }
.form-group.has-error .form-error { display: block; }
.form-group.has-error .form-input,
.form-group.has-error .form-select { border-color: var(--color-rose); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-10) var(--sp-8);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--color-amber);
  background: var(--color-amber-glow);
}

.upload-icon { font-size: 2.5rem; margin-bottom: var(--sp-3); }
.upload-text { color: var(--color-muted); font-size: 0.875rem; }
.upload-text strong { color: var(--color-amber); }

/* Form Sections */
.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
}

.form-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ================================================
   Tabs
   ================================================ */
.tabs-wrapper {
  display: flex;
  gap: var(--sp-1);
  background: var(--color-surface-2);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: var(--sp-6);
}

.tab-btn {
  flex: 1;
  padding: var(--sp-2) var(--sp-4);
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--t), color var(--t), box-shadow var(--t);
  text-align: center;
}

.tab-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.tab-btn:hover:not(.active) { color: var(--color-text-secondary); }

.tab-pane { display: none; animation: fadeIn 0.2s ease; }
.tab-pane.active { display: block; }

/* ================================================
   Grids
   ================================================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
.grid-cats    { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--sp-5); }
.grid-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--sp-3); }
.grid-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-4); }

/* ================================================
   Page Header
   ================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-8);
  gap: var(--sp-4);
}

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--sp-1);
}

.page-subtitle { color: var(--color-muted); font-size: 0.9375rem; }

.page-actions {
  display: flex;
  gap: var(--sp-3);
  flex-shrink: 0;
  align-items: center;
}

/* ================================================
   Stat Cards
   ================================================ */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  transition: transform var(--t), box-shadow var(--t);
}

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

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon-amber  { background: var(--color-amber-glow-2); }
.stat-icon-rose   { background: var(--color-rose-glow-2); }
.stat-icon-green  { background: var(--color-green-glow); }
.stat-icon-purple { background: var(--color-purple-glow); }
.stat-icon-blue   { background: var(--color-blue-glow); }

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  line-height: 1;
}

.stat-label { font-size: 0.8125rem; color: var(--color-muted); margin-top: 4px; }

/* ================================================
   Profile Hero
   ================================================ */
.profile-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: var(--sp-6);
}

.profile-banner {
  height: 180px;
  background: linear-gradient(135deg, #1e1608 0%, #2d1f0e 40%, #1a1208 100%);
  position: relative;
  overflow: hidden;
}

.profile-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 40px,
    rgba(245,158,11,0.03) 40px,
    rgba(245,158,11,0.03) 80px
  );
}

.profile-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-body {
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
  position: relative;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  border: 4px solid var(--color-surface);
  object-fit: cover;
  position: absolute;
  top: -50px;
  left: var(--sp-6);
  background: var(--color-surface-2);
  box-shadow: var(--shadow);
}

.profile-avatar-placeholder {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  border: 4px solid var(--color-surface);
  background: var(--color-surface-2);
  position: absolute;
  top: -50px;
  left: var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  box-shadow: var(--shadow);
}

.profile-info-row {
  padding-top: 58px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

.profile-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.profile-nickname {
  color: var(--color-muted);
  font-size: 0.9375rem;
  margin-top: 2px;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-3);
}

.profile-meta-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

/* ================================================
   Info Grid (key-value)
   ================================================ */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

.info-item {
  padding: var(--sp-4);
  background: var(--color-surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.info-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin-bottom: var(--sp-1);
}

.info-value {
  font-size: 0.9375rem;
  color: var(--color-text);
  font-weight: 500;
}

/* ================================================
   Timeline
   ================================================ */
.timeline {
  position: relative;
  padding-left: var(--sp-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--color-amber), var(--color-border));
  border-radius: var(--radius-full);
}

.timeline-item {
  position: relative;
  margin-bottom: var(--sp-5);
  animation: fadeIn 0.3s ease both;
}

.timeline-dot {
  position: absolute;
  left: calc(-32px + 5px);
  top: 6px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--color-amber);
  border: 3px solid var(--color-bg);
  z-index: 1;
  box-shadow: 0 0 0 2px var(--color-amber-glow-2);
}

.timeline-dot.rose {
  background: var(--color-rose);
  box-shadow: 0 0 0 2px var(--color-rose-glow-2);
}

.timeline-date {
  font-size: 0.8125rem;
  color: var(--color-amber);
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.timeline-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-4);
}

.timeline-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--color-text);
  margin-bottom: var(--sp-1);
}

.timeline-desc {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

/* ================================================
   Photo Gallery
   ================================================ */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-3);
}

.photo-item {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--color-surface-2);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}

.photo-item:hover img { transform: scale(1.06); }

.photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  transition: background var(--t);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  opacity: 0;
}

.photo-item:hover .photo-overlay {
  background: rgba(0,0,0,0.45);
  opacity: 1;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8);
  animation: fadeIn 0.2s ease;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: var(--sp-5);
  right: var(--sp-5);
}

.lightbox-caption {
  position: absolute;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  background: rgba(0,0,0,0.6);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-full);
}

/* ================================================
   Data Table
   ================================================ */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: background var(--t);
}

.data-table tbody tr:hover td { background: var(--color-surface-2); }

/* ================================================
   Section Headings
   ================================================ */
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.section-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--sp-6) 0;
}

/* ================================================
   Relation Chips
   ================================================ */
.relation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.relation-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  text-decoration: none;
  color: var(--color-text-secondary);
  transition: border-color var(--t), color var(--t), background var(--t);
}

.relation-chip:hover {
  border-color: var(--color-amber);
  color: var(--color-amber);
  background: var(--color-amber-glow);
}

.relation-chip-label {
  font-size: 0.6875rem;
  color: var(--color-muted);
}

.relation-chip-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--color-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

/* ================================================
   Filter Bar
   ================================================ */
.filter-bar {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.filter-btn.active {
  background: var(--color-amber);
  color: #1a1000;
  border-color: var(--color-amber);
  font-weight: 700;
}

.filter-btn:hover:not(.active) {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.filter-count {
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  font-size: 0.6875rem;
}

.filter-btn.active .filter-count {
  background: rgba(0,0,0,0.15);
}

/* Search */
.search-wrapper { position: relative; }

.search-icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  font-size: 1rem;
  pointer-events: none;
}

.search-input { padding-left: 2.5rem; }

/* ================================================
   Progress Bar
   ================================================ */
.progress-track {
  height: 8px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-amber-dark), var(--color-amber-light));
  transition: width 0.6s ease;
}

.progress-fill.danger { background: linear-gradient(90deg, var(--color-rose-dark), var(--color-rose-light)); }
.progress-fill.green  { background: linear-gradient(90deg, var(--color-green-dark), var(--color-green)); }

/* ================================================
   Alert / Notice
   ================================================ */
.alert {
  padding: var(--sp-4);
  border-radius: var(--radius);
  font-size: 0.875rem;
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}

.alert-amber {
  background: var(--color-amber-glow);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--color-text-secondary);
}

.alert-rose {
  background: var(--color-rose-glow);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--color-text-secondary);
}

.alert-green {
  background: var(--color-green-glow);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--color-text-secondary);
}

/* ================================================
   Memorial Page
   ================================================ */
.memorial-page {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #200a0a 0%, var(--color-bg) 65%);
}

.memorial-hero {
  text-align: center;
  padding: var(--sp-16) var(--sp-8) var(--sp-12);
  position: relative;
  overflow: hidden;
}

.memorial-photo {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-full);
  object-fit: cover;
  filter: sepia(40%) grayscale(20%);
  border: 5px solid var(--color-rose);
  box-shadow: 0 0 60px rgba(244, 63, 94, 0.3), var(--shadow-lg);
  margin: 0 auto var(--sp-6);
}

.memorial-photo-placeholder {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 5px solid var(--color-rose);
  box-shadow: 0 0 60px rgba(244, 63, 94, 0.3), var(--shadow-lg);
  margin: 0 auto var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  filter: grayscale(30%);
}

.memorial-name {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-rose-light);
  font-family: 'Playfair Display', serif;
  font-style: italic;
}

.memorial-dates {
  color: var(--color-muted);
  font-size: 1rem;
  margin: var(--sp-2) 0 var(--sp-5);
  letter-spacing: 0.05em;
}

.memorial-epitaph {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.8;
}

/* Falling petals */
@keyframes petalFall {
  0%   { transform: translateY(-50px) rotate(0deg);   opacity: 0; }
  10%  { opacity: 0.7; }
  90%  { opacity: 0.4; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

.petal {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  animation: petalFall linear infinite;
}

/* ================================================
   Login Page
   ================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.login-bg-circle {
  position: absolute;
  border-radius: var(--radius-full);
  background: var(--color-amber-glow);
  filter: blur(80px);
}

.login-bg-circle-2 {
  background: var(--color-rose-glow);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--sp-10) var(--sp-8);
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.5s ease;
}

.login-logo {
  text-align: center;
  margin-bottom: var(--sp-8);
}

.login-logo-emoji {
  font-size: 3.5rem;
  display: block;
  margin-bottom: var(--sp-3);
}

.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--color-text);
}

.login-subtitle {
  color: var(--color-muted);
  font-size: 0.875rem;
  margin-top: var(--sp-1);
}

/* ================================================
   Birthday / Upcoming Events
   ================================================ */
.birthday-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  transition: border-color var(--t);
}

.birthday-card:hover { border-color: var(--color-amber); }

.birthday-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--color-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.birthday-name { font-size: 0.9375rem; font-weight: 600; color: var(--color-text); }
.birthday-date { font-size: 0.8125rem; color: var(--color-amber); }
.birthday-days { font-size: 0.75rem; color: var(--color-muted); margin-top: 1px; }

/* ================================================
   Family Tree Container
   ================================================ */
#tree-container {
  width: 100%;
  height: calc(100vh - 200px);
  min-height: 500px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  cursor: grab;
}

#tree-container:active { cursor: grabbing; }

#tree-svg {
  width: 100%;
  height: 100%;
}

.tree-controls {
  position: absolute;
  bottom: var(--sp-5);
  right: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 10;
}

.tree-legend {
  position: absolute;
  top: var(--sp-5);
  left: var(--sp-5);
  background: rgba(28, 24, 20, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.75rem;
  z-index: 10;
}

.tree-legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.tree-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Tree node panel */
.tree-node-panel {
  position: absolute;
  top: var(--sp-5);
  right: var(--sp-5);
  width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-amber);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  z-index: 20;
  box-shadow: var(--shadow-amber);
  animation: slideInRight 0.2s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ================================================
   Empty State
   ================================================ */
.empty-state {
  text-align: center;
  padding: var(--sp-16) var(--sp-8);
  color: var(--color-muted);
}

.empty-state-icon { font-size: 3.5rem; margin-bottom: var(--sp-4); opacity: 0.4; }
.empty-state-title { font-size: 1.125rem; font-weight: 600; color: var(--color-text-secondary); margin-bottom: var(--sp-2); }
.empty-state-desc  { font-size: 0.875rem; margin-bottom: var(--sp-5); }

/* ================================================
   User Row (Settings)
   ================================================ */
.user-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  margin-bottom: var(--sp-3);
}

.user-row-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-amber-glow-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--color-amber);
  flex-shrink: 0;
  font-size: 1rem;
}

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.animate-fade { animation: fadeIn 0.3s ease both; }
.animate-scale { animation: scaleIn 0.3s ease both; }

/* Stagger */
.stagger > * { animation: fadeIn 0.35s ease both; }
.stagger > *:nth-child(1)  { animation-delay: 0ms;   }
.stagger > *:nth-child(2)  { animation-delay: 60ms;  }
.stagger > *:nth-child(3)  { animation-delay: 120ms; }
.stagger > *:nth-child(4)  { animation-delay: 180ms; }
.stagger > *:nth-child(5)  { animation-delay: 240ms; }
.stagger > *:nth-child(6)  { animation-delay: 300ms; }
.stagger > *:nth-child(7)  { animation-delay: 360ms; }
.stagger > *:nth-child(8)  { animation-delay: 420ms; }

/* ================================================
   Utility Classes
   ================================================ */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-1  { gap: var(--sp-1); }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.gap-5  { gap: var(--sp-5); }
.gap-6  { gap: var(--sp-6); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.flex-shrink-0 { flex-shrink: 0; }

.text-amber   { color: var(--color-amber); }
.text-rose    { color: var(--color-rose); }
.text-green   { color: var(--color-green); }
.text-muted   { color: var(--color-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-xs  { font-size: 0.75rem; }
.text-sm  { font-size: 0.875rem; }
.text-lg  { font-size: 1.125rem; }
.text-xl  { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-serif  { font-family: 'Playfair Display', serif; }
.font-bold   { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.italic { font-style: italic; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-w-0 { min-width: 0; }

.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }

.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }

.p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); }
.p-6 { padding: var(--sp-6); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.py-3 { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }

.rounded    { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.hidden   { display: none !important; }
.invisible { visibility: hidden; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }

.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--sp-6) 0;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cursor-pointer { cursor: pointer; }

/* ================================================
   Responsive
   ================================================ */

/* ── Tablet & below (sidebar hides) ── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.visible { display: block; }

  /* Main content: no left margin, space for bottom nav */
  .main-content,
  .app-main-wrap {
    margin-left: 0 !important;
  }

  .main-content {
    padding: var(--sp-5);
    padding-bottom: calc(var(--bottom-nav-height) + var(--sp-5) + env(safe-area-inset-bottom, 0px));
  }

  .top-bar     { display: flex; }
  .bottom-nav  { display: block; }

  /* Bottom nav accounts for iOS home indicator */
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  /* Stat cards: smaller icon on tablet */
  .stat-value { font-size: 1.5rem; }

  /* Profile: shrink avatar */
  .profile-avatar,
  .profile-avatar-placeholder {
    width: 80px;
    height: 80px;
    top: -40px;
  }
  .profile-body { padding-top: var(--sp-4); }
  .profile-info-row { padding-top: 48px; }
}

/* ── Small tablet & large mobile ── */
@media (max-width: 768px) {
  .form-row    { grid-template-columns: 1fr; }
  .info-grid   { grid-template-columns: 1fr; }
  .profile-info-row { flex-direction: column; align-items: flex-start; }

  /* Tabs: allow scrolling horizontally on small screens */
  .tabs-wrapper {
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .tabs-wrapper::-webkit-scrollbar { display: none; }
  .tab-btn { flex-shrink: 0; padding: var(--sp-2) var(--sp-3); font-size: 0.8125rem; }

  /* Cat grid: 2 columns on tablet */
  .grid-cats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .main-content {
    padding: var(--sp-4) var(--sp-3);
    padding-bottom: calc(var(--bottom-nav-height) + var(--sp-4) + env(safe-area-inset-bottom, 0px));
  }

  .page-header {
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
  }
  .page-title   { font-size: 1.375rem; }
  .page-subtitle{ font-size: 0.875rem; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .page-actions .btn { flex: 1; justify-content: center; }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  /* Stat cards: horizontal compact */
  .stat-card { padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); }
  .stat-icon  { width: 42px; height: 42px; font-size: 1.25rem; }
  .stat-value { font-size: 1.375rem; }
  .stat-label { font-size: 0.75rem; }

  /* Form sections */
  .form-section { padding: var(--sp-4); }
  .upload-area  { padding: var(--sp-6) var(--sp-4); }

  /* Profile hero */
  .profile-banner { height: 120px; }
  .profile-avatar,
  .profile-avatar-placeholder {
    width: 72px;
    height: 72px;
    top: -36px;
    left: var(--sp-4);
  }
  .profile-info-row  { padding-top: 44px; }
  .profile-name      { font-size: 1.25rem; }

  /* Memorial */
  .memorial-name { font-size: 1.75rem; }
  .memorial-photo,
  .memorial-photo-placeholder { width: 130px; height: 130px; }

  /* Timeline */
  .timeline { padding-left: var(--sp-6); }
  .timeline-dot { left: calc(-24px + 5px); }

  /* Table: allow horizontal scroll */
  .table-wrapper { overflow-x: auto; }
  .data-table { min-width: 480px; }

  /* Info grid */
  .info-grid { grid-template-columns: 1fr; }

  /* Relation chips: wrap nicely */
  .relation-chips { gap: var(--sp-2); }
  .relation-chip  { font-size: 0.75rem; padding: 6px 10px; }
}

/* ── Small mobile (iPhone SE etc.) ── */
@media (max-width: 480px) {
  .grid-cats    { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
  .grid-gallery { grid-template-columns: repeat(2, 1fr); }
  .photo-grid   { grid-template-columns: repeat(2, 1fr); }

  /* Tabs: vertical stack on very small screens */
  .tabs-wrapper {
    flex-direction: row;
    overflow-x: auto;
  }

  /* Bottom nav items: smaller text */
  .bottom-nav-item { font-size: 0.5625rem; }
  .bottom-nav-item .nav-icon { font-size: 1.25rem; }

  /* Page title even smaller */
  .page-title { font-size: 1.25rem; }

  /* Smaller buttons on page actions */
  .page-actions .btn { font-size: 0.8125rem; padding: var(--sp-2) var(--sp-3); }

  /* Cat card body tighter */
  .cat-card-body { padding: var(--sp-3); }
}

/* ── Touch devices: improve tap targets ── */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .tab-btn { min-height: 40px; }
  .form-input,
  .form-select,
  .form-textarea { font-size: 1rem; /* prevent iOS zoom on focus */ }
  .sidebar-nav a { padding: var(--sp-3) var(--sp-3); min-height: 44px; }
  .bottom-nav-item { padding: var(--sp-2); }
  #tree-container { touch-action: none; /* let D3 handle touch */ }
}
