:root {
  --bg-color: #fdfcf8;
  --panel-color: #fffefc;
  --accent-moss: #8b9d83;
  --accent-sage: #b4c9b4;
  --ink-color: #4a4442;
  --muted-ink: #7a726f;
  --border-soft: rgba(74, 68, 66, 0.08);
  --font-serif: 'Libre Baskerville', serif;
  --font-sans: 'Quicksand', sans-serif;
  --shadow-soft: 0 12px 30px -10px rgba(74, 68, 66, 0.1);
  --shadow-lift: 0 20px 40px -15px rgba(74, 68, 66, 0.15);
  --transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode {
  --bg-color: #242622;
  --panel-color: #2d302a;
  --ink-color: #d1d3cb;
  --muted-ink: #9ba694;
  --border-soft: rgba(209, 211, 203, 0.1);
  --shadow-soft: 0 12px 30px -10px rgba(0, 0, 0, 0.3);
  --shadow-lift: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

body.dark-mode .memory-card,
body.dark-mode .panel,
body.dark-mode .modal-card,
body.dark-mode .person-chip,
body.dark-mode .input,
body.dark-mode .textarea,
body.dark-mode .select-input,
body.dark-mode .tag-input,
body.dark-mode .mood-opt span {
  background-color: var(--panel-color);
  border-color: var(--border-soft);
}

body.dark-mode .navbar {
  background-color: rgba(36, 38, 34, 0.9);
  background-image: radial-gradient(circle, rgba(139, 157, 131, 0.12) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
}

body.dark-mode .photo-placeholder {
  color: var(--muted-ink);
}

body.dark-mode .letter {
  background-color: #2a2c25;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 27px,
    rgba(180, 201, 180, 0.12) 27px,
    rgba(180, 201, 180, 0.12) 28px
  );
  background-position: 0 36px;
}

body.dark-mode .nav-item:hover,
body.dark-mode .person-chip:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .navbar {
  border-bottom-color: var(--border-soft);
}

body.dark-mode .site-footer {
  border-top-color: var(--border-soft);
}

body.dark-mode .rewind-card,
body.dark-mode .quote-card {
  background: #2a2c25;
}

body.dark-mode {
  background: linear-gradient(135deg, #272922 0%, #161810 100%);
}

body.dark-mode::before {
  background: radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(0, 0, 0, 0.25) 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink-color);
  background: linear-gradient(135deg, #fefdf9 0%, #eddfc8 100%);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(74, 68, 66, 0.1) 100%);
  pointer-events: none;
  z-index: 9998;
}

.navbar, .panel, .memory-card, .btn, .input, .textarea, .modal-card, .person-chip, .quote-card {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Ffilter id='n'%3E%3FfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3F/filter%3E%3Frect width='100%25' height='100%25' filter='url(%23n)'/%3E%3F/svg%3E");
  opacity: 0.035;
  pointer-events: none;
  z-index: 9999;
}


.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 40px;
  background-color: rgba(253, 252, 248, 0.85);
  background-image: radial-gradient(circle, rgba(139, 157, 131, 0.18) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 16px; }
.brand-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.08));
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 28px;
  margin: 0;
  font-weight: 700;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}
.brand-main { color: var(--ink-color); }
.brand-dot { color: var(--accent-moss); font-weight: 900; }
.brand-ext {
  color: white;
  background: var(--accent-sage);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 2px;
  position: relative;
  transform: rotate(-2deg);
  transform-origin: center top;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
  text-transform: lowercase;
  cursor: pointer;
}

.brand-ext:hover,
.brand-ext.wiggling {
  animation: noteWiggle 0.6s ease-in-out;
}

.brand-ext:hover {
  animation-iteration-count: infinite;
}

@keyframes noteWiggle {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(3deg); }
}

.brand-ext .pin {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: var(--accent-moss);
  border-radius: 50%;
  box-shadow: inset -1px -1px 2px rgba(0,0,0,0.3);
}
.brand-tagline {
  font-size: 11px;
  margin: 2px 0 0 0;
  color: var(--muted-ink);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
  opacity: 0.8;
}

.nav-links { display: flex; gap: 12px; }
.nav-item {
  text-decoration: none;
  color: var(--ink-color);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 14px;
  transition: var(--transition);
}
.nav-item:hover { background: var(--border-soft); }
.nav-item.active { background: var(--ink-color); color: white; }

.nav-actions { display: flex; gap: 12px; }

.btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent-moss);
  color: #fff;
  box-shadow: 0 8px 16px rgba(139, 157, 131, 0.3);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(139, 157, 131, 0.4); }

.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; padding: 8px; border-radius: 50%; transition: var(--transition); }
.btn-icon:hover { background: var(--border-soft); }

.btn-ghost { background: transparent; border: 1px solid var(--border-soft); padding: 6px 16px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--muted-ink); cursor: pointer; transition: var(--transition); }
.btn-ghost.active { background: var(--accent-sage); color: white; border-color: var(--accent-sage); }

.container {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 32px;
  padding: 40px;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
}

.container::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background-image: repeating-linear-gradient(
    45deg,
    rgba(139, 157, 131, 0.07) 0px,
    rgba(139, 157, 131, 0.07) 1px,
    transparent 1px,
    transparent 18px
  );
  pointer-events: none;
  z-index: -1;
}

.keepsake-corner {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.memory-jar-container {
  background: #fffef0;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
  transform: rotate(-1deg);
}

body.dark-mode .memory-jar-container {
  background: #2a2c25;
}

.jar-svg {
  display: block;
  width: 120px;
  height: 160px;
  margin: 0 auto 16px;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.05));
}

.jar-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(180, 201, 180, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: pulseGlow 4s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.2); }
}

.rewind-card {
  background: #fffef0;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  position: relative;
  transform: rotate(1deg);
}

.rewind-card::before {
  content: "On This Day";
  position: absolute;
  top: -12px;
  left: 20px;
  background: var(--accent-moss);
  color: white;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  border-radius: 4px;
}

.rewind-content h5 { font-family: var(--font-serif); margin: 12px 0 8px 0; font-size: 16px; }
.rewind-content p { font-size: 13px; color: var(--muted-ink); margin: 0; line-height: 1.4; }


.tag-cloud {
  padding: 10px;
}

.tag-cloud-items {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.cloud-tag {
  font-family: 'Gochi Hand', cursive;
  font-size: 18px;
  color: var(--muted-ink);
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
}

.cloud-tag:hover { color: var(--accent-moss); transform: scale(1.1) rotate(-5deg); }

.heartbeat-stats {
  background: #fffef0;
  padding: 20px;
  margin-top: 16px;
  margin-bottom: 24px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  position: relative;
  transform: rotate(-0.5deg);
}

.heartbeat-stats::before {
  content: "Memory Pulse";
  position: absolute;
  top: -12px;
  left: 20px;
  background: var(--accent-moss);
  color: white;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  border-radius: 4px;
}

body.dark-mode .heartbeat-stats {
  background: #2a2c25;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-item:last-child { margin-bottom: 0; }
.stat-icon { font-size: 20px; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-weight: 800; font-size: 14px; }
.stat-label { font-size: 11px; color: var(--muted-ink); text-transform: uppercase; letter-spacing: 1px; }

@media (max-width: 1200px) {
  .container {
    grid-template-columns: 250px 1fr;
  }
  .keepsake-corner {
    display: none;
  }
}

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  .navbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-links {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .brand-tagline {
    display: none;
  }

  .brand-name {
    font-size: 20px;
    gap: 8px;
  }

  .brand-logo {
    height: 36px;
  }

  .brand-ext {
    font-size: 10px;
    padding: 3px 8px;
  }

  .nav-actions {
    gap: 6px;
  }

  .btn {
    padding: 10px 14px;
    font-size: 13px;
  }

  .btn-icon {
    font-size: 18px;
    padding: 6px;
  }

  .container {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
  }

  .sidebar .section {
    margin-bottom: 0;
    width: 100%;
  }

  .sidebar .section-title {
    font-size: 14px;
    margin-bottom: 10px;
  }

  .people-grid {
    flex-wrap: wrap;
  }

  .btn-add-family {
    display: inline-flex;
  }

  .quote-card {
    display: block;
  }

  .keepsake-corner {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
  }

  .memory-jar-container {
    width: 100%;
  }

  .jar-svg {
    width: 80px;
    height: 106px;
  }

  .stream-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .stream-title {
    font-size: 22px;
  }

  .stream-controls {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  .memory-card {
    transform: none !important;
  }

  .heartbeat-stats,
  .quote-card,
  .rewind-card,
  .memory-jar-container {
    transform: none;
  }
}

.section { margin-bottom: 40px; }
.section-title { font-family: var(--font-serif); font-size: 18px; margin-bottom: 16px; border-bottom: 2px solid var(--accent-sage); display: inline-block; padding-bottom: 4px; }

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title-row .section-title { margin-bottom: 0; }

.btn-add-family {
  margin-top: 12px;
  font-size: 13px;
  padding: 10px 16px;
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.avatar-opt {
  background: var(--bg-color);
  border: 2px solid var(--border-soft);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  font-size: 22px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--transition);
}
.avatar-opt:hover { border-color: var(--accent-sage); transform: scale(1.1); }
.avatar-opt.active { border-color: var(--accent-moss); background: rgba(139, 157, 131, 0.12); }

.people-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.person-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 99px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-sans);
}
.person-chip:hover { border-color: var(--accent-moss); transform: translateY(-2px); }
.person-chip.active { background: var(--accent-moss); color: white; border-color: var(--accent-moss); }
.avatar { font-size: 18px; }
.name { font-weight: 700; font-size: 13px; }


.quote-card {
  padding: 20px;
  margin-top: 16px;
  background: #fffef0;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  position: relative;
  font-style: italic;
  font-size: 14px;
  transform: rotate(0.8deg);
}

.quote-card::before {
  content: "Daily Wisdom";
  position: absolute;
  top: -12px;
  left: 20px;
  background: var(--accent-moss);
  color: white;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  border-radius: 4px;
}

.quote-card span { display: block; margin-top: 12px; font-weight: 700; font-style: normal; color: var(--accent-sage); }

.stream-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.stream-title { font-family: var(--font-serif); font-size: 32px; margin: 0; }
.stream-controls { display: flex; gap: 8px; }

.masonry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  align-items: center;
}

@media (max-width: 600px) {
  .masonry-grid {
    grid-template-columns: 1fr;
  }
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: rotate(var(--rotation)) translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: rotate(var(--rotation)) translateY(0) scale(1);
  }
}

.memory-card {
  break-inside: avoid;
  background: white;
  padding: 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  transform: rotate(var(--rotation));
  transition: var(--transition);
  position: relative;
}

.memory-card.is-new {
  animation: cardEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.memory-card:hover {
  transform: rotate(0deg) translateY(-8px);
  box-shadow: var(--shadow-lift);
  z-index: 10;
}

.polaroid { padding: 16px 16px 40px 16px; border-radius: 2px; background: var(--polaroid-bg, #fffef8); }

.polaroid .card-content > .card-date {
  display: block;
  margin-bottom: 6px;
}
.card-photo { border: 1px solid rgba(0,0,0,0.05); overflow: hidden; margin-bottom: 16px; border-radius: 4px; }
.card-img { width: 100%; height: 240px; object-fit: cover; display: block; }
.photo-placeholder { height: 240px; display: grid; place-items: center; color: var(--muted-ink); }
.card-photo.small .photo-placeholder { height: 120px; }
.photo-placeholder .emoji { font-size: 48px; }
.photo-placeholder small { font-weight: 700; margin-top: 8px; }

.letter {
  background-color: var(--letter-bg, #fffef0);
  background-image: repeating-linear-gradient(
    transparent,
    transparent 27px,
    rgba(180, 201, 180, 0.35) 27px,
    rgba(180, 201, 180, 0.35) 28px
  );
  background-position: 0 36px;
  padding: 32px 32px 48px 32px;
  border-radius: 4px;
  border-left: 4px solid var(--accent-sage);
}
.wax-seal {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  background: #4a5d4e;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  font-size: 18px;
}

.letter .card-content > .card-date {
  display: block;
  margin-bottom: 6px;
}

.mini-moment { padding: 12px; border-radius: 24px; }
.pin {
  position: absolute;
  top: -13px;
  left: 50%;
  width: 18px;
  height: 18px;
  background: radial-gradient(circle at 35% 35%, var(--pin-color-light, #e8453c), var(--pin-color-dark, #9b1c18));
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow:
    inset -2px -2px 4px rgba(0,0,0,0.35),
    inset 2px 2px 3px rgba(255,255,255,0.25),
    0 4px 8px rgba(0,0,0,0.25),
    0 1px 2px rgba(0,0,0,0.4);
  z-index: 2;
}
.pin::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 3px;
  height: 8px;
  background: linear-gradient(to bottom, #bbb, #888);
  border-radius: 0 0 2px 2px;
  transform: translateX(-50%);
  box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}

.card-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-date { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted-ink); letter-spacing: 0.5px; }
.card-tags { font-size: 11px; color: var(--accent-sage); font-weight: 700; }
.card-title { font-family: var(--font-serif); font-size: 18px; margin: 0 0 8px 0; line-height: 1.2; }
.card-body { font-size: 14px; margin: 0 0 16px 0; color: #555; font-weight: 500; }
.card-people { display: flex; gap: 4px; }
.mini-avatar { width: 24px; height: 24px; background: white; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border-soft); cursor: help; font-size: 14px; }

.tape-top {
  position: absolute;
  top: -15px;
  left: 50%;
  width: 80px;
  height: 30px;
  background: rgba(255, 235, 150, 0.5);
  backdrop-filter: blur(2px);
  transform: translateX(-50%) rotate(2deg);
  border: 1px solid rgba(0,0,0,0.05);
  clip-path: polygon(5% 0%, 95% 2%, 100% 50%, 95% 98%, 5% 100%, 0% 50%);
}

.audio {
  padding: 0;
  border-radius: 16px;
  overflow: visible;
  background: var(--audio-bg, #f0f5ff);
}

.audio .audio-player {
  border-radius: 16px 16px 0 0;
}

.audio .card-content {
  border-radius: 0 0 16px 16px;
}

.audio-player {
  background: var(--audio-bg, #f0f5ff);
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.audio-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-moss);
  border: none;
  color: white;
  font-size: 13px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 0;
  transition: transform 0.2s ease, background 0.2s ease;
}

.audio-play-btn:hover { transform: scale(1.1); background: var(--accent-sage); }
.audio-play-btn:active { transform: scale(0.95); }

.audio-waveform {
  flex: 1;
  height: 32px;
}

.audio-waveform rect {
  fill: rgba(80, 110, 80, 0.3);
  transition: fill 0.3s ease;
}

.audio.playing .audio-waveform rect {
  fill: var(--accent-sage);
  animation: waveBar 0.5s ease-in-out infinite alternate;
}

.audio.playing .audio-waveform rect:nth-child(2n) { animation-delay: 0.1s; }
.audio.playing .audio-waveform rect:nth-child(3n) { animation-delay: 0.2s; }
.audio.playing .audio-waveform rect:nth-child(4n) { animation-delay: 0.15s; }

@keyframes waveBar {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

.audio-duration {
  font-size: 10px;
  color: var(--muted-ink);
  font-weight: 800;
  font-family: var(--font-sans);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.audio .card-content {
  background: var(--audio-bg, #f0f5ff);
  padding: 14px 16px 20px;
}

.audio .card-date {
  display: block;
  margin-bottom: 4px;
}

.audio .card-title { margin-bottom: 0; }

body.dark-mode .audio,
body.dark-mode .audio .audio-player,
body.dark-mode .audio .card-content { background: #1e2a20 !important; }

.site-footer {
  text-align: center;
  padding: 60px 40px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted-ink);
  font-size: 13px;
  font-weight: 600;
  background-image: radial-gradient(circle, rgba(139, 157, 131, 0.18) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
}

.memory-card {
  cursor: pointer;
}

.card-modal-inner {
  width: min(520px, 90vw);
  position: relative;
  padding-top: 24px;
  margin: auto;
  transform: translateY(30px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .card-modal-inner {
  transform: translateY(0) scale(1);
}

.card-modal-inner .memory-card {
  transform: none !important;
  margin: 0;
  cursor: default;
  break-inside: unset;
  font-size: 1.1em;
}

.card-modal-inner .memory-card:hover {
  transform: none !important;
  box-shadow: var(--shadow-soft);
}

.card-modal-close {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--panel-color);
  border: 1px solid var(--border-soft);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted-ink);
  display: grid;
  place-items: center;
  z-index: 10;
  line-height: 1;
}

@media (max-width: 768px) {
  #cardModal {
    align-items: flex-end;
    padding: 0;
  }

  #cardModal .card-modal-inner {
    width: 100%;
    border-radius: 24px 24px 0 0;
    background: var(--bg-color);
    padding: 32px 20px 32px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
  }

  #cardModal.active .card-modal-inner {
    transform: translateY(0);
  }

  #cardModal .card-modal-close {
    top: 12px;
    right: 16px;
  }

  #cardModal .memory-card {
    box-shadow: none;
    border: 1px solid var(--border-soft);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 68, 66, 0.4);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-color);
  width: min(500px, 100%);
  border-radius: 24px;
  padding: 32px;
  position: relative;
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.25);
  transform: translateY(20px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid white;
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted-ink);
}

.modal-header { margin-bottom: 24px; }
.modal-title { font-family: var(--font-serif); font-size: 24px; margin: 0; }
.modal-subtitle { font-size: 14px; color: var(--muted-ink); margin-top: 4px; }

.form-group { margin-bottom: 20px; }
.label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 8px; color: var(--ink-color); }

.input, .textarea, .select-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: white;
  font-family: var(--font-sans);
  font-size: 14px;
  transition: var(--transition);
  appearance: none;
}

.select-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%237a726f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}

.input:focus, .textarea:focus, .select-input:focus {
  outline: none;
  border-color: var(--accent-moss);
  box-shadow: 0 0 0 4px rgba(139, 157, 131, 0.15);
}

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

.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}
.tag-chip {
  background: var(--accent-sage);
  color: white;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.remove-tag {
  background: none;
  border: none;
  color: white;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}
.remove-tag:hover { opacity: 1; }

.input-inline {
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 13px;
  flex: 1;
  min-width: 100px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
}

