:root {
  color-scheme: light;
  --ink: #25211d;
  --muted: #6d665e;
  --line: #ded7ce;
  --paper: #fffaf1;
  --surface: #ffffff;
  --wash: #f3efe7;
  --accent: #b13f2e;
  --accent-dark: #762b22;
  --green: #2d6a55;
  --blue: #285f8f;
  --gold: #b17916;
  --shadow: 0 18px 48px rgba(45, 38, 30, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  background: rgba(255, 250, 241, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 800;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  color: #fffdf8;
  background: var(--accent);
  border-radius: 999px;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.76rem;
  border-radius: 6px;
  letter-spacing: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 28px);
  color: var(--muted);
  font-size: 0.95rem;
}

.nav a:hover {
  color: var(--ink);
}

.account-form {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(160px, 220px) minmax(130px, 180px) auto;
  gap: 8px;
  align-items: end;
  margin-left: auto;
}

.account-form label {
  gap: 4px;
  font-size: 0.68rem;
}

.account-form input {
  min-height: 38px;
}

.account-form .button {
  min-height: 38px;
}

.owner-password-field {
  grid-column: 1 / -2;
}

.account-message {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.account-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-left: auto;
  padding: 8px 10px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-card span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: #fffdf8;
  background: var(--ink);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.account-card strong {
  min-width: 0;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  align-items: center;
  gap: clamp(28px, 5vw, 76px);
  padding: clamp(48px, 8vw, 92px) clamp(18px, 5vw, 72px) clamp(34px, 6vw, 64px);
  overflow: hidden;
}

.beta-gate {
  min-height: calc(100vh - 68px);
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 20px;
  padding: clamp(48px, 8vw, 92px) clamp(18px, 5vw, 72px);
  background: var(--paper);
}

.beta-gate h1 {
  max-width: 980px;
}

.beta-gate .button {
  margin-top: 4px;
}

body.beta-locked main {
  display: none;
}

body.beta-locked .nav {
  display: none;
}

body.beta-unlocked .beta-gate {
  display: none;
}

.hero-media {
  position: relative;
  min-height: 430px;
}

.paper {
  position: absolute;
  width: min(62vw, 520px);
  aspect-ratio: 0.76;
  background: linear-gradient(145deg, #ffffff, #f4eadb);
  border: 1px solid #e7d9c7;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.paper::before,
.paper::after {
  content: "";
  position: absolute;
  left: 9%;
  right: 9%;
  height: 1px;
  background: rgba(37, 33, 29, 0.22);
}

.paper::before {
  top: 23%;
  box-shadow: 0 34px rgba(37, 33, 29, 0.18), 0 68px rgba(37, 33, 29, 0.16), 0 102px rgba(37, 33, 29, 0.14);
}

.paper::after {
  top: 65%;
  width: 48%;
}

.paper-a {
  left: 7%;
  top: 4%;
  transform: rotate(-8deg);
}

.paper-b {
  left: 24%;
  top: 12%;
  transform: rotate(7deg);
  background: linear-gradient(145deg, #fffef9, #e8f0eb);
}

.paper-c {
  left: 15%;
  top: 24%;
  transform: rotate(-1deg);
  background: linear-gradient(145deg, #ffffff, #f1e4d5);
}

.hero-copy {
  max-width: 610px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4.2rem, 12vw, 9rem);
  line-height: 0.86;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  margin: 14px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.deck {
  max-width: 560px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1.08rem, 2.2vw, 1.32rem);
  line-height: 1.55;
}

.share-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.hero-actions,
.form-actions,
.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button,
.text-button {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 800;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--accent);
  color: #fffdf8;
  box-shadow: 0 10px 24px rgba(177, 63, 46, 0.22);
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger {
  background: #3b2b29;
  color: #fffdf8;
}

.read-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: clamp(24px, 5vw, 52px);
  padding: 58px clamp(18px, 5vw, 72px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sidebar {
  position: sticky;
  top: 90px;
  align-self: start;
}

.compact h2 {
  font-size: 1.8rem;
}

.category-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.category-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.category-tab.active {
  color: var(--ink);
  background: var(--wash);
  border-color: var(--ink);
}

.tools-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  margin: 24px 0;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  min-height: 260px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(177, 63, 46, 0.12);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.post-card {
  min-width: 0;
}

.card-button {
  display: grid;
  align-content: start;
  width: 100%;
  min-height: 270px;
  padding: 20px;
  text-align: left;
  color: inherit;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.card-button:hover {
  transform: translateY(-2px);
  border-color: #c9b8a5;
  box-shadow: 0 12px 26px rgba(45, 38, 30, 0.09);
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  color: #fffdf8;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.cat-essays {
  background: var(--accent);
}

.cat-memoirs {
  background: var(--green);
}

.cat-fiction {
  background: var(--blue);
}

.cat-notes {
  background: var(--gold);
}

.excerpt {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.byline {
  margin-top: 22px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.empty-state {
  padding: 36px;
  color: var(--muted);
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.reader-panel,
.practice-band,
.publish-band,
.library-band {
  padding: 58px clamp(18px, 5vw, 72px);
}

.reader-panel {
  background: #fffdf8;
  border-bottom: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.text-button {
  margin-bottom: 24px;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 800;
}

.reader-article {
  max-width: 790px;
  margin: 0 auto;
}

.reader-article h2 {
  font-size: clamp(2.4rem, 6vw, 5.2rem);
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 34px;
  color: var(--muted);
  font-weight: 700;
}

.reader-body {
  color: #322b25;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.16rem, 2.2vw, 1.32rem);
  line-height: 1.78;
}

.reader-body p {
  margin: 0;
  text-indent: 2em;
}

.reader-body p + p {
  margin-top: 0.9em;
}

.reader-body a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.practice-band {
  background: #fffdf8;
  border-bottom: 1px solid var(--line);
}

.practice-head {
  max-width: 850px;
}

.practice-menu {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.practice-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 210px;
  padding: 20px;
  text-align: left;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.practice-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #c9b8a5;
  box-shadow: 0 12px 26px rgba(45, 38, 30, 0.09);
}

.practice-card strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  line-height: 1.05;
}

.practice-card span:last-child {
  color: var(--muted);
  line-height: 1.5;
}

.practice-card.disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.practice-pill {
  width: fit-content;
  color: #fffdf8;
  background: var(--green);
}

.practice-pill.muted {
  background: var(--muted);
}

.practice-workbench {
  margin-top: 28px;
}

.practice-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.practice-toolbar .text-button {
  margin-bottom: 0;
}

.practice-selects {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 12px;
  min-width: min(100%, 420px);
}

.practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 18px;
  align-items: stretch;
}

.prompt-panel,
.practice-panel {
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.prompt-panel h3 {
  margin-top: 0;
}

.prompt-box {
  min-height: 130px;
  margin-top: 18px;
  padding: 20px;
  color: #322b25;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  line-height: 1.25;
}

.character-track {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 62px;
  margin-top: 18px;
  padding: 14px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.character-track span {
  display: inline-grid;
  place-items: center;
  min-width: 1.2em;
  min-height: 1.7em;
  padding: 0 0.15em;
  border-bottom: 2px solid var(--line);
  border-radius: 4px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1rem;
}

.character-track .correct {
  border-color: var(--green);
  background: #e6f0eb;
}

.character-track .incorrect {
  border-color: var(--accent);
  background: #f8dfd9;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.metrics-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics-grid span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics-grid strong {
  font-size: 1.25rem;
}

.practice-panel textarea {
  min-height: 180px;
}

.practice-feedback,
.practice-best {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.practice-feedback {
  font-weight: 800;
}

.compact-actions {
  margin-top: 18px;
}

.publish-band {
  background: var(--wash);
}

.section-note {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.account-gate {
  display: grid;
  gap: 6px;
  max-width: 780px;
  margin-top: 22px;
  padding: 18px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-gate span {
  color: var(--muted);
  line-height: 1.5;
}

.publish-form {
  display: grid;
  gap: 18px;
  max-width: 980px;
  margin-top: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.file-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 0 18px;
  background: #fffdf8;
  border: 1px dashed #b9aa99;
  border-radius: 8px;
  cursor: pointer;
}

.file-drop input,
.import-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.45;
}

.check-row input {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--accent);
}

.substack-note {
  max-width: 760px;
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.library-band {
  background: var(--paper);
}

.library-list {
  display: grid;
  gap: 10px;
  max-width: 980px;
  margin-top: 24px;
}

.library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.library-item strong {
  display: block;
  margin-bottom: 4px;
}

.library-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 10px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 800;
}

.status-badge.published {
  color: #1f533f;
  background: #dfece5;
}

.status-badge.pending {
  color: #6b3f08;
  background: #f4dfb9;
}

.mini-actions {
  display: flex;
  gap: 8px;
}

.mini-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.mini-actions [data-action="approve"] {
  color: #fffdf8;
  background: var(--green);
  border-color: var(--green);
}

@media (max-width: 1040px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-media {
    order: 2;
    min-height: 310px;
  }

  .paper {
    width: min(78vw, 420px);
  }

  .read-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .category-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .post-grid,
  .practice-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .practice-layout {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .account-form {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    margin-left: 0;
  }

  .account-card {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: center;
    gap: 10px;
    padding: 10px 14px 12px;
  }

  .nav {
    order: 5;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 6px;
    padding-top: 4px;
  }

  .nav a {
    display: grid;
    place-items: center;
    min-height: 40px;
    background: #fffdf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.86rem;
  }

  .account-form {
    order: 4;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-left: 0;
  }

  .account-form label {
    font-size: 0.76rem;
  }

  .account-form input,
  .account-form .button {
    min-height: 44px;
  }

  .account-card {
    order: 4;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-left: 0;
  }

  .account-card strong {
    white-space: normal;
  }

  .beta-badge {
    min-height: 20px;
    padding: 0 7px;
    font-size: 0.64rem;
  }

  .hero {
    min-height: auto;
    padding: 30px 18px 24px;
    gap: 18px;
  }

  h1 {
    font-size: clamp(3.4rem, 20vw, 5rem);
  }

  h2 {
    font-size: clamp(2rem, 11vw, 2.8rem);
  }

  .deck {
    margin-top: 16px;
    font-size: 1.04rem;
  }

  .hero-actions,
  .form-actions,
  .library-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .button {
    width: 100%;
    min-height: 48px;
  }

  .hero-media {
    min-height: 180px;
  }

  .paper {
    width: min(86vw, 330px);
  }

  .read-shell,
  .reader-panel,
  .practice-band,
  .publish-band,
  .library-band {
    padding: 38px 18px;
  }

  .tools-row,
  .post-grid,
  .practice-menu,
  .practice-selects,
  .metrics-grid,
  .form-grid,
  .library-item {
    grid-template-columns: 1fr;
  }

  .practice-card {
    min-height: 170px;
  }

  .prompt-panel,
  .practice-panel {
    padding: 16px;
  }

  .prompt-box {
    min-height: 110px;
    padding: 16px;
  }

  .category-list {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .category-tab {
    min-height: 44px;
    padding: 0 10px;
  }

  .card-button {
    min-height: 220px;
    padding: 18px;
  }

  .reader-article h2 {
    font-size: clamp(2.3rem, 16vw, 3.6rem);
  }

  .reader-body {
    font-size: 1.12rem;
    line-height: 1.72;
  }

  .file-drop {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding: 14px;
  }

  .mini-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .mini-actions button {
    min-height: 42px;
  }
}
