:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --ink: #1f2a24;
  --muted: #5f6b64;
  --line: #e7dfd1;
  --green: #14532d;
  --green-2: #1f7a45;
  --green-soft: #e6f2ea;
  --red: #b42318;
  --red-2: #961c13;
  --red-soft: #fdecea;
  --gold: #b7862b;
  --gold-ink: #8a6414;
  --note: #fffaf0;
  --shadow: 0 1px 2px rgba(31, 42, 36, .06), 0 4px 16px rgba(31, 42, 36, .06);
  --radius: 14px;
  --hand: "Patrick Hand", "Bradley Hand", "Segoe Print", "Chalkboard SE", "Comic Sans MS", cursive;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1713;
    --surface: #17221c;
    --ink: #edf2ee;
    --muted: #a3b0a8;
    --line: #2a3a31;
    --green: #7fcf9a;
    --green-2: #58b878;
    --green-soft: #173323;
    --red: #f2847d;
    --red-2: #e66b63;
    --red-soft: #3a1d1b;
    --gold: #d9ac52;
    --gold-ink: #e5be67;
    --note: #221f17;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; margin-top: 1.5rem; }
h4 { margin: 1rem 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
a { color: var(--green-2); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.mb-sm { margin-bottom: 12px; }
.mt-md { margin-top: 16px; }

.inapp-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--note);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 10px 0 4px;
  font-size: .875rem;
}

.topbar, main, .foot { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.topbar {
  padding-top: 14px;
  padding-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--serif); font-weight: 700; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.badge-unlocked { font-size: .8rem; font-weight: 700; color: var(--green); background: var(--green-soft); padding: 5px 10px; border-radius: 999px; }
.foot { color: var(--muted); font-size: .8rem; text-align: center; padding-top: 32px; padding-bottom: 40px; }

/* hero + setup */
.hero { padding: 20px 0 8px; }
.eyebrow { color: var(--red); font-weight: 600; font-size: .9rem; margin: 0 0 .5rem; }
.hero h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); }
.lede { font-size: 1.08rem; color: var(--muted); margin: .5rem 0 1rem; }
.perks { list-style: none; padding: 0; margin: 0 0 1.1rem; }
.perks li { padding-left: 1.6rem; position: relative; margin: .35rem 0; }
.perks li::before { content: "✦"; position: absolute; left: 0; color: var(--gold); }
.page-title { margin-top: 20px; }

.panic-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--note);
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.panic-head { margin-bottom: 12px; }
.panic-head h1 { font-size: clamp(1.7rem, 5.5vw, 2.2rem); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 12px 0; }
.card.compact { padding: 14px 16px; }
.card.compact h3 { margin-top: 0; }
.cta-box { background: var(--green-soft); border-color: var(--green-2); margin-top: 24px; }
.cta-box h3 { margin-top: 0; }
.inline-elf { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .92rem; }
.inline-elf input {
  flex: 1; padding: 9px 12px; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}

.setup fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.setup legend { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; margin-bottom: 8px; padding: 0; }
.setup label { display: block; font-weight: 600; font-size: .92rem; margin: 10px 0; }
.setup input:not([type=checkbox]):not([type=radio]), .setup select, #u-code, .select-inline {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.select-inline { width: auto; margin-top: 0; padding: 9px 12px; }
.inline-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.setup input:focus, .setup select:focus, #u-code:focus, .inline-elf input:focus { outline: 2px solid var(--green-2); outline-offset: 1px; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row label { margin: 0; }
.sup-tools { margin: 0 0 10px; color: var(--muted); }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.setup label.pick { margin: 0; font-weight: 400; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer; font-size: .9rem; user-select: none; }
.pick input:checked + span { background: var(--green-soft); border-color: var(--green-2); color: var(--green); font-weight: 600; }
.pick input:checked + span::before { content: "✓ "; }
.pick input:focus-visible + span { outline: 2px solid var(--green-2); }
.radios { margin-top: 12px; }
.setup .radios label, .setup label.check { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.btn:hover { border-color: var(--green-2); }
.btn.small-btn { padding: 6px 12px; font-size: .84rem; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.accent { background: var(--red); border-color: var(--red); color: #fff; }
.btn.accent:hover { background: var(--red-2); border-color: var(--red-2); }
@media (prefers-color-scheme: dark) { .btn.primary, .btn.accent { color: #0f1713; } }
.btn.big { padding: 13px 22px; font-size: 1.05rem; }
.btn.danger { color: var(--red); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--green-2); text-decoration: underline; cursor: pointer; }

/* tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 8px -16px 0; padding: 0 16px 2px; scrollbar-width: none; position: sticky; top: 0; background: var(--bg); z-index: 5; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; background: none; border: 0; padding: 12px 12px 10px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
.tabs button[aria-selected=true] { color: var(--green); border-bottom-color: var(--green); }

.panel { padding-top: 16px; }
.banner { background: var(--green); color: #fff; border-radius: var(--radius); padding: 14px 16px; }
.banner a, .banner-link { background: none; border: 0; padding: 0; font: inherit; color: #fff; text-decoration: underline; cursor: pointer; }
@media (prefers-color-scheme: dark) { .banner { background: var(--green-soft); color: var(--ink); } .banner a, .banner-link { color: var(--green); } }
.meta-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 2px 0; }
.progress { margin: 0; font-size: .875rem; }
.upsell { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--note); border: 1.5px solid var(--gold); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.upsell p { margin: 0; flex: 1 1 260px; font-size: .92rem; }
.panel-foot { text-align: center; margin-top: 20px; }
.hint-box { background: var(--note); border: 1px dashed var(--gold); border-radius: var(--radius); padding: 10px 14px; font-size: .9rem; margin: 12px 0; }

/* night cards */
.nights { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.night { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); scroll-margin-top: 60px; }
.night summary { list-style: none; display: flex; gap: 12px; padding: 14px 16px; cursor: pointer; }
.night summary::-webkit-details-marker { display: none; }
.n { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--green-soft); color: var(--green); }
.night.done .n { background: var(--green); color: #fff; }
.night.done .title { text-decoration: line-through; text-decoration-color: var(--muted); }
.sum-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.when { font-size: .8rem; color: var(--muted); }
.title { font-weight: 700; font-size: 1.02rem; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.cat { font-weight: 600; }
.cat-kind { color: var(--red); }
.cat-special { color: var(--gold-ink); }
.night-body { padding: 0 16px 16px 62px; }
.steps { margin: 0; padding-left: 1.2rem; }
.steps li { margin: .3rem 0; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .85rem; padding: 4px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green); }
.chip.buy { background: var(--red-soft); color: var(--red); }
.locked-body p { margin-top: 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.note { margin: 16px 0 0; background: var(--note); border: 1px dashed var(--gold); border-radius: 12px; padding: 14px 16px; transform: rotate(-.4deg); }
.note blockquote { margin: 0; font-family: var(--hand); font-size: 1.08rem; line-height: 1.45; }
.note figcaption { font-family: var(--hand); text-align: right; margin-top: 6px; color: var(--muted); }
.note.big blockquote { font-size: 1.3rem; }

/* other panels */
.shop { list-style: none; padding: 0; margin: 0 0 12px; }
.shop li { border-bottom: 1px solid var(--line); }
.shop-item { display: flex; gap: 10px; align-items: center; padding: 12px 2px; cursor: pointer; }
.shop-item input { width: 20px; height: 20px; accent-color: var(--green-2); }
.shop-item input:checked + span { text-decoration: line-through; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid .card { margin: 0; display: flex; flex-direction: column; }
.print-card h3 { margin-top: 0; }
.print-card .btn { margin-top: auto; align-self: flex-start; }
.fixes { padding-left: 1.2rem; }
.fixes li { margin: .4rem 0; }
.share { margin-top: 24px; }
.share p { margin-top: 0; }

/* unlock dialog */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(15, 23, 19, .55); }
.unlock { padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.unlock h2 { margin: 0; }
.unlock .perks { margin: 0; font-size: .92rem; }
.unlock .link { align-self: center; }
#u-buy { text-align: center; }
.redeem-only .perks, .redeem-only #u-buy, .redeem-only .buy-note, .redeem-only .sep { display: none; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.code-row { display: flex; gap: 8px; }
.code-row #u-code { margin: 0; text-transform: uppercase; }
.error { color: var(--red); margin: 0; min-height: 1.2em; font-size: .9rem; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  .night-body { padding-left: 16px; }
  .row { grid-template-columns: 1fr; }
}

/* print */
#print-root { display: none; }
@media print {
  @page { margin: .45in; }
  body { background: #fff; color: #000; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .p-note {
    position: relative;
    height: 4.5in;
    margin-bottom: .32in;
    padding: .42in .52in;
    border: 4px double #14532d;
    outline: 1px dashed #c9d6cd;
    outline-offset: 6px;
    border-radius: 18px;
    background: #fffdf7;
    display: flex;
    flex-direction: column;
    justify-content: center;
    break-inside: avoid;
    page-break-inside: avoid;
    font-family: var(--hand);
    color: #1f2a24;
  }
  #print-root > .p-note:nth-child(2n):not(:last-child) { break-after: page; page-break-after: always; }
  .p-stamp {
    position: absolute;
    top: 14px;
    right: 18px;
    border: 1.5px solid #b42318;
    border-radius: 8px;
    padding: 3px 7px;
    font-family: system-ui, sans-serif;
    font-size: 7pt;
    font-weight: 700;
    letter-spacing: .08em;
    text-align: center;
    color: #b42318;
    transform: rotate(6deg);
    opacity: .8;
  }
  .p-head { font-family: var(--serif); text-align: center; color: #b42318; font-size: 14pt; letter-spacing: .05em; margin-bottom: .18in; }
  .p-note p { font-size: 18pt; line-height: 1.4; margin: 0; }
  .p-sign { text-align: right; font-size: 17pt; margin-top: .18in; color: #14532d; }
  .p-meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    text-align: center;
    font-family: system-ui, sans-serif;
    font-size: 7.5pt;
    color: #7c8a81;
  }

  .p-quarter { display: grid; grid-template-columns: 1fr 1fr; gap: .25in; }
  .p-quarter .p-note { height: 4.6in; margin: 0; padding: .3in; break-after: auto; page-break-after: auto; outline: none; }
  .p-quarter .p-head { font-size: 11pt; }
  .p-lines { flex: 1; display: flex; flex-direction: column; justify-content: space-between; padding: .1in 0; }
  .p-line { display: block; flex: 1; border-bottom: 1px solid #c9d6cd; }

  .p-letter {
    min-height: 8.8in;
    padding: .6in .75in;
    border: 6px double #14532d;
    border-radius: 22px;
    background: #fffdf7;
    font-family: var(--hand);
    font-size: 16.5pt;
    line-height: 1.48;
    color: #1f2a24;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .p-crest { font-family: var(--serif); text-align: center; color: #b42318; font-size: 19pt; letter-spacing: .1em; margin-bottom: .28in; }
  .p-letter p { margin: 0 0 .16in; }
  .p-close { margin-top: .3in !important; }
  .p-sig { font-size: 23pt; color: #14532d; }

  /* 1-page Parent Master Sheet */
  .p-master { font-family: system-ui, -apple-system, sans-serif; color: #1f2a24; }
  .p-master-head { text-align: center; margin-bottom: 10px; }
  .p-master-head h2 { font-family: var(--serif); font-size: 15pt; margin: 0 0 2px; color: #14532d; }
  .p-master-head p { margin: 0; font-size: 9pt; color: #5f6b64; }
  .p-master table { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
  .p-master th { background: #14532d; color: #fff; text-align: left; padding: 4px 6px; font-weight: 600; }
  .p-master td { padding: 3.5px 6px; border-bottom: 1px solid #e7dfd1; vertical-align: top; }
  .p-master tr:nth-child(even) td { background: #fbf7f0; }
  .p-master .m-num, .p-master .m-chk { text-align: center; width: 22px; }
  .p-master .m-date { white-space: nowrap; width: 82px; }
  .p-master .m-min { white-space: nowrap; width: 46px; }

  /* Mini-Props + Nice List Certificate */
  .p-props-page { font-family: system-ui, -apple-system, sans-serif; color: #1f2a24; }
  .p-props-head { text-align: center; font-size: 9pt; color: #5f6b64; margin-bottom: 10px; }
  .p-signs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
  .p-sign-card {
    border: 2px dashed #14532d;
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    background: #fffdf7;
    break-inside: avoid;
  }
  .p-sign-badge { font-size: 7pt; font-weight: 700; letter-spacing: .1em; color: #b42318; margin-bottom: 4px; }
  .p-sign-title { font-family: var(--serif); font-size: 14pt; font-weight: 700; color: #14532d; margin-bottom: 4px; }
  .p-sign-sub { font-size: 8pt; color: #5f6b64; }

  .p-cert {
    border: 6px double #b7862b;
    border-radius: 20px;
    padding: 28px 34px;
    text-align: center;
    background: #fffdf7;
    break-inside: avoid;
  }
  .p-cert-kicker { font-size: 10pt; font-weight: 700; letter-spacing: .14em; color: #b42318; margin-bottom: 6px; }
  .p-cert-title { font-family: var(--serif); font-size: 28pt; font-weight: 700; color: #14532d; margin-bottom: 10px; }
  .p-cert-body { font-size: 12pt; margin: 6px auto; max-width: 5.5in; line-height: 1.45; }
  .p-cert-names { font-family: var(--hand); font-size: 26pt; color: #b42318; margin: 8px 0; border-bottom: 1.5px solid #e7dfd1; display: inline-block; padding: 0 24px 4px; }
  .p-cert-foot { display: flex; justify-content: space-between; margin-top: 22px; padding-top: 10px; border-top: 1px solid #e7dfd1; font-size: 10pt; color: #5f6b64; }
}
