:root {
  --bg: #f6efe2; --bg2: #efe5d2; --paper: #fffaf1; --note: #fbf3e2;
  --ink: #2b2420; --ink2: #4a3f37; --muted: #7d6f63; --line: #e4d8c4;
  --sage: #6d8b6f; --sage-bg: #e4ecdf; --rose: #b8737a; --rose-bg: #f5e1df; --gold: #a97a2c; --gold-bg: #f6e8c9;
  --accent: #8a5a44; --btn: #2b2420; --btn-ink: #fffaf1;
  --shadow: 0 1px 2px rgba(60,40,20,.06), 0 8px 28px -12px rgba(60,40,20,.18);
  --radius: 18px;
  --display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --hand: 'Caveat', 'Segoe Print', cursive;
  color-scheme: light;
}
[data-theme="midnight"] {
  --bg: #11142c; --bg2: #171b3a; --paper: #1a1e42; --note: #1f2550;
  --ink: #efe8d8; --ink2: #d6cfbf; --muted: #a29db6; --line: #2e3466;
  --sage: #9fc6a6; --sage-bg: #23394a; --rose: #e7a9b5; --rose-bg: #3d2a48; --gold: #e6c27a; --gold-bg: #3b3448;
  --accent: #e6c27a; --btn: #e6c27a; --btn-ink: #15183a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 130px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--sans);
  background-image: radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--gold) 8%, transparent), transparent 45%), radial-gradient(circle at 100% 30%, color-mix(in srgb, var(--sage) 7%, transparent), transparent 40%);
  background-attachment: fixed;
  transition: background-color .4s, color .4s;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code { font-size: .9em; background: var(--bg2); padding: .1em .35em; border-radius: 6px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; color: var(--ink); }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hide, [hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--btn); color: var(--btn-ink); padding: 8px 14px; border-radius: 99px; z-index: 99; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(14px, 4vw, 40px); padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 700 1.55rem/1 var(--display); letter-spacing: .01em; }
.brand img { width: 34px; height: 34px; object-fit: contain; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { position: relative; padding: 8px 14px; border-radius: 99px; text-decoration: none; color: var(--ink2); font-weight: 500; font-size: .95rem; transition: background .2s; }
.nav a:hover { background: var(--bg2); }
.nav a.on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 3px; vertical-align: 2px; }
.dot.ok { background: var(--sage); } .dot.warn { background: var(--rose); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.theme-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; display: grid; place-items: center; flex: none; }
.theme-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.theme-btn .moon { fill: currentColor; stroke: none; }
[data-theme="parchment"] .theme-btn .sun, [data-theme="midnight"] .theme-btn .moon { display: none; }

#view { flex: 1; width: 100%; outline: none; }
#view.enter > * { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: 600 .95rem/1.2 var(--sans);
  text-decoration: none; cursor: pointer; transition: transform .15s, box-shadow .2s, background .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: progress; transform: none; }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.ghost { background: transparent; border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
.btn.big { padding: 14px 26px; font-size: 1rem; }
.btn.small { padding: 6px 14px; font-size: .85rem; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--rose); }
.chip-btn {
  display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: transparent; color: var(--ink2); font: 500 .8rem/1.3 var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .2s, color .2s;
}
.chip-btn:hover { background: var(--bg2); color: var(--ink); text-decoration: none; }
.chip-btn:disabled { opacity: .6; cursor: progress; }
.chip-btn.danger { color: var(--rose); }
.chip-btn.save.on { background: var(--sage-bg); color: var(--sage); border-color: transparent; }
.linklike { background: none; border: 0; color: var(--rose); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--bg2); color: var(--ink2); font: 500 .72rem/1.6 var(--sans); white-space: nowrap; vertical-align: middle; text-transform: capitalize; }
.badge.sage { background: var(--sage-bg); color: var(--sage); }
.badge.rose { background: var(--rose-bg); color: var(--rose); }
.badge.gold { background: var(--gold-bg); color: var(--gold); }

.eyebrow { font: 600 .74rem/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: .6em; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(18px, 3vw, 30px); }
.section-title { font-size: clamp(1.7rem, 3.4vw, 2.4rem); text-align: center; margin: 0 0 .9em; }
.section-title.left { text-align: left; margin-top: 1.6em; font-size: 1.6rem; }
.lede { font: 400 clamp(1.05rem, 1.6vw, 1.2rem)/1.6 var(--serif); color: var(--ink2); max-width: 60ch; }
.notice { padding: 14px 18px; border-radius: 14px; background: var(--gold-bg); color: var(--ink); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); margin: 0 0 18px; }
.notice.err { background: var(--rose-bg); border-color: color-mix(in srgb, var(--rose) 35%, transparent); }
.notice.soft { background: var(--sage-bg); border-color: color-mix(in srgb, var(--sage) 30%, transparent); }
.notice .btn { margin-left: 8px; }
.key-notice { display: flex; gap: 16px; align-items: center; }
.key-notice p { margin: .2em 0 .7em; }
.notice-art { width: 84px; flex: none; }

/* ---------- hero ---------- */
.hero { position: relative; min-height: min(86vh, 760px); display: flex; align-items: center; overflow: hidden; isolation: isolate; }
.hero-art { position: absolute; inset: 0; z-index: -1; }
.hero-art img { width: 100%; height: 100%; object-fit: cover; object-position: 70% 50%; }
.hero-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 88%, transparent) 30%, color-mix(in srgb, var(--bg) 25%, transparent) 62%, transparent 80%), linear-gradient(0deg, var(--bg) 0%, transparent 22%); }
[data-theme="parchment"] .art-night, [data-theme="midnight"] .art-day { display: none; }
.hero-copy { width: min(1180px, 100%); margin: 0 auto; padding: clamp(40px, 8vw, 90px) clamp(18px, 5vw, 48px); }
.hero-copy > * { max-width: 560px; }
.hero h1 { font-size: clamp(2.6rem, 6.4vw, 4.8rem); font-weight: 600; letter-spacing: -.01em; line-height: 1.02; margin-bottom: .35em; }
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 1.6em 0 1em; }
.sample-link { font-family: var(--hand); font-size: 1.35rem; color: var(--ink2); }

.duo { width: min(1180px, 100% - 32px); margin: 10px auto 70px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 22px; }
.duo-card { display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: center; padding: 26px; border-radius: 24px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: transform .25s, box-shadow .25s; }
.duo-card:hover { transform: translateY(-4px) rotate(-.3deg); text-decoration: none; box-shadow: 0 18px 40px -18px rgba(60,40,20,.35); }
.duo-card img { width: 100%; transition: transform .4s; }
.duo-card:hover img { transform: scale(1.06) rotate(-3deg); }
.duo-card h2 { font-size: 1.75rem; }
.duo-card p { color: var(--ink2); font-size: .95rem; }
.arrow { font-family: var(--hand); font-size: 1.35rem; color: var(--accent); }

.how { width: min(1080px, 100% - 32px); margin: 0 auto 70px; }
.how-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 18px; }
.how-steps li { padding: 24px; border-top: 1px solid var(--line); }
.how-steps .num { font: italic 600 2.2rem/1 var(--display); color: var(--gold); }
.how-steps h3 { font-size: 1.45rem; margin-top: .3em; }
.how-steps p { color: var(--ink2); }
.recent { width: min(1180px, 100% - 32px); margin: 0 auto 70px; }

/* ---------- pages & forms ---------- */
.page { width: min(1180px, 100% - 32px); margin: 0 auto; padding: clamp(28px, 5vw, 56px) 0 70px; }
.page.narrow { width: min(760px, 100% - 32px); }
.page-title { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.input-card { margin: 24px 0 14px; display: grid; gap: 18px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg2); border-radius: 99px; overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px 14px; border-radius: 99px; font: 500 .92rem var(--sans); color: var(--ink2); cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.drop { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; padding: 26px 18px; border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; transition: border-color .2s, background .2s; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--gold); background: color-mix(in srgb, var(--gold-bg) 50%, transparent); }
.drop.has { border-style: solid; border-color: var(--sage); }
.drop-art { width: 110px; margin-bottom: 6px; transition: transform .3s; }
.drop:hover .drop-art { transform: rotate(-4deg) scale(1.05); }
.drop strong { font: 600 1.35rem var(--display); }
.drop span { color: var(--muted); font-size: .9rem; }
.drop .file-name { color: var(--sage); font-weight: 600; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=url], input[type=password], textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font: 400 1rem/1.5 var(--sans); transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; font-family: var(--serif); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 20%, transparent); }
.hint { font-size: .88rem; color: var(--muted); margin: 0; }
.levels { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.levels legend { font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.level input { position: absolute; opacity: 0; }
.level span { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; height: 100%; transition: all .2s; }
.level strong { font: 600 1.15rem var(--display); }
.level small { color: var(--muted); font-size: .8rem; }
.level input:checked + span { border-color: var(--ink); background: var(--bg2); box-shadow: inset 0 0 0 1px var(--ink); }
.level input:focus-visible + span { outline: 2px solid var(--gold); }
.status { margin: 0; min-height: 1.4em; font-size: .92rem; color: var(--muted); }
.status.ok { color: var(--sage); } .status.err { color: var(--rose); }
.privacy { text-align: center; max-width: 60ch; margin: 0 auto; }

/* ---------- reader ---------- */
.reader { width: min(1240px, 100% - 32px); margin: 0 auto; padding: clamp(24px, 4vw, 48px) 0 80px; }
.r-head { max-width: 900px; margin-bottom: 18px; }
.r-title { font-size: clamp(2rem, 4.4vw, 3.2rem); }
.r-meta { margin-bottom: 14px; }
.r-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; padding: 3px; border-radius: 99px; background: var(--bg2); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 99px; font: 500 .8rem var(--sans); color: var(--ink2); cursor: pointer; }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.r-progress { position: sticky; top: 61px; z-index: 20; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 16px; margin: 0 0 18px; border-radius: 99px; background: color-mix(in srgb, var(--paper) 97%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); font-size: .88rem; color: var(--ink2); }
.r-progress .bar { flex: 1 1 140px; height: 6px; border-radius: 99px; background: var(--bg2); overflow: hidden; }
.r-progress .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--sage), var(--gold)); border-radius: inherit; transition: width .6s ease; }
.r-progress select { width: auto; padding: 4px 10px; font-size: .82rem; border-radius: 99px; max-width: 200px; }
.overview { margin-bottom: 34px; }
.tldr { font: 400 clamp(1.15rem, 2vw, 1.4rem)/1.5 var(--serif); }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 20px; margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); }
.ov-grid h4 { font: 600 .74rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ov-grid p { font-size: .95rem; color: var(--ink2); margin: 0; }

.r-sec { font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 1.6em 0 .7em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.row { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); gap: clamp(18px, 3vw, 40px); padding: 16px 0; border-bottom: 1px dashed color-mix(in srgb, var(--line) 70%, transparent); }
.orig p { white-space: pre-line; font: 400 1.06rem/1.75 var(--serif); color: var(--ink); margin: 0; hyphens: auto; }
.row.caption .orig p { font-style: italic; color: var(--ink2); font-size: .98rem; }
.cap-tag { display: inline-block; font: 600 .68rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.note { position: relative; align-self: start; padding: 16px 18px 14px; border-radius: 4px 16px 16px 4px; background: var(--note); border-left: 3px solid var(--gold); font-size: .95rem; color: var(--ink2); }
.note.fresh { animation: inkin .7s ease both; }
@keyframes inkin { from { opacity: 0; transform: translateX(8px); filter: blur(2px); } }
.note.writing .pending i { animation-duration: 1s; }
.gist { font: 700 1.38rem/1.15 var(--hand); color: var(--accent); margin-bottom: .35em; }
.expl { margin-bottom: .6em; }
.expl strong { color: var(--ink); background: linear-gradient(transparent 62%, color-mix(in srgb, var(--gold) 30%, transparent) 62%); }
.terms { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.term { border-radius: 10px; background: var(--paper); border: 1px solid var(--line); font-size: .82rem; }
.term summary { list-style: none; cursor: pointer; padding: 3px 10px; font-weight: 600; color: var(--ink); }
.term summary::-webkit-details-marker { display: none; }
.term summary::before { content: '\2726  '; color: var(--gold); }
.term[open] { flex-basis: 100%; }
.term p { margin: 0; padding: 0 10px 8px; color: var(--ink2); }
.note-actions { display: flex; flex-wrap: wrap; gap: 6px; opacity: .75; transition: opacity .2s; }
.row:hover .note-actions, .note-actions:focus-within { opacity: 1; }
.askbox { display: flex; gap: 6px; margin-top: 10px; }
.askbox input { padding: 8px 12px; font-size: .9rem; }
.qa { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.qa .q { font-weight: 600; color: var(--ink); margin-bottom: .3em; }
.qa .q::before { content: 'Q. '; color: var(--gold); font-family: var(--display); }
.qa .a { margin: 0; }
.layout-notes .orig { display: none; }
.layout-notes .row, .layout-orig .row { grid-template-columns: 1fr; max-width: 760px; }
.layout-orig .note { display: none; }

.pending { display: grid; gap: 8px; padding: 4px 0; }
.pending i { display: block; height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--bg2), color-mix(in srgb, var(--gold) 22%, var(--bg2)), var(--bg2)); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
.pending i:nth-child(2) { width: 85%; } .pending i:nth-child(3) { width: 60%; }
.pending.wide { max-width: 600px; margin: 20px auto; }
@keyframes shimmer { to { background-position: -200% 0; } }

.glossary { margin: 40px 0; }
.glossary h2 { font-size: 2rem; }
.glossary dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px 24px; margin: 0; }
.glossary dt { font: 600 1.15rem var(--display); color: var(--ink); }
.glossary dd { margin: 0; font-size: .9rem; color: var(--ink2); }
.refs { margin-top: 30px; font-size: .85rem; color: var(--ink2); }
.refs summary { cursor: pointer; font-weight: 600; }
.refs ol { padding-left: 1.4em; max-height: 420px; overflow: auto; }

/* ---------- resources ---------- */
.resources { margin-top: 56px; }
.chipnav { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; margin-bottom: 10px; scrollbar-width: thin; justify-content: safe center; }
.chipnav a { flex: none; padding: 7px 14px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); color: var(--ink2); text-decoration: none; font-size: .85rem; font-weight: 500; }
.chipnav a:hover { background: var(--bg2); }
.rsec { margin: 34px 0; }
.rsec-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.rsec-head h3 { font-size: 1.65rem; margin: 0; }
.rsec-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.rcard { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line); transition: transform .2s, box-shadow .2s; min-width: 0; }
.rcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.rcard h4 { font: 600 1.18rem/1.25 var(--display); margin: 0; overflow-wrap: anywhere; }
.rcard h4 a { color: var(--ink); text-decoration: none; }
.rcard h4 a:hover { color: var(--accent); text-decoration: underline; }
.rc-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.byline { font-size: .82rem; color: var(--muted); margin: 0; }
.abs, .why { font-size: .86rem; color: var(--ink2); margin: 0; }
.why { font-style: italic; }
.rc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; align-items: center; }
.rcard.book { flex-direction: row; gap: 14px; }
.rcard.book > div:last-child { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.cover { flex: none; width: 64px; height: 92px; border-radius: 4px 8px 8px 4px; overflow: hidden; background: linear-gradient(135deg, var(--sage), var(--gold)); box-shadow: 2px 3px 8px rgba(0,0,0,.2); display: grid; place-items: center; color: #fff; font: 600 1.8rem var(--display); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.next .steps-list { font-family: var(--serif); font-size: 1.05rem; }
.steps-list { padding-left: 1.3em; display: grid; gap: 6px; }
.lgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 18px; }
.lgroup { padding: 16px 18px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line); }
.lgroup h4 { font-size: 1.2rem; }
.lgroup ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: .9rem; }
.lgroup li::before { content: '\2192  '; color: var(--gold); }

/* ---------- compass ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 18px; margin: 24px 0; }
.plan-card { position: relative; }
.plan-card h3 { font-size: 1.5rem; padding-right: 60px; }
.plan-card ol, .plan-card ul { padding-left: 1.2em; margin: 0; display: grid; gap: 8px; font-size: .95rem; }
.plan-card .copy-rq { position: absolute; top: 22px; right: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 14px; border-radius: 99px; background: var(--sage-bg); color: var(--sage); text-decoration: none; font-size: .88rem; font-weight: 500; }
.chip:hover { filter: brightness(1.05); text-decoration: underline; }
.progress-pill { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.quill { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold); border-top-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.readlist { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%); display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 20px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); box-shadow: 0 16px 40px -10px rgba(0,0,0,.35); z-index: 25; transition: transform .35s cubic-bezier(.2,.8,.2,1); white-space: nowrap; font-size: .9rem; max-width: calc(100% - 24px); }
.readlist.show { transform: translate(-50%, 0); }

/* ---------- library ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.lib-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: transform .2s, box-shadow .2s; }
.lib-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }
.lib-card .eyebrow { margin: 0; }
.lib-card h3 { font-size: 1.25rem; margin: 0; }
.lib-card.proj { border-left: 3px solid var(--sage); }
.mini-bar { height: 4px; border-radius: 99px; background: var(--bg2); overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--sage); }

/* ---------- settings ---------- */
.setting { margin: 18px 0; display: grid; gap: 12px; }
.setting h2 { font-size: 1.6rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.setting p { margin: 0; }
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; min-width: 0; }

/* ---------- contact ---------- */
.contact-sec { width: min(980px, 100% - 32px); margin: 0 auto 80px; }
.contact-card { display: grid; grid-template-columns: 180px 1fr; gap: 28px; align-items: center; padding: clamp(22px, 4vw, 40px); border-radius: 28px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); background-image: radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--rose) 10%, transparent), transparent 55%); }
.contact-card img { width: 100%; transform: rotate(-4deg); }
.contact-card h2 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
.contact-card p { color: var(--ink2); }
.contact-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
@media (max-width: 640px) { .contact-card { grid-template-columns: 1fr; text-align: center; } .contact-card img { width: 130px; margin: 0 auto; } .contact-links { justify-content: center; } }

/* ---------- footer & toasts ---------- */
.footer { border-top: 1px solid var(--line); padding: 32px clamp(16px, 4vw, 40px) max(24px, env(safe-area-inset-bottom)); background: var(--bg2); }
.footer-inner { width: min(1180px, 100%); margin: 0 auto; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-inner > div { max-width: 520px; }
.footer-brand { font: 700 1.5rem var(--display); margin: 0 0 4px; }
.footer-links { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.footer-links a { padding: 7px 16px; border-radius: 99px; border: 1px solid var(--line); background: var(--paper); text-decoration: none; color: var(--ink); font-size: .9rem; }
.footer-note { width: min(1180px, 100%); margin: 18px auto 0; font-size: .8rem; }
#toasts { position: fixed; top: 74px; right: 16px; z-index: 50; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 12px; background: var(--btn); color: var(--btn-ink); font-size: .9rem; box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); transition: all .3s; max-width: 320px; }
.toast.show { opacity: 1; transform: none; }
.toast-err { background: var(--rose); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .row { grid-template-columns: 1fr; gap: 10px; }
  .note { margin-left: 10px; }
  .hero { min-height: 0; flex-direction: column; align-items: stretch; }
  .hero-art { position: relative; height: 46vw; min-height: 220px; max-height: 420px; }
  .hero-art img { object-position: 75% 60%; }
  .hero-art::after { background: linear-gradient(0deg, var(--bg) 0%, transparent 45%); }
  .hero-copy { padding-top: 6px; }
  .r-progress { border-radius: 16px; top: 57px; }
}
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .topbar { flex-wrap: wrap; gap: 6px 10px; padding-bottom: 6px; }
  .nav { order: 3; width: 100%; margin: 0; justify-content: space-between; }
  .nav a { padding: 6px 10px; font-size: .88rem; }
  .theme-btn { margin-left: auto; width: 36px; height: 36px; }
  html { scroll-padding-top: 170px; }
  .r-progress { position: static; padding: 10px 14px; gap: 8px 12px; }
  .r-progress select { max-width: none; flex: 1; }
  #toasts { top: 104px; left: 16px; right: 16px; }
  .toast { max-width: none; }
  .duo-card { grid-template-columns: 1fr; text-align: center; padding: 22px; }
  .duo-card img { width: 140px; margin: 0 auto; }
  .levels { grid-template-columns: 1fr; }
  .key-notice { flex-direction: column; text-align: center; }
  .key-row { flex-direction: column; }
  .cta .btn { width: 100%; }
  .seg { width: 100%; } .seg button { flex: 1; padding: 6px 6px; }
  .orig p { font-size: 1.02rem; }
  .note { margin-left: 0; }
  .readlist { padding-left: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media print {
  .topbar, .footer, .r-tools, .r-progress, .note-actions, .askbox, #banner, .chipnav, .rc-actions, .readlist, #toasts { display: none !important; }
  body { background: #fff; color: #000; }
  .row { break-inside: avoid; grid-template-columns: 1.1fr .9fr; }
  .note { background: #f7f2e8; }
  .card, .rcard { box-shadow: none; }
}
