:root {
  --ink: #19231d;
  --muted: #68736c;
  --paper: #f5f2e9;
  --surface: #fffdf7;
  --line: #d9d7cc;
  --moss: #27553d;
  --acid: #d8ff72;
  --danger: #a23930;
  --shadow: 0 26px 70px rgba(29, 44, 35, 0.12);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.shell { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.page-shell { min-height: calc(100vh - 76px); padding-block: 64px 110px; }
.eyebrow { margin: 0 0 14px; color: var(--moss); font-size: .73rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.02; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 18px; min-height: 50px; padding: 0 22px; border: 1px solid var(--ink); cursor: pointer; font-weight: 600; transition: transform .2s, box-shadow .2s, background .2s; }
.primary-button { background: var(--ink); color: white; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(25,35,29,.18); }
.secondary-button { background: transparent; }

.site-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); background: rgba(245,242,233,.9); backdrop-filter: blur(16px); }
.nav-row { height: 76px; display: flex; align-items: center; justify-content: space-between; }
.brand, .landing-brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: -.02em; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--acid); font: 500 1.35rem var(--serif); }
.main-nav { display: flex; align-items: center; gap: 30px; color: #3f4942; font-size: .92rem; }
.main-nav a:hover, .text-button:hover { color: var(--moss); }
.main-nav form { margin: 0; }
.text-button, .danger-button { padding: 0; border: 0; background: none; color: inherit; cursor: pointer; }
.menu-button { display: none; border: 1px solid var(--line); background: transparent; padding: 8px 12px; }
.compose-button { position: fixed; right: 28px; bottom: 28px; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--acid); border: 1px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); font-weight: 600; }

.landing-page { min-height: 100vh; background: #dfe5d9; overflow-x: hidden; }
.landing-shell { width: min(1380px, 100%); min-height: 100vh; margin: auto; display: grid; grid-template-columns: 1.02fr .98fr; }
.landing-copy { padding: clamp(34px, 5vw, 86px); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.landing-brand { position: absolute; top: 42px; }
.landing-copy .eyebrow { margin-top: 60px; }
.landing-copy h1 { max-width: 690px; margin-bottom: 30px; font-size: clamp(4.3rem, 7.3vw, 8.6rem); letter-spacing: -.055em; }
.landing-copy h1 em { color: var(--moss); font-weight: 400; }
.landing-lead { max-width: 590px; color: #526057; font-size: clamp(1.05rem, 1.5vw, 1.32rem); }
.landing-copy .primary-button { margin-top: 28px; }
.privacy-note { margin-top: 18px; color: #68736c; font-size: .78rem; }
.landing-visual { position: relative; min-height: 720px; display: grid; place-items: center; overflow: hidden; background: var(--moss); }
.landing-visual::before { content: ""; position: absolute; inset: 0; opacity: .12; background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px); background-size: 44px 44px; }
.visual-orbit { position: absolute; border: 1px solid rgba(216,255,114,.4); border-radius: 50%; }
.orbit-one { width: 720px; height: 720px; }
.orbit-two { width: 500px; height: 500px; }
.paper-card { position: absolute; width: min(430px, 68%); padding: 36px; background: var(--surface); box-shadow: var(--shadow); }
.paper-card > span { color: var(--muted); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.paper-card h2 { margin: 82px 0 24px; font-size: clamp(2.2rem, 3.4vw, 4rem); }
.paper-card p { color: var(--muted); }
.paper-front { z-index: 2; transform: rotate(-3deg); }
.paper-back { transform: translate(18%, -22%) rotate(8deg); opacity: .72; }
.paper-meta { display: flex; justify-content: space-between; margin-top: 50px; padding-top: 18px; border-top: 1px solid var(--line); font-size: .8rem; }

.dashboard-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; padding-bottom: 70px; }
.dashboard-hero h1, .collection-hero h1, .section-heading h1 { margin-bottom: 18px; font-size: clamp(3.4rem, 7vw, 7rem); letter-spacing: -.045em; }
.dashboard-hero p:last-child, .collection-hero > p:last-child, .section-heading > p:last-child { max-width: 620px; color: var(--muted); font-size: 1.05rem; }
.story-library { border-top: 1px solid var(--ink); }
.library-heading { display: flex; align-items: flex-end; justify-content: space-between; padding: 28px 0; border-bottom: 1px solid var(--line); }
.library-heading h2 { margin: 0; font-size: 2.2rem; }
.library-heading .eyebrow { margin-bottom: 4px; }
.library-heading > a { font-size: .88rem; font-weight: 600; }
.story-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 30px; padding: 32px 0; border-bottom: 1px solid var(--line); }
.story-index { color: #9b9d91; font: 2.4rem var(--serif); }
.story-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; }
.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7a847d; }
.status-public::before { background: #4f8135; }
.story-row h3 { margin: 9px 0 7px; font-size: 2rem; }
.story-row-copy > p { max-width: 720px; margin: 0; color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 16px; font-size: .82rem; }
.danger-button { color: var(--danger); }

.collection-hero { max-width: 800px; margin-bottom: 60px; }
.story-grid { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--ink); border-left: 1px solid var(--line); }
.story-card { min-height: 390px; display: flex; flex-direction: column; padding: clamp(28px, 4vw, 50px); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255,253,247,.38); transition: background .2s, transform .2s; }
.story-card:hover { background: var(--surface); transform: translateY(-3px); }
.story-card-top { min-height: 28px; display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.edit-link { color: var(--moss); font: 600 .75rem var(--sans); text-transform: uppercase; }
.story-card h2 { margin: 48px 0 18px; font-size: clamp(2.1rem, 3.5vw, 3.5rem); }
.story-card > p { color: var(--muted); }
.story-card footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: auto; padding-top: 34px; font-size: .8rem; }
.author { display: flex; align-items: center; gap: 10px; }
.author img, .reading-author img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

.editor-wrap { max-width: 900px; margin: auto; }
.back-link { display: inline-block; margin-bottom: 54px; color: var(--muted); font-size: .85rem; }
.section-heading.compact h1 { font-size: clamp(3rem, 6vw, 5.7rem); }
.story-form { margin-top: 50px; padding: clamp(28px, 5vw, 58px); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.story-form > label, .form-footer label { display: block; margin: 0 0 9px; color: var(--muted); font-size: .73rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.story-form input, .story-form textarea, .story-form select { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; outline: 0; background: transparent; color: var(--ink); }
.story-form input { margin-bottom: 42px; padding: 8px 0 15px; font: 2.1rem var(--serif); }
.story-form textarea { min-height: 330px; padding: 14px 0; resize: vertical; font: 1.25rem/1.8 var(--serif); }
.story-form input:focus, .story-form textarea:focus, .story-form select:focus { border-color: var(--moss); }
.form-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-top: 36px; }
.form-footer select { min-width: 250px; padding: 10px 0; }
.form-actions { display: flex; gap: 10px; }
.alert { margin: 24px 0; padding: 14px 18px; border-left: 3px solid var(--danger); background: #f7e7e2; color: #6d261f; }

.reading-view { max-width: 850px; margin: auto; }
.reading-header { padding-bottom: 48px; border-bottom: 1px solid var(--line); }
.reading-header h1 { max-width: 780px; margin: 22px 0 34px; font-size: clamp(3.5rem, 7vw, 7rem); letter-spacing: -.045em; }
.reading-author { display: flex; align-items: center; gap: 13px; }
.reading-author div { display: flex; flex-direction: column; }
.reading-author div span { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.reading-author .edit-link { margin-left: auto; }
.reading-body { padding: 60px 0; white-space: pre-wrap; font: 1.35rem/1.85 var(--serif); }
.empty-state, .error-page { padding: 90px 20px; text-align: center; }
.empty-state h2, .empty-state h3, .error-page h1 { margin: 12px 0; font-size: clamp(2.4rem, 5vw, 4.6rem); }
.empty-state p, .error-page p { color: var(--muted); }
.empty-state .primary-button, .error-page .primary-button { margin-top: 20px; }
.empty-mark { color: var(--moss); font-size: 2.4rem; }

@media (max-width: 850px) {
  .landing-shell { grid-template-columns: 1fr; }
  .landing-copy { min-height: 720px; }
  .landing-visual { min-height: 650px; }
  .dashboard-hero { align-items: flex-start; flex-direction: column; }
  .story-grid { grid-template-columns: 1fr; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .form-actions { justify-content: flex-end; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 28px, 1180px); }
  .page-shell { padding-top: 42px; }
  .menu-button { display: block; }
  .main-nav { position: absolute; top: 76px; left: 0; right: 0; display: none; align-items: stretch; flex-direction: column; gap: 0; padding: 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
  .main-nav.is-open { display: flex; }
  .main-nav a, .main-nav form, .main-nav button { width: 100%; padding: 10px; text-align: left; }
  .compose-button { right: 16px; bottom: 16px; }
  .landing-copy { min-height: 660px; padding: 28px; }
  .landing-brand { top: 28px; }
  .landing-copy h1 { font-size: clamp(3.7rem, 18vw, 5.2rem); }
  .landing-visual { min-height: 560px; }
  .paper-card { width: 78%; padding: 26px; }
  .paper-card h2 { margin-top: 60px; }
  .story-row { grid-template-columns: 44px minmax(0, 1fr); gap: 14px; }
  .row-actions { grid-column: 2; }
  .story-form { padding: 22px; }
  .form-actions { flex-direction: column-reverse; }
  .primary-button, .secondary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
