/* A Diary — editorial interface v0.3.0 */
:root {
  color-scheme: light;
  --ink: #1d2c30;
  --ink-muted: #667579;
  --ink-faint: #8a9697;
  --green: #395b50;
  --green-dark: #28463d;
  --green-soft: #edf3ef;
  --accent: #ad8051;
  --paper: #fffefa;
  --canvas: #f3f5f3;
  --line: #e4e9e5;
  --line-warm: #e9e2d7;
  --danger: #98564c;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow-card: 0 12px 36px rgba(30, 45, 39, .07), 0 2px 6px rgba(30, 45, 39, .035);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(57, 91, 80, .32); outline-offset: 3px; }

/* Shared header */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 252, .94);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font: 600 19px/1 var(--serif);
  letter-spacing: -.02em;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--green-dark);
  color: white;
}
.brand-mark svg { display: block; width: 19px; height: 19px; }
.top-actions { display: flex; align-items: center; gap: 20px; color: var(--ink-muted); }
.author-label, .reader-label {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.quiet-link, .quiet-button {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  font: 550 12px/1.3 var(--sans);
  text-decoration: none;
}
.quiet-link:hover, .quiet-button:hover { color: var(--green); }
.inline-form { margin: 0; }

/* Full-width diary layout */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: calc(100vh - 64px);
}
.notice {
  grid-column: 1 / -1;
  margin: 12px 16px 0;
  padding: 12px 15px;
  border: 1px solid #d4e2d7;
  border-radius: 7px;
  background: #f1f7f2;
  color: #41624c;
  font-size: 12px;
}
.notice.error { border-color: #ecd8d3; background: #fbf2ef; color: var(--danger); }
.settings-shell > .notice { margin-bottom: 14px; }
.login-card > .notice, .install-form-wrap > .notice { margin: 9px 0 14px; }

.book-index {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
  padding: 18px 12px 14px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #f8faf8;
}
.index-heading { padding: 3px 10px 12px; border-bottom: 1px solid var(--line); }
.eyebrow {
  display: block;
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .15em;
  line-height: 1.4;
  text-transform: uppercase;
}
.index-heading h2 { margin: 4px 0 0; font: 22px/1.2 var(--serif); letter-spacing: -.025em; }
.index-note { padding: 10px 10px 3px; color: var(--ink-faint); font-size: 10px; }
.page-list {
  min-height: 0;
  flex: 1;
  padding: 6px 0 12px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.page-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 2px 0;
  padding: 7px 9px;
  border-radius: 7px;
  color: inherit;
  text-decoration: none;
  transition: background .12s ease;
}
.page-link:hover { background: #e9f0ea; }
.page-link.active { background: #e2ebe4; box-shadow: inset 0 0 0 1px #c5d5ca; }
.page-link-num {
  display: grid;
  flex: 0 0 28px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  background: #e8eee9;
  color: #5a6d64;
  font: 600 12px/1 var(--sans);
}
.page-link.active .page-link-num { background: var(--green-dark); color: #fff; }
.page-link-copy { display: grid; flex: 1; min-width: 0; gap: 2px; }
.page-link-title {
  overflow: hidden;
  color: #2c3b37;
  font: 550 12px/1.25 var(--sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-link-date { color: var(--ink-faint); font-size: 10px; }
.status-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c4a477;
}
.status-dot.published { background: #5a9a6e; }
.status-dot.draft { background: #c4a477; }
.index-foot {
  padding: 10px 10px 2px;
  border-top: 1px solid var(--line);
  color: #8b9691;
  font: italic 12px var(--serif);
}

/* Main stage — full width */
.book-stage {
  display: flex;
  min-width: 0;
  justify-content: stretch;
  padding: 20px 24px 48px;
  overflow: auto;
}
.paper {
  position: relative;
  width: 100%;
  max-width: none;
  min-height: 720px;
  padding: 36px clamp(28px, 4vw, 56px) 32px;
  overflow: visible;
  border: 1px solid #e9e7df;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow-card);
}
.paper::before { display: none; } /* remove decorative line for full-width cleanliness */
.paper-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-warm);
  color: #8b8273;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.entry-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 24px 0 8px; }
.entry-meta h1, .empty-paper h1, .settings-heading h1, .install-intro h1, .login-card h1 {
  margin: 6px 0 0;
  color: #243437;
  font: 600 clamp(26px, 3.2vw, 36px)/1.15 var(--serif);
  letter-spacing: -.03em;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid #d7e2d9;
  border-radius: 999px;
  background: #f2f7f3;
  color: #4a6654;
  font: 600 10px/1 var(--sans);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.status-pill.published { background: #e8f3eb; border-color: #c5dccb; color: #2f6b45; }
.status-pill.draft { background: #f8f2e8; border-color: #e8d9c0; color: #8a6a3a; }
.timestamps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 18px;
  color: var(--ink-faint);
  font-size: 11px;
}
.timestamps span + span::before {
  display: inline-block;
  width: 3px;
  height: 3px;
  margin-right: 10px;
  border-radius: 50%;
  background: #c3a77f;
  content: "";
  vertical-align: middle;
}

/* Title input */
.title-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--ink-muted);
  font: 600 11px/1.3 var(--sans);
}
.title-label span { color: var(--ink-faint); font-weight: 500; }
.title-input {
  width: 100%;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 500 16px/1.3 var(--serif);
}
.title-input:focus { border-color: #b7c9bc; outline: none; box-shadow: 0 0 0 3px rgba(57,91,80,.12); }

/* ========== Enhanced Word-style Editor ========== */
.word-editor {
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: #f7f9f6;
  overflow: hidden;
}
.editor-tabs {
  display: flex;
  gap: 2px;
  padding: 7px 9px 0;
  border-bottom: 1px solid var(--line);
  background: #eef2ee;
  overflow-x: auto;
}
.editor-tab {
  padding: 9px 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  font: 600 11px/1 var(--sans);
  white-space: nowrap;
}
.editor-tab.active {
  border-color: var(--line);
  background: #f7f9f6;
  color: var(--green-dark);
}
.editor-panel {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 10px 12px;
}
.editor-panel.active { display: flex; }
.editor-panel p {
  flex-basis: 100%;
  margin: 0 0 4px;
  color: var(--ink-muted);
  font-size: 11px;
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 10px;
  border-right: 1px solid var(--line);
}
.tool-group:last-child { border-right: 0; padding-right: 0; }
.editor-panel button,
.editor-panel select {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: 11px var(--sans);
}
.editor-panel button {
  padding: 0 9px;
}
.editor-panel button:hover { border-color: var(--green); background: var(--green-soft); }
.editor-panel button.active-cmd {
  border-color: var(--green-dark);
  background: var(--green-soft);
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px rgba(40,70,61,.15);
}
.editor-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 10px;
}
.editor-panel select { padding: 0 6px; }
.editor-panel .upload-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--green);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 600;
}
.editor-panel .tool-action { font-weight: 550; }
.editor-panel .danger-action { color: var(--danger); }

/* Image size controls */
.media-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.media-controls .size-btn {
  min-width: 42px;
  padding: 0 8px;
  font-size: 11px;
}
.media-controls .size-btn.active-size {
  border-color: var(--green-dark);
  background: var(--green-soft);
  font-weight: 600;
}

/* Split view: Edit + Preview */
.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  min-height: 480px;
  background: var(--paper);
}
.edit-pane, .preview-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.edit-pane { border-right: 1px solid var(--line); }
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #f4f7f4;
  color: var(--ink-muted);
  font: 600 10px/1 var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.preview-pane .pane-header { background: #eef3ef; }
.editor {
  flex: 1;
  min-height: 380px;
  padding: 18px 20px;
  overflow: auto;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--serif);
  outline: none;
}
.editor:empty::before {
  color: #a8b1ac;
  content: "Write about your day...";
  font-style: italic;
}
.editor img, .entry-content img {
  max-width: 100%;
  height: auto;
  margin: 10px 0;
  border-radius: 5px;
  box-shadow: 0 5px 16px rgba(30, 45, 39, .1);
  cursor: pointer;
  transition: outline .15s ease;
  /* Inline width/data-size from the editor (e.g. 25%) is preserved on save */
}
.editor img.selected-media,
.editor video.selected-media {
  outline: 3px solid rgba(57, 91, 80, .55);
  outline-offset: 3px;
}
.editor video, .entry-content video {
  display: block;
  width: 100%;
  max-height: 420px;
  margin: 12px 0;
  border-radius: 6px;
  background: #0c110e;
}
.live-preview {
  flex: 1;
  min-height: 380px;
  padding: 18px 20px;
  overflow: auto;
  background: var(--paper);
  font: 16px/1.65 var(--serif);
  color: var(--ink);
}
.live-preview:empty::before {
  color: #a8b1ac;
  content: "Preview appears here as you write…";
  font-style: italic;
}
.editor-hint {
  margin: 10px 0 0;
  color: #899591;
  font-size: 11px;
}
.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  color: var(--ink-faint);
  font-size: 11px;
}
.save-status.saving { color: var(--accent); }
.save-status.saved { color: #4a8a5e; }

/* Actions */
.entry-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font: 600 13px/1 var(--sans);
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
}
.button.primary {
  background: var(--green-dark);
  color: #fff;
}
.button.primary:hover { background: #1e3a32; }
.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}
.button.secondary:hover { border-color: #c5d5ca; background: var(--green-soft); }

.chapter-form {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line-warm);
}
.chapter-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-muted);
  font: 600 11px/1.3 var(--sans);
}
.chapter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.chapter-controls input {
  flex: 1;
  min-width: 180px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

/* Published content */
.published-title {
  margin: 0 0 14px;
  color: #243437;
  font: 600 22px/1.3 var(--serif);
}
.entry-content {
  font: 16px/1.7 var(--serif);
  color: var(--ink);
}
.entry-content p { margin: 0 0 1em; }
.entry-content h2 { margin: 1.4em 0 .5em; font: 600 1.35em/1.25 var(--serif); }
.entry-content h3 { margin: 1.2em 0 .4em; font: 600 1.15em/1.3 var(--serif); }
.entry-content blockquote {
  margin: 1em 0;
  padding: 4px 0 4px 16px;
  border-left: 3px solid var(--line-warm);
  color: var(--ink-muted);
  font-style: italic;
}
.unpublish-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 12px;
}

/* Page navigation */
.page-turn {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line-warm);
  font: 550 13px/1.3 var(--sans);
}
.page-turn a {
  color: var(--green-dark);
  text-decoration: none;
}
.page-turn a:hover { text-decoration: underline; }

/* Tables */
.editor table, .entry-content table, .live-preview table {
  width: 100%;
  margin: 14px 0;
  border-collapse: collapse;
}
.editor th, .editor td,
.entry-content th, .entry-content td,
.live-preview th, .live-preview td {
  min-width: 70px;
  padding: 8px;
  border: 1px solid var(--line-warm);
  vertical-align: top;
}
.editor th, .entry-content th, .live-preview th {
  background: var(--green-soft);
  font-weight: 600;
}

/* Upload progress */
.upload-progress {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--green-soft);
  color: var(--ink-muted);
  font-size: 11px;
}
.upload-progress > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 5px;
}
.upload-progress progress {
  width: 100%;
  height: 8px;
  accent-color: var(--green-dark);
}

/* Empty state */
.empty-paper { text-align: center; padding-top: 80px; }
.empty-paper .eyebrow { margin-bottom: 8px; }
.empty-paper p { color: var(--ink-muted); }

/* Settings & Login (unchanged structure) */
.settings-shell { width: min(780px, 100%); margin: 0 auto; padding: 52px 24px 90px; }
.settings-heading { margin-bottom: 22px; }
.settings-card {
  margin-bottom: 16px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  box-shadow: var(--shadow-card);
}
.settings-form { display: grid; gap: 12px; }
.settings-form label { display: grid; gap: 5px; color: var(--ink-muted); font: 600 11px/1.3 var(--sans); }
.settings-form input, .settings-form select {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.settings-form > input { max-width: 100%; }
.share-field { display: flex; gap: 8px; align-items: center; }
.share-field input {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9f6;
  color: #566762;
  font: 11px var(--sans);
}
.version-card { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; }
.version-card .eyebrow { width: 100%; }
.version-card strong { color: #34453f; font: 19px var(--serif); }
.version-card p { margin: 0; color: var(--ink-faint); font-size: 10px; }

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  width: min(100%, 400px);
  padding: 40px 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow-card);
}
.login-card h1 { margin-bottom: 6px; }
.login-card form { display: grid; gap: 14px; margin-top: 22px; }
.login-card label { display: grid; gap: 5px; color: var(--ink-muted); font: 600 11px/1.3 var(--sans); }
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* Install */
.install-page { min-height: 100vh; }
.install-shell {
  display: grid;
  grid-template-columns: .85fr 1fr;
  min-height: 100vh;
  max-width: 1080px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
}
.install-intro {
  padding: 48px 40px;
  background: linear-gradient(160deg, #1e332b 0%, #28463d 100%);
  color: #e8f0ea;
}
.install-intro .brand { color: #fff; margin-bottom: 36px; }
.install-intro h1 { color: #fff; font-size: 34px; }
.install-intro > p { max-width: 330px; color: #b8cfc2; font: 15px/1.7 var(--serif); }
.install-requirements { margin-top: 28px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.12); }
.install-requirements li { margin: 6px 0; color: #c5d9cc; font-size: 13px; }
.install-form-wrap { padding: 40px 36px; }
.install-form { display: grid; gap: 12px; }
.install-form .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.install-form .span-two { grid-column: 1 / -1; }
.install-form input, .install-form select { width: 100%; font-size: 11px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; }
.install-form small { color: var(--ink-faint); font-size: 9px font-weight: 400; line-height: 1.5; }
.install-submit { width: 100%; margin-top: 3px; }
.install-version { margin: 17px 0 0; color: #9aa49f; font-size: 9px; letter-spacing: .08em; text-align: center; }

/* Dark theme */

/* ===== Themes (high-contrast text) ===== */
:root, [data-theme="light"] {
  color-scheme: light;
  --ink: #1a1f24;
  --ink-muted: #4a5560;
  --ink-faint: #6b7580;
  --green: #2f5d4a;
  --green-dark: #1e3d32;
  --green-soft: #e8f0eb;
  --accent: #9a6b3a;
  --paper: #fffefb;
  --canvas: #f0f2f1;
  --line: #d9e0dc;
  --line-warm: #e4ddd2;
  --danger: #a13d32;
  --panel-bg: #f3f6f4;
  --shadow-card: 0 12px 36px rgba(30, 45, 39, .07), 0 2px 6px rgba(30, 45, 39, .035);
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef2f0;
  --ink-muted: #c5d0ca;
  --ink-faint: #9aaba3;
  --green: #8fd0a8;
  --green-dark: #6bb58c;
  --green-soft: #1a2a22;
  --accent: #e0b87a;
  --paper: #141c18;
  --canvas: #0c1210;
  --line: #2a3a32;
  --line-warm: #35443c;
  --danger: #f0a098;
  --panel-bg: #101814;
  --shadow-card: 0 12px 36px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.2);
}

[data-theme="parchment"] {
  color-scheme: light;
  --ink: #2c2118;
  --ink-muted: #5c4a3a;
  --ink-faint: #7a6552;
  --green: #6b4f32;
  --green-dark: #4a3620;
  --green-soft: #f0e6d4;
  --accent: #a67c52;
  --paper: #f7f0e1;
  --canvas: #ebe1cc;
  --line: #d4c4a8;
  --line-warm: #cbb892;
  --danger: #9c3b2e;
  --panel-bg: #f0e6d2;
  --shadow-card: 0 12px 36px rgba(60, 40, 20, .08);
}

[data-theme="ocean"] {
  color-scheme: light;
  --ink: #0f2430;
  --ink-muted: #3a5566;
  --ink-faint: #5a7384;
  --green: #1d5f7a;
  --green-dark: #134556;
  --green-soft: #e3eef4;
  --accent: #c47b3a;
  --paper: #f5fafc;
  --canvas: #e4eef3;
  --line: #c5d6e0;
  --line-warm: #d0c8b8;
  --danger: #b33a3a;
  --panel-bg: #e8f1f6;
  --shadow-card: 0 12px 36px rgba(20, 50, 70, .08);
}

[data-theme="slate"] {
  color-scheme: light;
  --ink: #1c1e22;
  --ink-muted: #4b515a;
  --ink-faint: #6a717c;
  --green: #3d4a55;
  --green-dark: #2a333c;
  --green-soft: #e8eaed;
  --accent: #8a6a3d;
  --paper: #f7f8f9;
  --canvas: #e6e8eb;
  --line: #cfd3d8;
  --line-warm: #d5cfc6;
  --danger: #a33a3a;
  --panel-bg: #eceef1;
  --shadow-card: 0 12px 36px rgba(30, 35, 40, .08);
}

[data-theme="rose"] {
  color-scheme: light;
  --ink: #2a181c;
  --ink-muted: #5c3d45;
  --ink-faint: #7a5860;
  --green: #7a4550;
  --green-dark: #5a3038;
  --green-soft: #f6e8eb;
  --accent: #b56b4a;
  --paper: #fdf8f8;
  --canvas: #f0e6e8;
  --line: #e0cdd2;
  --line-warm: #e2cfc4;
  --danger: #a83232;
  --panel-bg: #f5eaed;
  --shadow-card: 0 12px 36px rgba(80, 40, 50, .08);
}

/* Shared theme application */
body {
  color: var(--ink);
  background: var(--canvas);
}
.topbar, .topbar.topbar-menu {
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border-bottom-color: var(--line);
}
.paper, .editor, .editor-wrap, .settings-card, .login-card, .word-editor {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}
.editor, .entry-content, .live-preview {
  color: var(--ink);
}
.entry-meta h1, .page-link-title, .published-title, .settings-heading h1 {
  color: var(--ink);
}
.page-link:hover { background: var(--green-soft); }
.page-link.active {
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}
.button.primary {
  background: var(--green-dark);
  color: #fff;
}
.button.primary:hover { filter: brightness(1.08); }
.button.secondary, input, select, .title-input {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
.quiet-link, .quiet-button { color: var(--ink-muted); }
.quiet-link:hover, .quiet-button:hover { color: var(--green-dark); }
.editor-tabs { background: var(--panel-bg); border-color: var(--line); }
.editor-tab.active { background: var(--paper); color: var(--green-dark); border-color: var(--line); }
.editor-panel button, .editor-panel select {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
.book-index {
  background: color-mix(in srgb, var(--paper) 88%, var(--canvas));
  border-color: var(--line);
}
.status-pill { color: var(--ink); border-color: var(--line); background: var(--green-soft); }
.notice { background: var(--green-soft); border-color: var(--line); color: var(--ink); }
.notice.error { background: #fdf0ee; border-color: #e8c4be; color: var(--danger); }
[data-theme="dark"] .notice.error { background: #3a221f; border-color: #6a4038; }

/* Banner default gradient stays readable */
.site-banner:not(.has-image) {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 55%, color-mix(in srgb, var(--green) 70%, #fff) 100%);
}
.site-banner-title { color: #fff; }


/* ===== Site banner (above menu bar) ===== */
.site-banner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 180px;
  max-height: 22vw;
  min-height: 110px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #0a0c0e;
  color: #f4faf6;
  text-decoration: none;
}
.site-banner.has-image {
  /* Image carries the design; fixed stage so full artwork is visible */
  height: 200px;
  max-height: 28vw;
  min-height: 120px;
  background: #0a0c0e;
}
.site-banner-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain; /* entire banner visible — no cropping */
  object-position: center;
}
.site-banner-scrim { display: none; }
.site-banner-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 40px) 22px;
}
.site-banner-title {
  margin: 0;
  color: #fff;
  font: 600 clamp(26px, 4vw, 40px)/1.15 var(--serif);
  letter-spacing: -.03em;
  text-decoration: none;
  text-shadow: 0 1px 12px rgba(0,0,0,.35);
}
a.site-banner-title:hover { opacity: .92; }

.banner-size-hint {
  margin: -4px 0 10px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
}
.banner-preview {
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  height: 120px;
  background: #0a0c0e;
}
.banner-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

/* Menu bar under banner — no logo */
.topbar.topbar-menu {
  min-height: 48px;
  padding: 0 clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 252, .96);
}
.topbar-menu-label,
.topbar-home {
  color: var(--ink-muted);
  font: 600 11px/1 var(--sans);
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
}
.topbar-home:hover { color: var(--green); }

.banner-preview {
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  max-height: 160px;
  background: #eef2ee;
}
.banner-preview img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
}

[data-theme="dark"] .topbar.topbar-menu { background: rgba(20,30,25,.96); }
[data-theme="dark"] .site-banner:not(.has-image) {
  background: linear-gradient(135deg, #0f1a14 0%, #1a2e24 60%, #243b30 100%);
}

@media (max-width: 700px) {
  .site-banner { height: 100px; max-height: 100px; min-height: 88px; }
  .site-banner.has-image { height: 120px; max-height: 120px; min-height: 100px; }
  .site-banner-title { font-size: 22px; }
}
