/* Palmline - shared lab-notebook styles */
:root {
  --paper: #fbf8f1;
  --paper-2: #f4efe3;
  --grid-minor: rgba(64, 110, 170, 0.08);
  --grid-major: rgba(64, 110, 170, 0.16);
  --ink: #1d2433;
  --ink-soft: #4a5468;
  --ink-faint: #7b8496;
  --blue: #1f4fa3;
  --blue-2: #3a6fd0;
  --blue-wash: rgba(31, 79, 163, 0.08);
  --red: #c8463d;
  --red-wash: rgba(200, 70, 61, 0.08);
  --green: #2d7a4f;
  --amber: #b7791f;
  --rule: #d8d0bd;
  --card: rgba(255, 253, 248, 0.92);
  --shadow: 0 1px 0 rgba(29, 36, 51, 0.04), 0 6px 18px -10px rgba(29, 36, 51, 0.25);
  --margin-x: 56px;
  --radius: 6px;
  --f-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --f-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  font-family: var(--f-sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}
/* red margin line */
body::before {
  content: "";
  position: fixed;
  top: 0; bottom: 0;
  left: var(--margin-x);
  width: 2px;
  background: rgba(200, 70, 61, 0.45);
  pointer-events: none;
  z-index: 0;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--blue-2); }
img, svg, canvas, video { max-width: 100%; }
:focus-visible { outline: 2px dashed var(--blue); outline-offset: 3px; }

h1, h2, h3, h4 { font-family: var(--f-serif); font-weight: 600; line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code, pre, .mono { font-family: var(--f-mono); font-size: 0.88em; }

.hand { font-family: var(--f-hand); color: var(--blue); font-weight: 600; }
.hand-red { font-family: var(--f-hand); color: var(--red); font-weight: 600; }

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 0 calc(var(--margin-x) + 28px);
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 248, 241, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--f-serif);
  font-weight: 700;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.brand svg { width: 30px; height: 30px; }
.nav-links { display: flex; gap: 4px; margin-left: auto; list-style: none; padding: 0; margin-top: 0; margin-bottom: 0; }
.nav-links a {
  display: block;
  padding: 6px 10px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-links a:hover { color: var(--blue); background: var(--blue-wash); }
.nav-links a[aria-current="page"] { color: var(--blue); box-shadow: inset 0 -2px 0 var(--blue); border-radius: 0; }
.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--red);
  border: 1px dashed var(--red);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.demo-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1.5px solid var(--blue);
  background: var(--blue);
  color: #fff;
  font: 600 0.95rem/1.2 var(--f-sans);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { background: var(--blue-2); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 0 -1px rgba(31, 79, 163, 0.25); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; color: var(--blue); }
.btn-ghost:hover { background: var(--blue-wash); color: var(--blue); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-red { background: var(--red); border-color: var(--red); }
.btn-red:hover { background: #b23a32; }

/* ---------- Sections, figures, cards ---------- */
section { padding: 64px 0; }
.section-head { margin-bottom: 32px; max-width: 720px; }
.eyebrow {
  font-family: var(--f-hand);
  font-size: 1.45rem;
  color: var(--red);
  margin-bottom: 4px;
  display: block;
  transform: rotate(-1.5deg);
  transform-origin: left;
}
.lede { font-family: var(--f-serif); font-size: 1.18rem; color: var(--ink-soft); }
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.figure {
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0;
}
.figcap {
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
}
.figcap b { font-family: var(--f-serif); color: var(--ink); }
.annot {
  position: absolute;
  font-family: var(--f-hand);
  color: var(--blue);
  font-size: 1.2rem;
  line-height: 1.1;
  pointer-events: none;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.muted { color: var(--ink-faint); }
.small { font-size: 0.86rem; }
.tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid currentColor;
  line-height: 1.5;
  white-space: nowrap;
}
.tag-blue { color: var(--blue); background: var(--blue-wash); }
.tag-red { color: var(--red); background: var(--red-wash); }
.tag-green { color: var(--green); background: rgba(45, 122, 79, 0.08); }
.tag-amber { color: var(--amber); background: rgba(183, 121, 31, 0.08); }
.tag-grey { color: var(--ink-faint); background: rgba(123, 132, 150, 0.08); }

.banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 2px dashed var(--red);
  background: var(--red-wash);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--ink);
}
.banner strong { color: var(--red); }
.banner .stamp {
  flex-shrink: 0;
  font-family: var(--f-hand);
  font-size: 1.5rem;
  color: var(--red);
  border: 2px solid var(--red);
  border-radius: 6px;
  padding: 0 10px;
  transform: rotate(-4deg);
  line-height: 1.4;
}
.banner-blue { border-color: var(--blue); background: var(--blue-wash); }
.banner-blue strong { color: var(--blue); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: var(--card); }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { font-family: var(--f-serif); font-weight: 600; background: var(--paper-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* forms */
label { font-weight: 600; font-size: 0.9rem; display: block; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="url"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  font: 400 0.95rem/1.4 var(--f-sans);
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--rule);
  border-bottom: 2px solid var(--ink-faint);
  border-radius: 4px 4px 0 0;
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: none; border-bottom-color: var(--blue); box-shadow: 0 2px 0 0 var(--blue); }
textarea { resize: vertical; min-height: 96px; }
input[type="range"] { accent-color: var(--blue); width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--blue); }

/* FAQ */
.faq details {
  border-bottom: 1px solid var(--rule);
  padding: 14px 0;
}
.faq summary {
  cursor: pointer;
  font-family: var(--f-serif);
  font-weight: 600;
  font-size: 1.08rem;
  list-style: none;
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; font-family: var(--f-mono); color: var(--red); width: 14px; flex-shrink: 0; }
.faq details[open] summary::before { content: "\2212"; }
.faq details p { margin: 10px 0 0 26px; color: var(--ink-soft); }

/* footer */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--rule);
  background: rgba(244, 239, 227, 0.9);
  padding: 32px 0 40px;
  margin-top: 40px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.footer-grid { display: flex; flex-wrap: wrap; gap: 20px 40px; justify-content: space-between; align-items: flex-start; }
.footer-grid nav a { margin-right: 14px; color: var(--ink-soft); }
.disclaimer { margin-top: 18px; font-size: 0.8rem; color: var(--ink-faint); max-width: 760px; }

/* utilities */
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.stack > * + * { margin-top: 12px; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.page-hero { padding: 48px 0 24px; }
.page-hero h1 { font-size: clamp(1.9rem, 4.4vw, 2.8rem); }
.fig-no { font-family: var(--f-hand); color: var(--red); font-size: 1.15rem; font-weight: 700; margin-right: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .nav-toggle { display: inline-block; }
  .nav { flex-wrap: wrap; }
  .nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    padding-bottom: 10px;
    margin-left: 0;
  }
  .nav.open .nav-links { display: flex; }
  .nav-links a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--blue); }
  .nav .demo-chip { order: 2; }
}
@media (max-width: 680px) {
  :root { --margin-x: 14px; }
  .wrap { padding: 0 16px 0 calc(var(--margin-x) + 14px); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  section { padding: 44px 0; }
  .banner { flex-direction: column; gap: 8px; }
  .nav .demo-chip { display: none; }
}

/* wallet button (Sign in with Solana) */
#wallet-slot { display: inline-flex; align-items: center; flex-shrink: 0; margin-left: auto; }
#wallet-slot + .nav-links { margin-left: 0; }
#wallet-slot .ws-btn { padding: 6px 12px; font-size: 0.88rem; color: #fff; }
#wallet-slot .ws-btn.ws-on { color: var(--ink); }
.ws-back .ws-row .ws-pri { color: #fff; }
.ws-modal, .ws-item, .ws-row button, .ws-foot { border-color: rgba(29, 36, 51, 0.18) !important; }
.ws-item { background: var(--paper-2) !important; }
@media (max-width: 820px) {
  #wallet-slot + .nav-toggle { margin-left: 0; }
  .nav { gap: 10px; }
}
@media (max-width: 420px) {
  #wallet-slot .ws-btn { padding: 5px 9px; font-size: 0.8rem; }
}
