/* ==========================================
   BOSS CORP - ARCHIVE EDITION
   Theme: Vintage paper, brass accents, nostalgic photo album
   ========================================== */

/* Core Variables & Tokens */
:root {
  --bg-color: #eee2c9;
  --panel-bg: rgba(247, 238, 218, 0.88);
  --panel-border: rgba(101, 74, 42, 0.22);
  --text-primary: #342518;
  --text-secondary: #5f4a34;
  --text-muted: #8b7257;
  --ink-soft: rgba(52, 37, 24, 0.10);
  --paper-line: rgba(120, 93, 61, 0.08);
  --paper-stain: rgba(120, 84, 44, 0.10);
  --shadow-soft: 0 20px 54px rgba(74, 53, 33, 0.16);
  --shadow-tight: 0 10px 26px rgba(74, 53, 33, 0.13);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  
  --grad-boss: linear-gradient(135deg, #b98f54 0%, #ead29b 100%);
  --grad-parents: linear-gradient(135deg, #8ca7b4 0%, #d5d9d2 100%);
  --grad-sister: linear-gradient(135deg, #b86c66 0%, #e4b5a8 100%);
  --grad-cousins: linear-gradient(135deg, #6c8a74 0%, #d9d1ad 100%);
  --grad-friends: linear-gradient(135deg, #81665b 0%, #c7b4a4 100%);
  --grad-cream: linear-gradient(180deg, #f8f0dd 0%, #efe1c0 100%);
  
  --glow-boss: 0 10px 30px rgba(167, 126, 71, 0.26);
  --glow-parents: 0 10px 24px rgba(108, 122, 128, 0.20);
  --glow-sister: 0 10px 24px rgba(146, 89, 82, 0.22);
  --glow-cousins: 0 10px 24px rgba(101, 119, 91, 0.22);
  --glow-friends: 0 10px 24px rgba(118, 96, 84, 0.22);
  
  --font-display: 'Cormorant Garamond', serif;
  --font-title: 'Cormorant Garamond', serif;
  --font-body: 'Alegreya', serif;
  --font-stamp: 'Special Elite', serif;
  --paper-photo-url: url("https://images.unsplash.com/photo-1586074299757-dc655f18518c?auto=format&fit=crop&w=1800&q=80");
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 14% 16%, rgba(163, 119, 73, 0.13), transparent 24%),
    radial-gradient(circle at 86% 18%, rgba(120, 95, 66, 0.09), transparent 20%),
    radial-gradient(circle at 52% 78%, rgba(202, 183, 147, 0.18), transparent 26%),
    repeating-linear-gradient(0deg, transparent 0 35px, rgba(101, 74, 42, 0.02) 35px 36px),
    linear-gradient(180deg, rgba(244, 234, 212, 0.88) 0%, rgba(230, 212, 175, 0.92) 100%),
    var(--paper-photo-url);
  background-size: auto, auto, auto, auto, auto, cover;
  background-position: center, center, center, center, center, center;
  background-attachment: scroll, scroll, scroll, scroll, scroll, fixed;
  background-blend-mode: normal, normal, normal, multiply, normal, multiply;
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

body::before {
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.28), transparent 22%),
    radial-gradient(circle at 75% 68%, rgba(92, 64, 34, 0.08), transparent 20%),
    repeating-radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.018) 0 1px, transparent 1px 4px);
  opacity: 0.6;
}

body::after {
  box-shadow: inset 0 0 120px rgba(78, 52, 24, 0.18);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(160, 140, 130, 0.2);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(160, 140, 130, 0.4);
}

/* Background Glowing Orbs (Dreamy Birthday Pastel Clouds) */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.16;
  pointer-events: none;
  z-index: -1;
  mix-blend-mode: multiply; /* Blends colors beautifully on light background */
  will-change: transform;
}
.orb-1 {
  width: 400px;
  height: 400px;
  background: #c7a279;
  top: -80px;
  right: -50px;
  animation: float-orb 15s infinite alternate ease-in-out;
}
.orb-2 {
  width: 450px;
  height: 450px;
  background: #bfa77b;
  bottom: -120px;
  left: -80px;
  animation: float-orb 20s infinite alternate-reverse ease-in-out;
}
.orb-3 {
  width: 350px;
  height: 350px;
  background: #f2e2bb;
  top: 45%;
  left: 45%;
  transform: translate(-50%, -50%);
  opacity: 0.25;
}

@keyframes float-orb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -50px) scale(1.1); }
}

/* Glassmorphism Panel Helper */
.glass-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(180, 160, 150, 0.08);
}

/* Utility Hidden */
.hidden {
  display: none !important;
}

/* ==========================================
   1. PORTAL GATE (Invitation Seal Screen)
   ========================================== */
.portal-gate {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  z-index: 100;
  background:
    radial-gradient(circle at 20% 20%, rgba(120, 84, 44, 0.10), transparent 22%),
    radial-gradient(circle at 78% 24%, rgba(255, 255, 255, 0.34), transparent 18%),
    linear-gradient(180deg, rgba(244, 234, 213, 0.88) 0%, rgba(234, 216, 180, 0.92) 100%),
    var(--paper-photo-url);
  background-size: auto, auto, auto, cover;
  background-position: center;
  background-blend-mode: normal, normal, normal, multiply;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.8s;
  will-change: opacity, transform;
}

.portal-gate.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.portal-content {
  width: 100%;
  max-width: 430px;
  text-align: center;
  padding: clamp(34px, 7vw, 52px) 28px;
  background:
    repeating-linear-gradient(0deg, rgba(134, 99, 56, 0.025) 0 2px, transparent 2px 36px),
    linear-gradient(180deg, rgba(252, 246, 233, 0.98), rgba(240, 227, 198, 0.96));
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  animation: card-appear 0.8s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.portal-content::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(131, 98, 60, 0.24);
  border-radius: 10px;
  pointer-events: none;
}

@keyframes card-appear {
  0% { opacity: 0; transform: translateY(20px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.brand-badge {
  display: inline-block;
  font-family: var(--font-stamp);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  color: #7f5c35;
  padding: 7px 16px 5px;
  border: 1px dashed rgba(127, 92, 53, 0.5);
  border-radius: 999px;
  font-weight: 400;
  margin-bottom: 24px;
  background: rgba(255, 248, 233, 0.76);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.45);
  animation: none;
}

@keyframes border-glow {
  0% { box-shadow: 0 0 5px rgba(255, 167, 81, 0.1); border-color: rgba(255,167,81,0.4); }
  100% { box-shadow: 0 0 20px rgba(255, 167, 81, 0.3); border-color: rgba(255,167,81,1); }
}

.portal-title {
  font-family: var(--font-title);
  font-size: clamp(1.75rem, 8vw, 2.35rem);
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 12px;
  color: #412c1f;
  line-height: 1.05;
  text-transform: uppercase;
}

.portal-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
  font-weight: 500;
  max-width: 27ch;
  margin-inline: auto;
}

/* Biometric Scanner -> Gold Gift Seal styling */
.scanner-container {
  position: relative;
  width: 156px;
  height: 156px;
  margin: 0 auto 34px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.scanner-ring {
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  animation: rotation 16s linear infinite;
}

@keyframes rotation {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.scan-btn {
  position: relative;
  z-index: 2;
  width: 122px;
  height: 122px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(247, 236, 206, 0.94) 0%, rgba(232, 214, 176, 0.98) 100%);
  border: 1px solid rgba(121, 88, 44, 0.32);
  color: #6a4a25;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: transform 0.32s var(--ease-out), box-shadow 0.32s var(--ease-out), border-color 0.32s var(--ease-out), background 0.32s var(--ease-out);
  box-shadow: inset 0 0 14px rgba(121, 88, 44, 0.10), 0 10px 26px rgba(121, 88, 44, 0.16);
}

.scan-btn::before {
  content: '';
  position: absolute;
  inset: -6px;
  border: 2px solid transparent;
  border-top-color: #9f7741;
  border-bottom-color: #d1ba8b;
  border-radius: 50%;
  animation: rotation 4s linear infinite;
  opacity: 0.8;
}

.fingerprint-icon {
  width: 36px;
  height: 36px;
  color: #8a6538;
  transition: transform 0.3s, color 0.3s;
}

.scan-text {
  font-family: var(--font-stamp);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
}

/* Hover / Active Seal States */
.scan-btn:hover {
  background: radial-gradient(circle, rgba(247, 234, 197, 0.98) 0%, rgba(242, 226, 191, 0.98) 100%);
  box-shadow: 0 8px 25px rgba(121, 88, 44, 0.24);
  border-color: rgba(121, 88, 44, 0.6);
  transform: translateY(-3px) scale(1.03);
}
.scan-btn:active {
  transform: translateY(0) scale(0.97);
}
.scan-btn:hover .fingerprint-icon {
  transform: scale(1.15) rotate(5deg);
  color: #FFA751;
}

.scan-btn.scanning {
  cursor: wait;
  border-color: rgba(255, 167, 81, 0.85);
  box-shadow: 0 0 0 10px rgba(255, 167, 81, 0.08), 0 18px 44px rgba(255, 154, 158, 0.22);
  transform: scale(1.04);
}

.scan-btn.scanning .fingerprint-icon {
  animation: gift-pop 0.6s var(--ease-out) infinite alternate;
}

@keyframes gift-pop {
  from { transform: scale(1) rotate(-3deg); }
  to { transform: scale(1.12) rotate(5deg); }
}

/* Scanning scanline (Gold ribbon sweep) */
.laser-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(121, 88, 44, 0.2), transparent);
  box-shadow: 0 0 10px rgba(121, 88, 44, 0.22);
  top: 15px;
  animation: scan-laser 2.5s infinite ease-in-out;
  pointer-events: none;
  z-index: 3;
}

@keyframes scan-laser {
  0%, 100% { top: 15px; opacity: 0; }
  10%, 90% { opacity: 1; }
  50% { top: 130px; }
}

.security-disclaimer {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}
.security-disclaimer b {
  color: #84592d;
  font-family: var(--font-stamp);
  font-weight: 700;
}


/* ==========================================
   2. MAIN APPLICATION LAYER
   ========================================== */
.app-container {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(12px, 2.2vw, 22px);
  opacity: 0;
  transform: translateY(10px);
  animation: fade-in 0.85s 0.15s forwards var(--ease-out);
  will-change: opacity, transform;
}

@keyframes fade-in {
  to { opacity: 1; transform: translateY(0); }
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px 12px 18px;
  background:
    repeating-linear-gradient(0deg, rgba(132, 98, 58, 0.025) 0 2px, transparent 2px 34px),
    linear-gradient(180deg, rgba(248,241,223,0.96), rgba(236,223,193,0.90)),
    var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-tight);
  gap: 12px;
  position: relative;
  z-index: 20;
}

.header-logo {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.logo-accent {
  color: #a67a47;
}

.header-title {
  text-align: center;
  min-width: 0;
}
.header-title h2 {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #885c2a;
  text-transform: uppercase;
}
.header-title p {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  margin-top: 1px;
}

/* Audio toggle button */
.control-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(251, 245, 230, 0.88);
  border: 1px solid var(--ink-soft);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out), background-color 0.22s var(--ease-out), border-color 0.22s var(--ease-out);
}
.control-btn:hover {
  background: rgba(255, 248, 235, 0.96);
  border-color: rgba(128, 91, 46, 0.36);
  box-shadow: 0 8px 18px rgba(89, 62, 45, 0.14);
  transform: translateY(-1px);
}
.control-btn:active {
  transform: translateY(0) scale(0.96);
}
.audio-icon {
  width: 18px;
  height: 18px;
}


/* ==========================================
   3. INTERACTIVE ORG CHART TREE (ZOOM & SWIPE)
   ========================================== */
.tree-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 0; /* Participates properly in flex grow calculations */
  position: relative;
  gap: 0;
}

.tree-instructions {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
  opacity: 0.9;
  letter-spacing: 0.01em;
  background: rgba(248, 241, 225, 0.84);
  border: 1px dashed rgba(117, 96, 73, 0.28);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: 0 8px 18px rgba(89, 62, 45, 0.05);
}

/* Scrollable viewport framing the tree - Expands to fill vertical screen space */
.tree-viewport {
  width: 100%;
  flex-grow: 1;
  height: 0; /* Flexbox trick to let it grow dynamically */
  min-height: min(540px, calc(100dvh - 218px)); /* Good size for mobile / tablet view */
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px),
    linear-gradient(180deg, rgba(246, 237, 218, 0.90), rgba(233, 217, 185, 0.82)),
    var(--paper-photo-url);
  background-size: 36px 36px, 36px 36px, auto, cover;
  background-position: center;
  background-blend-mode: multiply, multiply, normal, soft-light;
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 8px 30px rgba(0,0,0,0.018), var(--shadow-tight);
}

.tree-viewport::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(137, 112, 73, 0.08), transparent 20%),
    radial-gradient(circle at 82% 70%, rgba(137, 112, 73, 0.07), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.40), rgba(255,255,255,0.08) 24%, rgba(255,255,255,0.18));
  pointer-events: none;
}

/* ZOOM FLOAT BUTTON - Inside Viewport on top of tree elements */
.zoom-toggle-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 30; /* Elevated to sit on top of everything inside viewport */
  background: rgba(248, 241, 225, 0.92);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-tight);
  transition: transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out), background-color 0.22s var(--ease-out);
  pointer-events: auto; /* Explicitly guarantee click response */
}
.zoom-toggle-btn:hover {
  background: rgba(255, 248, 235, 0.96);
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 6px 20px rgba(180, 160, 150, 0.12);
}
.zoom-icon {
  width: 20px;
  height: 20px;
}

.tree-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 680px;
  height: 980px;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.6s var(--ease-out);
  transform-origin: 0 0;
  z-index: 2;
  user-select: none;
  
  /* SPACIOUS VERTICAL NODE SEPARATION */
  gap: 74px; 
}

/* SVG Line connector canvas overlays - Inside tree-container, sharing coordinates */
.tree-connections {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.5s ease;
}

.tree-connections path {
  fill: none;
  stroke: rgba(113, 88, 61, 0.36);
  stroke-width: 2.2;
  stroke-dasharray: 4, 8;
  animation: dash 35s linear infinite;
  transition: stroke 0.4s ease, opacity 0.4s ease;
}

@keyframes dash {
  to {
    stroke-dashoffset: -100;
  }
}

/* Levels Row layouts */
.tree-row {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  
  /* SPACIOUS HORIZONTAL NODE SEPARATION */
  gap: 80px;
}

/* Nodes Styling */
.tree-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  border-radius: 18px;
  padding: 8px;
  transition: transform 0.35s var(--ease-out), opacity 0.5s ease, visibility 0.5s ease, filter 0.3s ease;
  will-change: transform, opacity;
}

.tree-container.zoomed-out .tree-node:hover {
  transform: translateY(-6px);
  filter: saturate(0.96);
}

.tree-node:focus-visible,
.scan-btn:focus-visible,
.control-btn:focus-visible,
.zoom-toggle-btn:focus-visible,
.tree-nav-btn:focus-visible,
.tree-nav-card:focus-visible,
.dialog-close-btn:focus-visible {
  outline: 3px solid rgba(255, 167, 81, 0.55);
  outline-offset: 3px;
}

/* ZOOM IN MODE: Focus on active member ONLY - hide everything else completely */
.tree-container.zoomed-in .tree-node:not(.active-node) {
  opacity: 0 !important;
  pointer-events: none;
  visibility: hidden;
}

/* Zoomed-in mode active node details - elegant float effect */
.tree-container.zoomed-in .tree-node.active-node {
  opacity: 1;
  animation: float-active-node 3.5s infinite alternate ease-in-out;
}

@keyframes float-active-node {
  0% { transform: scale(1.3) translateY(0); }
  100% { transform: scale(1.3) translateY(-8px); }
}

/* Zoomed-in mode connections are completely hidden for zero visual noise */
.tree-container.zoomed-in .tree-connections path {
  opacity: 0 !important;
}

/* Zoomed-out mode resets visibility */
.tree-container.zoomed-out .tree-node {
  opacity: 1;
  visibility: visible;
}
.tree-container.zoomed-out .tree-connections path {
  opacity: 1;
}

.avatar-wrapper {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  transition: transform 0.28s var(--ease-out);
}

.tree-node:hover .avatar-wrapper {
  transform: translateY(-2px);
}

.node-glow {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  opacity: 0.15;
  filter: blur(8px);
  transition: opacity 0.3s;
}
.tree-node.active-node .node-glow {
  opacity: 0.55;
}

/* Rotating outer gradient ring */
.avatar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 3px;
  background: var(--gradient);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin 9s linear infinite;
  opacity: 0.9;
  transition: box-shadow 0.3s ease;
}

.tree-node.active-node .avatar-ring {
  animation-duration: 3s; /* Spin faster when selected */
  box-shadow: var(--glow-shadow);
}

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

.avatar-image {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 251, 238, 0.96), rgba(229, 213, 182, 0.94));
  border: 2px solid rgba(110, 81, 48, 0.14);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  box-shadow: inset 0 2px 8px rgba(99, 73, 43, 0.10), 0 7px 18px rgba(89, 62, 45, 0.12);
  overflow: hidden;
  position: relative;
}

.avatar-initials {
  position: relative;
  z-index: 1;
  background: var(--gradient, var(--grad-boss));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.avatar-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 2;
}

.avatar-photo.is-loaded {
  opacity: 1;
}

.avatar-photo.is-missing {
  display: none;
}

/* Details below node */
.node-name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.24rem;
  color: var(--text-primary);
  margin-bottom: 2px;
  letter-spacing: 0.01em;
  transition: color 0.3s;
}
.tree-node.active-node .node-name {
  font-weight: 850;
}

.node-role-badge {
  font-family: var(--font-stamp);
  font-size: 0.52rem;
  font-weight: 400;
  letter-spacing: 0.10em;
  padding: 6px 12px 5px;
  border-radius: 12px;
  background: rgba(249, 243, 231, 0.92);
  border: 1px solid var(--border-color);
  color: var(--badge-text-color);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), background-color 0.25s var(--ease-out);
  max-width: 155px;
  line-height: 1.35;
  display: inline-block;
  text-align: center;
  word-wrap: break-word;
  white-space: normal;
}
.tree-node.active-node .node-role-badge {
  background: rgba(252, 247, 236, 0.98);
  box-shadow: 0 2px 10px rgba(99, 73, 43, 0.08);
}

/* Root node (The Boss) specifics */
.tree-node.boss-node .avatar-wrapper {
  width: 116px;
  height: 116px;
}
.tree-node.boss-node .avatar-image {
  width: 106px;
  height: 106px;
  font-size: 1.7rem;
}
.tree-node.boss-node .node-name {
  font-size: 1.2rem;
}

/* Level styling colors */
.level-0 { --gradient: var(--grad-boss); --border-color: rgba(255, 167, 81, 0.4); --badge-text-color: #E27B13; --glow-shadow: var(--glow-boss); }
.level-1.node-mom, .level-1.node-dad { --gradient: var(--grad-parents); --border-color: rgba(161, 196, 253, 0.5); --badge-text-color: #3B7DC2; --glow-shadow: var(--glow-parents); }
.level-2.node-akka { --gradient: var(--grad-sister); --border-color: rgba(255, 154, 158, 0.5); --badge-text-color: #D15A5E; --glow-shadow: var(--glow-sister); }
.level-2.node-jai-anna { --gradient: var(--grad-cousins); --border-color: rgba(132, 250, 176, 0.5); --badge-text-color: #2F9C5F; --glow-shadow: var(--glow-cousins); }
.level-3.node-aadhar { --gradient: var(--grad-friends); --border-color: rgba(161, 140, 209, 0.5); --badge-text-color: #7B62AE; --glow-shadow: var(--glow-friends); }
.level-3.node-oviya { --gradient: linear-gradient(135deg, #F6D365 0%, #FDA085 100%); --border-color: rgba(246, 168, 106, 0.5); --badge-text-color: #C86D2A; --glow-shadow: 0 8px 25px rgba(246, 168, 106, 0.28); }
.level-3.node-sarab { --gradient: linear-gradient(135deg, #89F7FE 0%, #66A6FF 100%); --border-color: rgba(102, 166, 255, 0.5); --badge-text-color: #3A73D1; --glow-shadow: 0 8px 25px rgba(102, 166, 255, 0.26); }
.level-3.node-adi { --gradient: linear-gradient(135deg, #FF758C 0%, #FF7EB3 100%); --border-color: rgba(255, 117, 151, 0.5); --badge-text-color: #D81B60; --glow-shadow: 0 8px 25px rgba(255, 117, 151, 0.28); }
.level-3.node-sanjay { --gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); --border-color: rgba(79, 195, 247, 0.5); --badge-text-color: #0288D1; --glow-shadow: 0 8px 25px rgba(79, 195, 247, 0.26); }


/* ==========================================
   4. NAVIGATION TRAY FOR ZOOMEED VIEW
   ========================================== */
.tree-nav-tray {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 440px;
  margin: 16px auto 0;
  gap: 12px;
  transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
  will-change: opacity, transform;
}

.tree-nav-tray.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

.tree-nav-btn {
  background: rgba(247, 238, 218, 0.96);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: var(--shadow-tight);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
  user-select: none;
  z-index: 5;
}
.tree-nav-btn:hover {
  background: #FFFFFF;
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(180, 160, 150, 0.12);
}
.tree-nav-btn:active {
  transform: scale(0.95);
}

.tree-nav-card {
  flex-grow: 1;
  background:
    repeating-linear-gradient(0deg, rgba(132, 98, 58, 0.022) 0 2px, transparent 2px 32px),
    linear-gradient(180deg, rgba(249,243,231,0.96), rgba(237,225,197,0.92));
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px 18px;
  box-shadow: var(--shadow-tight);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.28s var(--ease-out), box-shadow 0.28s var(--ease-out), border-color 0.28s var(--ease-out);
  position: relative;
  overflow: hidden;
}
.tree-nav-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--active-color, var(--grad-boss));
}
.tree-nav-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 167, 81, 0.30);
  box-shadow: 0 18px 42px rgba(89, 62, 45, 0.14);
}

.nav-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  background-color: rgba(255,255,255,0.74);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 800;
}

.nav-card-info {
  flex-grow: 1;
  text-align: left;
}

.nav-card-name {
  font-family: var(--font-title);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.nav-card-role {
  font-family: var(--font-stamp);
  font-size: 0.56rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.08em;
  margin-top: 1px;
}

.nav-card-action {
  font-family: var(--font-stamp);
  font-size: 0.54rem;
  font-weight: 400;
  color: var(--active-color-raw, #E27B13);
  letter-spacing: 0.10em;
  background: rgba(247, 238, 218, 0.86);
  border: 1px solid rgba(0, 0, 0, 0.05);
  padding: 6px 8px 4px;
  border-radius: 999px;
  white-space: nowrap;
  text-transform: uppercase;
}


/* ==========================================
   5. PROFILE DIALOG MODAL (Light Card)
   ========================================== */
dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  background: transparent;
  outline: none;
  padding: 0;
  z-index: 1000;
  width: calc(100% - 32px);
  max-width: min(480px, calc(100vw - 32px));
  overflow: visible;
  
  /* Entry transition setups */
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.35s;
  transition-timing-function: var(--ease-out);
  transition-behavior: allow-discrete;
}

dialog[open] {
  opacity: 1;
  transform: translateY(0) scale(1);
  
  @starting-style {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
}

/* Modal Backdrop Blur */
dialog::backdrop {
  background-color: rgba(255, 253, 248, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: 
    display 0.35s allow-discrete,
    overlay 0.35s allow-discrete,
    background-color 0.35s ease,
    backdrop-filter 0.35s ease;
}

dialog[open]::backdrop {
  background-color: rgba(39, 27, 17, 0.46);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  @starting-style {
    background-color: rgba(60, 50, 48, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
}

/* Dialog wrapper box layout */
.dialog-content {
  background:
    repeating-linear-gradient(0deg, rgba(132, 98, 58, 0.03) 0 2px, transparent 2px 32px),
    linear-gradient(180deg, rgba(250,243,229,0.98) 0%, rgba(234,220,192,0.98) 100%);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: clamp(16px, 4vw, 24px);
  width: 100%;
  box-shadow: 0 28px 70px -18px rgba(38, 31, 29, 0.28);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Custom border-glow dependent on profile theme color */
.dialog-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  inset: 12px;
  width: auto;
  height: auto;
  background: none;
  border: 1px solid rgba(120, 95, 66, 0.16);
  border-radius: 12px;
}

/* Close button overlay styling */
.dialog-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(249, 242, 226, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #333333;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.85rem;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), background-color 0.25s var(--ease-out);
  z-index: 25;
}
.dialog-close-btn:hover {
  background: rgba(255, 248, 236, 0.98);
  transform: translateY(-1px) rotate(90deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Fullscreen Autoplay Image Carousel */
.dialog-carousel-container {
  width: 100%;
  aspect-ratio: 1 / 1; /* Beautiful square layout */
  overflow: hidden;
  border-radius: 14px;
  position: relative;
  background-color: rgba(126, 95, 58, 0.06);
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
}

.dialog-carousel-track {
  width: 100%;
  height: 100%;
  position: relative;
}

.dialog-carousel-container::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 56%, rgba(56, 36, 20, 0.28));
  pointer-events: none;
}

.dialog-carousel-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: scale(1.025);
  transition: opacity 0.8s ease-in-out, transform 4.5s ease;
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(180, 143, 94, 0.18), rgba(223, 205, 173, 0.32));
}

.dialog-carousel-image.active {
  opacity: 1;
  transform: scale(1);
}

.dialog-carousel-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.dialog-carousel-image img.is-loaded {
  opacity: 1;
}

.dialog-carousel-image img.is-missing {
  display: none;
}

.dialog-image-fallback {
  font-family: var(--font-stamp);
  font-size: clamp(3rem, 18vw, 6rem);
  font-weight: 400;
  color: rgba(123, 87, 45, 0.34);
}


/* ==========================================
   7. FOOTER, BUTTONS, & GENERAL SURPRISES
   ========================================== */
.app-footer {
  margin-top: 16px;
  text-align: center;
}

.promote-btn {
  background: linear-gradient(90deg, #FFE259, #FFA751, #FFE259);
  background-size: 200% auto;
  border: none;
  padding: 12px 28px;
  border-radius: 50px;
  color: #FFFFFF;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 167, 81, 0.3);
  animation: shine 3s infinite, float-btn 3s infinite alternate ease-in-out;
  transition: transform 0.2s, box-shadow 0.2s;
}

.promote-btn:active {
  transform: scale(0.96);
  box-shadow: 0 3px 10px rgba(255, 167, 81, 0.2);
}

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

@keyframes float-btn {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

.btn-stars {
  animation: blink 1s infinite alternate;
}
.btn-stars:nth-child(2) {
  animation-delay: 0.5s;
}

@keyframes blink {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

.footer-copy {
  font-family: var(--font-stamp);
  font-size: 0.56rem;
  color: var(--text-muted);
  margin-top: 12px;
  letter-spacing: 0.12em;
  font-weight: 400;
  text-transform: uppercase;
}

/* FULL-SCREEN CONFETTI CANVAS */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Reduced Motion Settings */
@media (prefers-reduced-motion: reduce) {
  .scanner-ring,
  .laser-line,
  .avatar-ring,
  .tree-connections path,
  .promote-btn,
  .glow-orb {
    animation: none !important;
  }
  
  dialog,
  dialog::backdrop {
    transition-duration: 0.1s !important;
  }
  
  @starting-style {
    dialog[open] {
      transform: none !important;
    }
  }
}

/* Responsive Header & Spacing Adjustments */
@media (max-width: 480px) {
  .app-header {
    padding: 10px 14px;
    margin-bottom: 12px;
    gap: 8px;
  }
  .header-logo {
    font-size: 0.82rem;
    gap: 4px;
  }
  .header-title h2 {
    font-size: 0.72rem;
    letter-spacing: 0.02em;
  }
  .header-title p {
    font-size: 0.52rem;
    margin-top: 0;
  }
  .control-btn {
    width: 32px;
    height: 32px;
  }
  .audio-icon {
    width: 16px;
    height: 16px;
  }
}

/* Header Controls layout */
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Slim Audio Frame styling */
.slim-audio-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(247, 238, 218, 0.84);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 16px;
  margin-top: 14px;
  width: 100%;
}

.slim-wave-visualizer {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 12px;
}

.slim-wave-visualizer span {
  display: block;
  width: 2px;
  height: 4px;
  background-color: var(--profile-color-raw, #FFA751);
  border-radius: 1px;
  transition: height 0.15s ease;
}

.slim-wave-visualizer.active span {
  animation: slim-bounce 0.6s ease-in-out infinite alternate;
}

.slim-wave-visualizer.active span:nth-child(2n) { animation-delay: 0.1s; }
.slim-wave-visualizer.active span:nth-child(3n) { animation-delay: 0.2s; }
.slim-wave-visualizer.active span:nth-child(4n) { animation-delay: 0.05s; }
.slim-wave-visualizer.active span:nth-child(5n) { animation-delay: 0.15s; }

@keyframes slim-bounce {
  0% { height: 4px; }
  100% { height: 12px; }
}

.slim-audio-status {
  font-family: var(--font-stamp);
  font-size: 0.58rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Album Dialog Content */
.memory-dump-dialog {
  max-width: min(1080px, calc(100vw - 32px));
}

.album-title {
  font-family: var(--font-title);
  font-size: clamp(1.2rem, 2.6vw, 1.8rem);
  font-weight: 700;
  color: #6d4c2d;
  letter-spacing: 0.04em;
  text-align: center;
  margin: 8px 0 12px;
  text-transform: uppercase;
}

.album-decor-top, .album-decor-bottom {
  display: flex;
  justify-content: center;
  margin: 10px 0;
  position: relative;
}

.album-hero-photo {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  position: relative;
}

.album-decor-top img, .album-decor-bottom img {
  width: min(100%, 184px);
  height: auto;
  display: block;
  border: 8px solid #f9f2e4;
  box-shadow: 0 18px 34px rgba(89, 62, 45, 0.16);
  border-radius: 4px;
  filter: sepia(0.14) contrast(0.92) saturate(1.15) brightness(0.98);
  transition: transform 0.32s ease, filter 0.32s ease, box-shadow 0.32s ease;
}

.album-hero-photo:hover img,
.album-hero-photo:focus-visible img {
  filter: sepia(0) contrast(1) saturate(1) brightness(1);
  box-shadow: 0 22px 42px rgba(89, 62, 45, 0.22);
}

.album-decor-top img {
  transform: rotate(-3deg);
}

.album-decor-bottom img {
  transform: rotate(3deg);
}

.album-decor-top .album-hero-photo:hover img,
.album-decor-top .album-hero-photo:focus-visible img {
  transform: rotate(-1deg) translateY(-4px) scale(1.02);
}

.album-decor-bottom .album-hero-photo:hover img,
.album-decor-bottom .album-hero-photo:focus-visible img {
  transform: rotate(1deg) translateY(-4px) scale(1.02);
}

/* Tape for decor images too! */
.album-decor-top::before, .album-decor-bottom::before {
  content: "";
  position: absolute;
  top: -10px;
  width: 45px;
  height: 14px;
  background-color: rgba(245, 235, 215, 0.45);
  backdrop-filter: blur(1px);
  z-index: 2;
  border-left: 1px dashed rgba(0, 0, 0, 0.06);
  border-right: 1px dashed rgba(0, 0, 0, 0.06);
}

.album-decor-top::before {
  transform: rotate(1deg);
}

.album-decor-bottom::before {
  transform: rotate(-2deg);
}

.album-scroll-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 22px 18px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 8px 18px;
  max-height: min(58vh, 720px);
  scrollbar-width: thin;
}

.album-scroll-container::-webkit-scrollbar {
  width: 8px;
}

.polaroid-card {
  appearance: none;
  flex: none;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  padding: 10px 10px 18px;
  box-shadow: 0 12px 30px rgba(89, 62, 45, 0.12);
  display: flex;
  flex-direction: column;
  position: relative;
  text-align: left;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Retro masking/washi tape at the top */
.polaroid-card::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-1.5deg);
  width: 48px;
  height: 18px;
  background-color: rgba(245, 235, 215, 0.45); /* Translucent tan masking tape */
  backdrop-filter: blur(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  border-left: 1px dashed rgba(0, 0, 0, 0.06);
  border-right: 1px dashed rgba(0, 0, 0, 0.06);
  z-index: 2;
}

.polaroid-card:hover {
  transform: translateY(-8px) rotate(0deg) scale(1.03) !important;
  box-shadow: 0 20px 40px rgba(89, 62, 45, 0.18);
  z-index: 10;
}

.polaroid-card:focus-visible {
  transform: translateY(-8px) rotate(0deg) scale(1.03) !important;
  box-shadow: 0 0 0 3px rgba(157, 112, 57, 0.18), 0 20px 40px rgba(89, 62, 45, 0.18);
  z-index: 11;
}

.polaroid-img {
  width: 100%;
  aspect-ratio: 1 / 1; /* Classic square polaroid photo */
  border-radius: 1px;
  background: #f7f5f0;
  border: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.polaroid-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  /* Retro vintage sepia & vignette effect */
  filter: sepia(0.16) contrast(0.92) saturate(1.15) brightness(0.98);
  transition: opacity 0.35s ease, filter 0.3s ease;
}

.polaroid-img img.is-loaded {
  opacity: 1;
}

.polaroid-img img.is-missing {
  display: none;
}

.polaroid-fallback {
  font-family: var(--font-stamp);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  color: rgba(123, 87, 45, 0.44);
}

.polaroid-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-family: var(--font-stamp);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.album-lightbox-dialog {
  width: min(1180px, calc(100vw - 24px));
  max-width: none;
  padding: 0;
  border: 1px solid rgba(108, 82, 48, 0.2);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(249, 241, 220, 0.94), rgba(241, 230, 204, 0.92)),
    var(--paper-photo-url) center/cover;
  box-shadow: 0 30px 80px rgba(31, 22, 12, 0.32);
  overflow: hidden;
}

.album-lightbox-dialog::backdrop {
  background: rgba(38, 28, 16, 0.68);
  backdrop-filter: blur(8px);
}

.album-lightbox-stage {
  min-height: min(84vh, 900px);
  display: grid;
  place-items: center;
  padding: 64px 84px;
}

.album-lightbox-stage img {
  max-width: 100%;
  max-height: calc(84vh - 128px);
  width: auto;
  height: auto;
  display: block;
  border: 12px solid rgba(249, 242, 228, 0.96);
  border-radius: 6px;
  box-shadow: 0 28px 56px rgba(42, 31, 17, 0.28);
  filter: sepia(0.1) contrast(0.95) saturate(1.05);
}

.album-lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
}

.album-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(110, 84, 47, 0.2);
  background: rgba(252, 246, 233, 0.88);
  color: #6d4c2d;
  box-shadow: 0 14px 26px rgba(50, 36, 20, 0.16);
  font-size: 2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  transition: transform 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
}

.album-lightbox-nav:hover,
.album-lightbox-nav:focus-visible {
  transform: translateY(-50%) scale(1.05);
  background: rgba(255, 249, 238, 0.96);
  box-shadow: 0 18px 34px rgba(50, 36, 20, 0.22);
}

.album-lightbox-nav.prev {
  left: 20px;
}

.album-lightbox-nav.next {
  right: 20px;
}

.album-hero-photo:focus-visible {
  outline: none;
}

.album-hero-photo:focus-visible img {
  box-shadow: 0 0 0 3px rgba(157, 112, 57, 0.18), 0 22px 42px rgba(89, 62, 45, 0.22);
}


button,
.tree-nav-card,
.tree-node {
  touch-action: manipulation;
}

@media (max-width: 720px) {
  .portal-content {
    max-width: 360px;
  }

  .tree-viewport {
    min-height: min(510px, calc(100dvh - 230px));
  }

  .tree-container {
    width: 620px;
    height: 900px;
    margin: 0;
    gap: 62px;
  }

  .tree-row {
    gap: 40px;
  }

  .tree-nav-tray {
    max-width: 100%;
    gap: 8px;
  }

  .tree-nav-card {
    padding: 10px 12px;
    gap: 10px;
    min-width: 0;
  }

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

  .nav-card-name,
  .nav-card-role {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-card-action {
    display: none;
  }
}

@media (max-width: 480px) {
  body {
    line-height: 1.45;
  }

  .portal-gate {
    padding: 14px;
  }

  .portal-content {
    padding: 32px 18px;
  }

  .scanner-container {
    width: 138px;
    height: 138px;
    margin-bottom: 28px;
  }

  .scan-btn {
    width: 110px;
    height: 110px;
  }

  .laser-line {
    animation-duration: 2.9s;
  }

  .app-container {
    padding: 10px;
  }

  .app-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo controls"
      "title controls";
    align-items: center;
  }

  .header-logo {
    grid-area: logo;
  }

  .header-title {
    grid-area: title;
    text-align: left;
  }

  .header-controls {
    grid-area: controls;
  }

  .tree-instructions {
    width: 100%;
    border-radius: 8px;
    font-size: 0.74rem;
    padding: 7px 10px;
  }

  .tree-viewport {
    min-height: min(480px, calc(100dvh - 236px));
  }

  .zoom-toggle-btn {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
  }

  .tree-nav-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }

  .nav-card-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }

  .dialog-content {
    padding: 14px;
  }

  .album-decor-top img,
  .album-decor-bottom img {
    width: min(100%, 150px);
  }

  .album-scroll-container {
    gap: 12px;
    padding-top: 14px;
  }

  .polaroid-card {
    flex-basis: 78%;
  }

  .album-lightbox-dialog {
    width: calc(100vw - 16px);
    border-radius: 18px;
  }

  .album-lightbox-stage {
    min-height: min(74vh, 720px);
    padding: 52px 18px 34px;
  }

  .album-lightbox-stage img {
    max-height: calc(74vh - 84px);
    border-width: 8px;
  }

  .album-lightbox-nav {
    width: 42px;
    height: 42px;
    font-size: 1.7rem;
  }

  .album-lightbox-nav.prev {
    left: 10px;
  }

  .album-lightbox-nav.next {
    right: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  .scan-btn.scanning .fingerprint-icon,
  .tree-container.zoomed-in .tree-node.active-node,
  .slim-wave-visualizer.active span,
  .polaroid-card {
    animation: none !important;
  }

  .dialog-carousel-image,
  .app-container,
  .portal-content,
  .tree-container,
  .tree-node {
    transition-duration: 0.01ms !important;
  }
}
