:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #8a8a8a;
  --line: #111111;
  --soft: #d7d7d7;
  --hair: #ededed;
  --fill: #111111;
  --coral: #ff6f61;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  font-weight: 300;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: inherit;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--soft);
  border-radius: 0;
  background: var(--bg);
  padding: 9px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink);
}

/* ---- Buttons ---- */
.ghost-btn,
.solid-btn,
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 0;
  cursor: pointer;
  font-weight: 300;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.ghost-btn {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
}

.ghost-btn:hover {
  background: var(--fill);
  color: #fff;
}

.solid-btn {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  background: var(--fill);
  color: #fff;
}

.solid-btn:hover {
  background: var(--bg);
  color: var(--ink);
}

.link-btn {
  min-height: 28px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.link-btn:hover {
  text-decoration: underline;
}

button:disabled {
  opacity: 0.4;
  cursor: wait;
}

.eyebrow {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

summary {
  cursor: pointer;
  font-weight: 400;
}

/* ---- App shell (3 columns) ---- */
.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 330px;
  grid-template-rows: 54px minmax(0, 1fr);
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions form {
  margin: 0;
}

.sync-state {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.messages {
  grid-column: 1 / -1;
  padding: 8px 18px;
  border-bottom: 1px solid var(--hair);
}

.message {
  margin: 4px 0;
  font-size: 13px;
  color: var(--ink);
}

/* ---- Left rail ---- */
.rail {
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 16px 14px;
}

.project-switch {
  border-bottom: 1px solid var(--hair);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.project-switch > summary {
  list-style: none;
}

.project-switch > summary::-webkit-details-marker {
  display: none;
}

.project-name {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  font-weight: 300;
}

.project-list {
  display: grid;
  gap: 2px;
  margin-top: 10px;
}

.project-row {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid transparent;
  text-decoration: none;
}

.project-row:hover {
  border-color: var(--soft);
}

.project-row.active {
  background: var(--fill);
  color: #fff;
}

.project-row small,
.chapter-row small,
.side-list small {
  color: var(--muted);
  font-size: 12px;
}

.project-row.active small {
  color: #cfcfcf;
}

.archive-list {
  margin-top: 10px;
}

.archive-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.new-project {
  border-bottom: 1px solid var(--hair);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.new-project summary {
  font-weight: 300;
}

.stack-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.stack-form.dense {
  gap: 8px;
}

.stack-form label,
.profile-form label,
.project-meta label,
.meta-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.index-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.chapter-list {
  display: grid;
  gap: 2px;
}

.chapter-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border: 1px solid transparent;
}

.chapter-row:hover {
  border-color: var(--soft);
}

.chapter-row.active {
  background: var(--fill);
  color: #fff;
}

.chapter-row.active .drag-handle,
.chapter-row.active small {
  color: #cfcfcf;
}

.chapter-row.dragging {
  opacity: 0.4;
}

.chapter-row.drop-target {
  border-top: 2px solid var(--ink);
}

.drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  user-select: none;
}

.chapter-open {
  display: grid;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  min-width: 0;
}

.chapter-open span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-del {
  min-height: 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.chapter-row.active .row-del {
  color: #fff;
}

/* ---- Center editor ---- */
.editor {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.project-meta {
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
}

.project-meta > summary {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.title-input {
  border: 0;
  padding: 14px 0 10px;
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 200;
  letter-spacing: 0;
}

.title-input:focus {
  border: 0;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.idea-line {
  margin-top: 10px;
}

.chapter-title {
  border: 0;
  border-bottom: 1px solid var(--hair);
  padding: 16px 22px;
  font-size: 22px;
  font-weight: 300;
}

.chapter-title:focus {
  border: 0;
  border-bottom: 1px solid var(--ink);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 22px;
  border-bottom: 1px solid var(--hair);
}

.file-action {
  position: relative;
  overflow: hidden;
}

.file-action input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.word-meter {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.word-meter strong {
  font-weight: 400;
  color: var(--ink);
}

.manuscript {
  flex: 1;
  min-height: 0;
  border: 0;
  resize: none;
  padding: 30px clamp(22px, 6vw, 90px);
  font-size: 18px;
  font-weight: 300;
  line-height: 1.85;
}

.manuscript:focus {
  border: 0;
}

.voice-line {
  min-height: 30px;
  padding: 6px 22px;
  border-top: 1px solid var(--hair);
  font-size: 12px;
  color: var(--muted);
}

/* ---- Right assistant ---- */
.assistant {
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 16px 14px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.assistant-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--soft);
  color: var(--muted);
}

.badge.live {
  border-color: var(--ink);
  color: var(--ink);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tool-grid .ghost-btn {
  min-height: 40px;
}

.ai-output {
  border: 1px solid var(--line);
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 6px 12px;
  border-bottom: 1px solid var(--hair);
  font-size: 13px;
}

.ai-output pre {
  margin: 0;
  padding: 14px;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  font-weight: 400;
}

.side-list {
  border-top: 1px solid var(--hair);
  padding-top: 10px;
}

.side-list summary {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-list article {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hair);
  font-size: 13px;
}

.side-list strong {
  font-weight: 400;
}

.project-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--hair);
  padding-top: 12px;
}

.project-actions form {
  flex: 1;
  margin: 0;
}

.project-actions .ghost-btn {
  width: 100%;
}

/* ---- Auth / profile ---- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-panel {
  width: min(420px, 100%);
  padding: 36px 32px;
  border: 1px solid var(--line);
}

.auth-panel.wide {
  width: min(560px, 100%);
}

.auth-panel .brand {
  display: inline-block;
  margin-bottom: 8px;
}

.auth-panel h1 {
  margin: 18px 0 22px;
  font-size: 30px;
  font-weight: 200;
}

.profile-form ul {
  margin: 4px 0 0;
  padding-left: 16px;
  color: var(--ink);
  font-size: 12px;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: 54px minmax(0, 1fr) auto;
  }

  .assistant {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 50vh;
  }
}

@media (max-width: 760px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: 54px auto auto auto;
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 40vh;
  }

  .editor {
    overflow: visible;
  }

  .manuscript {
    min-height: 50vh;
    padding: 22px 18px;
  }

  .assistant {
    max-height: none;
  }

  .meta-grid,
  .tool-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .meta-grid,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .word-meter {
    width: 100%;
    margin-left: 0;
  }
}

/* ============ Landing page ============ */
.lp {
  background: var(--bg);
  color: var(--ink);
}

.lp .solid-btn.lg,
.lp .ghost-btn.lg {
  min-height: 52px;
  padding: 0 26px;
  font-size: 15px;
}

.lp-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 5vw, 64px);
  height: 66px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.lp-links {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.4vw, 30px);
}

.lp-links a {
  text-decoration: none;
  font-size: 14px;
}

.lp-links a:not(.solid-btn):not(.ghost-btn):hover {
  text-decoration: underline;
}

.lp-menu-toggle,
.lp-burger {
  display: none;
}

.lp-burger span {
  display: block;
  width: 22px;
  height: 1px;
  margin: 5px 0;
  background: var(--ink);
}

/* Hero */
.lp-hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 40px;
  padding: clamp(48px, 9vw, 120px) clamp(18px, 5vw, 64px);
  max-width: 1240px;
  margin: 0 auto;
}

.lp-hero h1 {
  margin: 14px 0 22px;
  font-size: clamp(40px, 7vw, 86px);
  font-weight: 200;
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.lp-lead {
  max-width: 46ch;
  font-size: clamp(16px, 1.5vw, 20px);
  line-height: 1.6;
  color: #555;
}

.lp-lead strong,
.lp-band strong {
  font-weight: 500;
  color: var(--ink);
}

.lp-hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.lp-hero-art {
  display: flex;
  justify-content: center;
  color: #111;
}

.lp-hero-art svg {
  width: min(400px, 100%);
  height: auto;
}

/* Sections */
.lp-section {
  padding: clamp(56px, 8vw, 110px) clamp(18px, 5vw, 64px);
  max-width: 1180px;
  margin: 0 auto;
  border-top: 1px solid var(--hair);
}

.lp-section.center {
  text-align: center;
}

.eyebrow.center {
  text-align: center;
  margin-bottom: 36px;
}

.lp-soft-title,
.lp-band h2,
.lp-section h2 {
  font-size: clamp(26px, 4vw, 44px);
  font-weight: 200;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 auto 18px;
}

.lp-muted-lead {
  max-width: 52ch;
  margin: 0 auto 28px;
  color: #555;
  font-size: 17px;
  line-height: 1.6;
}

/* Steps */
.lp-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}

.lp-steps article {
  padding: 28px 22px 10px;
  border-top: 1px solid var(--line);
}

.lp-num {
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.lp-steps h3 {
  margin: 16px 0 10px;
  font-size: 22px;
  font-weight: 300;
}

.lp-steps p {
  color: #555;
  line-height: 1.55;
  font-size: 15px;
}

/* Features */
.lp-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 1180px;
  margin: 0 auto;
  border-top: 1px solid var(--hair);
}

.lp-feature {
  padding: clamp(28px, 4vw, 50px);
  border-top: 1px solid var(--hair);
  border-right: 1px solid var(--hair);
}

.lp-feature:nth-child(2n) {
  border-right: 0;
}

.lp-feature h3 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 300;
}

.lp-feature p {
  margin: 0;
  color: #555;
  line-height: 1.6;
  font-size: 16px;
}

/* Inverted band */
.lp-band {
  background: var(--ink);
  color: #fff;
  text-align: center;
  padding: clamp(60px, 9vw, 120px) clamp(20px, 6vw, 80px);
}

.lp-band h2 {
  color: #fff;
}

.lp-band p {
  max-width: 56ch;
  margin: 0 auto 30px;
  font-size: clamp(16px, 1.6vw, 20px);
  line-height: 1.6;
  color: #cfcfcf;
}

.lp-band strong {
  color: #fff;
}

.solid-btn.invert {
  background: #fff;
  color: var(--ink);
  border-color: #fff;
}

.solid-btn.invert:hover {
  background: transparent;
  color: #fff;
}

/* Footer */
.lp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 30px clamp(18px, 5vw, 64px);
  border-top: 1px solid var(--line);
}

.lp-footer nav {
  display: flex;
  gap: 22px;
}

.lp-footer a {
  text-decoration: none;
  font-size: 14px;
}

.lp-footer a:hover {
  text-decoration: underline;
}

.lp-footer small {
  color: var(--muted);
}

/* Landing responsive */
@media (max-width: 900px) {
  .lp-hero {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .lp-lead {
    margin-left: auto;
    margin-right: auto;
  }

  .lp-hero-cta {
    justify-content: center;
  }

  .lp-hero-art {
    order: -1;
  }

  .lp-hero-art svg {
    width: min(260px, 70%);
  }

  .lp-steps {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .lp-burger {
    display: block;
    cursor: pointer;
  }

  .lp-links {
    position: absolute;
    top: 66px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
  }

  .lp-menu-toggle:checked ~ .lp-links {
    max-height: 380px;
  }

  .lp-links a {
    padding: 14px clamp(18px, 5vw, 64px);
    border-top: 1px solid var(--hair);
    text-align: left;
  }

  .lp-links a.solid-btn,
  .lp-links a.ghost-btn {
    justify-content: flex-start;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}

@media (max-width: 560px) {
  .lp-steps,
  .lp-features {
    grid-template-columns: 1fr;
  }

  .lp-feature {
    border-right: 0;
  }

  .lp-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============ Public pages (catalog / book / reader) ============ */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(18px, 5vw, 64px);
  height: 64px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 24px);
}

.site-nav a {
  text-decoration: none;
  font-size: 14px;
}

.site-nav a:not(.ghost-btn):not(.solid-btn):hover {
  text-decoration: underline;
}

.site-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px clamp(18px, 5vw, 64px);
  border-top: 1px solid var(--line);
}

.site-footer small {
  color: var(--muted);
}

/* Catalog */
.catalog,
.book-detail,
.reader {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 72px) clamp(18px, 5vw, 64px);
}

.catalog-head h1 {
  margin: 8px 0 0;
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 200;
  letter-spacing: -0.01em;
}

.cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 36px;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--soft);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--ink);
}

.chip.active {
  background: var(--fill);
  color: #fff;
  border-color: var(--ink);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0;
  border-top: 1px solid var(--hair);
  border-left: 1px solid var(--hair);
}

.book-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  border-right: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  transition: background 0.12s ease;
}

.book-card:hover {
  background: #fafafa;
}

.book-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
}

.book-cat {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.book-card h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 300;
  line-height: 1.2;
}

.book-author {
  margin: 0;
  color: #555;
  font-size: 14px;
}

.book-blurb {
  margin: 4px 0 0;
  color: #555;
  font-size: 14px;
  line-height: 1.55;
}

.book-meta {
  margin-top: auto;
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 40px 0;
  color: var(--muted);
}

/* Book detail */
.back-link {
  display: inline-block;
  margin-bottom: 28px;
  font-size: 14px;
  text-decoration: none;
  color: var(--muted);
}

.back-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.book-detail h1 {
  margin: 10px 0 6px;
  font-size: clamp(30px, 5vw, 56px);
  font-weight: 200;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.book-synopsis {
  max-width: 60ch;
  margin: 22px 0;
  font-size: 18px;
  line-height: 1.7;
  color: #333;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 40px;
}

.coupon-input {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 20px 0 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 300;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.coupon-input::placeholder {
  color: var(--soft);
  text-transform: none;
  letter-spacing: 0;
}

.coupon-input:focus {
  outline: none;
  border-color: var(--ink);
}

.ghost-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.toc {
  border-top: 1px solid var(--hair);
  padding-top: 20px;
}

.toc ol {
  margin: 12px 0 0;
  padding-left: 20px;
  line-height: 2;
}

/* Reader */
.reader {
  max-width: 760px;
}

.reader-body {
  font-size: 19px;
  line-height: 1.85;
  font-weight: 300;
}

.reader-title {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 200;
  letter-spacing: -0.01em;
  margin: 10px 0 4px;
}

.reader-author {
  color: var(--muted);
  margin: 0 0 40px;
}

.reader-chapter {
  margin: 48px 0;
}

.reader-chapter h2 {
  font-size: 24px;
  font-weight: 400;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hair);
}

.reader-chapter p {
  margin: 0 0 1.1em;
}

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

/* Publish panel + import (in studio) */
.publish-panel {
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
}

.publish-panel > summary {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.pub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.pub-grid label,
.pub-blurb {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.pub-blurb {
  margin-top: 10px;
}

.pub-hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
  font-weight: 300;
  color: #6b6b6b;
}

.pub-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pub-status {
  font-size: 12px;
  color: var(--muted);
}

.publish-panel[data-published="1"] .pub-status {
  color: var(--ink);
}

.publish-panel[data-published="1"] [data-publish] {
  display: none;
}

.publish-panel[data-published="0"] [data-unpublish] {
  display: none;
}

.import-line {
  margin-bottom: 14px;
}

.file-action.sm {
  width: 100%;
  min-height: 34px;
  font-size: 13px;
}

/* ============ Landing — extra sections ============ */
.lp .center {
  text-align: center;
}

.lp-cta-row {
  margin-top: 30px;
  text-align: center;
}

.lp-book-grid {
  margin-top: 34px;
}

/* Studio mockup */
.studio-mock {
  max-width: 780px;
  margin: 40px auto 0;
  border: 1px solid var(--line);
  background: #fff;
}

.sm-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.sm-top span {
  width: 46px;
  height: 8px;
  background: var(--hair);
}

.sm-top .sm-grow {
  flex: 1;
  background: transparent;
}

.sm-top i {
  width: 26px;
  height: 8px;
  background: var(--hair);
}

.sm-body {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  min-height: 230px;
}

.sm-rail,
.sm-assist {
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.sm-rail {
  border-right: 1px solid var(--line);
}

.sm-assist {
  border-left: 1px solid var(--line);
}

.sm-rail i,
.sm-assist i {
  height: 12px;
  background: var(--hair);
}

.sm-rail i.on {
  background: var(--fill);
}

.sm-assist .sm-block {
  height: 60px;
  background: #f1f1f1;
}

.sm-editor {
  padding: 22px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.sm-editor b {
  height: 18px;
  width: 55%;
  background: #d8d8d8;
}

.sm-editor u {
  height: 9px;
  background: var(--hair);
}

.sm-editor u.short {
  width: 68%;
}

/* Audiobook / voice section */
.lp-audio {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 40px;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(56px, 8vw, 100px) clamp(18px, 5vw, 64px);
  border-top: 1px solid var(--hair);
}

.lp-audio h2 {
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 200;
  letter-spacing: -0.01em;
  margin: 10px 0 16px;
}

.lp-audio p {
  max-width: 48ch;
  color: #555;
  font-size: 17px;
  line-height: 1.65;
}

.lp-audio-art {
  display: flex;
  justify-content: center;
  color: var(--ink);
}

.lp-audio-art svg {
  width: min(320px, 100%);
  height: auto;
}

@media (max-width: 900px) {
  .lp-audio {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .lp-audio p {
    margin-left: auto;
    margin-right: auto;
  }

  .lp-audio-art {
    order: -1;
  }

  .sm-body {
    min-height: 180px;
  }
}

/* ============ Book covers ============ */
.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #fff;
}

.book-card .cover {
  border-bottom: 1px solid var(--hair);
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-auto {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  background: #fff;
  color: var(--ink);
}

.cover-mark {
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.cover-title {
  font-size: clamp(17px, 2.4vw, 23px);
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.cover-author {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Variant 1 — inverted */
.cover-v1 .cover-auto {
  background: var(--ink);
  color: #fff;
}

.cover-v1 .cover-mark,
.cover-v1 .cover-author {
  color: #9a9a9a;
}

/* Variant 2 — centered, ruled */
.cover-v2 .cover-auto {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}

.cover-v2 .cover-mark {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  text-align: center;
}

.cover-v2 .cover-title {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 14px 4px;
}

.cover-v2 .cover-author {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
}

/* Variant 3 — title anchored bottom, larger */
.cover-v3 .cover-auto {
  justify-content: flex-end;
}

.cover-v3 .cover-mark {
  position: absolute;
  top: 18px;
  left: 18px;
}

.cover-v3 .cover-title {
  font-size: clamp(20px, 3vw, 28px);
}

/* Book detail with cover */
.book-detail-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 44px;
  align-items: start;
}

.book-cover-lg .cover {
  border: 1px solid var(--line);
}

.book-info h1 {
  margin: 8px 0 6px;
}

.cover-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.cover-line .muted {
  font-size: 12px;
}

@media (max-width: 640px) {
  .book-detail-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .book-cover-lg {
    max-width: 200px;
  }
}

/* ============ Subscription / profile status ============ */
.subscribe {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(40px, 7vw, 80px) clamp(18px, 5vw, 64px);
}

.subscribe h1 {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 200;
  letter-spacing: -0.01em;
  margin: 8px 0 24px;
}

.notice {
  padding: 12px 14px;
  border: 1px solid var(--line);
  margin-bottom: 20px;
  font-size: 14px;
}

.notice.ok {
  background: var(--ink);
  color: #fff;
}

.plan-card {
  border: 1px solid var(--line);
  padding: 28px;
  display: grid;
  gap: 16px;
}

.plan-state {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.plan-price {
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 200;
  margin: 0;
}

.plan-feats {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: #444;
  line-height: 1.5;
}

.plan-card form {
  margin: 0;
}

.profile-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
}

/* ============ Price, paywall, CRM ============ */
.book-price {
  font-size: 22px;
  font-weight: 300;
  margin: 6px 0 0;
}

.paywall {
  margin-top: 44px;
  padding: 32px;
  border: 1px solid var(--line);
  text-align: center;
}

.paywall h3 {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 200;
  margin: 8px 0 10px;
}

.paywall form {
  margin-top: 18px;
}

.crm {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 64px) clamp(18px, 5vw, 64px);
}

.crm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.crm-head h1 {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 200;
  margin: 6px 0 0;
}

.crm-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--line);
  margin-bottom: 36px;
}

.crm-totals > div {
  padding: 16px 18px;
  border-right: 1px solid var(--hair);
  display: grid;
  gap: 6px;
}

.crm-totals > div:last-child {
  border-right: 0;
}

.crm-totals strong {
  font-size: 22px;
  font-weight: 400;
}

.crm-block {
  margin-bottom: 40px;
}

.crm-block h2 {
  font-size: 18px;
  font-weight: 400;
  margin: 0 0 14px;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.crm-table th,
.crm-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair);
  vertical-align: top;
}

.crm-table th {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

.payout-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.payout-form input {
  width: auto;
  min-width: 120px;
}

@media (max-width: 640px) {
  .payout-form {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ============ Audiobook player ============ */
.audio-chapter {
  margin: 26px 0;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hair);
}

.audio-chapter h2 {
  font-size: 20px;
  font-weight: 400;
  margin: 0 0 12px;
}

.audio-chapter audio {
  width: 100%;
}

/* ============ Reader library + account ============ */
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-bottom: 40px;
}

.lib-card {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 16px;
  border: 1px solid var(--hair);
  padding: 14px;
}

.lib-cover {
  display: block;
}

.lib-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.lib-body h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 300;
}

.lib-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.lib-actions .solid-btn,
.lib-actions .ghost-btn {
  min-height: 30px;
  font-size: 13px;
}

.lib-next {
  font-size: 12px;
  margin: 4px 0 0;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  border: 1px solid var(--hair);
  padding: 16px;
  margin-bottom: 16px;
}

.account-grid p {
  margin: 4px 0 0;
}

.account-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.danger-zone {
  margin-top: 24px;
  border-top: 1px solid var(--hair);
  padding-top: 16px;
}

.danger-zone summary {
  color: #b00020;
}

.danger-zone form {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  max-width: 360px;
}

.danger-btn {
  background: #b00020;
  border-color: #b00020;
}

.danger-btn:hover {
  background: #fff;
  color: #b00020;
}

/* ============ Legal pages + footer links ============ */
.legal {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(36px, 6vw, 72px) clamp(18px, 5vw, 64px);
  font-weight: 300;
  line-height: 1.7;
}

.legal h1 {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 200;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

.legal h2 {
  font-size: 18px;
  font-weight: 400;
  margin: 32px 0 8px;
}

.legal p,
.legal li {
  color: #333;
}

.legal ul {
  padding-left: 20px;
}

.legal-note {
  color: var(--muted);
  font-size: 13px;
  border: 1px solid var(--hair);
  padding: 8px 12px;
  margin: 0 0 8px;
}

.footer-legal {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-legal a {
  text-decoration: none;
  font-size: 14px;
}

.footer-legal a:hover {
  text-decoration: underline;
}

/* ============ Landing two-door split ============ */
.lp-split {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(40px, 7vw, 90px) clamp(18px, 5vw, 64px) clamp(30px, 5vw, 56px);
}

.lp-split h1 {
  font-size: clamp(32px, 6vw, 60px);
  font-weight: 200;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 10px 0 40px;
}

.split-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
}

.split-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(26px, 4vw, 46px);
}

.split-card:first-child {
  border-right: 1px solid var(--line);
}

.split-card h2 {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 200;
  letter-spacing: -0.01em;
  margin: 0;
}

.split-card > p {
  color: #555;
  line-height: 1.6;
  margin: 0;
}

.split-feats {
  list-style: none;
  padding: 0;
  margin: 4px 0 10px;
  display: grid;
  gap: 8px;
}

.split-feats li {
  padding-left: 20px;
  position: relative;
  color: #333;
}

.split-feats li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--muted);
}

.split-card .solid-btn {
  margin-top: auto;
}

.split-more {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

.split-more:hover {
  color: var(--ink);
}

@media (max-width: 760px) {
  .split-cards {
    grid-template-columns: 1fr;
  }

  .split-card:first-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

/* ============ Landing emblem ============ */
.lp-emblem {
  display: flex;
  justify-content: center;
  color: var(--ink);
  margin-bottom: 14px;
}

.lp-emblem svg {
  width: clamp(116px, 16vw, 200px);
  height: auto;
}

/* Split cards as links + concise */
.split-card {
  text-decoration: none;
  color: inherit;
  transition: background 0.12s ease;
}

.split-card:hover {
  background: #fafafa;
}

.split-card > p {
  flex: none;
}

.split-go {
  margin-top: auto;
  padding-top: 12px;
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
}

.split-card:hover .split-go {
  text-decoration: underline;
}

/* ============ Catalog format badges ============ */
.book-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.fmt {
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border: 1px solid var(--soft);
  color: var(--muted);
  white-space: nowrap;
}

.fmt-audio {
  border-color: var(--ink);
  color: var(--ink);
}

/* ---- Guided chapter, help guide, modals ---- */
.guided-open {
  width: 100%;
  margin: 4px 0 12px;
  padding: 9px 12px;
  background: var(--bg);
  color: var(--coral);
  border: 1px solid var(--coral);
  font: inherit;
  font-weight: 400;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.guided-open:hover { background: var(--coral); color: #fff; }

.fab-help {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  border: none;
  font-size: 1.15rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(17, 17, 17, 0.22);
}
.fab-help:hover { filter: brightness(1.06); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 17, 17, 0.5);
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  overflow: auto;
  padding: 28px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
}
.modal-card h2 { font-weight: 300; margin: 0 0 6px; }
.modal-x {
  position: absolute;
  top: 8px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
}

.help-list { font-weight: 300; line-height: 1.6; padding-left: 18px; margin: 14px 0 20px; }
.help-list li { margin-bottom: 9px; }

.guided-step { border-top: 1px solid var(--hair); padding: 14px 0; }
.guided-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  margin-bottom: 8px;
}
.guided-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--coral);
  color: var(--coral);
  border-radius: 50%;
  font-size: 0.8rem;
}
.guided-step textarea {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  font: inherit;
  font-weight: 300;
  line-height: 1.5;
  resize: vertical;
}
.guided-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.ghost-btn.sm { padding: 4px 10px; font-size: 0.82rem; margin-left: auto; }

/* ---- Credits ---- */
.credit-meter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--coral);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
}
.credit-meter strong { color: var(--coral); font-weight: 500; }
.credit-meter:hover { background: var(--coral); color: #fff; }
.credit-meter:hover strong { color: #fff; }

.credits-packs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 22px 0;
}
.pack-card { border: 1px solid var(--line); padding: 22px; text-align: center; }
.pack-card .plan-price { margin: 0 0 2px; font-weight: 300; }
.pack-price { font-size: 1.5rem; font-weight: 300; margin: 0; }
.pack-card form { margin-top: 14px; }

.credits-costs { margin: 26px 0; }
.cost-list { list-style: none; padding: 0; margin: 12px 0; }
.cost-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--hair);
  font-weight: 300;
}
.cost-list li strong { font-weight: 500; color: var(--coral); }
.lead-muted { color: var(--muted); font-weight: 300; max-width: 62ch; }
.ledger { width: 100%; border-collapse: collapse; font-weight: 300; font-size: 0.9rem; margin-top: 10px; }
.ledger td { padding: 7px 8px; border-bottom: 1px solid var(--hair); }
.ledger .num { text-align: right; }

/* ---- Multilingual (translations) ---- */
.lang-section { margin: 26px 0; border-top: 1px solid var(--hair); padding-top: 18px; }
.lang-list { list-style: none; padding: 0; margin: 12px 0; }
.lang-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 9px 0;
  border-bottom: 1px solid var(--hair);
  font-weight: 300;
}
.lang-actions { display: flex; gap: 12px; }
.lang-add { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 6px; }
.lang-add select { width: auto; min-width: 160px; }
.lang-note { margin-top: 16px; }
