:root {
    --ink: #3f2a21;
    --ink-soft: #6e5141;
    --paper: #ead3a4;
    --paper-light: #f4e4bd;
    --paper-dark: #c59f6d;
    --book: #50311f;
    --book-dark: #2e1b13;
    --accent: #7c3f24;
    --line: rgba(89, 57, 35, .35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 10%, rgba(255,255,255,.08), transparent 28%),
        radial-gradient(circle at 80% 25%, rgba(0,0,0,.16), transparent 32%),
        linear-gradient(135deg, #2c1a12, #67452d 45%, #2f1c13);
    font-family: Georgia, "Times New Roman", serif;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .24;
    background-image:
      repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.025) 3px 4px),
      repeating-linear-gradient(90deg, transparent 0 5px, rgba(0,0,0,.02) 5px 6px);
}

.book-shell {
    width: min(1160px, calc(100% - 28px));
    margin: 34px auto;
    padding: 18px;
    border-radius: 24px 12px 24px 12px;
    background: linear-gradient(90deg, #352014 0, #5a3723 3%, #3b2418 6%, #6a432a 50%, #3d2518 94%, #5d3824 97%, #321d13 100%);
    box-shadow: 0 28px 70px rgba(0,0,0,.48), inset 0 0 0 1px rgba(255,255,255,.08);
    position: relative;
}

.book-ribbon {
    position: absolute;
    top: 0;
    right: 8%;
    width: 30px;
    height: 160px;
    background: linear-gradient(90deg, #5f1f1d, #8a2c27 45%, #541b1a);
    box-shadow: 0 5px 8px rgba(0,0,0,.2);
    z-index: 3;
}
.book-ribbon::after {
    content: "";
    position: absolute;
    bottom: -17px;
    left: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 17px solid #681f1d;
}

.paper-page {
    position: relative;
    overflow: hidden;
    padding: clamp(38px, 6vw, 86px) clamp(24px, 7vw, 96px) 44px;
    background:
      radial-gradient(circle at 10% 20%, rgba(109,65,34,.09) 0 2px, transparent 3px),
      radial-gradient(circle at 82% 72%, rgba(109,65,34,.08) 0 1.5px, transparent 2.5px),
      linear-gradient(90deg, rgba(120,76,42,.10), transparent 7%, transparent 93%, rgba(120,76,42,.10)),
      linear-gradient(180deg, var(--paper-light), var(--paper) 48%, #dfc38f);
    box-shadow: inset 0 0 55px rgba(91,53,29,.2), inset 0 0 0 1px rgba(111,70,39,.18);
    border-radius: 7px;
}

.paper-page::before,
.paper-page::after {
    content: "";
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(5px);
    opacity: .14;
    background: #7d4624;
}
.paper-page::before { width: 190px; height: 110px; left: -65px; top: 17%; transform: rotate(-15deg); }
.paper-page::after { width: 160px; height: 90px; right: -45px; bottom: 12%; transform: rotate(12deg); }

.chapter-header, .continue-section, .reader-section, .page-footer { position: relative; z-index: 1; }
.chapter-header { text-align: center; margin-bottom: 38px; }
.ornament { font-size: 34px; line-height: 1; color: var(--accent); opacity: .85; }
.eyebrow {
    margin: 12px 0 5px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .22em;
    color: var(--ink-soft);
}
h1, h2 { font-weight: 700; letter-spacing: .05em; }
h1 { margin: 7px 0 10px; font-size: clamp(36px, 7vw, 66px); }
h2 { margin: 7px 0 12px; font-size: clamp(28px, 5vw, 44px); line-height: 1.08; }
.chapter-rule {
    width: min(340px, 70%);
    height: 1px;
    margin: 21px auto 0;
    background: linear-gradient(90deg, transparent, var(--ink-soft), transparent);
}
.chapter-rule::after {
    content: "◆";
    position: relative;
    top: -9px;
    display: inline-block;
    padding: 0 10px;
    background: var(--paper-light);
    color: var(--ink-soft);
    font-size: 12px;
}

.chapter-text {
    max-width: 830px;
    margin: 0 auto;
    font-size: clamp(16px, 1.6vw, 18px);
    line-height: 1.6;
    text-align: justify;
    hyphens: auto;
}
.chapter-text p { margin: 0 0 1.15em; }
.chapter-text p:first-child::first-letter {
    float: left;
    font-size: 4.5em;
    line-height: .78;
    padding: .08em .11em 0 0;
    color: var(--accent);
}

.continue-section {
    max-width: 850px;
    margin: 62px auto 0;
    padding: 38px clamp(18px, 4vw, 42px) 34px;
    border: 1px solid rgba(104,61,36,.34);
    background: rgba(248,232,193,.43);
    box-shadow: 0 14px 30px rgba(83,47,28,.12), inset 0 0 26px rgba(116,75,44,.08);
    transform: rotate(-.15deg);
}
.ink-divider { text-align: center; margin-top: -57px; margin-bottom: 18px; }
.ink-divider span {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--book);
    color: #f3dbac;
    font-size: 22px;
    box-shadow: 0 5px 12px rgba(0,0,0,.25);
}
.author-intro {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 22px;
    align-items: center;
    margin: 4px 0 30px;
    padding: 18px 20px;
    border: 1px solid rgba(104,61,36,.25);
    border-radius: 4px;
    background: rgba(255,246,218,.3);
    box-shadow: inset 0 0 20px rgba(116,75,44,.06);
}
.author-avatar {
    display: block;
    width: 112px;
    height: 112px;
    object-fit: cover;
    object-position: 58% center;
    border: 4px solid rgba(248,232,193,.8);
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(89,57,35,.35), 0 8px 18px rgba(83,47,28,.2);
}
.author-copy p {
    margin: 0;
    font-size: 16px;
    line-height: 1.55;
}
.author-copy .author-callout {
    margin-top: 10px;
    color: var(--accent);
    font-size: 18px;
    font-weight: 700;
}
.prompt { font-size: 19px; line-height: 1.55; color: var(--ink-soft); max-width: 690px; }

.story-form { margin-top: 27px; }
.story-form label { display: block; margin: 20px 0 8px; font-weight: 700; font-size: 17px; }
.story-form input,
.story-form textarea {
    width: 100%;
    border: 0;
    border-bottom: 1px solid rgba(86,52,33,.58);
    padding: 13px 12px;
    color: var(--ink);
    background: rgba(255,248,226,.35);
    font: inherit;
    font-size: 18px;
    outline: none;
    border-radius: 2px 2px 0 0;
    box-shadow: inset 0 -1px rgba(255,255,255,.5);
}
.story-form textarea {
    resize: vertical;
    min-height: 190px;
    line-height: 1.55;
    background-image: repeating-linear-gradient(transparent 0 30px, rgba(108,72,45,.14) 30px 31px);
    background-attachment: local;
}
.story-form input:focus,
.story-form textarea:focus { background-color: rgba(255,250,232,.68); border-color: var(--accent); }
.form-meta { display: flex; justify-content: space-between; gap: 16px; margin-top: 7px; font-size: 12px; color: var(--ink-soft); }
.story-form button {
    display: block;
    margin: 28px auto 10px;
    min-height: 52px;
    padding: 14px 28px;
    border: 1px solid #2f1b12;
    border-radius: 3px;
    color: #f7e5bd;
    background: linear-gradient(#65412c, #412719);
    box-shadow: 0 5px 0 #28170f, 0 10px 18px rgba(0,0,0,.22);
    font: 700 15px Georgia, serif;
    letter-spacing: .11em;
    cursor: pointer;
}
.story-form button:hover { transform: translateY(-1px); }
.story-form button:active { transform: translateY(3px); box-shadow: 0 2px 0 #28170f, 0 4px 9px rgba(0,0,0,.2); }
.moderation-note { text-align: center; color: var(--ink-soft); font-size: 13px; margin: 15px 0 0; }
.honeypot { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

.flash { margin: 20px 0 4px; padding: 15px 17px; border: 1px solid; line-height: 1.45; }
.flash.success { background: rgba(76,107,54,.09); border-color: rgba(64,90,46,.35); }
.flash.error { background: rgba(137,57,42,.08); border-color: rgba(137,57,42,.38); }

.reader-section { margin: 72px auto 0; max-width: 970px; text-align: center; }
.story-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 34px;
    margin-top: 38px;
    align-items: start;
}
.reader-card {
    position: relative;
    min-height: 205px;
    padding: 34px 30px 24px;
    text-align: left;
    background:
      radial-gradient(circle at 20% 20%, rgba(111,66,35,.07) 0 2px, transparent 3px),
      linear-gradient(165deg, #f1deb1, #dfbd82);
    border: 1px solid rgba(98,61,36,.28);
    box-shadow: 0 13px 24px rgba(76,43,25,.19);
    clip-path: polygon(1% 2%, 24% 0, 50% 2%, 76% .5%, 99% 3%, 98% 30%, 100% 58%, 97% 99%, 71% 97%, 47% 100%, 23% 97%, 1% 99%, 2% 70%, 0 38%);
}
.reader-card:nth-child(4n+1) { transform: rotate(-1.1deg); }
.reader-card:nth-child(4n+2) { transform: rotate(.9deg) translateY(7px); }
.reader-card:nth-child(4n+3) { transform: rotate(.5deg); }
.reader-card:nth-child(4n) { transform: rotate(-.7deg) translateY(5px); }
.reader-card p { margin: 0; font-size: 18px; line-height: 1.6; white-space: normal; }
.reader-card footer { margin-top: 22px; text-align: right; font-style: italic; font-weight: 700; }
.pin {
    position: absolute;
    width: 13px;
    height: 13px;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: #5c3925;
    box-shadow: 0 1px 1px #fff7ce inset, 0 2px 4px rgba(0,0,0,.32);
}
.empty-note {
    margin: 34px auto 0;
    max-width: 560px;
    padding: 30px;
    border: 1px dashed rgba(94,57,34,.35);
    color: var(--ink-soft);
}
.empty-note p { margin: 6px 0; }

.page-footer { text-align: center; margin-top: 66px; color: var(--ink-soft); }
.page-footer span { font-size: 26px; color: var(--accent); }
.page-footer p { font-size: 13px; letter-spacing: .05em; }

.setup-message {
    max-width: 650px;
    margin: 15vh auto;
    padding: 36px;
    background: #f0ddb3;
    box-shadow: 0 18px 50px rgba(0,0,0,.35);
    text-align: center;
}

@media (max-width: 760px) {
    .book-shell { width: 100%; margin: 0; padding: 7px; border-radius: 0; }
    .paper-page { border-radius: 2px; padding: 48px 20px 34px; }
    .book-ribbon { right: 12%; width: 23px; height: 105px; }
    .chapter-header { margin-bottom: 28px; }
    .chapter-text { text-align: left; font-size: 16px; line-height: 1.55; }
    .chapter-text p:first-child::first-letter { font-size: 3.6em; }
    .continue-section { margin-top: 48px; padding: 34px 17px 28px; transform: none; }
    .author-intro { grid-template-columns: 82px minmax(0, 1fr); gap: 14px; margin-bottom: 25px; padding: 14px; }
    .author-avatar { width: 82px; height: 82px; border-width: 3px; }
    .author-copy p { font-size: 14px; line-height: 1.45; }
    .author-copy .author-callout { margin-top: 7px; font-size: 16px; }
    .prompt { font-size: 17px; }
    .story-stack { grid-template-columns: 1fr; gap: 22px; }
    .reader-card { min-height: 170px; padding: 31px 23px 22px; }
    .reader-card p { font-size: 17px; }
    .form-meta { font-size: 11px; }
}
