:root {
  color-scheme: light;
  --ink: #292137;
  --muted: #5f556b;
  --violet: #5137ba;
  --violet-hover: #402798;
  --tint: #eee7fb;
  --canvas: #f7f2fa;
  --rail: #faf6fb;
  --paper: #fffdff;
  --border: #e4dbe9;
  --input-border: #cfc2d7;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
}

button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .cm-editor.cm-focused {
  outline: 3px solid #7662ee;
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 65px;
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 3.25rem);
  padding: 0 1.65rem;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  min-width: max-content;
  font-size: .98rem;
  font-weight: 740;
  letter-spacing: -.04em;
}

.topbar nav { display: flex; gap: 1.4rem; min-width: 0; align-self: stretch; align-items: stretch; }
.topbar nav a { display: grid; align-content: center; padding: 0 .1rem; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.topbar nav a:hover, .topbar nav a[aria-current] { color: var(--ink); }
.topbar nav a[aria-current] { box-shadow: inset 0 -3px var(--violet); font-weight: 700; }
.topbar-actions { margin-left: auto; display: flex; gap: .45rem; }

.workspace { min-height: calc(100dvh - 65px); display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 65px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  height: calc(100dvh - 65px);
  padding: 1.2rem .9rem 1rem;
  background: var(--rail);
  border-right: 1px solid var(--border);
}

.sidebar-title { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding-inline: .3rem; }
.sidebar-title h2 { margin: 0; font: 400 1.38rem/1.05 var(--serif); letter-spacing: -.035em; }
.sidebar-title button { white-space: nowrap; }
.sidebar-note { margin-top: auto; padding: .75rem .55rem 0; border-top: 1px solid var(--border); color: var(--muted); font-size: .785rem; display: flex; align-items: center; gap: .45rem; }
.sidebar-note i { width: 7px; height: 7px; flex: 0 0 auto; background: #318450; border-radius: 50%; }
.sidebar-note[data-state="pending"] i { background: #8c661d; }
.sidebar-note[data-state="error"] i { background: #b33b42; }
.project-list { display: grid; align-content: start; gap: .25rem; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: .2rem; }
.sidebar-tools { display: grid; justify-items: start; gap: .1rem; }
.project-list button, .sample-link {
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  padding: .55rem .6rem;
  font-size: .875rem;
}

.project-list button { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.project-title { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-icon { width: 13px; height: 16px; flex: 0 0 auto; border: 1px solid currentColor; border-left-width: 3px; border-radius: 2px; opacity: .65; }
.project-list button:hover, .sample-link:hover { background: var(--tint); }
.project-list button[aria-current] { background: var(--tint); border-color: #dfd2f2; color: var(--violet-hover); font-weight: 700; }
.empty { margin: 0; padding: .35rem .6rem; font-size: .875rem; color: var(--muted); }
.sample-link { color: var(--violet-hover); }

.work-area { width: min(100%, 1220px); margin: 0 auto; padding: 2.5rem clamp(1.25rem, 4vw, 3.75rem) 5rem; }
.work-header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.35rem; }
.work-context { color: var(--violet-hover); font-size: .85rem; font-weight: 630; margin: 0 0 .35rem; }
h1 { margin: 0; color: var(--ink); font: 400 clamp(2.1rem, 4vw, 3.65rem)/1.02 var(--serif); letter-spacing: -.057em; overflow-wrap: anywhere; }
h2 { margin: 0 0 .55rem; font: 670 1.2rem/1.18 var(--sans); letter-spacing: -.028em; }
h3 { letter-spacing: -.025em; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.panel, .context-card { border: 1px solid var(--border); border-radius: 13px; background: var(--paper); padding: 1.45rem; box-shadow: 0 3px 8px #382b4e07; }
.panel > :last-child, .context-card p:last-child { margin-bottom: 0; }
.panel-heading { padding-bottom: .35rem; }
.panel-heading p { margin-bottom: .85rem; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(238px, 1fr); gap: 1rem; align-items: start; }
.setup-layout { grid-template-columns: minmax(0, 1.7fr) minmax(237px, .94fr); }

label { display: block; margin-bottom: 1rem; font-size: .875rem; font-weight: 620; }
label > input, label > select, label > textarea { margin-top: .38rem; }
.optional { margin-left: .25rem; color: var(--muted); font-size: .8125rem; font-weight: 450; }
input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  padding: .59rem .68rem;
  font-size: 1rem;
  font-weight: 400;
}

input::placeholder, textarea::placeholder { color: #626675; opacity: 1; }
.brief [name="topic"] { font: 1.13rem/1.5 var(--serif); background: #faf6fc; }
textarea { resize: vertical; line-height: 1.55; }
select {
  appearance: none;
  padding-right: 1.8rem;
  background-image: linear-gradient(45deg, transparent 50%, #555969 50%), linear-gradient(135deg, #555969 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.form-actions, .actions, .chapter-actions, .export-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.form-actions { margin-top: 1.05rem; }
.primary, .secondary, .import-control {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .3rem;
  min-height: 38px;
  padding: .52rem .78rem;
  border: 1px solid transparent;
  border-radius: 7px;
  text-align: center;
  font-size: .875rem;
  font-weight: 630;
  line-height: 1.35;
}

.primary { background: var(--violet); color: white; }
.primary:hover { background: var(--violet-hover); }
.secondary, .import-control { background: var(--paper); color: var(--ink); border-color: var(--input-border); }
.secondary:hover, .import-control:hover { background: var(--rail); border-color: #ad99bf; }
.compact { padding: .38rem .55rem; min-height: 34px; }
.import-control { position: relative; overflow: hidden; cursor: pointer; margin: 0; }
.import-control input { position: absolute; inset: 0; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.import-control:focus-within { outline: 3px solid #7662ee; outline-offset: 3px; }
.brief-details { padding: .7rem 0 .3rem; border-top: 1px solid var(--border); }
.brief-details summary { color: var(--muted); font-size: .875rem; }
.brief-details[open] summary { margin-bottom: .8rem; }
.extra-label { margin-top: .8rem; }

.guided-start { display: grid; gap: .55rem; margin: 0 0 .9rem; }
.draft-builder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .7rem 1.15rem;
  padding: .85rem 1rem;
  border: 1px solid #dcd4fb;
  border-inline-start: 3px solid var(--violet);
  border-radius: 7px;
  background: #f8f6ff;
}

.draft-builder-copy { flex: 1 1 14rem; min-width: 0; }
.draft-builder h3 { margin: 0 0 .18rem; font-size: 1rem; }
.draft-builder p { margin: 0; color: var(--muted); font-size: .875rem; }
.draft-builder [role="status"]:not(:empty) { margin-top: .35rem; }
.draft-builder p.draft-builder-privacy { margin-top: .35rem; font-size: .8rem; }
.draft-builder-privacy a { text-decoration: underline; text-underline-offset: .15em; }
.draft-builder-actions > :is(a, button) { min-height: 44px; }
.starter-outline { padding: 0 .8rem .1rem; border: 1px solid var(--border); border-radius: 7px; }
.starter-outline summary { padding-block: .68rem; color: #412eac; font-size: .9rem; font-weight: 650; }
.starter-outline p, .starter-outline ol { margin: 0 0 .65rem; font-size: .875rem; }
.starter-outline p { color: var(--muted); overflow-wrap: anywhere; }
.starter-outline ol { padding-inline-start: 1.55rem; }
.resume-builder { margin: .95rem 0 0; }

.builder-conversation { max-width: 745px; margin-inline: auto; }
.conversation-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .65rem 1rem; margin-bottom: 1.25rem; }
.conversation-heading h1 { font: 400 clamp(2.65rem, 5vw, 3.9rem)/1 var(--mte-editorial-serif); letter-spacing: -.025em; }
.conversation-messages { display: grid; justify-items: end; gap: .6rem; margin: 0 0 .9rem; padding: 0; list-style: none; }
.conversation-message { display: grid; gap: .28rem; max-width: min(85%, 570px); padding: .72rem 1rem; border: 1px solid #ded4f2; border-radius: 14px 14px 4px 14px; background: #eee7fa; overflow-wrap: anywhere; }
.conversation-message span { color: var(--violet-hover); font-size: .76rem; font-weight: 700; }
.conversation-message p { margin: 0; white-space: pre-wrap; }
.conversation-response { padding: clamp(1rem, 2.8vw, 1.6rem); border: 1px solid #e1d6f1; border-radius: 15px; background: var(--paper); box-shadow: 0 10px 30px #5544750e; }
.conversation-response-title { display: flex; align-items: start; gap: .65rem; }
.conversation-response-title .mte-mark { --mte-mark-size: 29px; margin-top: .1rem; }
.conversation-response-title h2 { margin-bottom: .15rem; font: 400 clamp(1.65rem, 3.6vw, 2.25rem)/1 var(--mte-editorial-serif); letter-spacing: -.015em; }
.conversation-response-title p, .conversation-plan-hint { margin: 0; color: var(--muted); font-size: .85rem; }
.conversation-plan { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.4rem; row-gap: .3rem; margin: .9rem 0; padding-inline-start: 1.25rem; font-size: .9rem; }
.conversation-plan li { padding-inline-start: .25rem; }
.conversation-plan li::marker { color: var(--violet-hover); font-variant-numeric: tabular-nums; font-weight: 680; }
.conversation-plan-hint:not([hidden]) { margin-bottom: .8rem; }
.conversation-build { display: grid; grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr) auto; gap: .7rem 1rem; align-items: center; padding-top: .85rem; border-top: 1px solid var(--border); }
.conversation-build label { margin: 0; font-size: .83rem; }
.conversation-build select { font-size: .88rem; }
.conversation-cost p { margin: 0; color: var(--muted); font-size: .85rem; }
.conversation-cost #conversation-estimate { color: var(--ink); font-weight: 650; }
.conversation-cost #conversation-access:not(:empty) { margin-top: .22rem; }
.conversation-privacy { margin: .68rem 0 0; color: var(--muted); font-size: .78rem; }
.conversation-privacy a { text-decoration: underline; text-underline-offset: .12em; }
.conversation-compose { margin-top: .8rem; padding: .82rem 1rem; border: 1px solid #dfd2f1; border-radius: 13px; background: var(--paper); }
.conversation-compose label { margin: 0 0 .36rem; }
.conversation-compose-row { display: flex; align-items: end; gap: .55rem; }
.conversation-compose textarea { min-height: 64px; background: #faf6fc; }
.conversation-compose [role="status"] { margin: .4rem 0 0; color: var(--muted); font-size: .82rem; }
.conversation-compose [data-error="true"] { color: #8c2937; }

.build-activity {
  margin: 0 0 1rem;
  padding: clamp(1rem, 2.1vw, 1.6rem);
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--paper);
  box-shadow: 0 7px 24px #382b4e0b;
}
.build-activity-header { margin-bottom: 1rem; }
.build-activity-header h2 { font: 400 clamp(1.65rem, 3vw, 2.25rem)/1.08 var(--serif); letter-spacing: -.043em; }
.build-activity-header p { margin: 0; color: var(--muted); font-size: .9rem; }
.build-stages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.build-stages li { display: grid; grid-template-columns: 15px minmax(0, 1fr); align-content: start; align-items: start; gap: .36rem .55rem; background: var(--rail); border: 1px solid var(--border); border-radius: 8px; padding: .75rem; }
.build-stages li[data-state="active"] { border-color: #9c83d5; background: #f1e8fc; }
.build-stages h3, .build-stages p { margin: 0; }
.build-stages h3 { font-size: .9rem; line-height: 1.25; }
.build-stages p { margin-top: .16rem; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.build-stage-marker { width: 13px; height: 13px; margin-top: 2px; border: 1px solid var(--input-border); border-radius: 50%; }
[data-state="done"] .build-stage-marker { position: relative; background: #d9eadf; border-color: #b0cdb9; }
[data-state="done"] .build-stage-marker::after { content: ''; position: absolute; width: 3px; height: 6px; left: 4px; top: 1px; border: solid #326348; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
[data-state="active"] .build-stage-marker { background: var(--violet); border: 3px solid #e0cff8; }
.build-stage-state { grid-column: 2; color: var(--muted); font-size: .75rem; font-weight: 650; }
[data-state="active"] .build-stage-state { color: var(--violet-hover); }

.project-menu { position: relative; }
.project-menu summary { list-style: none; }
.project-menu summary::-webkit-details-marker { display: none; }
.menu-options {
  position: absolute;
  z-index: 2;
  top: calc(100% + 5px);
  right: 0;
  display: grid;
  min-width: 174px;
  padding: .3rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px #191b2414;
}
.menu-options button { padding: .5rem .6rem; border: 0; border-radius: 5px; text-align: left; background: none; font-size: .875rem; }
.menu-options button:hover { background: var(--tint); }
.menu-options .danger { color: #9f2835; }

.context-card { padding: 0; overflow: hidden; }
.context-content { padding: 1.25rem; }
.context-content p { color: var(--muted); }
.context-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.context-graphic {
  min-height: 230px;
  display: grid;
  place-items: center;
  background: #e5d9f0;
  border-bottom: 1px solid #d9c9e6;
}

.context-book {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 118px;
  aspect-ratio: 2/3;
  padding: 13px 11px 14px 15px;
  border-radius: 2px 5px 5px 2px;
  background: #234038;
  color: #edf1d9;
  transform: rotate(-8deg);
  box-shadow: inset 4px 0 #132a24, 3px 2px #d1d6b9, 10px 14px 17px #34274440;
}

.context-book span { font-size: .53rem; font-weight: 700; letter-spacing: .11em; }
.context-book-title { font: 1.19rem/1.05 var(--serif); }
.book-rule { border-top: 1px solid #c6d69b; }
.book-rule.short { width: 40%; }
#feedback { margin: 0 0 1rem; padding: .65rem .8rem; border: 1px solid #ddd5f7; border-radius: 8px; background: #f2effd; font-size: .875rem; }
#feedback[data-error="true"] { background: #fff0ef; border-color: #f1c6c3; color: #8c2937; }

.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem; border: 1px solid var(--border); border-radius: 11px; background: #f0e8f5; margin-bottom: 1rem; padding: .28rem; }
.tabs button { min-height: 42px; border: 1px solid transparent; border-radius: 7px; background: transparent; padding: .48rem .35rem; color: var(--muted); font-weight: 620; font-size: .875rem; }
.tabs button:hover { color: var(--violet-hover); background: #f8f1fc; }
.tabs [aria-pressed="true"] { border-color: #e1d5eb; background: var(--paper); color: var(--violet-hover); box-shadow: 0 1px 4px #44315815; font-weight: 720; }
.section-top { display: flex; justify-content: space-between; gap: .75rem; align-items: start; margin-bottom: 1rem; }
.section-top p { margin: 0; }
.section-top h2 { margin-bottom: .35rem; }
.outline-layout { display: grid; gap: 1rem; }
.outline-layout .panel { min-width: 0; }
.book-fields { display: grid; grid-template-columns: 1.1fr 1.1fr 1fr; gap: .75rem; }
.book-fields label { margin: 0; }
.chapter-list { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .65rem; }
.chapter-row { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; display: grid; grid-template-columns: 31px minmax(0, 1fr) auto; align-items: start; gap: .65rem; }
.chapter-num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: var(--tint); color: #4a36b5; font-size: .8125rem; font-weight: 700; }
.chapter-row label { margin-bottom: .6rem; }
.chapter-row label:last-child { margin-bottom: 0; }
.chapter-actions { align-content: start; justify-content: end; max-width: 160px; }

.manuscript-layout { display: grid; grid-template-columns: 192px minmax(0, 1fr); gap: .9rem; align-items: start; }
.chapter-index { padding: .8rem; }
.chapter-index h2 { margin: .15rem .4rem .65rem; font-size: .875rem; }
.chapter-index ol { display: grid; gap: .15rem; list-style: none; margin: 0; padding: 0; }
.chapter-index button { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr); gap: .35rem; width: 100%; padding: .55rem .4rem; border: 1px solid transparent; border-radius: 6px; background: none; text-align: left; color: var(--ink); font-size: .875rem; overflow-wrap: anywhere; }
.chapter-index button:hover { background: #f5f3fb; }
.chapter-index button[aria-current] { background: var(--tint); color: #412eac; font-weight: 650; }
.chapter-index small { display: block; color: var(--muted); font-size: .75rem; font-weight: 500; }
.chapter-index .index-number { color: var(--muted); font-variant-numeric: tabular-nums; }
.manuscript-panel { padding: 0; overflow: hidden; }
.manuscript-header { padding: 1.2rem 1.25rem .8rem; }
.manuscript-header h2 { margin-bottom: .35rem; font: 1.7rem/1.12 var(--serif); }
.manuscript-header p { margin: 0; }
.manuscript-controls { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .45rem; padding: .45rem .75rem; background: #fafafd; border-block: 1px solid var(--border); }
.format-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.format-tools button, .mode-switch button {
  min-width: 38px;
  min-height: 33px;
  padding: .27rem .4rem;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 640;
}

.format-tools button:hover, .mode-switch button:hover { background: var(--tint); }
.format-tools .italic { font-style: italic; }
.mode-switch { display: flex; gap: 2px; }
.mode-switch [aria-pressed="true"] { border-color: #dbd4f3; background: var(--tint); color: #412eac; }
.editor-field { padding: .95rem 1.25rem 0; }
.editor-field label { margin: 0 0 .35rem; color: var(--muted); }
.manuscript-area { min-height: 340px; font: 1rem/1.65 var(--serif); }
.editor-field .cm-editor {
  min-height: 340px;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
}

.editor-field .cm-scroller { max-height: 65vh; font: 1.04rem/1.67 var(--serif); }
.editor-field .cm-content { padding: .75rem .45rem; }
.manuscript-preview { padding: 1.2rem 1.4rem; min-height: 290px; }
.manuscript-footer { padding: .7rem 1.25rem .95rem; }
.counter { font-size: .8125rem; color: var(--muted); margin: 0; }
.manuscript-panel details { margin: .15rem 1.25rem 1rem; padding: .7rem; border: 1px solid var(--border); border-radius: 7px; }
.manuscript-panel details summary { font-size: .875rem; font-weight: 650; }
.manuscript-panel details .chapter-ai-actions { margin-top: .7rem; display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.manuscript-panel details .chapter-ai-actions label { margin: 0; }
.manuscript-panel details .chapter-ai-actions input { max-width: 110px; }

.cover-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: .9rem; }
.theme { display: grid; gap: .4rem; background: #fafafd; border: 1px solid var(--border); border-radius: 7px; padding: .45rem; color: var(--ink); text-align: left; font-size: .8125rem; }
.theme[aria-pressed="true"] { outline: 2px solid var(--violet); outline-offset: 1px; }
.theme i { height: 39px; border-radius: 4px; }
.book-cover {
  width: min(100%, 245px);
  aspect-ratio: 2/3;
  margin: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12% 9%;
  overflow: hidden;
  overflow-wrap: anywhere;
  border-radius: 3px 8px 8px 3px;
  background: var(--cover-bg);
  color: var(--cover-fg);
  box-shadow: inset 5px 0 #0003, 0 13px 25px #251d4933;
}

.book-cover i { display: block; border-top: 1px solid var(--cover-accent); width: 100%; }
.book-cover h3 { font: 400 clamp(1.4rem, 3.5vw, 2.3rem)/1.02 var(--serif); margin: .35rem 0 .55rem; letter-spacing: -.04em; }
.book-cover h3, .book-cover p { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; -webkit-line-clamp: 4; }
.book-cover p, .book-cover span { font-size: .8125rem; margin: 0; }
.book-cover p { -webkit-line-clamp: 3; }
.book-cover img { position: absolute; width: 100%; height: 100%; object-fit: cover; inset: 0; }
.cover-stage { min-height: 305px; display: grid; place-items: center; padding: 1.3rem; border: 1px solid #e4dff3; border-radius: 11px; background: #edeaf8; }

.preview-layout { grid-template-columns: minmax(0, 1.75fr) minmax(221px, .9fr); }
.preview-side { display: grid; gap: .75rem; }
.export-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.export-actions button { text-align: center; }
.contents, .reader-body { padding: 1rem 0; border-top: 1px solid var(--border); }
.contents h3 { margin: 0 0 .35rem; font-size: .94rem; }
.contents ol { margin: 0; padding-left: 1.35rem; font-size: .875rem; }
.contents a { color: #412eac; text-decoration: underline; text-underline-offset: 3px; }
.reader-body { scroll-margin-top: 80px; }
.reader-body > h3 { font: 1.55rem/1.1 var(--serif); margin: .25rem 0 .7rem; }
.reading-text { overflow-wrap: anywhere; font: 1.06rem/1.68 var(--serif); }
.reading-text > :last-child { margin-bottom: 0; }
.reading-text :is(h3, h4, h5, h6) { margin: .9rem 0 .3rem; font-size: 1.12rem; }
.reading-text blockquote { margin: .5rem 0; padding-left: .85rem; border-left: 3px solid #d5c9f2; }

dialog { width: min(480px, calc(100% - 2rem)); padding: 1.4rem; border: 1px solid var(--border); border-radius: 12px; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: #17132777; }
.studio-tour { width: min(660px, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 0; box-shadow: 0 22px 75px #271a4547; }
.studio-tour::backdrop { background: #25173881; }
.tour-spread { display: grid; grid-template-columns: minmax(134px, .5fr) minmax(0, 1.5fr); }
.tour-margin { background: #efe5f6; border-inline-end: 1px solid #e3d5eb; padding: 1.6rem .9rem 1.35rem 1.15rem; }
.tour-margin p { color: var(--violet-hover); font-size: .9rem; font-weight: 690; margin-bottom: .85rem; }
.tour-margin ol { display: grid; list-style: none; padding: 0; margin: 0; gap: .19rem; color: var(--muted); font-size: .85rem; }
.tour-margin li { padding: .36rem .52rem; border-inline-start: 2px solid transparent; }
.tour-margin li[aria-current="step"] { border-color: var(--violet); color: var(--violet-hover); background: #faf4fc; font-weight: 680; }
.tour-page { min-height: 246px; padding: clamp(1.2rem, 4vw, 2.35rem); display: flex; flex-direction: column; }
.tour-page h2 { margin: 0 0 .65rem; font: 400 clamp(1.85rem, 5.2vw, 2.65rem)/1.06 var(--serif); letter-spacing: -.045em; }
.tour-page > p { color: var(--muted); margin: 0 0 1.35rem; max-width: 43ch; }
.tour-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .4rem; margin-top: auto; }
.tour-actions button { min-height: 42px; }
.tour-actions #studio-tour-skip { margin-inline-end: auto; }
.project-sync-summary { color: var(--muted); }
.project-sync-status { padding: .65rem .75rem; border-radius: 7px; background: var(--tint); font-size: .875rem; }
.project-sync-footer { justify-content: flex-end; margin-top: 1.1rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.reading-text a { color: #412eac; text-decoration: underline; text-underline-offset: 3px; }
.reading-text pre { overflow: auto; padding: .75rem; background: var(--canvas); border-radius: 6px; white-space: pre-wrap; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 1060px) {
  .workspace { grid-template-columns: 186px minmax(0, 1fr); }
  .sidebar { padding-inline: .55rem; }
  .work-area { padding-inline: 1.35rem; }
  .manuscript-layout { grid-template-columns: 159px minmax(0, 1fr); }
  .chapter-actions { max-width: 108px; }
  .build-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .topbar { padding: .55rem .9rem 0; gap: .2rem .7rem; flex-wrap: wrap; }
  .topbar nav { order: 3; flex: 1 0 100%; gap: 1.05rem; overflow: auto; }
  .topbar nav a { padding: .48rem 0; }
  .workspace { display: block; }
  .sidebar { position: static; height: auto; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .35rem .75rem; border-right: 0; border-bottom: 1px solid var(--border); padding: .55rem .9rem; }
  .sidebar-title { padding-inline: 0; gap: .45rem; }
  .project-list { display: flex; overflow-x: auto; scrollbar-width: thin; }
  .project-list button { flex: 0 0 auto; max-width: 200px; }
  .sidebar-tools { display: flex; flex-wrap: wrap; gap: .15rem .5rem; }
  .sidebar-tools .sample-link { padding: .35rem 0; font-size: .8rem; }
  .sidebar-note { margin: 0; padding: 0; border: 0; justify-self: end; align-self: center; }
  .work-area { padding: 1.5rem .9rem 3rem; }
  .work-header { align-items: start; }
  .split { grid-template-columns: 1fr; }
  .context-card { display: grid; grid-template-columns: 1fr 1fr; }
  .context-graphic { min-height: 194px; }
  .preview-side { grid-row: 1; grid-template-columns: 1fr 1fr; align-items: start; }
}

@media (max-width: 530px) {
  .sidebar { column-gap: .3rem; }
  .sidebar-note { gap: .3rem; font-size: .73rem; }
  .work-header { display: grid; gap: .7rem; }
  .menu-options { left: 0; right: auto; }
  .panel { padding: .95rem; }
  .manuscript-panel { padding: 0; }
  .manuscript-layout { grid-template-columns: 1fr; gap: .6rem; }
  .chapter-index ol { display: flex; overflow: auto; padding: 3px; }
  .chapter-index li { flex: 0 0 min(170px, 45%); }
  .context-card { display: block; }
  .book-fields, .chapter-row { grid-template-columns: 1fr; }
  .chapter-actions { max-width: none; justify-content: start; }
  .section-top { flex-wrap: wrap; }
  .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .build-stages { grid-template-columns: 1fr; }
  .build-stages li { grid-template-columns: 15px minmax(0, 1fr) auto; align-items: center; }
  .build-stage-marker { margin-top: 0; }
  .build-stage-state { grid-column: auto; }
  .cover-stage { min-height: auto; }
  .preview-side { grid-template-columns: 1fr; }
  .preview-side .book-cover { max-width: 165px; }
  .draft-builder-actions { width: 100%; }
  .draft-builder-actions > :is(a, button) { width: 100%; }
  .conversation-heading { margin-bottom: .85rem; }
  .conversation-heading h1 { font-size: clamp(1.75rem, 8vw, 2.25rem); }
  .conversation-heading .secondary { min-height: 36px; padding: .35rem .52rem; }
  .conversation-message { max-width: 94%; }
  .conversation-plan { grid-template-columns: 1fr; row-gap: .18rem; }
  .conversation-build { grid-template-columns: minmax(0, 1fr); gap: .65rem; }
  .conversation-compose-row { align-items: stretch; flex-direction: column; }
}

@media (max-width: 560px) {
  .tour-spread { display: block; }
  .tour-margin { padding: .82rem 1rem .65rem; border-inline-end: 0; border-bottom: 1px solid #e3d5eb; }
  .tour-margin p { margin-bottom: .45rem; }
  .tour-margin ol { display: flex; flex-wrap: wrap; gap: .2rem; }
  .tour-page { min-height: 232px; }
}

#feedback a { margin-left: .5rem; color: #412eac; font-weight: 690; text-decoration: underline; text-underline-offset: 3px; }
