:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111111;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.45);
  --line: rgba(255, 255, 255, 0.12);
  --cell: #1a1a1a;
  --cell-full: #3a3a3a;
  --header: rgba(255, 255, 255, 0.85);
  --topnav-bg: #111111;
  --theme-color: #111111;
  /* Match mid-head: 12px type + 6+4 padding */
  --title-bar-h: calc(12px * 1.3 + 10px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --third: calc(100vw / 3);
  /* Remembered purple (local experiments only — do NOT ship): #70a0ff */
  --accent-milka-purple: #70a0ff;
  /* Production today accent: old DOS / CGA green */
  --accent-milka: #55ff55;
}

/* Lightest neutral grey that still keeps white text readable */
html[data-theme="light"] {
  color-scheme: dark;
  --bg: #6e6e6e;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.7);
  --line: rgba(255, 255, 255, 0.22);
  --cell: #636363;
  --cell-full: #555555;
  --header: #ffffff;
  --topnav-bg: #6e6e6e;
  --theme-color: #6e6e6e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

/* —— Topnav (all zoom levels) ——
   Right controls sit in the mid-view third column:
   list-mode inset from its left, theme from its right, SIGN IN/OUT centered. */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: calc(var(--safe-top) + var(--title-bar-h));
  padding-top: var(--safe-top);
  padding-left: 0;
  padding-right: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--topnav-bg);
  border-bottom: 1px solid var(--line);
  color: #ffffff;
  box-sizing: border-box;
}

.topnav-main {
  flex: 1 1 auto;
  width: calc(var(--third) * 2);
  max-width: calc(var(--third) * 2);
  min-width: 0;
  display: flex;
  align-items: center;
  padding-left: 8px;
  box-sizing: border-box;
}

.topnav-third {
  flex: 0 0 var(--third);
  width: var(--third);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: var(--title-bar-h) minmax(0, 1fr) var(--title-bar-h);
  align-items: center;
  /* Match mid-head horizontal inset (8px) from the third-column edges */
  padding-left: 8px;
  padding-right: 8px;
}

.topnav-auth-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 100%;
}

.auth-guest,
.auth-user {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.auth-guest[hidden],
.auth-user[hidden],
.auth-btn[hidden] {
  display: none !important;
}

.auth-email {
  width: 100%;
  height: calc(var(--title-bar-h) - 6px);
  margin: 0;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 12px;
  outline: none;
  box-shadow: none;
}

.auth-email::placeholder {
  color: var(--muted);
}

.auth-email.auth-email-invalid {
  color: #ffb4b4;
}

.auth-email-label {
  display: block;
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-btn {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  height: calc(var(--title-bar-h) - 6px);
  margin: 0;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.auth-btn.auth-btn-muted,
.auth-btn:disabled {
  color: var(--muted);
  cursor: default;
}

.auth-code-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.auth-code-row[hidden] {
  display: none !important;
}

.auth-code {
  flex: 1 1 auto;
  min-width: 0;
  height: calc(var(--title-bar-h) - 6px);
  margin: 0;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.12em;
  outline: none;
}

/* List mode: empty circle = checkboxes, small filled circle = bullets */
.list-mode-toggle {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  width: var(--title-bar-h);
  height: var(--title-bar-h);
  border: 0;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.list-mode-icon {
  display: block;
  box-sizing: border-box;
  border-radius: 50%;
  pointer-events: none;
}

/* Match theme-toggle drawn circle exactly (16px outer diameter) */
.list-mode-toggle[data-mode="check"] .list-mode-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  border: 1.5px solid #ffffff;
  background: transparent;
  box-sizing: border-box;
}

.list-mode-toggle[data-mode="bullet"] .list-mode-icon {
  width: 8px;
  height: 8px;
  min-width: 8px;
  min-height: 8px;
  border: 0;
  background: #ffffff;
}

.theme-toggle {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  width: var(--title-bar-h);
  height: var(--title-bar-h);
  border: 0;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-toggle-img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
  pointer-events: none;
  /* Force pure white — plain invert(1) on the navy asset looked yellowish */
  filter: brightness(0) invert(1);
}

html[data-theme="light"] .theme-toggle-img {
  transform: scaleX(-1);
}

#app {
  height: 100%;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.view {
  position: absolute;
  inset: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-top: calc(var(--safe-top) + var(--title-bar-h));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  color: var(--fg);
  transform: translate3d(0, 0, 0);
  z-index: 1;
  visibility: hidden;
  pointer-events: none;
}

.view.is-current {
  visibility: visible;
  pointer-events: auto;
  z-index: 3;
}

.view.is-under {
  visibility: visible;
  pointer-events: none;
  z-index: 2;
}

.view.is-dragging {
  overflow: hidden;
}

.view.slide-animating {
  transition: transform 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
}



.edge-zone {
  display: none;
}

/* —— Month —— */
/* Portrait: pairs stack (one month under the next). Landscape: two months per row. */
.month-pair {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  box-sizing: border-box;
}

.month-block {
  padding: 12px 8px 28px;
  box-sizing: border-box;
  /* Portrait-wide cap — same day-cell size in landscape; two fit side by side */
  width: 100%;
  max-width: var(--portrait-w, 100%);
  margin-left: auto;
  margin-right: auto;
}

@media (orientation: landscape) {
  .month-pair {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 8px;
    padding: 0 6px 8px;
  }

  .month-pair .month-block {
    flex: 0 1 var(--portrait-w, 50%);
    width: calc(50% - 4px);
    max-width: var(--portrait-w, calc(50% - 4px));
    margin-left: 0;
    margin-right: 0;
    padding-bottom: 16px;
  }
}

.month-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 8px 4px 12px;
  color: var(--fg);
}

.dow-row,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.dow-row {
  margin-bottom: 6px;
}

.dow {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
}

.m-cell {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--cell);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #ffffff;
  user-select: none;
  cursor: pointer;
}

.m-cell.empty {
  background: transparent;
  border-color: transparent;
}

.m-cell.has {
  background: var(--cell-full);
  font-weight: 600;
}

.m-cell.today {
  color: var(--accent-milka);
  font-weight: 700;
  outline: 1px solid rgba(85, 255, 85, 0.75);
}

.m-cell.is-selected {
  outline: 2px solid #ffffff;
  background: #2a2a2a;
}

html[data-theme="light"] .m-cell.is-selected {
  background: #555555;
}

/* —— Mid —— */
#view-mid {
  overflow-x: hidden;
}

.mid-grid {
  display: grid;
  grid-template-columns: repeat(3, var(--third));
  width: 100vw;
}

.mid-cell {
  width: var(--third);
  height: var(--third);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.mid-cell.has {
  background: #161616;
}

html[data-theme="light"] .mid-cell.has {
  background: #5c5c5c;
}

.mid-cell.is-selected {
  outline: 2px solid #ffffff;
  outline-offset: -2px;
  background: #222222;
  z-index: 1;
}

html[data-theme="light"] .mid-cell.is-selected {
  background: #505050;
}

.mid-cell.is-selected .mid-head {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.mid-cell.is-selected .mid-head.today {
  color: var(--accent-milka);
}

html[data-theme="light"] .mid-cell.is-selected .mid-head {
  background: rgba(0, 0, 0, 0.18);
}

.mid-head {
  flex: 0 0 auto;
  height: var(--title-bar-h);
  box-sizing: border-box;
  padding: 6px 8px 4px;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--header);
  /* Slightly lifted strip so the date bar doesn’t blend into the text area */
  background: rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid var(--line);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
}

html[data-theme="light"] .mid-head {
  background: rgba(0, 0, 0, 0.14);
}

.mid-head.today {
  color: var(--accent-milka);
  font-weight: 700;
}

.mid-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 0;
  /* Keep body on the cell background — contrast comes from the head strip */
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 16px;
  line-height: 1.3;
  padding: 4px 6px;
  outline: none;
  overflow: hidden;
  /* Preview only — no caret / keyboard */
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
}

.mid-preview {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  pointer-events: none;
}

/* —— Entry lists (checkbox / bullet) —— */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.entry-row {
  position: relative;
  display: block;
  width: 100%;
}

.entry-mark {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  left: 0;
  top: 1px;
  z-index: 1;
  margin: 0;
  padding: 0;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.entry-mark::before {
  content: "";
  display: block;
  box-sizing: border-box;
  border-radius: 50%;
}

.entry-mark[data-mode="check"]::before {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--muted);
  background: transparent;
  box-shadow: none;
}

/* Checked: same grey ring as unchecked + same-grey center dot (not a bright fill) */
.entry-mark[data-mode="check"].is-checked::before {
  border: 1.5px solid var(--muted);
  background: radial-gradient(
    circle at center,
    var(--muted) 0 3.5px,
    transparent 3.6px
  );
  box-shadow: none;
}

.entry-mark[data-mode="bullet"]::before {
  width: 7px;
  height: 7px;
  border: 0;
  background: var(--muted);
}

.entry-mark[data-mode="bullet"] {
  cursor: default;
}

.entry-text {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 2px 0;
  border: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  field-sizing: content;
  min-height: calc(16px * 1.35);
  /* First line clears the mark; wrapped lines stay flush left (not indented) */
  text-indent: 26px;
}

.entry-text::placeholder {
  color: var(--muted);
}

.entry-row.is-plain .entry-text {
  text-indent: 0;
}

.entry-row.is-done .entry-text {
  color: var(--muted);
  text-decoration: line-through;
  /* Same grey as unchecked — only the strike marks done */
  opacity: 1;
}

.entry-list-compact .entry-row.is-plain .entry-text,
.day-entry-list .entry-row.is-plain .entry-text {
  text-indent: 0;
}

.entry-list-compact .entry-mark {
  width: 18px;
  height: 18px;
  top: 1px;
}

.entry-list-compact .entry-mark[data-mode="check"]::before {
  width: 14px;
  height: 14px;
}

.entry-list-compact .entry-text {
  font-size: 15px;
  min-height: calc(15px * 1.35);
  text-indent: 22px;
}

/* —— Day —— */
#view-day {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Content under fixed topnav — pages abut datebox-to-datebox (paper scroll) */
.day-rail {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

.day-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  will-change: transform;
}

.day-page-current {
  z-index: 2;
}

.day-page-peer {
  z-index: 1;
  visibility: hidden;
  pointer-events: none;
}

.day-page-peer.is-active {
  visibility: visible;
}

.day-page.slide-animating {
  transition: transform 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Scrub-only cue on incoming page edge (simple ↑ / ↓ glyphs) */
.day-scrub-arrow {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
  height: var(--title-bar-h);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

/* Prev from above → ↓ in a datebox-tall band at the bottom (tip mirrors ↑ inset) */
.day-scrub-arrow.is-from-above {
  top: auto;
  bottom: 0;
}

/* Next from below → ↑ centered in the date box */
.day-scrub-arrow.is-from-below {
  top: 0;
  bottom: auto;
}

.day-page-header {
  flex: 0 0 auto;
  height: var(--title-bar-h);
  box-sizing: border-box;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: #ffffff;
  /* Same strip shade as mid-view date bar */
  background: rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid var(--line);
  user-select: none;
  display: flex;
  align-items: center;
}

.day-page-header.today {
  color: var(--accent-milka);
  font-weight: 700;
}

html[data-theme="light"] .day-page-header {
  background: rgba(0, 0, 0, 0.14);
}

.day-entry-list {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  padding: 12px 16px 24px;
  box-sizing: border-box;
}

.day-entry-list .entry-mark {
  width: 24px;
  height: 24px;
  top: 4px;
}

.day-entry-list .entry-mark[data-mode="check"]::before {
  width: 18px;
  height: 18px;
}

.day-entry-list .entry-text {
  font-size: 16px;
  line-height: 1.45;
  padding: 4px 0;
  text-indent: 28px;
}

/* —— Jurnal topnav: centered goals + density —— */
.topnav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
}

.topnav-main {
  width: auto;
  max-width: none;
  grid-column: 1;
}

.goals-toggle {
  grid-column: 2;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  width: var(--title-bar-h);
  height: var(--title-bar-h);
  border: 0;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  justify-self: center;
  opacity: 0.4;
}

.goals-toggle.is-active {
  opacity: 1;
}

.goals-toggle-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  overflow: visible;
}

.topnav-third {
  grid-column: 3;
  justify-self: end;
  width: var(--third);
  max-width: 100%;
}

.density-toggle {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  width: var(--title-bar-h);
  height: var(--title-bar-h);
  border: 0;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Same idle grey as .goals-toggle */
  opacity: 0.4;
  transition: opacity 0.12s ease;
}

/* Fully lit only on the journal (day) page */
.density-toggle.is-active {
  opacity: 1;
  cursor: pointer;
}

.density-toggle:not(.is-active) {
  cursor: default;
  pointer-events: none;
}

/* Off journal: one flat grey — don't stack ring/dot dimming on button opacity */
.density-toggle:not(.is-active) .density-ring,
.density-toggle:not(.is-active) .density-dot {
  opacity: 1;
}

.density-toggle-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  overflow: visible;
}

/* On journal: both shapes visible; the inactive mode shape is greyed. */
.density-ring,
.density-dot {
  opacity: 1;
  transition: opacity 0.12s ease;
}

.density-toggle.is-active[data-density="expanded"] .density-dot,
.density-toggle.is-active[data-density="compact"] .density-ring {
  opacity: 0.4;
}

/* Goals floating preview — fixed editable overlay (pre-shell, working editable state) */
.goals-preview {
  position: fixed;
  z-index: 45;
  top: calc(var(--safe-top) + var(--title-bar-h) + 8px);
  right: 8px;
  left: auto;
  transform: translate3d(0, 0, 0);
  isolation: isolate;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  width: 40vw;
  height: auto;
  min-width: 144px;
  min-height: 44px;
  max-width: 320px;
  max-height: var(--goals-preview-max-h, 40vh);
  box-sizing: border-box;
  margin: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0;
  resize: none;
  overflow: hidden;
  background: #2a2a2a;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  color: #ffffff;
  font-size: clamp(12px, 3vw, 20px);
  font-family: inherit;
  font-weight: 700;
  line-height: 1.15;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  caret-color: #ffffff;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
  text-transform: uppercase;
  pointer-events: auto;
  -webkit-user-select: text;
  user-select: text;
  field-sizing: content;
}

html[data-theme="light"] .goals-preview {
  background: #4a4a4a;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color: #ffffff;
}

.goals-preview.is-off,
.goals-preview[hidden] {
  display: none !important;
}

.goals-preview::placeholder {
  color: rgba(255, 255, 255, 0.55);
  opacity: 1;
  font-weight: 600;
  text-transform: uppercase;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.55);
}

/* Journal feed */
#view-day {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.journal-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background: var(--bg);
}

.journal-day {
  display: flex;
  flex-direction: column;
  /* Lifted shade on page bg — date + text share one panel (same idea as dark) */
  background: rgba(255, 255, 255, 0.07);
  /* Line between days only — not between a date and its own text */
  border-top: 1px solid var(--line);
}

.journal-day:first-child {
  border-top: 0;
}

html[data-theme="light"] .journal-day {
  /* Lighter grey panel on #6e6e6e — not the dark mid-head strip */
  background: rgba(255, 255, 255, 0.14);
}

.journal-day-header {
  position: sticky;
  top: 0;
  z-index: 2;
  /* Sticky date: 75% page bg — readable, text still rolls underneath */
  background: color-mix(in srgb, var(--bg) 75%, transparent) !important;
  border-bottom: 0;
}

html[data-theme="light"] .journal-day-header {
  background: color-mix(in srgb, var(--bg) 75%, transparent) !important;
}

/* Compact: empty dates muted; dates with text clearly highlighted */
html[data-density="compact"] .journal-day-header {
  color: var(--muted);
  font-weight: 600;
  border-bottom: 0;
}

html[data-density="compact"] .journal-day-header.has-content {
  color: #ffffff;
  font-weight: 700;
}

/* Compact: today stays DOS green whether or not it has text */
html[data-density="compact"] .journal-day-header.today,
html[data-density="compact"] .journal-day-header.today.has-content {
  color: var(--accent-milka);
  font-weight: 700;
}

.journal-day-body {
  padding: 0 16px 12px;
  box-sizing: border-box;
  background: transparent;
}

.journal-day-field {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 2px 0 8px;
  border: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  outline: none;
  min-height: calc(16px * 1.45);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  /* Grow to full text in Expanded; JS caps at 10 pages */
  field-sizing: content;
}

/* Expanded: never clamp visible day text to a single preview line */
html[data-density="expanded"] .journal-day:not(.is-day-closed) .journal-day-field {
  overflow: hidden;
}

.journal-day-field::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* Global compact hides bodies — unless this day was individually expanded */
html[data-density="compact"] .journal-day-body {
  display: none !important;
}

html[data-density="compact"] .journal-day.is-day-open .journal-day-body {
  display: block !important;
}

/* Global expanded shows bodies — unless this day was individually collapsed */
html[data-density="expanded"] .journal-day.is-day-closed .journal-day-body {
  display: none !important;
}

/* Goals full page — fixed poster, no scroll ever */
.view-goals {
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}

.goals-editor {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  margin: 0;
  padding: 12px 16px;
  border: 0;
  resize: none;
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  /* Base fallback; JS sets font-size from preview font/width ratio */
  font-size: 7.5vw;
  font-weight: 700;
  line-height: 1.15;
  outline: none;
  box-sizing: border-box;
  /* Poster: no internal scroll chrome */
  scrollbar-width: none;
  text-transform: uppercase;
  caret-color: #ffffff;
}

.goals-editor::placeholder {
  color: rgba(255, 255, 255, 0.55);
  opacity: 1;
  font-weight: 600;
  text-transform: uppercase;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.55);
}

.goals-editor::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.goals-editor:read-only {
  opacity: 0.95;
}

/* —— Topics-style confirm sheet (sign out, etc.) —— */
.confirm-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(0, 0, 0, 0.45);
  -webkit-tap-highlight-color: transparent;
}

.confirm-backdrop.is-open {
  display: block;
}

.confirm-sheet {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 270;
  max-width: 360px;
  margin: 0 auto;
  padding: 20px 16px 16px;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  border-radius: 14px;
  background: #e8e8e8;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.confirm-sheet.is-open {
  display: flex;
}

html[data-theme="dark"] .confirm-sheet {
  background: #2c3034;
}

.confirm-title {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #222;
}

html[data-theme="dark"] .confirm-title {
  color: #f0f0f0;
}

.confirm-msg {
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
  color: #555;
  padding: 0 4px 4px;
}

html[data-theme="dark"] .confirm-msg {
  color: rgba(255, 255, 255, 0.65);
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.confirm-actions button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 14px 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.confirm-actions button:active {
  filter: brightness(0.96);
}

.confirm-actions .confirm-cancel {
  background: #c8c8c8;
  color: #333;
}

html[data-theme="dark"] .confirm-actions .confirm-cancel {
  background: #4a4e52;
  color: #eee;
}

.confirm-actions .confirm-ok {
  background: #6b6b6b;
  color: #fff;
}

/* Topics: sign-out uses YES green; delete stays the only red */
.confirm-actions .confirm-ok.is-yes {
  background: #58b97d;
  color: #fff;
}

.confirm-actions .confirm-ok.is-danger {
  background: #b91c1c;
  color: #fff;
}
