:root {
  --background: #fbf7ef;
  --foreground: #221c18;
  --card: #fffdf9;
  --muted: #7f7168;
  --muted-surface: #f7efe2;
  --border: #eadccb;
  --primary: #d99822;
  --primary-dark: #9b5f09;
  --primary-foreground: #fffaf0;
  --ring: #d7ae6d;
  --danger: #b91c1c;
  --success: #166534;
  --shadow: 0 18px 60px rgba(74, 45, 18, 0.1);
  --radius: 16px;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(226, 163, 47, 0.16), transparent 30rem),
    radial-gradient(circle at top right, rgba(207, 159, 91, 0.12), transparent 26rem),
    var(--background);
  color: var(--foreground);
  font-family: var(--sans);
}

a {
  color: inherit;
}

.site-header {
  align-items: center;
  background: rgba(255, 253, 249, 0.72);
  border-bottom: 1px solid rgba(234, 220, 203, 0.78);
  display: flex;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 48px);
  position: sticky;
  top: 0;
  backdrop-filter: blur(16px);
  z-index: 10;
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: 12px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  text-decoration: none;
}

.brand-mark {
  height: 30px;
  width: 30px;
}

.nav-actions,
.auth-links,
.memory-actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.account-menu {
  min-width: 148px;
  position: relative;
}

.account-menu-trigger {
  align-items: center;
  background: rgba(255, 253, 249, 0.85);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--foreground);
  cursor: pointer;
  display: inline-flex;
  font-size: 15px;
  font-weight: 750;
  gap: 10px;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 16px 0 18px;
  width: 100%;
}

.account-menu-trigger::-webkit-details-marker {
  display: none;
}

.account-menu-trigger::after {
  color: var(--muted);
  content: "\25BE";
  font-size: 12px;
  line-height: 1;
}

.account-menu-icon {
  background:
    radial-gradient(circle at 50% 36%, #704408 0 4px, transparent 4px),
    radial-gradient(circle at 50% 92%, #704408 0 9px, transparent 9px),
    #fff4d8;
  border: 1px solid #eed196;
  border-radius: 50%;
  flex: 0 0 auto;
  height: 24px;
  width: 24px;
}

.account-menu[open] .account-menu-trigger {
  background: linear-gradient(135deg, #fee9bb, #f4d086);
  border-color: transparent;
  color: #5f3909;
}

.account-menu[open] .account-menu-trigger::after {
  color: #704408;
  transform: rotate(180deg);
}

.account-menu-panel {
  background: rgba(255, 253, 249, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 100%;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
}

.account-menu-panel form {
  margin: 0;
}

.account-menu-item {
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: #6b5e55;
  cursor: pointer;
  display: block;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.account-menu-item:hover,
.account-menu-item:focus {
  background: var(--muted-surface);
  color: var(--foreground);
}

.page-shell {
  margin: 0 auto;
  max-width: 900px;
  padding: 48px 20px 72px;
}

.hero {
  padding: 32px 0 22px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin: 0;
}

h1 {
  font-size: clamp(42px, 8vw, 72px);
}

h2 {
  font-size: 30px;
}

.hero-copy,
.card-header p,
.empty-state p {
  color: var(--muted);
  line-height: 1.6;
}

.card {
  background: rgba(255, 253, 249, 0.84);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.composer-card,
.auth-card {
  margin-bottom: 32px;
}

.composer-card {
  margin-left: auto;
  margin-right: auto;
  max-width: 760px;
  padding: 28px 30px 30px;
}

.card-header {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
}

.card-header p {
  margin: 8px 0 0;
}

.composer-spark {
  color: #e0a12c;
  font-size: 30px;
  line-height: 1;
  padding-top: 5px;
}

.composer,
.stacked-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.label {
  font-size: 13px;
  font-weight: 700;
}

.visually-hidden {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  position: absolute;
  width: 1px;
  clip: rect(0, 0, 0, 0);
}

.input,
.textarea {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--foreground);
  font: inherit;
  padding: 13px 16px;
  width: 100%;
}

.textarea-frame {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.textarea-frame:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 4px rgba(215, 174, 109, 0.18);
}

.textarea-frame .textarea {
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 138px;
  resize: vertical;
}

.input:focus,
.textarea:focus {
  outline: none;
}

.composer-tools {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 16px;
  padding: 0 16px 14px;
}

.character-count {
  font-size: 13px;
  margin-left: auto;
}

.dictation-button {
  align-items: center;
  background: #fff4d8;
  border: 1px solid #eed196;
  border-radius: 999px;
  color: #704408;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  gap: 9px;
  min-height: 34px;
  padding: 0 13px;
}

.dictation-button::before {
  content: "\25CF";
  font-size: 10px;
}

.dictation-button.recording {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.dictation-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.dictation-waveform {
  align-items: center;
  display: inline-flex;
  gap: 2px;
  height: 20px;
  overflow: hidden;
  width: 76px;
}

.dictation-waveform[hidden] {
  display: none;
}

.dictation-waveform-bar {
  background: rgba(153, 27, 27, 0.34);
  border-radius: 999px;
  display: block;
  flex: 0 0 2px;
  transition: background 120ms ease, height 120ms ease;
}

.dictation-waveform-bar.speaking {
  background: #dc2626;
}

.dictation-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 8px 2px 0;
  min-height: 18px;
}

.dictation-status.error {
  color: var(--danger);
}

.dictation-suggestions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.dictation-suggestions-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.dictation-suggestion {
  background: #dfe4c4;
  border: 0;
  border-radius: 999px;
  color: #4b5a20;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  padding: 7px 11px;
}

.date-updated {
  animation: date-updated-pulse 1.4s ease-out;
}

@keyframes date-updated-pulse {
  0% {
    background: #fff0c7;
    box-shadow: 0 0 0 0 rgba(217, 152, 34, 0.42);
  }

  45% {
    background: #fff7df;
    box-shadow: 0 0 0 5px rgba(217, 152, 34, 0.18);
  }

  100% {
    background: var(--card);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dictation-waveform-bar {
    transition: none;
  }

  .timeline-item.animating {
    animation: none;
  }
}

.composer-footer {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.compact-field {
  max-width: 210px;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 750;
  justify-content: center;
  min-height: 46px;
  padding: 0 22px;
  text-decoration: none;
}

.button:disabled {
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.58;
}

.button-primary {
  background: linear-gradient(135deg, #d59628, #e6b85f);
  box-shadow: 0 14px 26px rgba(181, 119, 21, 0.22);
  color: var(--primary-foreground);
}

.button-secondary,
.button-ghost {
  background: rgba(255, 253, 249, 0.85);
  border-color: var(--border);
}

.button-danger {
  background: var(--danger);
  color: white;
}

.full-width {
  width: 100%;
}

.filter-bar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 24px;
  max-width: 760px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-pill {
  align-items: center;
  background: rgba(255, 253, 249, 0.64);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #594b42;
  display: inline-flex;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  text-decoration: none;
}

.filter-pill.active {
  background: linear-gradient(135deg, #fee9bb, #f4d086);
  border-color: transparent;
  color: #5f3909;
  font-weight: 750;
}

.filter-clear {
  color: #685c54;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.timeline {
  margin: 0 auto;
  max-width: 760px;
  padding-left: 54px;
  position: relative;
}

.timeline::before {
  background: #e9d9c5;
  bottom: 0;
  content: "";
  left: 11px;
  position: absolute;
  top: 12px;
  width: 1px;
}

.timeline-group {
  color: #7a695f;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0;
  margin: 24px 0 14px;
}

.timeline-item {
  margin-bottom: 18px;
  position: relative;
}

.timeline-marker {
  align-items: center;
  border: 1px solid rgba(211, 154, 76, 0.28);
  border-radius: 50%;
  display: flex;
  font-size: 18px;
  height: 42px;
  justify-content: center;
  left: -63px;
  position: absolute;
  top: 10px;
  width: 42px;
}

.marker-0 {
  background: #fff0c7;
  color: #e1a023;
}

.marker-1 {
  background: #ffe1d0;
  color: #d75f27;
}

.marker-2 {
  background: #e8ecd4;
  color: #6d7f35;
}

.marker-3 {
  background: #ffe2d0;
  color: #d26831;
}

.memory-card {
  overflow: hidden;
  padding-bottom: 19px;
}

.memory-card-header,
.memory-card-content,
.people-list,
.memory-actions {
  padding-left: 26px;
  padding-right: 26px;
}

.memory-card-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding-top: 19px;
}

.memory-card-content {
  padding-top: 12px;
}

.memory-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-family: var(--sans);
  font-size: 14px;
  gap: 9px;
}

.memory-body {
  font-size: 20px;
  line-height: 1.5;
}

.memory-body p {
  margin: 0 0 12px;
}

.mention {
  background: #ffe0a5;
  border-radius: 999px;
  color: #7d4907;
  font-weight: 800;
  padding: 1px 8px;
  text-decoration: none;
}

.mention:hover,
.mention.active {
  background: #f4c76c;
}

.people-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
  padding-top: 2px;
}

.badge {
  background: #dfe4c4;
  border-radius: 999px;
  color: #4b5a20;
  font-size: 13px;
  font-weight: 750;
  padding: 7px 11px;
  text-decoration: none;
}

.badge.active {
  background: #c9d293;
}

.memory-actions {
  color: #6b5e55;
  gap: 18px;
  padding-bottom: 18px;
  padding-top: 14px;
}

.icon-link {
  color: #6b5e55;
  font-family: var(--sans);
  font-size: 15px;
  text-decoration: none;
}

.edit-icon-link {
  align-items: center;
  border-radius: 999px;
  color: #6b5e55;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 17px;
  height: 28px;
  justify-content: center;
  text-decoration: none;
  width: 28px;
}

.edit-icon-link:hover {
  background: var(--muted-surface);
}

/* --- Real-time memory card animations --- */

.timeline-item.animating {
  animation: memory-fade-in 600ms ease-out both;
}

@keyframes memory-fade-in {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.below-form {
  margin-top: 8px;
}

.link {
  color: var(--foreground);
  font-size: 14px;
  font-weight: 700;
  text-decoration-color: var(--ring);
  text-underline-offset: 4px;
}

.alert {
  border-radius: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.alert ul {
  margin-bottom: 0;
}

.alert-error {
  background: #fee2e2;
  color: #7f1d1d;
}

.alert-success {
  background: #dcfce7;
  color: var(--success);
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 34px;
  text-align: center;
}

.auth-card {
  margin-left: auto;
  margin-right: auto;
  max-width: 480px;
  padding: 24px;
}

.auth-card .card-header {
  margin-bottom: 28px;
}

.auth-card .stacked-form {
  gap: 20px;
}

.auth-card .stacked-form .button {
  margin-top: 8px;
}

.auth-links {
  padding-top: 18px;
}

@media (max-width: 720px) {
  .site-header {
    align-items: center;
    flex-direction: row;
    gap: 14px;
    position: static;
  }

  .brand {
    font-size: 26px;
  }

  .nav-actions,
  .filter-bar,
  .composer-footer {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .nav-actions {
    align-items: flex-end;
    flex: 0 0 auto;
    margin-left: auto;
    width: auto;
  }

  .account-menu-panel {
    position: absolute;
  }

  .page-shell {
    padding-top: 28px;
  }

  .composer-card {
    padding: 22px 18px;
  }

  .compact-field {
    max-width: none;
  }

  .composer-footer .button {
    width: 100%;
  }

  .timeline {
    padding-left: 38px;
  }

  .timeline-marker {
    height: 34px;
    left: -44px;
    width: 34px;
  }

  .timeline::before {
    left: 10px;
  }

  .memory-card-header,
  .memory-card-content,
  .people-list,
  .memory-actions {
    padding-left: 18px;
    padding-right: 18px;
  }

  .memory-body {
    font-size: 18px;
  }
}
