:root {
  --paper: #efeee7;
  --surface: rgba(255, 255, 252, .66);
  --ink: #171819;
  --muted: #898a83;
  --line: rgba(23, 24, 25, .16);
  --accent: #5d75bd;
  --cursor-x: 50vw;
  --cursor-y: 45vh;
}

body[data-theme="dark"] {
  --paper: #11151d;
  --surface: rgba(26, 33, 45, .78);
  --ink: #eef2fa;
  --muted: #9ca8ba;
  --line: rgba(235, 241, 249, .18);
  --accent: #9fb4ff;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  transition: background 300ms ease, color 300ms ease;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: .31;
  background-image: radial-gradient(var(--ink) .48px, transparent .75px);
  background-size: 7px 7px;
  mask-image: radial-gradient(circle 390px at var(--cursor-x) var(--cursor-y), black 0%, rgba(0, 0, 0, .28) 42%, transparent 75%);
}

button, a { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { text-decoration: none; }
#paper-canvas { position: fixed; z-index: -2; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .36; }

.site-header, .site-main, .site-footer { width: min(1440px, calc(100% - 48px)); margin: 0 auto; }
.site-header {
  display: grid;
  grid-template-columns: 1fr auto;
  min-height: 74px;
  align-items: start;
  border-bottom: 1px solid var(--line);
}
.wordmark { align-self: center; font-size: 18px; font-weight: 680; }
.wordmark span { color: var(--accent); }
.header-controls { display: grid; justify-items: end; gap: 8px; padding-top: 18px; }
.main-nav { display: flex; align-items: center; gap: 17px; }
.nav-cluster { position: relative; display: flex; align-items: baseline; gap: 3px; }
.nav-item, .menu-toggle {
  padding: 0;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  transition: color 160ms ease;
}
.nav-item:hover, .nav-item.is-active, .nav-cluster:hover .nav-item, .nav-cluster.is-open .nav-item { color: var(--ink); }
.menu-toggle { width: 10px; color: var(--muted); font-size: 11px; opacity: 0; transform: translateY(1px); transition: opacity 150ms ease, color 150ms ease; }
.nav-cluster:hover .menu-toggle, .nav-cluster.is-open .menu-toggle { opacity: 1; color: var(--accent); }
.nav-menu {
  position: absolute;
  z-index: 12;
  top: 20px;
  right: -9px;
  display: grid;
  min-width: max-content;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 14px 30px rgba(12, 15, 21, .08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
}
.nav-cluster:hover .nav-menu, .nav-cluster.is-open .nav-menu { opacity: 1; pointer-events: auto; transform: translateY(0); }
.nav-menu button { padding: 6px 8px; cursor: pointer; background: transparent; color: var(--muted); text-align: left; font-size: 12px; white-space: nowrap; }
.nav-menu button:hover { color: var(--ink); background: rgba(93, 117, 189, .11); }
.theme-switch { display: flex; gap: 10px; color: var(--muted); font-size: 11px; }
.theme-choice { padding: 0; cursor: pointer; background: transparent; color: inherit; text-transform: lowercase; }
.theme-choice.is-active { color: var(--ink); }

.site-main { position: relative; height: calc(100svh - 124px); min-height: 540px; }
.home-view {
  display: grid;
  grid-template-columns: minmax(360px, .84fr) minmax(520px, 1.16fr);
  gap: 12px;
  height: 100%;
  padding-top: clamp(28px, 6vh, 88px);
  padding-bottom: 62px;
}
.hero-copy, .atlas { min-width: 0; background: var(--surface); }
.hero-copy { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 5vw, 88px); }
.eyebrow { margin: 0 0 15px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.hero-copy h1 { max-width: 10ch; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(46px, 5vw, 86px); font-weight: 400; line-height: .99; }
.hero-note { max-width: 390px; margin: 25px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 29px; }
.text-link { padding: 0 0 4px; cursor: pointer; border-bottom: 1px solid currentColor; background: transparent; font-size: 13px; }
.text-link.quiet { color: var(--muted); }

.atlas { display: grid; grid-template-rows: auto 1fr auto; padding: clamp(20px, 2vw, 34px); overflow: hidden; }
.atlas-topline, .atlas-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.atlas-topline p { margin: 0; }
.atlas-stack { position: relative; min-height: 360px; margin: 18px 0; outline: none; cursor: ew-resize; }
.atlas-stack:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }
.atlas-card {
  position: absolute;
  top: 5%;
  left: 50%;
  width: min(56%, 460px);
  height: 89%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .4);
  background: #6274a9;
  box-shadow: 0 16px 34px rgba(8, 10, 17, .17);
  transition: transform 560ms cubic-bezier(.18, .75, .23, 1), opacity 360ms ease, filter 300ms ease, box-shadow 300ms ease;
}
.atlas-card::after { position: absolute; inset: 0; content: ""; background: rgba(9, 13, 25, .07); pointer-events: none; transition: background 240ms ease; }
.atlas-card img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform 500ms cubic-bezier(.18, .75, .23, 1), filter 450ms ease; }
.atlas-card span { position: absolute; z-index: 1; top: 10px; left: 10px; color: rgba(255, 255, 255, .84); font-size: 10px; }
.atlas-stack:hover .atlas-card:not(.is-current) { filter: brightness(.78); }
.atlas-card.is-current { box-shadow: 0 24px 48px rgba(8, 10, 17, .27); }
.atlas-card.is-current::after { background: transparent; }
.atlas-card.is-current img { transform: scale(1.035); }
.atlas-controls { min-height: 28px; }
.atlas-controls p { flex: 1; margin: 0; text-align: center; text-transform: none; }
.atlas-arrow { width: 34px; height: 28px; padding: 0; cursor: pointer; background: transparent; color: var(--ink); font-size: 23px; line-height: 1; transition: color 150ms ease, transform 150ms ease; }
.atlas-arrow:hover { color: var(--accent); transform: scale(1.12); }

.content-layer {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding-top: clamp(28px, 6vh, 88px);
  background: var(--paper);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 220ms ease, transform 260ms ease;
}
body:not([data-view="home"]) .home-view { opacity: 0; pointer-events: none; transform: scale(.995); }
body:not([data-view="home"]) .content-layer { opacity: 1; pointer-events: auto; transform: translateY(0); }
.layer-header { display: flex; align-items: start; justify-content: space-between; gap: 32px; padding: 0 clamp(20px, 4vw, 68px) 25px; border-bottom: 1px solid var(--line); background: var(--surface); }
.layer-header h2 { max-width: 800px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 4vw, 70px); font-weight: 400; line-height: 1; }
.close-layer { flex: 0 0 auto; width: 36px; height: 36px; margin-top: 4px; cursor: pointer; background: transparent; color: var(--muted); font-size: 32px; line-height: 1; transition: color 150ms ease, transform 180ms ease; }
.close-layer:hover { color: var(--ink); transform: rotate(90deg); }
.layer-body { min-height: 0; overflow: auto; padding: 28px clamp(20px, 4vw, 68px) 52px; background: var(--surface); }
.collection-list { display: grid; border-top: 1px solid var(--line); }
.collection-item { display: grid; grid-template-columns: minmax(150px, .5fr) minmax(220px, 1fr) minmax(200px, .8fr) auto; gap: 24px; align-items: baseline; padding: 22px 0; cursor: pointer; border-bottom: 1px solid var(--line); background: transparent; text-align: left; transition: padding 180ms ease, color 180ms ease; }
.collection-item:hover { padding-left: 10px; color: var(--accent); }
.collection-item span, .collection-item em { color: var(--muted); font-size: 12px; font-style: normal; line-height: 1.4; }
.collection-item strong { font-family: Georgia, "Times New Roman", serif; font-size: clamp(23px, 2.6vw, 38px); font-weight: 400; line-height: 1; }
.collection-item b { font-size: 14px; font-weight: 400; }
.quiet-lines { max-width: 850px; display: grid; gap: 0; border-top: 1px solid var(--line); }
.quiet-lines p { max-width: 750px; margin: 0; padding: 22px 0; border-bottom: 1px solid var(--line); font-family: Georgia, "Times New Roman", serif; font-size: clamp(23px, 2.6vw, 38px); line-height: 1.1; }

.notes-toolbar { display: flex; justify-content: flex-start; margin-bottom: 14px; }
.publish-button { padding: 8px 12px; cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 13px; transition: background 160ms ease, color 160ms ease; }
.publish-button:hover { background: var(--ink); color: var(--paper); }
.note-form { max-width: 980px; display: grid; gap: 12px; margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); background: rgba(93, 117, 189, .07); }
.note-form[hidden] { display: none; }
.note-form textarea { min-height: 122px; width: 100%; resize: vertical; border: 0; outline: 0; background: transparent; color: var(--ink); font: 16px/1.55 Georgia, "Times New Roman", serif; }
.text-button { margin-left: 12px; padding: 8px 0; cursor: pointer; background: transparent; color: var(--muted); font-size: 13px; }
.notes-list { display: grid; gap: 10px; }
.note-card { max-width: 1120px; display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 12px; padding: 22px; border: 1px solid var(--line); background: rgba(255, 255, 252, .26); }
.note-mark { width: 12px; height: 12px; margin-top: 5px; border-radius: 50%; background: var(--ink); opacity: .72; }
.note-card p { grid-column: 2; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(19px, 2vw, 30px); line-height: 1.2; }
.note-card time { grid-column: 2; margin-top: 18px; color: var(--muted); font-size: 12px; }

.site-footer { display: grid; grid-template-columns: 1.5fr 1fr 1fr auto; gap: 20px; min-height: 50px; align-items: end; padding: 0 0 20px; color: var(--muted); font-size: 11px; }
.site-footer p { margin: 0; }
.site-footer a { justify-self: end; border-bottom: 1px solid transparent; }
.site-footer a:hover { color: var(--ink); border-color: currentColor; }
.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; padding: 10px 12px; transform: translateY(20px); border: 1px solid var(--line); background: var(--ink); color: var(--paper); font-size: 12px; opacity: 0; transition: transform 200ms ease, opacity 200ms ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-height: 820px) and (min-width: 901px) {
  .site-main { height: calc(100svh - 142px); min-height: 0; }
  .home-view { padding-top: 28px; padding-bottom: 28px; }
  .hero-copy { padding: 34px clamp(34px, 4vw, 58px); }
  .hero-copy h1 { font-size: clamp(42px, 4.6vw, 66px); }
  .hero-note { margin-top: 18px; }
  .hero-actions { margin-top: 21px; }
  .atlas { padding: 21px; }
  .atlas-stack { min-height: 280px; margin: 12px 0; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .site-header, .site-main, .site-footer { width: min(100% - 28px, 720px); }
  .site-header { min-height: 86px; }
  .header-controls { gap: 10px; padding-top: 16px; }
  .main-nav { gap: 11px; }
  .nav-item { font-size: 12px; }
  .site-main { height: auto; min-height: calc(100svh - 136px); }
  .home-view { grid-template-columns: 1fr; height: auto; min-height: calc(100svh - 136px); padding-top: 26px; }
  .hero-copy { min-height: 390px; }
  .hero-copy h1 { max-width: 12ch; }
  .atlas { min-height: 490px; }
  .atlas-stack { min-height: 340px; }
  .atlas-card { width: min(62%, 420px); }
  .content-layer { position: fixed; z-index: 10; inset: 86px 0 0; width: 100%; padding: 0; }
  .layer-header { padding: 25px 14px 20px; }
  .layer-body { padding: 22px 14px 44px; }
  .collection-item { grid-template-columns: 1fr auto; gap: 9px 16px; }
  .collection-item strong, .collection-item em { grid-column: 1; }
  .collection-item b { grid-column: 2; grid-row: 1 / 3; }
  .site-footer { grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 20px; }
  .site-footer a { justify-self: start; }
}

@media (max-width: 520px) {
  .site-header { grid-template-columns: 1fr; padding-top: 13px; }
  .wordmark { align-self: start; }
  .header-controls { justify-items: start; padding: 0 0 13px; }
  .main-nav { width: 100%; justify-content: space-between; }
  .nav-cluster { gap: 1px; }
  .menu-toggle { width: 9px; font-size: 10px; opacity: .72; }
  .nav-menu { right: auto; left: -8px; }
  .content-layer { inset: 105px 0 0; }
  .hero-copy { padding: 30px 24px; }
  .hero-copy h1 { font-size: clamp(44px, 13vw, 60px); }
  .atlas { padding: 20px; }
  .atlas-card { width: 68%; }
  .layer-header h2 { font-size: 40px; }
  .note-card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  #paper-canvas { display: none; }
}
