/* ==========================================================================
   Design Tokens & CSS Variables (Apple Human Interface Guidelines Inspired)
   ========================================================================== */
:root {
  /* Color Palette - Light Mode Default */
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  
  --bg-primary: #F5F5F7;
  --bg-secondary: rgba(255, 255, 255, 0.72);
  --bg-secondary-hover: rgba(255, 255, 255, 0.95);
  --bg-secondary-active: rgba(240, 240, 245, 0.95);
  
  --card-border: rgba(0, 0, 0, 0.06);
  --card-border-hover: rgba(0, 0, 0, 0.12);
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
  --card-shadow-hover: 0 12px 30px -4px rgba(0, 0, 0, 0.09), 0 4px 10px rgba(0, 0, 0, 0.04);
  
  --text-primary: #1D1D1F;
  --text-secondary: #86868B;
  --text-tertiary: #A1A1A6;
  
  --accent-blue: #0071E3;
  --accent-focus: rgba(0, 113, 227, 0.4);
  
  --search-bg: rgba(0, 0, 0, 0.04);
  --search-border: rgba(0, 0, 0, 0.06);
  --search-focus-bg: #FFFFFF;
  
  --badge-bg: rgba(0, 0, 0, 0.05);
  --badge-text: #6E6E73;
  
  --blur-backdrop: saturate(180%) blur(20px);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition-fast: 160ms cubic-bezier(0.25, 1, 0.5, 1);
  --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-smooth: 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Mode Palette */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #000000;
    --bg-secondary: rgba(28, 28, 30, 0.75);
    --bg-secondary-hover: rgba(44, 44, 46, 0.9);
    --bg-secondary-active: rgba(58, 58, 60, 0.95);
    
    --card-border: rgba(255, 255, 255, 0.1);
    --card-border-hover: rgba(255, 255, 255, 0.2);
    --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    --card-shadow-hover: 0 14px 34px -4px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
    
    --text-primary: #F5F5F7;
    --text-secondary: #86868B;
    --text-tertiary: #6E6E73;
    
    --accent-blue: #2997FF;
    --accent-focus: rgba(41, 151, 255, 0.45);
    
    --search-bg: rgba(255, 255, 255, 0.08);
    --search-border: rgba(255, 255, 255, 0.1);
    --search-focus-bg: #1C1C1E;
    
    --badge-bg: rgba(255, 255, 255, 0.08);
    --badge-text: #A1A1A6;
  }
}

/* Explicit User Overrides */
[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: rgba(28, 28, 30, 0.75);
  --bg-secondary-hover: rgba(44, 44, 46, 0.9);
  --bg-secondary-active: rgba(58, 58, 60, 0.95);
  --card-border: rgba(255, 255, 255, 0.1);
  --card-border-hover: rgba(255, 255, 255, 0.2);
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  --card-shadow-hover: 0 14px 34px -4px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
  --text-primary: #F5F5F7;
  --text-secondary: #86868B;
  --text-tertiary: #6E6E73;
  --accent-blue: #2997FF;
  --accent-focus: rgba(41, 151, 255, 0.45);
  --search-bg: rgba(255, 255, 255, 0.08);
  --search-border: rgba(255, 255, 255, 0.1);
  --search-focus-bg: #1C1C1E;
  --badge-bg: rgba(255, 255, 255, 0.08);
  --badge-text: #A1A1A6;
}

[data-theme="light"] {
  --bg-primary: #F5F5F7;
  --bg-secondary: rgba(255, 255, 255, 0.72);
  --bg-secondary-hover: rgba(255, 255, 255, 0.95);
  --bg-secondary-active: rgba(240, 240, 245, 0.95);
  --card-border: rgba(0, 0, 0, 0.06);
  --card-border-hover: rgba(0, 0, 0, 0.12);
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
  --card-shadow-hover: 0 12px 30px -4px rgba(0, 0, 0, 0.09), 0 4px 10px rgba(0, 0, 0, 0.04);
  --text-primary: #1D1D1F;
  --text-secondary: #86868B;
  --text-tertiary: #A1A1A6;
  --accent-blue: #0071E3;
  --accent-focus: rgba(0, 113, 227, 0.4);
  --search-bg: rgba(0, 0, 0, 0.04);
  --search-border: rgba(0, 0, 0, 0.06);
  --search-focus-bg: #FFFFFF;
  --badge-bg: rgba(0, 0, 0, 0.05);
  --badge-text: #6E6E73;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.47059;
  font-weight: 400;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-x: hidden;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* Ambient Subtle Background Glow */
body::before {
  content: "";
  position: fixed;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0, 113, 227, 0.08) 0%, rgba(94, 92, 230, 0) 100%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   Page Layout Container
   ========================================================================== */
.container {
  width: 100%;
  max-width: 620px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 24px);
  padding-block-start: clamp(36px, 8vh, 64px);
  padding-block-end: clamp(40px, 8vh, 80px);
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 4vh, 32px);
}

/* ==========================================================================
   Header & Profile
   ========================================================================== */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.header__controls {
  position: absolute;
  top: 0;
  right: 0;
}

.theme-btn {
  background: var(--bg-secondary);
  backdrop-filter: var(--blur-backdrop);
  -webkit-backdrop-filter: var(--blur-backdrop);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.theme-btn:hover {
  transform: scale(1.05);
  color: var(--text-primary);
  background: var(--bg-secondary-hover);
  border-color: var(--card-border-hover);
}

.theme-btn:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.theme-btn svg {
  width: 18px;
  height: 18px;
}

.avatar {
  position: relative;
  width: 82px;
  height: 82px;
  border-radius: 22px;
  background: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px -6px rgba(10, 132, 255, 0.35);
  margin-block-end: 18px;
  user-select: none;
}

.avatar__initials {
  color: #FFFFFF;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.avatar__status {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background-color: #30D158;
  border: 3px solid var(--bg-primary);
  border-radius: var(--radius-full);
  transition: border-color var(--transition-smooth);
}

.header__title {
  font-size: clamp(1.45rem, 3.5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text-primary);
  margin-block-end: 4px;
}

.header__subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Spotlight Search Filter (Apple Style)
   ========================================================================== */
.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  height: 44px;
  padding-inline-start: 42px;
  padding-inline-end: 44px;
  background-color: var(--search-bg);
  border: 1px solid var(--search-border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
  backdrop-filter: var(--blur-backdrop);
  -webkit-backdrop-filter: var(--blur-backdrop);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  background-color: var(--search-focus-bg);
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-focus);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--badge-bg);
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  pointer-events: none;
}

/* ==========================================================================
   Sections & Links
   ========================================================================== */
.sections {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 6px;
}

.section__title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.section__badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 8px;
  background-color: var(--badge-bg);
  color: var(--badge-text);
  border-radius: var(--radius-full);
}

.link-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   Link Cards (Apple Glassmorphism / Squircle Style)
   ========================================================================== */
.link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background-color: var(--bg-secondary);
  backdrop-filter: var(--blur-backdrop);
  -webkit-backdrop-filter: var(--blur-backdrop);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.link-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 100%);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

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

.link-card:hover::before {
  opacity: 1;
}

.link-card:active {
  transform: scale(0.985);
  background-color: var(--bg-secondary-active);
}

.link-card:focus-visible {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-focus);
}

/* Icon Squircle */
.link-card__icon-wrap {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transition: transform var(--transition-bounce);
}

.link-card:hover .link-card__icon-wrap {
  transform: scale(1.05);
}

.link-card__icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

/* Specific App Icon Color Themes (iOS Vibrant Gradients) */
.icon-theme--finance   { background: linear-gradient(135deg, #30D158 0%, #1E8238 100%); }
.icon-theme--nas-1     { background: linear-gradient(135deg, #0A84FF 0%, #0056B3 100%); }
.icon-theme--nas-2     { background: linear-gradient(135deg, #5E5CE6 0%, #3B38A8 100%); }
.icon-theme--media     { background: linear-gradient(135deg, #BF5AF2 0%, #8928BE 100%); }
.icon-theme--health    { background: linear-gradient(135deg, #FF453A 0%, #D70015 100%); }
.icon-theme--photos    { background: linear-gradient(135deg, #FF9F0A 0%, #FF375F 100%); }
.icon-theme--download  { background: linear-gradient(135deg, #32D74B 0%, #009688 100%); }
.icon-theme--sync      { background: linear-gradient(135deg, #64D2FF 0%, #0071E3 100%); }
.icon-theme--n8n       { background: linear-gradient(135deg, #FF375F 0%, #FF9F0A 100%); }
.icon-theme--nginx     { background: linear-gradient(135deg, #34C759 0%, #00693E 100%); }
.icon-theme--docker    { background: linear-gradient(135deg, #00C7BE 0%, #007799 100%); }

/* Text Details */
.link-card__content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.link-card__title {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-card__url {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

/* Trailing Chevron / Action */
.link-card__arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.link-card:hover .link-card__arrow {
  transform: translateX(3px);
  color: var(--text-primary);
}

/* ==========================================================================
   Empty State when searching
   ========================================================================== */
.search-empty {
  display: none;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.search-empty svg {
  width: 36px;
  height: 36px;
  margin-block-end: 10px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  text-align: center;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--badge-bg);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.footer__status-dot {
  width: 6px;
  height: 6px;
  background-color: #30D158;
  border-radius: var(--radius-full);
  box-shadow: 0 0 6px rgba(48, 209, 88, 0.6);
}

.footer__copy {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

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