:root {
  --background: #fafafa;
  --foreground: #0f172a;
  --card: #ffffff;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --accent: #0052ff;
  --accent-secondary: #4d7cff;
  --accent-foreground: #ffffff;
  --danger: #b42318;
  --warning: #9c741d;
  --success: #136c4c;
  --ring: rgba(0, 82, 255, 0.22);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08);
  --shadow-accent: 0 10px 28px rgba(0, 82, 255, 0.24);
  --gradient: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  --display: Calistoga, Georgia, Cambria, "Times New Roman", Times, serif;
  --body:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --mono:
    "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(241, 245, 249, 0.64), transparent 420px),
    var(--background);
  color: var(--foreground);
  font-family: var(--body);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(
    rgba(15, 23, 42, 0.08) 1px,
    transparent 1px
  );
  background-size: 28px 28px;
  content: "";
  opacity: 0.32;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: 18px;
  top: -48px;
  z-index: 8;
  border-radius: 8px;
  background: var(--foreground);
  color: white;
  padding: 10px 14px;
  text-decoration: none;
}

.skip-link:focus {
  top: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.88);
  background: rgba(250, 250, 250, 0.86);
  padding: 22px clamp(18px, 4vw, 56px);
  backdrop-filter: blur(16px);
}

.brand-lockup,
.topbar-actions,
.form-actions,
.split-heading,
.memory-actions,
.report-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--gradient);
  box-shadow: var(--shadow-accent);
  color: var(--accent-foreground);
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 700;
}

.eyebrow,
.section-label,
.month-title {
  margin: 0;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  border: 1px solid rgba(0, 82, 255, 0.24);
  border-radius: 999px;
  background: rgba(0, 82, 255, 0.06);
  padding: 7px 11px;
}

.section-label span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--gradient);
  animation: pulse 2.4s ease-in-out infinite;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
.overview h2 {
  font-family: var(--display);
  font-weight: 400;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.12rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.status-message {
  min-height: 1.25rem;
  margin: 6px 0 0;
  color: var(--muted-foreground);
  font-size: 0.86rem;
}

button,
.import-button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  padding: 10px 14px;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

button:hover,
.import-button:hover {
  border-color: rgba(0, 82, 255, 0.42);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.import-button input {
  display: none;
}

.primary {
  width: fit-content;
  border-color: transparent;
  background: var(--gradient);
  box-shadow: var(--shadow-accent);
  color: white;
}

.primary:hover {
  filter: brightness(1.04);
}

.ghost {
  min-height: 36px;
  padding: 7px 10px;
  color: var(--accent);
}

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

.hidden {
  display: none;
}

.shell {
  display: grid;
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 64px;
  grid-template-columns: minmax(280px, 410px) 1fr;
  gap: 18px;
}

.overview {
  position: relative;
  display: grid;
  overflow: hidden;
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 82, 255, 0.08), transparent 38%),
    var(--card);
  box-shadow: var(--shadow-md);
  padding: clamp(24px, 4vw, 42px);
}

.overview > *,
.composer,
.insights,
.archive,
.memory-card {
  min-width: 0;
}

.overview::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 34%;
  height: 3px;
  background: var(--gradient);
  content: "";
}

.overview h2 {
  max-width: min(780px, calc(100vw - 104px));
  margin: 18px 0 16px;
  font-size: clamp(2.15rem, 5vw, 4.7rem);
  line-height: 1.04;
  overflow-wrap: break-word;
}

.overview h2::after {
  display: block;
  width: min(260px, 54%);
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(0, 82, 255, 0.22),
    rgba(77, 124, 255, 0.08)
  );
  content: "";
}

.overview p {
  max-width: min(680px, calc(100vw - 104px));
  margin-bottom: 0;
  color: var(--muted-foreground);
  font-size: 1.05rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.proof-grid {
  display: grid;
  align-content: center;
  gap: 12px;
}

.proof-grid a {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 16px;
  text-decoration: none;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.proof-grid a:hover {
  border-color: rgba(0, 82, 255, 0.42);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.proof-grid strong {
  display: block;
  margin-bottom: 5px;
}

.proof-grid span {
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.composer,
.insights,
.archive {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-md);
}

.composer,
.insights {
  padding: 22px;
}

.composer {
  position: sticky;
  top: 104px;
  align-self: start;
}

.insights {
  grid-column: 1;
}

.archive {
  overflow: hidden;
  grid-column: 2;
  grid-row: 2 / span 2;
}

.split-heading {
  justify-content: space-between;
}

.section-heading {
  display: grid;
  gap: 8px;
}

.section-heading p,
.archive-count {
  margin-bottom: 0;
  color: var(--muted-foreground);
  line-height: 1.55;
}

form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: #fbfdff;
  color: var(--foreground);
  padding: 12px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea {
  min-height: 170px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.import-button:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.insight-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.insight-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}

.insight-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--gradient);
  content: "";
}

.insight-card strong {
  display: block;
  margin-bottom: 5px;
}

.insight-card span {
  color: var(--muted-foreground);
  line-height: 1.45;
}

.reflection-report {
  margin-top: 16px;
  border: 1px solid rgba(0, 82, 255, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 82, 255, 0.08), transparent), #ffffff;
  padding: 16px;
}

.reflection-report h3 {
  margin-bottom: 8px;
}

.reflection-report p,
.reflection-report li {
  color: var(--muted-foreground);
  line-height: 1.55;
}

.reflection-report ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.archive-header {
  display: grid;
  align-items: center;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 22px;
}

.search {
  background: white;
}

.tag-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: rgba(241, 245, 249, 0.7);
  padding: 14px 22px;
}

.tag-filter {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.84rem;
}

.tag-filter.active {
  border-color: transparent;
  background: var(--gradient);
  color: white;
}

.tag-filter:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.timeline {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.month-group {
  display: grid;
  gap: 10px;
}

.month-title {
  color: var(--accent);
}

.memory-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.memory-card:hover {
  border-color: rgba(0, 82, 255, 0.22);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.memory-card.pinned {
  border-color: rgba(156, 116, 29, 0.46);
  background: linear-gradient(
    135deg,
    rgba(156, 116, 29, 0.12),
    rgba(255, 255, 255, 0.9)
  );
}

.memory-card.pinned::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--warning), #f5c451);
  content: "";
}

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

.memory-meta {
  margin-bottom: 4px;
  color: var(--muted-foreground);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.memory-body {
  margin: 12px 0;
  color: #344054;
  line-height: 1.62;
  white-space: pre-wrap;
}

.tag-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.tag {
  border-radius: 999px;
  background: rgba(0, 82, 255, 0.08);
  color: #003bb8;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.empty {
  padding: 36px 22px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.68;
    transform: scale(1.28);
  }
}

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

@media (max-width: 1180px) {
  .topbar,
  .overview,
  .archive-header,
  .field-grid,
  .split-heading {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    display: grid;
  }

  .shell {
    width: calc(100% - 24px);
    max-width: 1180px;
    grid-template-columns: 1fr;
  }

  .overview h2 {
    max-width: 100%;
    font-size: clamp(1.55rem, 7vw, 1.85rem);
    line-height: 1.08;
    overflow-wrap: anywhere;
  }

  .overview p {
    max-width: 100%;
    font-size: 0.98rem;
    overflow-wrap: anywhere;
  }

  .overview {
    width: 100%;
    max-width: 100%;
    padding: 24px;
  }

  .proof-grid,
  .proof-grid a {
    width: 100%;
    max-width: 100%;
  }

  .overview,
  .composer,
  .insights,
  .archive {
    grid-column: auto;
    grid-row: auto;
  }

  .composer {
    position: static;
  }

  .memory-card-header {
    display: grid;
  }
}

@media print {
  .topbar-actions,
  .composer,
  .tag-filters,
  .search,
  .memory-actions,
  .report-actions,
  .skip-link,
  .overview {
    display: none;
  }

  .topbar {
    position: static;
    padding: 0 0 18px;
  }

  .shell {
    display: block;
    width: 100%;
    margin: 0;
  }

  .insights,
  .archive {
    border-color: #d0d5dd;
    box-shadow: none;
    margin-bottom: 18px;
  }

  .memory-card {
    break-inside: avoid;
  }
}
