:root {
  color-scheme: light;
  --ink: #14201b;
  --muted: #65716b;
  --paper: #fbfaf6;
  --panel: rgba(255, 255, 255, 0.9);
  --line: #dfe5df;
  --accent: #235c45;
  --accent-dark: #174332;
  --accent-soft: #e8f0eb;
  --danger: #8f2f27;
  --shadow: 0 18px 45px rgba(25, 49, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(211, 226, 217, 0.75), transparent 30rem),
    linear-gradient(145deg, #f8f6ef 0%, #eef3ef 100%);
}

button,
a {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
pre:focus-visible {
  outline: 3px solid rgba(35, 92, 69, 0.3);
  outline-offset: 3px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 5rem;
  padding: 1rem clamp(1rem, 4vw, 3.5rem);
  border-bottom: 1px solid rgba(20, 32, 27, 0.09);
  background: rgba(251, 250, 246, 0.76);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  color: white;
  font-family: Georgia, serif;
  font-size: 1.35rem;
  background: var(--accent);
  border-radius: 0.75rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.session-status {
  color: var(--muted);
  font-size: 0.78rem;
}

.account-actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

.button,
.icon-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding: 0.65rem 1.15rem;
  color: white;
  font-weight: 700;
  text-decoration: none;
  background: var(--accent);
}

.button:hover {
  background: var(--accent-dark);
}

.button.secondary {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

main {
  width: min(90rem, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.panel {
  border: 1px solid rgba(20, 32, 27, 0.09);
  background: var(--panel);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

.welcome {
  width: min(42rem, 100%);
  margin: clamp(3rem, 10vh, 8rem) auto;
  padding: clamp(2rem, 7vw, 4rem);
}

.welcome h1 {
  max-width: 14ch;
  margin: 0 0 1rem;
  font-family: Georgia, serif;
  font-size: clamp(2.25rem, 8vw, 4.75rem);
  font-weight: 500;
  line-height: 0.98;
}

.welcome > p:not(.eyebrow) {
  max-width: 35rem;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.archive-layout {
  display: grid;
  grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr);
  gap: 1rem;
  min-height: calc(100vh - 8rem);
}

.archive-nav,
.document {
  min-height: 0;
  overflow: hidden;
}

.archive-nav {
  padding: 1.25rem;
}

.archive-nav-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.archive-nav h1,
.document h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-weight: 500;
}

.archive-nav h1 {
  font-size: 2rem;
}

.document-groups {
  display: grid;
  gap: 1.5rem;
}

.document-groups h2 {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.document-list {
  display: grid;
  gap: 0.35rem;
}

.document-link {
  width: 100%;
  padding: 0.75rem;
  overflow: hidden;
  color: var(--ink);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 0.65rem;
  cursor: pointer;
}

.document-link:hover,
.document-link.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.icon-button {
  padding: 0.5rem 0.7rem;
  color: var(--accent);
  background: transparent;
}

.document {
  padding: clamp(1.35rem, 4vw, 3rem);
}

.document h2 {
  overflow-wrap: anywhere;
  font-size: clamp(1.65rem, 4vw, 2.75rem);
}

.document pre {
  max-height: calc(100vh - 14rem);
  margin: 2rem 0 0;
  padding: 1.25rem;
  overflow: auto;
  color: #25332d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
}

.document-empty {
  display: grid;
  min-height: 60vh;
  place-content: center;
  text-align: center;
}

.document-empty p:last-child,
.empty-list {
  color: var(--muted);
}

.empty-list {
  margin: 0.4rem 0;
  font-size: 0.85rem;
}

.error {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  color: var(--danger);
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
  }

  .account-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .session-status {
    width: 100%;
    text-align: right;
  }

  .archive-layout {
    grid-template-columns: 1fr;
  }

  .archive-nav {
    max-height: 45vh;
    overflow: auto;
  }

  .document pre {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .brand small,
  .session-status,
  #passkey-link {
    display: none;
  }

  .topbar,
  main {
    padding-right: 0.8rem;
    padding-left: 0.8rem;
  }

  .welcome {
    margin-top: 2rem;
  }
}
