/* ==========================================================================
   pipt — editorial stylesheet (Geist + Geist Mono + Georgia)
   Palette + layout mirrored from the reference site; everything configurable
   via data attributes / tokens here.
   ========================================================================== */

:root {
  --ink: #1f2922;
  --muted: #747a72;
  --line: #d4d8cf;
  --blue: #3f654e;
  --paper: #eef1e9;
  --surface: #fafaf5;
  --clay: #bf684f;
  --rail: #233128;
  --rail-muted: #aeb8aa;
  --side: #e5e8df;
  --side-muted: #687069;
  --green-deep: #2f3d34;
  --font-sans: "Geist", ui-sans-serif, system-ui, Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

a { color: inherit; }

/* ---------------------------------------------------------------- shell -- */
.site-shell {
  background: var(--paper);
  display: grid;
  grid-template-columns: 202px minmax(0, 1fr);
  min-height: 100vh;
}
.site-content { background: var(--paper); min-width: 0; }

/* ---------------------------------------------------------------- rail --- */
.index-rail {
  height: 100vh;
  position: sticky;
  top: 0;
  color: var(--ink);
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 30px 20px 22px;
  display: flex;
  flex-direction: column;
}
.rail-heading .brand {
  color: inherit;
  letter-spacing: -0.065em;
  font-size: 31px;
  font-weight: 530;
  line-height: 1;
  text-decoration: none;
  display: inline-block;
}
.rail-heading p {
  max-width: 145px;
  color: var(--side-muted);
  font: 12px/1.45 var(--font-sans);
  margin: 14px 0 0;
}
.rail-nav {
  display: grid;
  gap: 3px;
  margin: clamp(46px, 9vh, 86px) 0 38px;
}
.rail-nav a {
  color: var(--side-muted);
  font: 500 12px/1.25 var(--font-sans);
  border-radius: 7px;
  padding: 9px 10px;
  text-decoration: none;
}
.rail-nav a:hover { color: var(--ink); background: #1f29220f; }
.rail-actions { margin-top: auto; display: grid; gap: 14px; }
.rail-notebook {
  background: none;
  border: 0;
  padding: 0;
  width: max-content;
  font: 500 13px/1.2 var(--font-sans);
  color: var(--ink);
  letter-spacing: -0.005em;
}
.rail-notebook:hover { text-decoration: underline; text-underline-offset: 3px; }
.rail-social {
  color: var(--side-muted);
  font: 500 12px/1.3 var(--font-sans);
  text-decoration: none;
}
.rail-social b { font-weight: 400; }
.rail-social:hover { color: var(--ink); }

/* ---------------------------------------------------------------- page --- */
.page { width: min(1180px, 100% - 72px); margin: 0 auto; padding: 46px 0 56px; }

/* ---------------------------------------------------------------- intro -- */
.intro h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(48px, 6.5vw, 92px);
  font-weight: 460;
  line-height: 0.9;
  letter-spacing: -0.072em;
}
.intro h1 em { color: var(--clay); font-style: normal; }
.pairing-line {
  max-width: 760px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font: 13px/1.45 var(--font-sans);
  margin: 22px 0 0;
  padding-top: 14px;
}
.pairing-line strong { color: var(--ink); font-weight: 560; }

/* ---------------------------------------------------------- study frame -- */
.study-frame {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  width: calc(100% + 74px);
  margin-left: -37px;
  margin-top: 34px;
}
.room { position: relative; overflow: hidden; aspect-ratio: 3; min-height: 360px; max-height: 440px; background: #f2f0e7; }
.room-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.room-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: #f2f0e7;
  color: var(--muted);
  font: 10px var(--font-mono);
  transition: opacity 0.45s ease;
}
.room.is-ready .room-loading { opacity: 0; pointer-events: none; }

.thought {
  z-index: 2;
  position: absolute;
  top: 32px;
  left: 32px;
  width: min(250px, 42%);
  color: var(--green-deep);
  margin: 0;
  font: italic 15px/1.4 var(--serif);
  text-align: left;
  pointer-events: none;
}
.thought span {
  display: block;
  color: var(--muted);
  font: 9px var(--font-mono);
  margin-bottom: 7px;
  font-style: normal;
}
.notice {
  z-index: 2;
  position: absolute;
  bottom: 27px;
  left: 28px;
  background: #fafaf5e0;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  padding: 7px 9px;
  font: 10px var(--font-mono);
  animation: 0.2s ease-out appear;
}
.notice::before { content: "· "; color: var(--clay); }

.study-aside {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1.05fr 1.35fr 0.8fr;
}
.study-aside > div {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 138px;
  padding: 20px 22px;
}
.study-aside > div + div { border-left: 1px solid var(--line); }
.study-aside span {
  font: 10px var(--font-mono);
  color: var(--muted);
}
.study-aside p {
  margin: 0;
  color: var(--green-deep);
  font: 15px/1.5 var(--serif);
}
.shared-note p { color: var(--muted); }
.shared-note .auto-note { margin-top: 6px; font: 10px/1.45 var(--font-mono); color: var(--clay); }

/* ---------------------------------------------------------- study form --- */
.study-form { border-top: 1px solid var(--line); padding: 18px 22px; background: var(--paper); }
.study-form label { display: block; font: 10px var(--font-mono); color: var(--muted); margin-bottom: 12px; }
.study-form label span { color: var(--clay); }
.study-row { display: flex; gap: 10px; }
.study-row input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: 13px var(--font-sans);
  color: var(--ink);
  outline: none;
}
.study-row input:focus { border-color: var(--blue); }
.study-row button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  padding: 0 18px;
  font: 500 13px var(--font-sans);
}
.study-row button:hover { background: var(--blue); border-color: var(--blue); }
.study-row button:disabled { opacity: 0.55; cursor: progress; }
.study-status { margin: 10px 0 0; font: 12px/1.45 var(--font-sans); color: var(--muted); }
.study-status.err { color: var(--clay); }
.study-status.ok { color: var(--blue); }

/* ------------------------------------------------------ notebook preview */
.notebook-preview { padding: 92px 0 72px; }
.notebook-preview header { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 30px; }
.notebook-preview header span,
.made-by-pipt header span,
.about-pipt span { display: block; color: var(--blue); font: 10px var(--font-mono); margin-bottom: 9px; }
.notebook-preview h2,
.made-by-pipt h2 { margin: 0; font-size: clamp(26px, 3.4vw, 40px); font-weight: 460; letter-spacing: -0.035em; line-height: 1; }
.notebook-preview header > button {
  background: none;
  border: 0;
  padding: 6px 2px;
  font: 11px var(--font-mono);
  color: var(--clay);
}
.notebook-preview header > button:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.note-list { list-style: none; margin: 0; padding: 0; }
.note-list li {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 40px;
  padding: 24px 0;
}
.note-list li:first-child { border-top: 1px solid var(--ink); }
.note-subject { display: grid; gap: 7px; align-content: start; }
.note-subject span { font: 430 20px/1.1 var(--serif); letter-spacing: -0.01em; color: var(--ink); }
.note-subject time { font: 10px var(--font-mono); color: var(--muted); }
.note-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 24px; }
.note-body p { margin: 0; max-width: 62ch; color: var(--green-deep); font: 15px/1.55 var(--serif); }
.note-body a { font: 10px var(--font-mono); color: var(--clay); text-decoration: underline; text-underline-offset: 3px; }
.note-body a:hover { color: var(--ink); }

/* ------------------------------------------------------------- made-by --- */
.made-by-pipt { padding: 12px 0 64px; }
.made-list { margin-left: 150px; }
.made-list article {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 28px;
  padding: 18px 0 20px;
}
.made-list article:first-child { border-top-color: var(--ink); }
.made-list article h2 { margin: 0 0 7px; font: 460 18px/1.25 var(--serif); letter-spacing: -0.01em; color: var(--ink); }
.made-list article p { margin: 0; color: var(--muted); font: 13px/1.45 var(--font-sans); }
.made-list article > a {
  font: 11px var(--font-mono);
  color: var(--clay);
  text-decoration: none;
  padding-top: 5px;
}
.made-list article > a:hover { color: var(--ink); }

/* --------------------------------------------------------------- about --- */
.about-pipt {
  color: var(--ink);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
  margin-top: 20px;
  padding: 52px 0 66px;
}
.about-copy { max-width: 520px; }
.about-copy p { margin: 4px 0 0; font: 460 19px/1.5 var(--serif); letter-spacing: -0.01em; color: var(--green-deep); }
.learning-list {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  column-gap: 56px;
  margin: 52px 0 0 150px;
  padding-top: 22px;
}
.learning-list > span { grid-column: 1; margin-bottom: 8px; }
.learning-list ul {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  font: 13px/1.55 var(--serif);
  color: #5e675f;
}
.learning-list li { margin-right: 12px; }
.learning-list li.current { color: var(--ink); text-decoration: underline; text-decoration-color: var(--clay); text-underline-offset: 3px; }
.learning-list li.more { color: var(--muted); font-style: italic; }
.pairing-note { grid-area: 1 / 2 / span 2; border-left: 2px solid var(--clay); margin: 0; padding-left: 24px; }
.pairing-note > span { color: var(--clay); font: 10px var(--font-mono); margin-bottom: 11px; }
.pairing-note strong { display: block; color: var(--ink); letter-spacing: -0.02em; font-size: 15px; font-weight: 540; }
.pairing-note p { margin: 10px 0 0; color: var(--muted); font: 13px/1.55 var(--font-sans); }

/* -------------------------------------------------------------- footer --- */
.site-content > footer {
  color: var(--muted);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px 36px;
  font: 12px var(--font-sans);
}

/* -------------------------------------------------------------- dialog --- */
.notebook-dialog {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px;
  padding: 0;
  width: min(780px, calc(100% - 40px));
  max-height: min(85vh, 900px);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.notebook-dialog[open] { display: flex; }
.notebook-dialog::backdrop { background: #1f292240; backdrop-filter: blur(2px); }

.nd-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  padding: 26px 30px 20px;
  border-bottom: 1px solid var(--line);
}
.nd-head span { display: block; color: var(--blue); font: 10px var(--font-mono); margin-bottom: 8px; }
.nd-head h2 { margin: 0; font-size: clamp(24px, 3.4vw, 34px); font-weight: 460; letter-spacing: -0.04em; line-height: 1; }
.nd-close {
  background: none;
  border: 0;
  padding: 6px 2px;
  font: 11px var(--font-mono);
  color: var(--clay);
}
.nd-close:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.nd-list {
  list-style: none;
  margin: 0;
  padding: 8px 30px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.nd-entry { padding: 26px 0 30px; border-bottom: 1px solid var(--line); }
.nd-entry:last-child { border-bottom: 0; }
.nd-entry .nd-subject {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  font: 10px var(--font-mono);
  color: var(--blue);
  background: var(--surface);
}
.nd-entry h3 {
  margin: 13px 0 6px;
  font: 460 26px/1.15 var(--serif);
  letter-spacing: -0.015em;
  color: var(--ink);
}
.nd-entry .nd-time { display: block; font: 10px var(--font-mono); color: var(--muted); margin-bottom: 14px; }
.nd-links { display: flex; gap: 18px; margin: 2px 0 16px; }
.nd-links a { font: 10px var(--font-mono); color: var(--clay); text-decoration: underline; text-underline-offset: 3px; }
.nd-links a:hover { color: var(--ink); }
.nd-links a.disabled { color: var(--muted); pointer-events: none; text-decoration: none; }
.nd-part { margin: 14px 0 0; }
.nd-part h4 { margin: 0 0 6px; font: 10px var(--font-mono); font-weight: 400; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.nd-part p { margin: 0; color: var(--green-deep); font: 15px/1.55 var(--serif); max-width: 62ch; }
.nd-part ol { margin: 0; padding-left: 20px; color: var(--green-deep); font: 15px/1.55 var(--serif); }
.nd-part ol li + li { margin-top: 6px; }
.nd-wonders p { color: var(--clay); }
.nd-empty { padding: 60px 0; text-align: center; color: var(--muted); font: 13px var(--font-sans); }

.nd-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 30px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.nd-export {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 16px;
  font: 11px var(--font-mono);
  color: var(--ink);
}
.nd-export:hover { border-color: var(--ink); }
.nd-count { font: 10px var(--font-mono); color: var(--muted); }

/* ============================================================ keyframes == */
@keyframes appear {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------- reveal on scroll --- */
.js .notebook-preview,
.js .made-by-pipt,
.js .about-pipt {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.js .notebook-preview.in,
.js .made-by-pipt.in,
.js .about-pipt.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .notebook-preview,
  .js .made-by-pipt,
  .js .about-pipt { transition: none; opacity: 1; transform: none; }
}

/* ============================================================= responsive = */
@media (max-width: 1060px) {
  .site-shell { grid-template-columns: 168px minmax(0, 1fr); }
  .page { width: min(900px, 100% - 44px); }
  .study-frame { width: 100%; margin-left: 0; }
  .thought { width: 56%; top: 24px; left: 22px; }
  .notice { max-width: calc(100% - 40px); bottom: 20px; left: 20px; }
}

@media (max-width: 760px) {
  .site-shell { display: block; }
  .index-rail {
    position: sticky;
    z-index: 10;
    width: 100%;
    box-sizing: border-box;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    height: 58px;
    padding: 0 16px;
  }
  .rail-heading p,
  .rail-nav { display: none; }
  .rail-heading .brand { font-size: 24px; }
  .rail-actions { margin: 0; display: flex; align-items: center; gap: 16px; }
  .rail-social { display: none; }
  .page { width: calc(100% - 28px); padding: 34px 0 40px; }
  .intro h1 { font-size: clamp(44px, 13vw, 68px); }
  .room { min-height: 340px; max-height: none; }
  .notice { bottom: 16px; left: 16px; }
  .study-aside { grid-template-columns: 1fr; }
  .study-aside > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .note-list li { grid-template-columns: 1fr; gap: 12px; padding: 18px 0; }
  .note-body { grid-column: 1; grid-template-columns: 1fr; gap: 13px; }
  .made-list { margin-left: 0; }
  .learning-list { margin: 36px 0 0; grid-template-columns: 1fr; row-gap: 30px; }
  .pairing-note { grid-area: auto; }
  .notebook-preview { padding: 56px 0 48px; }
  .site-content > footer { padding: 14px 18px; }
  .nd-head, .nd-list, .nd-foot { padding-left: 20px; padding-right: 20px; }
}
