:root,
[data-theme="light"] {
  color-scheme: light dark;
  /* Minimal stratosphere palette - warm with purple tints */
  --bg-start: #f8f6ff; /* warm white with purple hint */
  --bg-mid: #f0ede8; /* warm beige */
  --bg-end: #e6e2f5; /* purple-tinted horizon */
  --ink: #2d2520; /* warm charcoal */
  --muted: #6b5b4f; /* muted brown */
  --border: #d4c4e0; /* purple-tinted border */
  --card-bg: rgba(255, 250, 250, 0.9);
  --accent: #7c5295; /* muted purple */
  --warn: #c17817; /* warm amber */
  --star-1: rgba(138, 101, 175, 0.35); /* purple starlight */
  --star-2: rgba(255, 245, 255, 0.4); /* soft purple glow */
  /* Earth band (day) - warmer, more organic */
  --earth-high: #d6e8d4; /* soft sage */
  --earth-low: #a8c4a2; /* gentle moss */
  --earth-pattern: rgba(76, 122, 71, 0.15); /* forest speckles */
}
[data-theme="dark"] {
  /* Stratosphere dark - warm with purple depths */
  --bg-start: #1a1625; /* deep purple-brown */
  --bg-mid: #242019; /* charcoal brown */
  --bg-end: #2d1f35; /* purple night */
  --ink: #f5ebe0; /* warm cream */
  --muted: #b5a085; /* warm beige */
  --border: #3d2f4a; /* purple-brown border */
  --card-bg: rgba(45, 38, 45, 0.88); /* purple-tinted card */
  --accent: #b085d4; /* soft purple */
  --star-1: rgba(176, 133, 212, 0.45); /* purple starlight */
  --star-2: rgba(255, 235, 255, 0.3); /* warm purple glow */
  /* Earth band (night) - cozy evening */
  --earth-high: #1f1a15; /* evening hills */
  --earth-low: #141109; /* deep shadows */
  --earth-pattern: rgba(176, 133, 212, 0.15); /* purple fireflies */
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  line-height: 1.45;
  color: var(--ink);
  /* Stratosphere gradient with purple atmosphere */
  background: radial-gradient(
      ellipse 1200px 600px at 50% -10%,
      rgba(138, 101, 175, 0.2),
      transparent 60%
    ),
    radial-gradient(
      ellipse 800px 400px at 30% 20%,
      rgba(176, 133, 212, 0.1),
      transparent 50%
    ),
    linear-gradient(
      to bottom,
      var(--bg-start) 0%,
      var(--bg-mid) 50%,
      var(--bg-end) 100%
    );
  letter-spacing: 0.2px;
  position: relative;
  min-height: 100vh;
}
/* Blurred minimal stars behind content */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
/* Softer, more organic stars */
body::before {
  background-image: radial-gradient(var(--star-2) 0.8px, transparent 1.8px),
    radial-gradient(var(--star-1) 1.1px, transparent 2.2px),
    radial-gradient(var(--star-2) 0.5px, transparent 1.4px),
    radial-gradient(var(--star-1) 0.3px, transparent 0.9px);
  background-size: 180px 200px, 280px 320px, 120px 150px, 90px 110px;
  background-repeat: repeat;
  background-position: 0 0, 60px 30px, 120px 80px, 200px 150px;
  filter: blur(0.6px);
  opacity: 0.5;
}
/* Dark mode: warmer, gentler stars */
[data-theme="dark"] body::before {
  background-size: 140px 160px, 220px 250px, 100px 120px, 80px 95px;
  opacity: 0.7;
  filter: blur(0.5px);
}
/* Organic earth pattern - more like scattered leaves/stones */
body::after {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  height: 35vh;
  background-image: radial-gradient(
      var(--earth-pattern) 1.2px,
      transparent 2.8px
    ),
    radial-gradient(var(--earth-pattern) 0.8px, transparent 2px),
    radial-gradient(var(--earth-pattern) 1.6px, transparent 3.2px);
  background-size: 180px 200px, 120px 140px, 240px 280px;
  background-repeat: repeat;
  background-position: 30% 100%, 70% 95%, 10% 98%;
  opacity: 0.4;
  filter: blur(0.6px);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  background: linear-gradient(
    to bottom,
    rgba(248, 246, 255, 0.85),
    rgba(240, 237, 232, 0.75)
  );
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  z-index: 10;
}
/* Dark mode: warmer, cozier navbar */
[data-theme="dark"] .site-header {
  background: linear-gradient(
    to bottom,
    rgba(26, 22, 37, 0.9),
    rgba(36, 32, 25, 0.8)
  );
  border-bottom-color: rgba(181, 160, 133, 0.3);
}
.site-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 1px;
}
.site-header h1 a {
  text-decoration: none;
  color: inherit;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-toggle {
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--ink);
  border-radius: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}
.theme-toggle:hover {
  background: var(--border);
  transform: translateY(-1px);
}
.user-pill {
  color: inherit;
  text-decoration: none;
}
.about-link {
  color: inherit;
  text-decoration: none;
  opacity: 0.7;
  padding: 2px 4px;
  transition: all 0.2s ease;
}
.about-link:hover {
  opacity: 1;
  background: rgba(124, 82, 149, 0.1);
}

.container {
  padding: 12px 12px 24px;
  max-width: 820px;
  margin: 0 auto;
  position: relative;
  z-index: 1; /* below header, above stars */
}

.note-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 1em;
  margin-bottom: 2em;
  border-bottom: 1px solid var(--border);
}
.note-form textarea {
  width: 100%;
  border-radius: 0;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  background: var(--card-bg);
  color: var(--ink);
  transition: all 0.2s ease;
  line-height: 1.5;
}
.note-form textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
.note-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card-bg);
  box-shadow: 0 0 0 2px rgba(124, 82, 149, 0.1);
}
[data-theme="dark"] .note-form textarea:focus {
  box-shadow: 0 0 0 2px rgba(176, 133, 212, 0.2);
}
.note-form .form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.note-form input[type="text"] {
  flex: 1;
  min-width: 0;
  border-radius: 0;
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--ink);
  transition: all 0.2s ease;
}
.note-form input[type="text"]::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
.note-form input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card-bg);
  box-shadow: 0 0 0 2px rgba(124, 82, 149, 0.1);
}
[data-theme="dark"] .note-form input[type="text"]:focus {
  box-shadow: 0 0 0 2px rgba(176, 133, 212, 0.2);
}
.note-form button {
  padding: 10px 16px;
  border-radius: 0;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
}
.note-form button:hover {
  background: var(--accent);
  color: var(--card-bg);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(124, 82, 149, 0.2);
}
.note-form .remember {
  font-size: 12px;
  opacity: 0.8;
}
.note-form .hint {
  margin: 0;
  font-size: 12px;
  opacity: 0.7;
}
.counter-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}
.char-counter {
  font-size: 12px;
  opacity: 0.6;
}
.char-counter.near {
  color: var(--warn);
  opacity: 1;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Masonry-like with CSS columns; simple and mobile-friendly */
.soup {
  column-width: 280px;
  column-gap: 16px;
}
.note-card {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 12px 14px;
  margin: 0 0 16px;
  box-shadow: 0 1px 6px rgba(45, 37, 45, 0.05);
  transition: all 0.3s ease;
  position: relative;
}
.note-card h2 {
  padding: 0;
  margin: 0.75rem 0;
}
.note-card:hover {
  box-shadow: 0 3px 12px rgba(45, 37, 45, 0.08);
}
.note-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 16px;
  margin-bottom: 12px;
  line-height: 1.5;
  color: var(--ink);
}
.note-text a {
  color: var(--accent);
  text-decoration: underline;
}
.note-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0.3px;
}
.note-meta .dot {
  opacity: 0.5;
}

.note-meta a.author,
.note-meta a.xp-link {
  color: var(--accent);
}

.note-meta .xp-links {
  display: block;
}

/* Crosspost links on their own row below meta */
.xp-row {
  margin-top: 4px;
  display: flex;
  gap: 8px;
  font-size: 11px;
  font-style: italic;
  flex-wrap: wrap;
  padding-left: 2px;
}
.xp-row .xp {
  color: var(--accent);
  text-decoration: none;
  opacity: 0.85;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.xp-row .xp:hover,
.xp-row .xp:focus-visible {
  opacity: 1;
  text-decoration: underline;
  outline: none;
}

.note-del {
  color: #b84a4a;
  text-decoration: none;
  opacity: 0.8;
  text-transform: lowercase;
}
.note-del:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Subtle flag button for reporting inappropriate notes */
.flag-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: 0;
  padding: 2px 4px;
  color: var(--muted);
  opacity: 0.45;
  cursor: pointer;
  line-height: 1;
  font-size: 16px;
  border-radius: 2px;
  transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}
.flag-btn:hover,
.flag-btn:focus {
  color: var(--accent);
  opacity: 0.95;
  transform: translateY(-1px);
  outline: none;
}
.flag-btn.flagged {
  color: var(--warn);
  opacity: 0.9;
}

/* Inline placement inside note-meta footer */
.note-meta .flag-btn {
  position: static;
  top: auto;
  right: auto;
  padding: 0 2px;
  font-size: 12px;
}

/* Gentle, organic drift animation */
@media (prefers-reduced-motion: no-preference) {
  .note-card {
    animation: gentle-drift 28s ease-in-out infinite;
  }
  .note-card:nth-child(3n) {
    animation-duration: 34s;
    animation-delay: -8s;
  }
  .note-card:nth-child(4n) {
    animation-duration: 40s;
    animation-delay: -15s;
  }
  .note-card:nth-child(5n) {
    animation-delay: -5s;
  }
}
@keyframes gentle-drift {
  0%,
  100% {
    transform: translateZ(0) rotate(0) translateY(0px);
  }
  25% {
    transform: translateZ(0) rotate(0) translateY(-1px) translateX(0.5px);
  }
  50% {
    transform: translateZ(0) rotate(0) translateY(-2px) translateX(-0.3px);
  }
  75% {
    transform: translateZ(0) rotate(0) translateY(-1px) translateX(0.2px);
  }
}

.empty {
  opacity: 0.6;
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
  font-size: 18px;
  line-height: 1.6;
}

.profile-header .website {
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
}

.profile-header .website a {
  color: var(--accent);
}

/* Responsive header: show hamburger on small viewports and hide inline links */
.nav-toggle {
  display: none;
  border: 0;
  background: var(--card-bg);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* Mobile menu container (JS toggles the hidden attribute) */
.mobile-menu {
  position: absolute;
  top: 100%;
  right: 8px;
  left: 8px;
  width: auto;
  max-width: calc(100% - 16px);
  box-sizing: border-box;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 30;
  padding: 8px;

  /* Layout links vertically and add spacing */
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

/* Hidden by default (JS manages this; keep display none for safety) */
.mobile-menu[hidden] {
  display: none;
}

/* Make mobile links stack and easier to tap */
.mobile-menu a,
.mobile-menu .mobile-link,
.mobile-menu .mobile-user {
  display: block;
  padding: 8px 10px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
}
.mobile-menu a:hover,
.mobile-menu .mobile-link:hover,
.mobile-menu .mobile-user:hover {
  background: rgba(124, 82, 149, 0.06);
}

/* Mobile-specific tweaks */
@media (max-width: 720px) {
  .header-links {
    display: none !important;
  }
  .nav-toggle {
    display: inline-flex !important;
  }
  .header-actions {
    gap: 8px;
  }
  .site-header h1 {
    font-size: 18px;
  }
}
