@font-face {
  font-family: "Playwrite US Trad";
  src: url("fonts/cursive.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #24211d;
  --muted: #746d64;
  --paper: #fffaf0;
  --paper-deep: #f4ead8;
  --cover: #23413f;
  --cover-deep: #142927;
  --book-cover: #23413f;
  --book-cover-deep: #142927;
  --gold: #c49a49;
  --rose: #a85550;
  --sky: #d7e8ec;
  --journal-accent: #1f3a5f;
  --line: rgba(55, 85, 93, 0.22);
  --shadow: 0 24px 80px rgba(34, 28, 20, 0.22);
  font-family: "Georgia", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(196, 154, 73, 0.22), transparent 32rem),
    linear-gradient(135deg, #e7f0ee 0%, #f8efe1 48%, #e8d8cf 100%);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.shell {
  display: grid;
  grid-template-columns: 18rem 1fr;
  min-height: 100vh;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.2rem;
  background: rgba(255, 250, 240, 0.76);
  border-right: 1px solid rgba(36, 33, 29, 0.12);
  backdrop-filter: blur(18px);
}

.cover-nav { display: none; }

.shell.cover-mode {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
}

.shell.cover-mode .rail {
  position: relative;
  top: auto;
  z-index: 20;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 4.5rem;
  padding: 0.55rem max(0.85rem, env(safe-area-inset-right)) 0.55rem max(0.85rem, env(safe-area-inset-left));
  border-right: 0;
  border-bottom: 1px solid rgba(36, 33, 29, 0.12);
  box-shadow: none;
}

.shell.cover-mode .brand {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.shell.cover-mode .brand-copy strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.1;
}

.shell.cover-mode .nav-actions,
.shell.cover-mode .rail-statuses,
.shell.cover-mode .rail > .journal-app-version,
.shell.cover-mode .template-panel,
.shell.cover-mode .daily-spark { display: none; }

.shell.cover-mode .cover-nav { display: block; position: relative; flex: 0 0 auto; }

.cover-nav > button {
  min-width: 4.8rem;
  min-height: 2.65rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #1f3a5f;
  border-radius: 0.4rem;
  background: #fffaf0;
  color: #1f3a5f;
  font: 700 0.9rem "Trebuchet MS", Arial, sans-serif;
}

.cover-nav > button[aria-expanded="true"] { background: #1f3a5f; color: #fff; }

.cover-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 0.25rem;
  width: min(15.5rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 5.5rem);
  overflow-y: auto;
  padding: 0.45rem;
  border: 1px solid rgba(36, 33, 29, 0.2);
  border-radius: 0.45rem;
  background: #fffaf0;
  box-shadow: 0 14px 32px rgba(20, 41, 39, 0.22);
}

.cover-menu[hidden],
.cover-menu button[hidden] { display: none; }

.cover-menu button {
  min-height: 2.7rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.3rem;
  background: transparent;
  color: #142927;
  text-align: left;
  font: 700 0.9rem "Trebuchet MS", Arial, sans-serif;
}

.cover-menu button:hover,
.cover-menu button:focus-visible { background: #e7f0ee; }

.shell.cover-mode .stage { padding: 0.75rem 1rem 1.5rem; }
.shell.cover-mode .book-cover { min-height: calc(100dvh - 6.75rem); }

.cover-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: min(38rem, 100%);
  margin: 0 auto 0.75rem;
  padding: 0.7rem 0.9rem;
  border-left: 4px solid #a82e3e;
  border-radius: 0.3rem;
  background: #fff0ed;
  color: #78212d;
  font: 700 0.88rem/1.35 "Trebuchet MS", Arial, sans-serif;
}

.cover-notice[hidden] { display: none; }
.cover-notice p { margin: 0; }
.cover-notice button {
  flex: 0 0 auto;
  min-height: 2.4rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid currentColor;
  border-radius: 0.3rem;
  background: #fff;
  color: inherit;
  font: inherit;
}

@media (max-width: 480px) {
  .shell.cover-mode .brand-mark { width: 2.15rem; height: 2.15rem; }
  .cover-notice { align-items: stretch; flex-direction: column; }
  .cover-notice button { align-self: start; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem;
  color: var(--cover-deep);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.brand-copy {
  display: grid;
  gap: 0.12rem;
}

.brand-copy strong { font-size: 0.98rem; }

.brand-mark {
  width: 2.7rem;
  height: 2.7rem;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(31, 53, 90, 0.18);
}

.nav-actions,
.template-list,
.marker-row {
  display: grid;
  gap: 0.55rem;
}

.rail-sync-status {
  margin: -0.65rem 0 0;
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.75rem;
  text-align: center;
}

.journal-app-version {
  margin: -0.8rem 0 0;
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.72rem;
  text-align: center;
}

.settings-panel > .journal-app-version,
.account-panel > .journal-app-version {
  margin: 0 0 0.9rem;
  text-align: right;
}

.nav-actions button,
.template-list button,
.topbar-actions button,
.paper-actions button,
.daily-spark,
.settings-panel button,
.history-header button,
.companion-page button {
  border-radius: 0.45rem;
  padding: 0.72rem 0.85rem;
  background: #fffaf0;
  color: var(--cover-deep);
  border: 1px solid rgba(36, 33, 29, 0.13);
  box-shadow: 0 10px 30px rgba(36, 33, 29, 0.08);
}

.nav-actions button:hover,
.template-list button:hover,
.topbar-actions button:hover,
.paper-actions button:hover,
.settings-panel button:hover,
.history-header button:hover,
.companion-page button:hover {
  border-color: rgba(196, 154, 73, 0.72);
}

.nav-actions #coverButton {
  background: #1f3a5f;
  border-color: #1f3a5f;
  color: #fff;
  font-weight: 700;
}

.nav-actions #coverButton:hover,
.nav-actions #coverButton:focus-visible {
  background: #294c77;
  border-color: #294c77;
}

.template-panel h2,
.companion-page h2,
.settings-panel h2 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  color: var(--cover-deep);
}

.template-list button {
  text-align: left;
}

.template-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.template-panel-heading h2 {
  margin-bottom: 0.7rem;
}

.template-panel .template-add-button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  background: var(--cover);
  color: #fffaf0;
  font: 700 1.2rem/1 "Trebuchet MS", Arial, sans-serif;
}

.template-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem;
}

.template-row > button:first-child {
  min-width: 0;
}

.template-list .template-remove {
  width: 2.4rem;
  padding-inline: 0;
  text-align: center;
  color: var(--rose);
}

.daily-spark {
  margin-top: auto;
  background: #f7efe0;
}

.daily-spark span,
.date-label,
.cover-kicker {
  color: var(--rose);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.daily-spark p {
  margin: 0.45rem 0 0;
  line-height: 1.45;
}

.stage {
  min-width: 0;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.book-view {
  display: none;
}

.book-view.active {
  display: block;
}

.books-panel {
  width: min(46rem, 100%);
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.books-panel h2 { margin: 0.2rem 0 0; font-size: 2rem; }
.books-panel h3 { margin: 0 0 0.8rem; font-size: 1.15rem; }
.books-status { min-height: 1.5rem; color: var(--muted); }
.books-status[data-tone="error"] {
  padding: 0.8rem 1rem;
  border: 1px solid #ae594c;
  border-left: 0.3rem solid #ae594c;
  border-radius: 0.35rem;
  background: #fff3ef;
  color: #783128;
  font-weight: 700;
}
.current-journal-label {
  width: min(31rem, 100%);
  margin: 0 auto;
  color: #263d43;
  font: 700 0.9rem/1.3 "Trebuchet MS", Arial, sans-serif;
  text-align: center;
  overflow-wrap: anywhere;
}
.journal-context {
  margin: 0 0 0.2rem;
  color: #2c5655;
  font: 700 0.82rem/1.3 "Trebuchet MS", Arial, sans-serif;
  overflow-wrap: anywhere;
}
.books-list { display: grid; gap: 0.6rem; margin: 1.4rem 0 2rem; }
.book-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  min-height: 5rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(36, 33, 29, 0.17);
  border-left: 0.3rem solid var(--journal-accent);
  border-radius: 0.35rem;
  background: var(--paper);
}
.book-row[data-active="true"] { border-color: var(--journal-accent); }
.book-row > div:first-child { display: grid; gap: 0.25rem; min-width: 0; }
.book-row strong { overflow-wrap: anywhere; }
.book-row span { color: var(--muted); font: 0.82rem "Trebuchet MS", Arial, sans-serif; }
.book-row > div:last-child { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.books-panel button { min-height: 2.6rem; padding: 0.55rem 0.8rem; border-radius: 0.35rem; background: var(--cover); color: white; }
.books-panel button.quiet-button { background: var(--paper); color: var(--cover-deep); border: 1px solid rgba(36, 33, 29, 0.22); }
.books-panel button:disabled { opacity: 0.5; cursor: not-allowed; }
.books-create { display: grid; gap: 0.65rem; padding-top: 1.5rem; border-top: 1px solid rgba(36, 33, 29, 0.2); }
.books-create label, .books-create p { font: 0.9rem/1.4 "Trebuchet MS", Arial, sans-serif; }
.books-create p { margin: 0; color: var(--muted); }
.books-create input { width: 100%; min-height: 2.8rem; padding: 0.6rem; border: 1px solid rgba(36, 33, 29, 0.3); border-radius: 0.35rem; background: #fff; }
.books-create button { justify-self: start; }
.locked-book-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.4rem; }

@media (max-width: 600px) {
  .book-row { align-items: flex-start; flex-direction: column; }
  .book-row > div:last-child { width: 100%; }
  .book-row button { flex: 1; }
  .books-panel .panel-heading { align-items: flex-start; }
}

.book-cover {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.8rem;
  min-height: calc(100vh - 5rem);
}

.book-cover.opening, .book-cover.closing { position: relative; perspective: 1200px; }

.book-cover.opening::before, .book-cover.closing::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(31rem, 100%);
  aspect-ratio: 5 / 7;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.45rem;
  background: #fffaf0;
  box-shadow: var(--shadow);
}

.book-cover.opening .cover-frame {
  z-index: 1;
  transform-origin: left center;
  animation: cover-opening 850ms ease-in-out forwards;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.book-cover.closing .cover-frame {
  z-index: 1;
  transform-origin: left center;
  animation: cover-closing 850ms ease-in-out forwards;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

@keyframes cover-opening {
  from { transform: rotateY(0); opacity: 1; }
  to { transform: rotateY(-82deg); opacity: 0.08; }
}

@keyframes cover-closing {
  from { transform: rotateY(-82deg); opacity: 0.08; }
  to { transform: rotateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .book-cover.opening::before, .book-cover.closing::before { display: none; }
  .book-cover.opening .cover-frame, .book-cover.closing .cover-frame { animation: none; }
}

.personal-cover-open {
  min-width: 10rem;
  min-height: 2.9rem;
  border: 0;
  border-radius: 0.4rem;
  background: #23413f;
  color: #fff;
  font: 600 1rem "Cormorant Garamond", Georgia, serif;
  cursor: pointer;
}

.personal-cover-open[hidden] { display: none; }

.cover-frame {
  width: min(31rem, 100%);
  min-height: 42rem;
  padding: 3rem;
  border-radius: 0.75rem 1.4rem 1.4rem 0.75rem;
  color: #fff8e8;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 12%),
    repeating-linear-gradient(90deg, transparent 0 1.1rem, rgba(255, 255, 255, 0.035) 1.1rem 1.16rem),
    linear-gradient(145deg, var(--book-cover), var(--book-cover-deep));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
}

.cover-frame::after {
  content: "";
  position: absolute;
  inset: 1.1rem;
  border: 1px solid rgba(196, 154, 73, 0.72);
  border-radius: 0.5rem 1rem 1rem 0.5rem;
  pointer-events: none;
}

.cover-frame::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 1.1rem;
  left: 1.1rem;
  width: 52%;
  height: 0.62rem;
  border-radius: 0.2rem 999px 999px 0.2rem;
  background: var(--journal-accent);
  box-shadow:
    0 0 0 2px rgba(244, 216, 145, 0.62),
    0 4px 12px rgba(0, 0, 0, 0.26);
}

.cover-frame > * {
  position: relative;
  z-index: 2;
}

.cover-artwork {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  opacity: 0.58;
  mix-blend-mode: screen;
  pointer-events: none;
}

.cover-artwork[hidden] {
  display: none;
}

.cover-frame.photo-cover {
  aspect-ratio: 5 / 7;
  min-height: 0;
  padding: 2.4rem;
  overflow: hidden;
  background: #14364a;
}

.cover-frame.photo-cover::before { display: none; }

.cover-frame.photo-cover::after {
  z-index: 1;
  inset: 0;
  border: 0;
  border-radius: inherit;
  background: linear-gradient(180deg,
    rgba(8, 29, 45, 0.84) 0%,
    rgba(8, 29, 45, 0.73) 32%,
    rgba(8, 29, 45, 0.23) 58%,
    rgba(8, 29, 45, 0.05) 72%,
    rgba(8, 29, 45, 0.48) 100%);
}

.cover-frame.photo-cover .cover-artwork {
  opacity: 1;
  mix-blend-mode: normal;
}

.cover-frame.photo-cover .cover-kicker,
.cover-frame.photo-cover .cover-line,
.cover-frame.photo-cover .cover-copy {
  display: none;
}

.cover-frame.photo-cover .cover-logo {
  top: 1.5rem;
  right: 1.6rem;
  width: 4.1rem;
  height: 4.1rem;
}

.cover-frame.photo-cover h1 {
  max-width: 100%;
  margin: 5.8rem 0 0.9rem;
  color: #fff;
  font-size: 3.7rem;
  line-height: 0.95;
  text-shadow: 0 2px 5px rgba(4, 22, 34, 0.55);
}

.cover-frame.photo-cover .cover-name span,
.cover-frame.photo-cover .cover-name strong {
  color: #fff;
  text-shadow: 0 2px 5px rgba(4, 22, 34, 0.65);
}

.cover-frame.photo-cover .cover-name span { font-size: 0.78rem; }
.cover-frame.photo-cover .cover-name strong { font-size: 2rem; }

.cover-frame.photo-cover .cover-actions {
  position: absolute;
  right: 2.4rem;
  bottom: 2rem;
  left: 2.4rem;
}

.cover-frame.photo-cover .cover-actions button {
  width: 100%;
  margin: 0;
  background: #fffaf0;
  color: #112d40;
  border: 1px solid #fff;
  box-shadow: 0 3px 14px rgba(4, 22, 34, 0.3);
}

.cover-frame[data-cover-style="daybreak"] {
  aspect-ratio: 5 / 7;
  min-height: 0;
  color: #153247;
  background: #f6fbf8;
}

.cover-frame[data-cover-style="daybreak"] .cover-artwork {
  opacity: 1;
  mix-blend-mode: normal;
}

.cover-frame[data-cover-style="daybreak"] .cover-kicker,
.cover-frame[data-cover-style="daybreak"] .cover-line,
.cover-frame[data-cover-style="daybreak"] .cover-copy {
  display: none;
}

.cover-frame[data-cover-style="daybreak"] h1 {
  margin: 5.8rem 0 1.15rem;
  color: #153247;
  font-size: 3.9rem;
  line-height: 0.94;
}

.cover-frame[data-cover-style="daybreak"] .cover-name span,
.cover-frame[data-cover-style="daybreak"] .cover-name strong {
  color: #183b4b;
}

.cover-frame[data-cover-style="daybreak"] .cover-name span {
  font-size: 0.79rem;
}

.cover-frame[data-cover-style="daybreak"] .cover-actions button {
  margin-top: 2.1rem;
  background: #ffda74;
  color: #16344a;
  border: 1px solid #bf8537;
  box-shadow: 0 4px 12px rgba(16, 52, 71, 0.15);
}

.cover-frame[data-cover-style="floral"]::after {
  border-color: rgba(244, 216, 145, 0.9);
}

.cover-frame[data-cover-style="unicorn"] {
  color: #503460;
  background: #f3e6f3;
}

.cover-frame[data-cover-style="unicorn"] .cover-artwork {
  opacity: 1;
  mix-blend-mode: normal;
}

.cover-frame[data-cover-style="unicorn"]::before {
  background: #b76eb1;
}

.cover-frame[data-cover-style="unicorn"]::after {
  border-color: rgba(137, 78, 141, 0.7);
}

.cover-frame[data-cover-style="unicorn"] .cover-kicker,
.cover-frame[data-cover-style="unicorn"] .cover-line,
.cover-frame[data-cover-style="unicorn"] .cover-copy {
  display: none;
}

.cover-frame[data-cover-style="unicorn"] h1 {
  position: absolute;
  top: 21%;
  right: 5%;
  left: 50%;
  max-width: none;
  margin: 0;
  color: #4b315c;
  font: 500 1.2rem/1.05 "Cormorant Garamond", Georgia, serif;
  text-align: center;
}

.cover-frame[data-cover-style="unicorn"] .cover-name {
  position: absolute;
  top: 31%;
  right: 4%;
  left: 49%;
  gap: 0.25rem;
  text-align: center;
}

.cover-frame[data-cover-style="unicorn"] .cover-name span,
.cover-frame[data-cover-style="unicorn"] .cover-name strong {
  max-width: none;
  color: #60366d;
  font-family: "Allura", "Segoe Print", cursive;
  font-weight: 400;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
}

.cover-frame[data-cover-style="unicorn"] .cover-name span {
  font-size: 2.2rem;
}

.cover-frame[data-cover-style="unicorn"] .cover-name strong {
  overflow-wrap: anywhere;
  font-size: 2.9rem;
}

.cover-frame[data-cover-style="unicorn"] .cover-actions {
  position: absolute;
  top: 60%;
  right: 5%;
  left: 49%;
  justify-content: center;
}

.cover-frame[data-cover-style="unicorn"] .cover-actions button {
  margin: 0;
  background: #60366d;
  color: #fff;
}

.cover-frame[data-cover-style="color-story"] {
  color: #263a4e;
  background: #f8f5ef;
}

.cover-frame[data-cover-style="color-story"] .cover-artwork {
  opacity: 1;
  mix-blend-mode: normal;
}

.cover-frame[data-cover-style="color-story"]::before {
  background: #4278ad;
}

.cover-frame[data-cover-style="color-story"]::after {
  border-color: rgba(191, 126, 156, 0.75);
}

.cover-frame[data-cover-style="color-story"] .cover-kicker,
.cover-frame[data-cover-style="color-story"] .cover-line,
.cover-frame[data-cover-style="color-story"] .cover-copy {
  display: none;
}

.cover-frame[data-cover-style="color-story"] h1 {
  position: absolute;
  top: 21%;
  right: 5%;
  left: 49%;
  max-width: none;
  margin: 0;
  color: #24364f;
  font: 500 1.25rem/1.05 "Cormorant Garamond", Georgia, serif;
  text-align: center;
}

.cover-frame[data-cover-style="color-story"] .cover-name {
  position: absolute;
  top: 31%;
  right: 4%;
  left: 49%;
  gap: 0.25rem;
  text-align: center;
}

.cover-frame[data-cover-style="color-story"] .cover-name span,
.cover-frame[data-cover-style="color-story"] .cover-name strong {
  max-width: none;
  color: #65406d;
  font-family: "Allura", "Segoe Print", cursive;
  font-weight: 400;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
}

.cover-frame[data-cover-style="color-story"] .cover-name span {
  font-size: 2.1rem;
}

.cover-frame[data-cover-style="color-story"] .cover-name strong {
  overflow-wrap: anywhere;
  font-size: 2.8rem;
}

.cover-frame[data-cover-style="color-story"] .cover-actions {
  position: absolute;
  top: 61%;
  right: 5%;
  left: 49%;
  justify-content: center;
}

.cover-frame[data-cover-style="color-story"] .cover-actions button {
  margin: 0;
  background: #243f69;
  color: #fff;
}

.cover-frame[data-cover-style="island-resolve"] {
  color: #102944;
  background: #153859;
}

.cover-frame[data-cover-style="island-resolve"] .cover-artwork {
  opacity: 1;
  mix-blend-mode: normal;
}

.cover-frame[data-cover-style="island-resolve"]::before {
  background: #153f76;
}

.cover-frame[data-cover-style="island-resolve"]::after {
  border-color: rgba(238, 195, 111, 0.86);
}

.cover-frame[data-cover-style="island-resolve"] .cover-kicker,
.cover-frame[data-cover-style="island-resolve"] .cover-line,
.cover-frame[data-cover-style="island-resolve"] .cover-copy {
  display: none;
}

.cover-frame[data-cover-style="island-resolve"] h1 {
  position: absolute;
  top: 21%;
  right: 5%;
  left: 49%;
  max-width: none;
  margin: 0;
  color: #102944;
  font: 600 1.25rem/1.05 "Cormorant Garamond", Georgia, serif;
  text-align: center;
  text-shadow: 0 1px 6px rgba(255, 250, 240, 0.58);
}

.cover-frame[data-cover-style="island-resolve"] .cover-name {
  position: absolute;
  top: 31%;
  right: 4%;
  left: 49%;
  gap: 0.25rem;
  text-align: center;
}

.cover-frame[data-cover-style="island-resolve"] .cover-name span,
.cover-frame[data-cover-style="island-resolve"] .cover-name strong {
  max-width: none;
  color: #102944;
  font-family: "Allura", "Segoe Print", cursive;
  font-weight: 400;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  text-shadow: 0 1px 7px rgba(255, 250, 240, 0.65);
}

.cover-frame[data-cover-style="island-resolve"] .cover-name span {
  font-size: 2.1rem;
}

.cover-frame[data-cover-style="island-resolve"] .cover-name strong {
  overflow-wrap: anywhere;
  font-size: 2.8rem;
}

.cover-frame[data-cover-style="island-resolve"] .cover-actions {
  position: absolute;
  top: 61%;
  right: 5%;
  left: 49%;
  justify-content: center;
}

.cover-frame[data-cover-style="island-resolve"] .cover-actions button {
  margin: 0;
  background: #102e56;
  color: #fff;
}

.cover-frame[data-cover-style="personal"] {
  aspect-ratio: 5 / 7;
  min-height: 0;
  padding: 0;
  background: #23413f;
}

.cover-frame[data-cover-style="personal"] .cover-artwork {
  opacity: 1;
  mix-blend-mode: normal;
  object-fit: cover;
}

.cover-frame[data-cover-style="personal"]::before,
.cover-frame[data-cover-style="personal"]::after,
.cover-frame[data-cover-style="personal"] .cover-kicker,
.cover-frame[data-cover-style="personal"] .cover-logo,
.cover-frame[data-cover-style="personal"] h1,
.cover-frame[data-cover-style="personal"] .cover-name,
.cover-frame[data-cover-style="personal"] .cover-line,
.cover-frame[data-cover-style="personal"] .cover-copy,
.cover-frame[data-cover-style="personal"] .cover-actions {
  display: none;
}

.cover-logo {
  position: absolute;
  z-index: 3;
  top: 3.25rem;
  right: 3rem;
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(244, 216, 145, 0.75);
}

.cover-frame h1 {
  margin: 5rem 0 1rem;
  font-size: clamp(3.3rem, 7vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: 0;
  max-width: 24rem;
}

.cover-name {
  display: grid;
  gap: 0.18rem;
  margin: 0;
  color: #f4d891;
}

.cover-name span {
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cover-name strong {
  max-width: 23rem;
  color: #fff4c7;
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  font-weight: 500;
  line-height: 1.1;
}

.cover-line {
  width: 7rem;
  height: 2px;
  margin: 2.6rem 0;
  background: var(--gold);
}

.cover-copy {
  max-width: 21rem;
  line-height: 1.7;
}

.cover-frame button {
  margin-top: 2rem;
  padding: 0.85rem 1.15rem;
  border-radius: 0.45rem;
  background: var(--gold);
  color: #1d211f;
  font-weight: 700;
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.cover-actions .cover-secondary {
  background: transparent;
  color: #fff8e8;
  border: 1px solid rgba(244, 216, 145, 0.72);
}

.topbar,
.history-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.topbar {
  align-items: stretch;
  flex-direction: column;
  gap: 0.75rem;
}

.topbar > div:first-child { min-width: 0; }

.title-input {
  display: block;
  width: 100%;
  max-width: 42rem;
  min-height: 3.1rem;
  border: 0;
  border-bottom: 1px solid rgba(36, 33, 29, 0.25);
  background: transparent;
  color: var(--ink);
  font-size: 2.6rem;
  line-height: 1.15;
  outline: 0;
}

.title-input:focus-visible { border-bottom: 2px solid #1f3a5f; }

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: start;
}

.page-navigation {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem 1rem;
  flex-basis: 100%;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid #bac9d6;
  border-left: 0.3rem solid #243e68;
  border-radius: 0.65rem;
  background: #edf3f8;
}

.page-navigation-heading { display: grid; gap: 0.12rem; }
.page-navigation-heading strong { color: #172f51; font: 700 0.95rem/1.2 "Trebuchet MS", Arial, sans-serif; }
.page-navigation-heading label { color: #405773; font: 0.77rem/1.2 "Trebuchet MS", Arial, sans-serif; }
.page-navigation-controls { display: flex; align-items: stretch; justify-content: flex-end; gap: 0.45rem; min-width: 0; }
.page-navigation-controls button { white-space: nowrap; }
.page-navigation-controls select { min-width: 10rem; max-width: 18rem; background: #fff; color: #182f50; font-weight: 700; }
.page-navigation-controls button:disabled { opacity: 0.48; }

.topbar-actions button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.danger-button {
  border-color: rgba(168, 85, 80, 0.42) !important;
  color: #873f3b !important;
  background: rgba(255, 250, 240, 0.88) !important;
}

.danger-button:hover {
  border-color: #a85550 !important;
  background: #fff4f1 !important;
}

select,
input[type="date"],
.search-box input,
.settings-panel input,
.settings-panel textarea,
.settings-panel select {
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.45rem;
  padding: 0.68rem 0.75rem;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
}

.book-spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  gap: 1rem;
  align-items: start;
}

.paper-page,
.companion-page,
.settings-panel,
.account-panel {
  border-radius: 0.55rem;
  background: var(--paper);
  box-shadow: var(--shadow);
  border: 1px solid rgba(36, 33, 29, 0.12);
}

.backup-actions,
.restore-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.journal-copies p {
  line-height: 1.45;
}

.journal-copies .backup-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.journal-copies .backup-actions button,
.journal-copies .backup-actions .file-button {
  width: 100%;
  min-width: 0;
  min-height: 2.9rem;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
}

.journal-copies #driveExportButton {
  background: #1f3a5f;
  border-color: #1f3a5f;
  color: #fff;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid rgba(36, 33, 29, 0.18);
  border-radius: 0.45rem;
  background: rgba(255, 250, 240, 0.82);
  color: var(--ink);
  cursor: pointer;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
}

.file-button:hover {
  background: #fffaf0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.restore-preview {
  margin-top: 0.85rem;
  padding: 0.9rem;
  border-left: 3px solid var(--gold);
  background: rgba(255, 250, 240, 0.76);
}

.restore-preview p {
  margin: 0.35rem 0 0.8rem;
  color: var(--muted);
}

.quiet-button {
  background: transparent !important;
  color: var(--ink) !important;
  border: 1px solid rgba(36, 33, 29, 0.2) !important;
}

.paper-page {
  min-height: 42rem;
  padding: 1.2rem 1.2rem 1.6rem 4.1rem;
  position: relative;
}

.paper-page.page-created {
  animation: page-created 360ms ease-out;
}

@keyframes page-created {
  from {
    opacity: 0.72;
    transform: translateX(0.75rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .paper-page.page-created {
    animation: none;
  }
}

.paper-page::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3rem;
  width: 2px;
  background: rgba(168, 85, 80, 0.36);
}

.paper-page::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 52%;
  height: 0.5rem;
  border-radius: 0.45rem 999px 999px 0;
  background: var(--journal-accent);
}

.paper-header {
  display: flex;
  gap: 0.7rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.ink-toolbar {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 0.75rem;
  font-family: "Trebuchet MS", Arial, sans-serif;
}

.mode-tabs,
.ink-tool-tabs,
.ink-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.writing-toolbar-row,
.writing-tools,
.page-font-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.writing-toolbar-row {
  justify-content: space-between;
  flex-wrap: wrap;
}

.writing-tools {
  flex-wrap: wrap;
}

.page-font-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.page-font-label select {
  min-height: 2.35rem;
  max-width: 11rem;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  border: 1px solid rgba(36, 33, 29, 0.17);
  border-radius: 0.4rem;
  background: rgba(255, 250, 240, 0.92);
  color: var(--cover-deep);
  font: 700 0.78rem/1 "Trebuchet MS", Arial, sans-serif;
}

.emoji-control {
  position: relative;
}

.emoji-picker-button span,
.emoji-option {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.emoji-caret-marker {
  display: inline-block;
  width: 0;
  height: 1em;
  overflow: hidden;
  pointer-events: none;
}

.emoji-panel {
  position: absolute;
  z-index: 12;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(23rem, calc(100vw - 2rem));
  max-height: 24rem;
  overflow: auto;
  padding: 0.85rem;
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.5rem;
  background: #fffaf0;
  box-shadow: 0 16px 38px rgba(36, 33, 29, 0.22);
}

.emoji-panel[hidden] {
  display: none;
}

.emoji-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  color: var(--cover-deep);
}

.emoji-panel .emoji-close-button {
  width: 2.35rem;
  min-height: 2.35rem;
  padding: 0;
  font-size: 1rem;
}

.emoji-search-label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.emoji-search-label input {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.4rem;
  background: #fff;
  color: var(--ink);
  font: 400 0.9rem/1.2 "Trebuchet MS", Arial, sans-serif;
}

.emoji-search-label input:focus {
  border-color: var(--journal-accent);
  outline: 2px solid color-mix(in srgb, var(--journal-accent) 28%, transparent);
  outline-offset: 1px;
}

.emoji-result-status {
  min-height: 1rem;
  margin: 0.45rem 0 0.2rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.emoji-grid {
  display: grid;
  gap: 0.4rem;
}

.emoji-group-label {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.emoji-group {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.3rem;
}

.emoji-empty {
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.emoji-panel .emoji-option {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.2rem;
  border-color: rgba(36, 33, 29, 0.1);
  background: #fff;
  font-size: 1.45rem;
}

.emoji-panel .emoji-option:hover,
.emoji-panel .emoji-option:focus-visible {
  border-color: var(--journal-accent);
  background: rgba(196, 154, 73, 0.1);
  transform: translateY(-1px);
}

.ink-toolbar button {
  min-height: 2.35rem;
  padding: 0.5rem 0.72rem;
  border: 1px solid rgba(36, 33, 29, 0.17);
  border-radius: 0.4rem;
  background: rgba(255, 250, 240, 0.88);
  color: var(--cover-deep);
  font: 700 0.78rem/1 "Trebuchet MS", Arial, sans-serif;
}

.ink-toolbar button[aria-pressed="true"] {
  border-color: var(--journal-accent);
  background: var(--journal-accent);
  color: #fffaf0;
}

.ink-toolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.ink-tools[hidden] {
  display: none;
}

.ink-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 0.8rem;
}

.ink-tool-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ink-tool-tabs button { width: 100%; min-width: 0; }

.ink-color-panel {
  min-width: 0;
  padding: 0.75rem 0;
  border-top: 1px solid rgba(36, 33, 29, 0.15);
  border-bottom: 1px solid rgba(36, 33, 29, 0.15);
}

.ink-color-heading,
.ink-custom-row,
.ink-options-row,
.ink-history-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ink-color-heading { justify-content: space-between; margin-bottom: 0.65rem; }
.ink-color-heading strong { color: var(--cover-deep); font-size: 0.85rem; }
.ink-color-heading span { color: var(--muted); font: 700 0.72rem/1 "Trebuchet MS", Arial, sans-serif; }

.ink-palette {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.ink-toolbar .ink-palette button {
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(36, 33, 29, 0.2);
  border-radius: 0.25rem;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}

.ink-toolbar .ink-palette button[aria-pressed="true"] {
  background: var(--swatch);
  color: inherit;
  outline: 2px solid var(--cover-deep);
  outline-offset: 2px;
}

.ink-custom-row { justify-content: space-between; flex-wrap: wrap; }
.ink-color-label { flex: 0 0 auto; color: var(--cover-deep); }
.ink-current-swatch {
  display: block;
  width: 2.4rem;
  height: 2.4rem;
  flex: 0 0 2.4rem;
  border: 1px solid rgba(36, 33, 29, 0.22);
  border-radius: 0.25rem;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}
.ink-color-label span { white-space: nowrap; }

.rgb-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  width: min(100%, 16rem);
  min-width: 0;
}
.rgb-controls label { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.3rem; min-width: 0; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.rgb-controls input { width: 100%; min-width: 0; min-height: 2.45rem; padding: 0.3rem; text-align: center; font: 700 0.85rem/1 "Trebuchet MS", Arial, sans-serif; }
.rgb-controls input::-webkit-inner-spin-button { display: none; }
.rgb-controls input { appearance: textfield; }

.ink-options-row { justify-content: space-between; flex-wrap: wrap; }
.ink-width-label { flex: 1 1 10rem; }
.ink-width-label input { flex: 1; min-width: 5rem; max-width: 18rem; }
.ink-history-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ink-history-row button { width: 100%; min-width: 0; }

.ink-color-label,
.ink-width-label,
.stylus-only-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}


.ink-width-label input {
  width: 7rem;
  accent-color: var(--journal-accent);
}

.stylus-only-label input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--journal-accent);
}

.template-picker {
  display: flex;
  gap: 0.5rem;
}

.template-picker select {
  min-width: 11rem;
  width: 100%;
}

.template-picker button {
  border-radius: 0.45rem;
  padding: 0.55rem 0.75rem;
  background: var(--cover);
  color: #fffaf0;
}

.template-dialog {
  width: min(36rem, calc(100% - 2rem));
  padding: 0;
  border: 1px solid rgba(36, 33, 29, 0.18);
  border-radius: 0.5rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.template-dialog::backdrop {
  background: rgba(20, 41, 39, 0.58);
  backdrop-filter: blur(4px);
}

.cover-setup-dialog {
  width: min(46rem, calc(100% - 1.5rem));
  padding: 0;
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.55rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.cover-setup-dialog::backdrop {
  background: rgba(20, 28, 27, 0.7);
  backdrop-filter: blur(5px);
}

.cover-setup-content {
  padding: 1.5rem;
}

.cover-setup-content h2 {
  margin: 0.2rem 0 0.45rem;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1;
}

.cover-setup-copy {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.cover-choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.cover-choice-grid button {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.45rem;
  background: #fffaf0;
  color: var(--ink);
  text-align: left;
}

.cover-choice-grid button:hover,
.cover-choice-grid button:focus-visible {
  border-color: var(--gold);
  outline: 2px solid rgba(196, 154, 73, 0.3);
  outline-offset: 2px;
}

.cover-choice-grid strong,
.cover-choice-grid small {
  padding-inline: 0.15rem;
}

.cover-choice-grid small {
  color: var(--muted);
}

.cover-choice-preview {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 4;
  margin-bottom: 0.35rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.floral-preview {
  background:
    linear-gradient(rgba(104, 66, 122, 0.15), rgba(52, 26, 63, 0.35)),
    url("floral-cover.png") center / cover,
    #68427a;
}

.daybreak-preview {
  background: #08283a url("daybreak-cover.png") center 60% / cover;
}

.island-escape-preview { background: #438bb1 url("photo-island-escape.jpg") center / cover; }
.enchanted-garden-preview { background: #789479 url("photo-enchanted-garden.jpg") center / cover; }
.mountain-trail-preview { background: #6a9bb1 url("photo-mountain-trail.jpg") center / cover; }
.tomorrow-city-preview { background: #314a78 url("photo-tomorrow-city.jpg") center / cover; }

.classic-preview {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 18%),
    linear-gradient(145deg, #23413f, #142927);
}

.custom-preview {
  background: conic-gradient(from 45deg, #1f3a5f, #704d75, #7b3148, #246b68, #1f3a5f);
}

.template-dialog form {
  display: grid;
  gap: 1rem;
  padding: 1.35rem;
}

.template-dialog label {
  display: grid;
  gap: 0.45rem;
  color: var(--cover-deep);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
}

.template-dialog input,
.template-dialog textarea {
  width: 100%;
  border: 1px solid rgba(36, 33, 29, 0.18);
  border-radius: 0.35rem;
  padding: 0.72rem;
  background: #fffdf7;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.55;
}

.dialog-heading,
.template-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dialog-heading h2 {
  margin: 0.15rem 0 0;
}

.template-dialog .dialog-close {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
}

.template-dialog-actions button {
  min-height: 2.8rem;
  padding: 0.7rem 1rem;
  border-radius: 0.45rem;
  background: var(--cover);
  color: #fffaf0;
}

.lined-paper {
  display: block;
  width: 100%;
  min-height: 30rem;
  border: 0;
  outline: 0;
  color: #2d2924;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 1.86rem,
      var(--line) 1.88rem,
      var(--line) 2rem
    );
  background-size: 100% 2rem;
  background-attachment: local;
  line-height: 2rem;
  font-size: 1.12rem;
  padding: 0 0.2rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
  caret-color: #1f3a5f;
  -webkit-tap-highlight-color: transparent;
}

::highlight(journal-search-match) {
  background: #ffe28a;
  color: #18283d;
  text-decoration: underline 2px #203e69;
}

.look-back-jump-notice {
  margin: 0.3rem 0 0.8rem;
  padding: 0.65rem 0.85rem;
  border: 2px solid #29436d;
  border-radius: 0.7rem;
  background: #fff0b8;
  color: #18283d;
  font: 700 0.88rem/1.4 "Trebuchet MS", Arial, sans-serif;
}

.entry-recovery { margin-top: 0.85rem; }
.entry-recovery-list { display: grid; gap: 0.65rem; margin-top: 0.65rem; }
.entry-recovery-list[hidden] { display: none; }
.entry-recovery-list p { margin: 0.2rem 0; line-height: 1.45; }
.entry-recovery-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.75rem;
  border: 1px solid #aab7b1;
  border-radius: 0.6rem;
  background: #fffdf7;
}
.entry-recovery-choice button { min-height: 2.7rem; }

.title-input.look-back-title-match {
  background: #fff0b8;
  outline: 2px solid #29436d;
  outline-offset: 2px;
}

.lined-paper:empty::before {
  content: attr(data-placeholder);
  color: rgba(84, 78, 69, 0.48);
  pointer-events: none;
}

.page-canvas {
  position: relative;
  min-height: 30rem;
}

.page-canvas::after {
  content: "";
  display: block;
  clear: both;
}

.page-canvas[data-page-type="drawing"] {
  min-height: 1400px;
  background: white;
}

.paper-page[data-page-type="drawing"] .writing-toolbar-row,
.paper-page[data-page-type="drawing"] .template-picker {
  display: none;
}

.page-canvas[data-page-type="drawing"] .lined-paper {
  visibility: hidden;
  min-height: 65dvh;
}

.drawing-canvas {
  position: absolute;
  z-index: 5;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
}

.drawing-canvas[data-active="true"] {
  pointer-events: auto;
  cursor: crosshair;
}

.page-attachments {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #daceba;
}

.page-attachments h2 {
  margin: 0 0 0.65rem;
  color: #1f355a;
  font-size: 1.18rem;
}

.photo-slots, .voice-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.attachment-slot {
  display: grid;
  align-content: start;
  gap: 0.4rem;
  min-width: 0;
  padding: 0.5rem;
  border: 1px solid #daceba;
  border-radius: 0.6rem;
  background: #fffaf0;
  color: #1f355a;
}

.attachment-label {
  padding: 0.1rem 0.15rem;
  font: 700 0.82rem/1.3 "Trebuchet MS", Arial, sans-serif;
}

.attachment-photo, .photo-empty {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 0.4rem;
  background: #f1e9dc;
}

.attachment-photo img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
}

.page-attachments button.attachment-photo {
  padding: 0;
  border: 0;
  overflow: hidden;
  cursor: zoom-in;
}

.attachment-photo:focus-visible { outline: 3px solid #1f355a; outline-offset: 3px; }

.photo-viewer-dialog {
  box-sizing: border-box;
  width: min(58rem, calc(100vw - 1rem));
  max-height: calc(100dvh - 1rem);
  margin: auto;
  padding: clamp(0.75rem, 2vw, 1.4rem);
  overflow: auto;
  border: 1px solid #cbb88f;
  border-radius: 1rem;
  background: #fffaf0;
  color: #1f355a;
}
.photo-viewer-dialog::backdrop { background: rgba(12, 24, 43, 0.82); }
.photo-viewer-heading { display: flex; align-items: center; gap: 0.75rem; justify-content: space-between; margin-bottom: 0.75rem; }
.photo-viewer-heading h2 { margin: 0; min-width: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.photo-viewer-heading button { flex-shrink: 0; min-height: 2.75rem; padding: 0.55rem 1rem; background: #1f355a; color: #fffaf0; }
.photo-viewer-stage { width: min(70dvh, 100%); aspect-ratio: 1; margin: 0 auto; display: grid; place-items: center; overflow: hidden; background: #f1e9dc; border-radius: 0.5rem; }
.photo-viewer-stage img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }

.page-attachments button {
  min-height: 2.75rem;
  padding: 0.35rem;
  border: 1px solid #daceba;
  border-radius: 0.4rem;
  background: #fffdf8;
  color: inherit;
  font: 700 0.8rem/1.3 "Trebuchet MS", Arial, sans-serif;
  overflow-wrap: anywhere;
}

.page-attachments .photo-empty {
  border-style: dashed;
  background: #f6f0e6;
}

.attachment-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.attachment-controls button { flex: 1 1 auto; }
.page-attachments .voice-filled {
  background: #203b61;
  color: #fff;
  border-color: #203b61;
}

.voice-filled .voice-play {
  border-color: #8294ad;
  background: transparent;
}

#photoStatus {
  min-height: 1.35em;
  margin: 0.45rem 0 0.75rem;
  color: #354763;
  font: 0.88rem/1.4 "Trebuchet MS", Arial, sans-serif;
}

@media (max-width: 650px) {
  .photo-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .voice-slots { grid-template-columns: 1fr; }
}

.lined-paper[data-journal-font="elegant"] {
  font-family: Georgia, "Times New Roman", serif;
}

.lined-paper[data-journal-font="handwriting"] {
  font-family: "Playwrite US Trad", "Segoe Script", cursive;
  font-size: 1.35rem;
  font-weight: 400;
  font-feature-settings: "calt" 1, "liga" 1;
  letter-spacing: 0;
}

.lined-paper[data-journal-font="classic"] {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
}

.lined-paper[data-journal-font="clean"] {
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 1rem;
}

.lined-paper[data-journal-font="handwriting"],
.lined-paper[data-journal-font="readable"] {
  color: #000;
  font-style: normal;
  font-weight: 400;
}

.lined-paper[data-journal-font="readable"] {
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: 1.1rem;
}

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.2rem;
}

.voice-panel {
  margin-top: 1.4rem;
  padding: 1rem 0 0;
  border-top: 1px solid #b9c5c3;
  color: var(--ink);
}
.voice-heading,
.voice-recorder,
.voice-player-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.voice-heading { justify-content: space-between; }
.voice-heading h2 { margin: 0; font-size: 1.25rem; }
.voice-panel > p { margin: 0.55rem 0 0.9rem; }
.voice-recorder { padding: 0.25rem 0 0.35rem; }
.voice-record-button {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 4rem;
  padding: 0.55rem 1.15rem 0.55rem 0.65rem;
  border: 2px solid #172e50;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #294c78, #182e50);
  box-shadow: 0 7px 17px rgba(24, 46, 80, 0.2);
  color: #fffaf0;
  text-align: left;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.voice-record-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(24, 46, 80, 0.26); }
.voice-record-button:focus-visible { outline: 3px solid #b65a36; outline-offset: 3px; }
.voice-record-button:disabled { opacity: 0.6; cursor: not-allowed; }
.voice-record-button[hidden] { display: none; }
.voice-record-icon {
  display: grid;
  place-items: center;
  flex: 0 0 2.65rem;
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 50%;
  background: #f5dfb3;
  color: #182e50;
}
.voice-record-icon svg { width: 1.5rem; height: 1.5rem; }
.voice-record-copy { display: grid; gap: 0.08rem; font-family: "Trebuchet MS", Arial, sans-serif; }
.voice-record-copy strong { font-size: 1rem; line-height: 1.2; }
.voice-record-copy small { font-size: 0.8rem; color: #f1ddb6; }
.voice-recorder #stopVoiceButton { min-height: 3rem; padding: 0.65rem 1rem; border-radius: 0.65rem; background: #f5dfb3; color: #172e50; font-weight: 700; }
.voice-recorder #cancelVoiceButton { min-height: 3rem; padding: 0.65rem 1rem; border: 1px solid #879693; border-radius: 0.65rem; background: #fffaf0; color: #1e3d3a; }
.voice-recorder #stopVoiceButton[hidden], .voice-recorder #cancelVoiceButton[hidden] { display: none; }
.voice-timer { padding: 0.4rem 0.6rem; border-radius: 0.45rem; background: #edf2f6; color: #173846; font: 700 1rem "Trebuchet MS", Arial, sans-serif; font-variant-numeric: tabular-nums; }
.voice-status { min-height: 1.3rem; font-size: 0.92rem; color: #31544a; }
.voice-usage { color: #485952; font: 0.84rem "Trebuchet MS", Arial, sans-serif; }
.voice-status[data-tone="error"] { color: #883d36; font-weight: 700; }
.voice-note-pending { color: #fff0bb; font-size: 0.8rem; }
.voice-player-dialog {
  box-sizing: border-box;
  width: min(32rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: 1.2rem;
  border: 1px solid #a8c1bc;
  border-radius: 7px;
  background: #fffdf8;
  color: #233b37;
  box-shadow: 0 22px 60px rgba(19, 39, 36, 0.28);
}
.voice-player-dialog::backdrop { background: rgba(18, 35, 38, 0.62); }
.voice-player-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.voice-player-heading h2 { margin: 0.25rem 0 0; font-size: 1.55rem; overflow-wrap: anywhere; }
.voice-player-meta { margin: 0.85rem 0; color: #4d615c; font: 0.9rem "Trebuchet MS", Arial, sans-serif; }
.voice-player-dialog audio { display: block; width: 100%; margin: 0.8rem 0; }
#voicePlayerStatus { min-height: 1.35rem; font: 0.9rem "Trebuchet MS", Arial, sans-serif; }
.voice-player-actions { margin-top: 0.7rem; }
.voice-player-actions button { min-height: 2.75rem; }
@media (max-width: 480px) {
  .voice-recorder button { flex: 1 1 9rem; }
  .voice-record-button { flex-basis: 100% !important; justify-content: center; }
  .voice-player-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .voice-player-actions button { min-width: 0; }
}

.save-status {
  flex: 0 0 100%;
  box-sizing: border-box;
  width: 100%;
  height: 2.75rem;
  margin: 0;
  padding: 0.66rem 0.7rem;
  border: 1px solid #9eb2bd;
  border-radius: 0.3rem;
  background: #edf5f8;
  color: #173846;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-status[data-tone="saved"]::before {
  content: "\2713";
  font-size: 1rem;
}

.save-status[data-tone="saved"] {
  color: #173846;
}

.save-status[data-tone="error"] {
  border-color: #a82e3e;
  background: #fff0ed;
  color: #78212d;
}

.save-status[data-tone="error"]::before {
  content: "!";
  font-size: 1.1rem;
}

@media (max-width: 680px) {
  .topbar-actions .save-status {
    grid-column: 1 / -1;
    font-size: 0.8rem;
  }
}

.save-toast {
  pointer-events: none;
  position: fixed;
  z-index: 50;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.78rem 1rem 0.78rem 2.25rem;
  border: 1px solid rgba(255, 250, 240, 0.24);
  border-radius: 0.45rem;
  background: var(--cover-deep);
  color: #fffaf0;
  box-shadow: 0 12px 32px rgba(20, 41, 39, 0.3);
  font: 700 0.9rem/1.25 "Trebuchet MS", Arial, sans-serif;
  opacity: 0;
  transform: translateY(0.75rem);
  transition: opacity 180ms ease, transform 180ms ease;
}

.save-toast::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.95rem;
  width: 0.7rem;
  height: 0.7rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  transform: translateY(-50%);
  animation: save-spin 800ms linear infinite;
}

.save-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.save-toast[data-tone="saved"]::before {
  border: 0;
  border-radius: 0;
  width: 0.75rem;
  height: 0.4rem;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-65%) rotate(-45deg);
  animation: none;
}

.save-toast[data-tone="error"] {
  background: #7f2f35;
}

.color-name-hint {
  position: fixed;
  z-index: 60;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  max-width: calc(100vw - 2rem);
  padding: 0.72rem 1rem;
  border: 1px solid rgba(255, 250, 240, 0.28);
  border-radius: 0.4rem;
  background: #24211d;
  color: #fffaf0;
  box-shadow: 0 12px 32px rgba(36, 33, 29, 0.28);
  font: 700 0.88rem/1.25 "Trebuchet MS", Arial, sans-serif;
  opacity: 0;
  transform: translate(-50%, -0.5rem);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.color-name-hint.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes save-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.companion-page {
  display: grid;
  gap: 1.1rem;
  padding: 1rem;
}

.companion-page section {
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(36, 33, 29, 0.12);
}

.companion-page section:last-child {
  border-bottom: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.stat-grid div {
  padding: 0.75rem;
  border-radius: 0.45rem;
  background: #f4ead8;
}

.stat-grid strong,
.stat-grid span {
  display: block;
}

.stat-grid strong {
  font-size: 1.4rem;
}

.stat-grid span {
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.75rem;
}

.marker-row label,
.settings-panel label {
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.86rem;
}

.marker-row label {
  grid-template-columns: 1.2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  min-height: 1.75rem;
  color: var(--ink);
}

.marker-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--journal-accent);
}

.auto-backup-status {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.78rem;
  line-height: 1.4;
}

.history-header h2,
.settings-panel h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.8rem;
}

.search-box {
  display: grid;
  gap: 0.45rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.86rem;
}

.search-box input {
  width: min(40rem, 100%);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1rem;
}

.history-recovery-note {
  max-width: 44rem;
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border-left: 4px solid #1f3a5f;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
  line-height: 1.5;
}

.history-item {
  display: grid;
  gap: 0.35rem;
  min-height: 9rem;
  padding: 1rem;
  text-align: left;
  border-radius: 0.5rem;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
  border: 1px solid rgba(36, 33, 29, 0.12);
}

.history-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.history-item-actions button {
  min-height: 2.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.4rem;
  background: var(--cover);
  color: #fffaf0;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
}

.history-date,
.history-preview {
  color: var(--muted);
}

.history-pages summary {
  cursor: pointer;
  padding: 0.55rem 0;
  color: var(--cover-deep);
  font: 700 0.9rem/1.4 "Trebuchet MS", Arial, sans-serif;
}

.history-pages ul {
  display: grid;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-pages li {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}

.history-pages button {
  min-height: 2.75rem;
  padding: 0.4rem 0.55rem;
  overflow-wrap: anywhere;
}

.history-pages li button:first-child {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.empty-history {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1rem;
  border-radius: 0.5rem;
  background: rgba(255, 250, 240, 0.78);
  color: var(--muted);
}

.entry-tags { margin-top: 1rem; border-top: 1px solid rgba(36, 33, 29, 0.16); padding-top: 0.8rem; }
.entry-tags summary, .look-back-tags summary { cursor: pointer; font: 700 0.9rem/1.4 "Trebuchet MS", Arial, sans-serif; color: var(--cover-deep); }
.entry-tags > p, .look-back-summary-controls p, .look-back-intro { color: var(--muted); line-height: 1.5; }
.entry-tags > p { margin: 0.55rem 0; font-size: 0.85rem; }
.tag-list, .tag-suggestions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.75rem 0; }
.tag-chip, .tag-filter, .tag-suggestions button { display: inline-flex; align-items: center; gap: 0.3rem; min-height: 2rem; padding: 0.28rem 0.6rem; border: 1px solid #9ba9a2; border-radius: 0.35rem; background: #eef3ed; color: #1f302e; font: 700 0.8rem/1.3 "Trebuchet MS", Arial, sans-serif; }
.tag-chip button { min-width: 1.5rem; min-height: 1.5rem; padding: 0; background: transparent; color: inherit; font: 700 1.15rem/1 Arial, sans-serif; }
.tag-chip-marker { background: #e9edf5; border-color: #a4b2d0; color: #253958; }
.tag-filter[aria-pressed="true"] { background: var(--cover); color: #fffaf0; }
.tag-form label { display: block; margin-bottom: 0.4rem; font: 700 0.8rem/1.3 "Trebuchet MS", Arial, sans-serif; }
.tag-form > div { display: flex; gap: 0.4rem; }
.tag-form input { min-width: 0; flex: 1; width: 100%; padding: 0.6rem; border: 1px solid #9ba9a2; border-radius: 0.35rem; background: #fffaf0; }
.tag-form button, .look-back-entry button, .look-back-summary-controls button, .look-back-consent-actions button { min-height: 2.6rem; padding: 0.55rem 0.85rem; border-radius: 0.35rem; background: var(--cover); color: #fffaf0; font: 700 0.85rem/1.3 "Trebuchet MS", Arial, sans-serif; }
.tag-suggestions button { background: #fffaf0; }
.tag-message { min-height: 1.1rem; }
.look-back-view { padding: clamp(1rem, 3vw, 2.5rem); }
.look-back-intro { max-width: 40rem; margin: 0.6rem 0 1.25rem; font-size: 1.04rem; }
.look-back-book-name { margin: -0.65rem 0 1.2rem; color: #293b59; font: 700 0.84rem/1.3 "Trebuchet MS", Arial, sans-serif; }
.look-back-filters { display: grid; grid-template-columns: minmax(12rem, 2fr) repeat(2, minmax(8rem, 1fr)) auto auto; align-items: end; gap: 0.7rem; margin-bottom: 1rem; }
.look-back-filters label { display: grid; gap: 0.35rem; color: var(--muted); font: 700 0.83rem/1.3 "Trebuchet MS", Arial, sans-serif; }
.look-back-filters input { width: 100%; min-height: 2.7rem; padding: 0.5rem 0.65rem; border: 1px solid #aab7b1; border-radius: 0.35rem; background: #fffaf0; color: var(--ink); }
.look-back-filters label { min-width: 0; }
.look-back-filters > button { min-height: 2.7rem; padding: 0.55rem 0.8rem; border: 1px solid #9ba9a2; border-radius: 0.35rem; background: #fffaf0; color: var(--cover-deep); font: 700 0.83rem/1.3 "Trebuchet MS", Arial, sans-serif; }
.look-back-tags { border-top: 1px solid #c5d0ca; border-bottom: 1px solid #c5d0ca; padding: 0.7rem 0; }
.look-back-summary-controls { margin: 1.15rem 0; }
.look-back-summary-controls p { margin: 0.45rem 0 0; font-size: 0.88rem; }
.look-back-count { color: var(--cover-deep); font: 700 0.9rem/1.4 "Trebuchet MS", Arial, sans-serif; }
.look-back-columns, .look-back-entry { display: grid; grid-template-columns: minmax(9rem, 1fr) minmax(0, 2.8fr) minmax(8rem, 1fr); gap: 1.2rem; align-items: start; }
.look-back-columns { padding: 0.55rem 0.8rem; border-top: 1px solid #b9c6c0; border-bottom: 1px solid #b9c6c0; color: #293b59; font: 700 0.78rem/1.3 "Trebuchet MS", Arial, sans-serif; }
.look-back-results { min-width: 0; }
.look-back-entry { min-width: 0; padding: 1rem 0.8rem; border-bottom: 1px solid #c9d2cb; background: #fffdf7; }
.look-back-entry:nth-child(even) { background: #f3f7f3; }
.look-back-date, .look-back-summary, .look-back-actions { min-width: 0; }
.look-back-entry h3 { margin: 0.35rem 0 0; font-size: 1.04rem; line-height: 1.3; overflow-wrap: anywhere; }
.look-back-entry .date-label { display: block; margin: 0; font: 700 0.83rem/1.4 "Trebuchet MS", Arial, sans-serif; color: #293b59; }
.look-back-summary > strong { color: #273a36; font: 700 0.8rem/1.3 "Trebuchet MS", Arial, sans-serif; }
.look-back-entry .look-back-preview { margin: 0.4rem 0 0; line-height: 1.5; overflow-wrap: anywhere; }
.look-back-entry .look-back-preview:empty { display: none; }
.look-back-original { margin-top: 0.6rem; }
.look-back-original summary { cursor: pointer; color: #335b69; font: 700 0.78rem/1.4 "Trebuchet MS", Arial, sans-serif; }
.look-back-original p { margin: 0.45rem 0 0; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.look-back-actions .tag-list { margin: 0 0 0.6rem; }
.look-back-entry button { align-self: start; }
.look-back-consent { width: min(32rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 1.4rem; border: 1px solid #9ba9a2; border-radius: 0.4rem; background: #fffaf0; color: var(--ink); box-shadow: var(--shadow); }
.look-back-consent::backdrop { background: rgba(17, 34, 31, 0.6); }
.look-back-consent h2 { margin: 0; font-size: 1.8rem; }
.look-back-consent p { line-height: 1.5; }
.look-back-consent-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.look-back-consent-actions button:last-child { border: 1px solid #9ba9a2; background: #fffaf0; color: var(--cover-deep); }

@media (max-width: 1100px) {
  .look-back-filters { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); }
  .look-back-filters > button { width: 100%; }
}
@media (max-width: 680px) {
  .look-back-view { padding: 1rem 0.35rem; }
  .look-back-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .look-back-filters label:first-child { grid-column: 1 / -1; }
  .look-back-summary-controls button { width: 100%; }
  .look-back-columns { display: none; }
  .look-back-entry { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; padding: 1rem 0.6rem; }
  .look-back-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
  .look-back-actions .tag-list { margin: 0; }
}
.ai-reflection-setting { display: flex !important; align-items: center; gap: 0.55rem; color: var(--ink) !important; }
.ai-reflection-setting input { width: 1.2rem; height: 1.2rem; flex: 0 0 1.2rem; accent-color: var(--journal-accent); }

.settings-panel {
  width: min(42rem, 100%);
  display: grid;
  gap: 1rem;
  padding: 1.4rem;
}

.personal-cover-settings {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem 0;
  border-top: 1px solid rgba(36, 33, 29, 0.12);
  border-bottom: 1px solid rgba(36, 33, 29, 0.12);
}

.personal-cover-settings input[type="file"] {
  width: 100%;
  min-width: 0;
  padding: 0.5rem;
  background: #fffaf0;
}

.personal-cover-settings input[type="file"]::file-selector-button {
  margin-right: 0.7rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(36, 33, 29, 0.18);
  border-radius: 0.35rem;
  background: #f4ead8;
  color: var(--cover-deep);
  cursor: pointer;
}

.cover-image-help {
  border-top: 1px solid rgba(36, 33, 29, 0.12);
  color: var(--ink);
  font: 0.88rem/1.5 "Trebuchet MS", Arial, sans-serif;
}

.cover-image-help summary {
  min-height: 2.6rem;
  padding: 0.55rem 0;
  cursor: pointer;
  font-weight: 700;
}

.cover-image-help summary:focus-visible {
  outline: 2px solid var(--cover-deep);
  outline-offset: 2px;
}

.cover-image-help-content { padding: 0 0 0.35rem; }
.cover-image-help-content ol { margin: 0.25rem 0 0; padding-left: 1.45rem; }
.cover-image-help-content li { margin-bottom: 0.75rem; padding-left: 0.15rem; }
.cover-image-help-content p { margin: 0.25rem 0 0; color: var(--muted); }
.cover-image-help-content label { display: block; margin: 0.8rem 0 0.35rem; font-weight: 700; }
.cover-prompt-text {
  display: block;
  width: 100%;
  min-width: 0;
  height: 12rem;
  padding: 0.75rem;
  border: 1px solid rgba(36, 33, 29, 0.25);
  border-radius: 0.3rem;
  background: #fffdf8;
  color: var(--ink);
  font: 0.86rem/1.5 "Trebuchet MS", Arial, sans-serif;
  resize: vertical;
}
.cover-prompt-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; margin: 0.65rem 0; }
.cover-prompt-actions .quiet-button { min-height: 2.7rem; }
.cover-prompt-actions p { flex: 1 1 10rem; margin: 0; }

.personal-cover-settings-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem;
}

.personal-cover-settings-actions p {
  margin: 0;
  color: var(--muted);
  font: 0.85rem/1.4 "Trebuchet MS", Arial, sans-serif;
}

.personal-cover-settings-actions p[data-tone="error"] { color: #9a3636; }

.personal-cover-settings-actions button { min-height: 2.6rem; }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading .quiet-button {
  flex: 0 0 auto;
  min-height: 2.6rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.45rem;
}

.account-heading {
  margin-bottom: 0.8rem;
}

.accent-fieldset {
  margin: 0;
  padding: 0.9rem;
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.45rem;
}

.accent-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.86rem;
}

.accent-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.settings-panel .color-swatch {
  position: relative;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 2.35rem;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(36, 33, 29, 0.24);
}

.settings-panel .color-swatch::after {
  content: attr(data-color-name);
  position: absolute;
  z-index: 12;
  bottom: calc(100% + 0.55rem);
  left: 50%;
  padding: 0.4rem 0.52rem;
  border-radius: 0.3rem;
  background: #24211d;
  color: #fffaf0;
  box-shadow: 0 8px 22px rgba(36, 33, 29, 0.22);
  font: 700 0.74rem/1 "Trebuchet MS", Arial, sans-serif;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 0.25rem);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.settings-panel .color-swatch:hover::after,
.settings-panel .color-swatch:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.settings-panel .color-swatch:hover {
  border-color: var(--paper);
  background: var(--swatch);
}

.settings-panel .color-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--ink);
}

.custom-color-label {
  display: inline-flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 0.5rem !important;
  min-height: 2.35rem;
  margin-left: 0.2rem;
}

.custom-color-label input[type="color"] {
  width: 2.7rem;
  height: 2.35rem;
  padding: 0.18rem;
  border-radius: 0.35rem;
  cursor: pointer;
}

.color-description,
.setting-help {
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.78rem;
  line-height: 1.4;
}

.color-description {
  margin: 0.65rem 0 0;
  font-weight: 700;
}

.setting-help {
  display: block;
  font-weight: 400;
}

.account-panel {
  width: min(42rem, 100%);
  padding: 1.4rem;
}

.account-panel h2 {
  margin: 0.2rem 0 0.65rem;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.account-panel p {
  line-height: 1.55;
}

.signup-instructions {
  margin-top: 1.1rem;
  padding: 1rem 1.2rem;
  border: 1px solid rgba(31, 58, 95, 0.3);
  border-left: 5px solid #1f3a5f;
  border-radius: 0.7rem;
  background: #edf2f7;
  color: #172d47;
}

.signup-instructions[hidden] { display: none; }
.signup-instructions h3 { margin: 0 0 0.6rem; font-size: clamp(1.25rem, 4vw, 1.55rem); }
.signup-instructions ol { margin: 0; padding-left: 1.5rem; }
.signup-instructions li { padding: 0.18rem 0 0.18rem 0.15rem; line-height: 1.45; }
.signup-instructions li::marker { font-weight: 700; color: #1f3a5f; }
.signup-instructions p { margin: 0.65rem 0 0; }

.account-form,
.account-form label {
  display: grid;
  gap: 0.55rem;
}

.account-form {
  margin-top: 1.2rem;
  gap: 1rem;
}

.account-form label {
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.86rem;
}

.account-form input {
  min-height: 2.8rem;
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 0.45rem;
  padding: 0.68rem 0.75rem;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
}

.account-form .signup-password-confirm[hidden] { display: none; }

.signup-confirmation {
  display: grid;
  gap: 0.8rem;
}

.signup-confirmation[hidden] { display: none; }
.signup-confirmation .signup-password-confirm { margin-bottom: 0.2rem; }
.account-form .signup-age-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  color: var(--ink);
  font-size: 1rem;
}
.account-form .signup-age-choice input {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 1.25rem;
  margin: 0.1rem 0 0;
  padding: 0;
  flex: none;
  accent-color: var(--cover);
}

.account-form.signup-mode #signInButton,
.account-form.signup-mode #resendConfirmationButton,
.account-form.signup-mode #forgotPasswordButton { display: none; }
.account-form.signup-mode #createAccountButton {
  background: var(--cover);
  color: #fffaf0;
}
.signup-confirmation #signupBackButton {
  justify-self: start;
  margin-top: 0.1rem;
  padding: 0;
  min-height: 2rem;
  border: 0;
  background: transparent;
  color: var(--cover);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.18rem;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.account-actions button {
  min-height: 2.8rem;
  padding: 0.7rem 1rem;
  border-radius: 0.45rem;
  background: var(--cover);
  color: #fffaf0;
}

.account-actions .resend-button {
  flex-basis: 100%;
}

.sync-card {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0;
  padding: 1rem;
  border-left: 3px solid var(--gold);
  background: rgba(244, 234, 216, 0.78);
}

.sync-card span,
.account-message {
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.86rem;
}

.account-message {
  margin: 0;
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--cover);
  border-radius: 0.35rem;
  background: #e7f0ee;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.45;
}

.account-message:empty {
  display: none;
}

.account-message[data-tone="error"] {
  border-color: #a82e3e;
  background: #fff0ed;
  color: #78212d;
  font-weight: 700;
}

.signup-email-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-top: 1.2rem;
  padding: 1.2rem;
  border: 2px solid #1f3a5f;
  border-left-width: 7px;
  border-radius: 0.8rem;
  background: #fff4d9;
  box-shadow: 0 8px 24px rgba(31, 58, 95, 0.13);
  color: #172d47;
}

.signup-email-notice[hidden] { display: none; }
.signup-email-notice-mark { font: 700 2rem/1 Arial, sans-serif; }
.signup-email-notice h3 { margin: 0 0 0.45rem; font-size: clamp(1.3rem, 4vw, 1.6rem); }
.signup-email-notice p { margin: 0; line-height: 1.45; overflow-wrap: anywhere; }
.signup-email-notice .signup-email-notice-hint { margin-top: 0.55rem; font-weight: 700; }

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.7rem;
    padding: max(0.65rem, env(safe-area-inset-top)) 0.85rem 0.65rem;
    border-right: 0;
    border-bottom: 1px solid rgba(36, 33, 29, 0.12);
    box-shadow: 0 8px 24px rgba(36, 33, 29, 0.08);
  }

  .brand {
    min-width: 0;
    min-height: 2.75rem;
    padding: 0;
  }

  .brand-mark {
    width: 2.45rem;
  }

  .brand-copy strong { display: none; }

  .nav-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .nav-actions button {
    min-height: 2.7rem;
    padding: 0.55rem 0.45rem;
    white-space: nowrap;
  }

  .template-panel,
  .daily-spark,
  .rail-sync-status {
    display: none;
  }

  .rail > .journal-app-version {
    display: none;
  }

  .book-spread {
    grid-template-columns: 1fr;
  }

  .companion-page {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .companion-page section {
    min-width: 0;
    border-bottom: 0;
    border-right: 1px solid rgba(36, 33, 29, 0.12);
    padding: 0 1rem 0 0;
  }

  .companion-page section:last-child {
    border-right: 0;
    padding-right: 0;
  }
}

@media (max-width: 680px) {
  .rail {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: max(0.55rem, env(safe-area-inset-top)) 0.55rem 0.55rem;
  }

  .brand {
    display: flex;
    justify-self: start;
    gap: 0.4rem;
    min-height: 2.2rem;
    margin-bottom: 0.4rem;
    font-size: 1rem;
  }

  .brand-mark { width: 2rem; height: 2rem; }

  .brand-copy strong { display: block; }

  .title-input {
    min-height: 2.7rem;
    font-size: 1.8rem;
    scroll-margin-top: 11rem;
  }

  .nav-actions {
    width: 100%;
    gap: 0.35rem;
  }

  .nav-actions button {
    min-width: 0;
    min-height: 2.8rem;
    padding: 0.5rem 0.2rem;
    overflow: hidden;
    font-size: 0.78rem;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .stage {
    padding: 0.75rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .page-navigation {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
    padding: 0.7rem;
  }

  .page-navigation-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-navigation-controls select { grid-column: 1 / -1; grid-row: 1; max-width: none; width: 100%; }
  .page-navigation-controls button { min-width: 0; white-space: normal; }

  .topbar-actions select {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .topbar-actions .danger-button {
    grid-column: 1 / -1;
  }

  .title-input {
    width: 100%;
    font-size: 2.15rem;
  }

  .paper-page {
    min-height: calc(100dvh - 10rem);
    padding: 0.95rem 0.8rem 1.2rem 1.8rem;
    border-radius: 0.35rem;
  }

  .paper-page::before {
    left: 1.15rem;
  }

  .paper-header {
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
  }

  .ink-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .ink-tool-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ink-tool-tabs button,
  .ink-tools > button {
    width: 100%;
  }

  .ink-color-label,
  .ink-width-label,
  .stylus-only-label {
    justify-content: center;
  }

  .ink-width-label {
    flex: 1 1 100%;
  }

  .ink-width-label input {
    min-width: 0;
    width: 100%;
  }

  .ink-palette { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .ink-custom-row { align-items: stretch; }
  .ink-color-label { width: 100%; justify-content: flex-start; }
  .rgb-controls { width: 100%; }
  .ink-history-row button { min-width: 0; }

  .writing-toolbar-row,
  .writing-tools,
  .page-font-label {
    align-items: stretch;
  }

  .writing-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .page-font-label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .page-font-label select {
    width: 100%;
    max-width: none;
  }

  .emoji-panel {
    position: fixed;
    top: auto;
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    left: 0.75rem;
    width: auto;
    max-height: min(70dvh, 32rem);
    padding: 1rem;
  }

  .emoji-panel .emoji-option {
    min-height: 3rem;
    font-size: 1.55rem;
  }

  .paper-header input,
  .paper-header select {
    width: 100%;
    min-height: 2.75rem;
  }

  .template-picker {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .template-picker select {
    min-width: 0;
  }

  .template-dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .template-dialog-actions button {
    width: 100%;
  }

  .lined-paper {
    min-height: 58dvh;
    font-size: 1rem;
  }

  .page-canvas {
    min-height: 58dvh;
  }

  .lined-paper[data-journal-font="handwriting"] {
    font-size: 1.3rem;
  }

  .lined-paper[data-journal-font="classic"] {
    font-size: 1.2rem;
  }

  .save-toast {
    right: 1rem;
    bottom: max(0.85rem, env(safe-area-inset-bottom));
    left: 1rem;
    max-width: none;
    text-align: center;
  }

  .paper-actions,
  .backup-actions,
  .restore-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .paper-actions button,
  .backup-actions button,
  .backup-actions .file-button,
  .restore-actions button {
    width: 100%;
    min-height: 2.9rem;
    justify-content: center;
    text-align: center;
  }

  .companion-page {
    grid-template-columns: 1fr;
  }

  .companion-page section {
    border-right: 0;
    border-bottom: 1px solid rgba(36, 33, 29, 0.12);
    padding: 0 0 1rem;
  }

  .history-header {
    align-items: stretch;
    flex-direction: column;
  }

  .history-header button {
    min-height: 2.8rem;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    padding: 1rem;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .account-panel {
    padding: 1rem;
  }

  .account-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .cover-actions {
    display: grid;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .cover-frame {
    min-height: min(37rem, calc(100dvh - 6.5rem));
    padding: 1.8rem;
  }

  .cover-logo {
    top: 3.15rem;
    right: 2.2rem;
    width: 3.8rem;
    height: 3.8rem;
  }

  .cover-frame h1 {
    margin-top: 3.5rem;
    font-size: 3.25rem;
  }

  .cover-frame.photo-cover {
    min-height: 0;
    padding: 1.5rem;
  }

  .cover-frame.photo-cover .cover-logo {
    top: 1.1rem;
    right: 1.2rem;
    width: 3.25rem;
    height: 3.25rem;
  }

  .cover-frame.photo-cover h1 {
    margin-top: 4.9rem;
    margin-bottom: 0.65rem;
    font-size: 2.55rem;
  }

  .cover-frame.photo-cover .cover-name strong { font-size: 1.7rem; }

  .cover-frame.photo-cover .cover-name strong[data-long-name="true"] {
    font-size: 1.25rem;
    overflow-wrap: anywhere;
  }

  .cover-frame.photo-cover .cover-actions {
    right: 1.5rem;
    bottom: 1.5rem;
    left: 1.5rem;
  }

  .cover-frame[data-cover-style="daybreak"] {
    min-height: 0;
    padding: 1.55rem;
  }

  .cover-frame[data-cover-style="daybreak"] h1 {
    margin-top: 5.5rem;
    margin-bottom: 0.7rem;
    font-size: 2.55rem;
  }

  .cover-frame[data-cover-style="daybreak"] .cover-name strong {
    font-size: 1.7rem;
  }

  .cover-frame[data-cover-style="daybreak"] .cover-actions button {
    margin-top: 1.15rem;
  }

  .cover-frame[data-cover-style="unicorn"] h1 {
    top: 21%;
    right: 4%;
    left: 50%;
    margin: 0;
    font-size: 1rem;
  }

  .cover-frame[data-cover-style="unicorn"] .cover-name {
    top: 30%;
    right: 4%;
    left: 49%;
  }

  .cover-frame[data-cover-style="unicorn"] .cover-name span {
    font-size: 1.8rem;
  }

  .cover-frame[data-cover-style="unicorn"] .cover-name strong {
    font-size: 2.3rem;
  }

  .cover-frame[data-cover-style="color-story"] h1 {
    top: 21%;
    right: 4%;
    left: 50%;
    margin: 0;
    font-size: 1rem;
  }

  .cover-frame[data-cover-style="color-story"] .cover-name {
    top: 30%;
    right: 4%;
    left: 49%;
  }

  .cover-frame[data-cover-style="color-story"] .cover-name span {
    font-size: 1.8rem;
  }

  .cover-frame[data-cover-style="color-story"] .cover-name strong {
    font-size: 2.3rem;
  }

  .cover-frame[data-cover-style="island-resolve"] h1 {
    top: 21%;
    right: 4%;
    left: 50%;
    margin: 0;
    font-size: 1rem;
  }

  .cover-frame[data-cover-style="island-resolve"] .cover-name {
    top: 30%;
    right: 4%;
    left: 49%;
  }

  .cover-frame[data-cover-style="island-resolve"] .cover-name span {
    font-size: 1.8rem;
  }

  .cover-frame[data-cover-style="island-resolve"] .cover-name strong {
    font-size: 2.3rem;
  }

  .cover-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 360px) {
  .look-back-filters { grid-template-columns: minmax(0, 1fr); }
  .look-back-filters label:first-child { grid-column: auto; }
  .writing-tools { grid-template-columns: minmax(0, 1fr); }
  .ink-palette { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cover-frame[data-cover-style="unicorn"] .cover-name span { font-size: 1.5rem; }
  .cover-frame[data-cover-style="unicorn"] .cover-name strong { font-size: 2.1rem; }
  .cover-frame[data-cover-style="color-story"] .cover-name span { font-size: 1.5rem; }
  .cover-frame[data-cover-style="color-story"] .cover-name strong { font-size: 2.1rem; }
  .cover-frame[data-cover-style="island-resolve"] .cover-name span { font-size: 1.5rem; }
  .cover-frame[data-cover-style="island-resolve"] .cover-name strong { font-size: 2.1rem; }
}

.sync-card[data-tone="issue"] {
  border: 1px solid #8c5651;
  background: #fcf0eb;
  color: #542b28;
}
#syncHelpButton { min-height: 2.75rem; }
#syncHelpButton[hidden] { display: none; }
#syncBackupButton[hidden] { display: none; }
