/* Travel Diary. A book: a serif for the writing, photos set like prints,
   and shimmering ocean blue (Mike, 2026-10-09) -- deep sea to bright aqua,
   with a slow glint across the buttons like light on water. Distinct from
   Memos (amber) and the landlording apps (green) on the home screen. */

:root {
  --paper: #edf5f9;
  --page: #fffefb;
  --ink: #1f2a33;
  --ink-soft: #566573;
  --ink-faint: #8c9aa6;
  --line: #d5e4ec;
  --accent: #0e6ba8;
  --accent-ink: #ffffff;
  --accent-soft: #d8ecf6;
  --mark: #ffe28a;
  --ocean: linear-gradient(120deg, #0a3a63 0%, #0e6ba8 45%, #1fa6cf 80%, #3cc6d9 100%);
  --sea-glint: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .38) 50%, transparent 70%);
  --danger: #b3261e;
  --ok: #2e7d4f;
  --warn: #9a6200;
  --shadow: 0 1px 2px rgba(10, 50, 80, .10), 0 6px 18px rgba(10, 50, 80, .10);
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1822;
    --page: #12222e;
    --ink: #e4eef4;
    --ink-soft: #a6b9c6;
    --ink-faint: #6f8594;
    --line: #213645;
    --accent: #5cc4e6;
    --accent-ink: #06202f;
    --accent-soft: #163447;
    --mark: #6b5510;
    --ocean: linear-gradient(120deg, #0d4f80 0%, #1785c2 45%, #2fb5da 80%, #5fd6e4 100%);
    --danger: #ff8a80;
    --ok: #7bd29c;
    --warn: #f0c060;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: linear-gradient(180deg, var(--accent-soft) 0, var(--paper) 340px);
  background-repeat: no-repeat;
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* --- Buttons and fields -------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--page); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--ocean); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: none; color: var(--ink); cursor: pointer;
}
.icon-btn:active, .btn:active { transform: scale(.97); }

.field-label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.text-input {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--page);
}
.text-input:focus, .prose-input:focus, .caption-input:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.error-line { color: var(--danger); margin: 12px 0 0; }

/* --- Passcode screen ------------------------------------------------------------ */

.login { max-width: 360px; margin: 12vh auto 0; padding: 0 20px; text-align: center; }
.login form { text-align: left; }
.login-icon { margin: 0 auto 8px; border-radius: 18px; }
.login h1 { font: 600 28px/1.2 var(--serif); margin: 0 0 12px; }
.trust-row { display: flex; gap: 10px; align-items: center; margin: 16px 0 20px; color: var(--ink-soft); }
.trust-row input { width: 20px; height: 20px; accent-color: var(--accent); }

/* --- Top bar --------------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  min-height: 56px; padding: env(safe-area-inset-top) 8px 0;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid transparent;
  border-image: var(--ocean) 1;
}
.topbar-title {
  flex: 1; min-width: 0; margin: 0 8px;
  font: 600 19px/1.2 var(--serif);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sync-chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--page); font-size: 13px; color: var(--ink-soft); cursor: pointer;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.sync-chip[data-state="synced"] .sync-dot { background: var(--ok); }
.sync-chip[data-state="syncing"] .sync-dot { background: var(--accent); animation: pulse 1s infinite alternate; }
.sync-chip[data-state="offline"] .sync-dot,
.sync-chip[data-state="local"] .sync-dot { background: var(--warn); }
.sync-chip[data-state="error"] .sync-dot { background: var(--danger); }
@keyframes pulse { to { opacity: .3; } }
@media (max-width: 330px) { .sync-text { display: none; } }

.view { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

/* --- Home: the shelf of trips ------------------------------------------------------ */

.shelf { max-width: 720px; margin: 0 auto; padding: 18px 16px; display: grid; gap: 16px; }
.trip-card {
  display: block; overflow: hidden; border-radius: var(--radius);
  background: var(--page); box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
}
.trip-cover { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; background: var(--accent-soft); }
.trip-cover.blank { display: grid; place-items: center; background: var(--ocean); color: #fff; font: 600 40px var(--serif); }
.trip-meta { padding: 12px 16px 14px; }
.trip-name { margin: 0; font: 600 21px/1.25 var(--serif); }
.trip-sub { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }

.empty {
  max-width: 420px; margin: 12vh auto 0; padding: 0 24px; text-align: center; color: var(--ink-soft);
}
.empty h2 { font: 600 24px/1.3 var(--serif); color: var(--ink); margin: 0 0 8px; }

.fab {
  position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  display: inline-flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 22px; border: 0; border-radius: 999px;
  background: var(--ocean); color: #fff;
  font-weight: 700; font-size: 16px; box-shadow: var(--shadow), 0 6px 20px rgba(14, 107, 168, .35);
  cursor: pointer;
}

/* --- The book (phone's reading view and the family share page) ---------------------- */

.book { max-width: 680px; margin: 0 auto; padding: 8px 0 40px; }
.title-page { padding: 28px 22px 8px; text-align: center; }
.cover {
  width: 100%; max-height: 62vh; object-fit: cover;
  border-radius: 4px; box-shadow: var(--shadow); margin-bottom: 22px;
}
.book-title { margin: 0; font: 600 34px/1.15 var(--serif); letter-spacing: -.01em; }
.book-sub { margin: 8px 0 0; color: var(--ink-soft); font: italic 18px/1.4 var(--serif); }

.chapter {
  position: relative;
  margin: 26px 12px 0; padding: 26px 20px 22px;
  background: var(--page); border-radius: 6px; box-shadow: var(--shadow);
}
.chapter-head { margin-bottom: 14px; padding-right: 36px; }
.chapter-kicker {
  margin: 0; color: var(--accent);
  background: var(--ocean); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; width: fit-content;
  font: 700 12px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase;
}
.chapter-title { margin: 6px 0 0; font: 600 25px/1.25 var(--serif); }
.chapter-place { margin: 4px 0 0; color: var(--ink-soft); font: italic 16px/1.4 var(--serif); }
.chapter-edit { position: absolute; top: 14px; right: 10px; color: var(--ink-soft); }

.prose {
  margin: 0 0 1em; font: 19px/1.65 var(--serif);
  white-space: pre-line; overflow-wrap: anywhere;
}
.chapter .prose:first-of-type::first-letter {
  float: left; margin: 6px 8px 0 0;
  font: 600 3.1em/0.8 var(--serif); color: var(--accent);
}

.photo-row { display: grid; gap: 8px; margin: 18px -8px 20px; }
.photo-row.n2 { grid-template-columns: 1fr 1fr; }
.photo { margin: 0; }
.photo img {
  width: 100%; border-radius: 3px; background: var(--accent-soft);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.photo-row.n2 .photo img { aspect-ratio: 1; object-fit: cover; }
.photo figcaption {
  margin-top: 6px; padding: 0 4px; text-align: center;
  color: var(--ink-soft); font: italic 15px/1.4 var(--serif);
}
.photo.missing img { aspect-ratio: 4 / 3; }

.empty-note { text-align: center; color: var(--ink-soft); font: italic 18px var(--serif); margin: 40px 20px; }
.colophon { text-align: center; color: var(--ink-faint); font-size: 13px; margin: 36px 0 0; }

@media (min-width: 700px) {
  .chapter { margin: 32px 0 0; padding: 40px 48px 32px; }
  .photo-row { margin: 22px -20px 24px; }
}

/* --- Writing a day ------------------------------------------------------------------- */

.editor { max-width: 680px; margin: 0 auto; padding: 12px 14px; }
.editor-fields { display: grid; gap: 0; }
.editor-fields .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.title-input { font: 600 22px/1.3 var(--serif); }

.blocks { margin-top: 18px; display: grid; gap: 14px; }
.block {
  position: relative; background: var(--page); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px;
}
.prose-input {
  display: block; width: 100%; min-height: 140px; resize: none; overflow: hidden;
  padding: 8px 6px; border: 0; border-radius: 6px; background: transparent;
  font: 19px/1.6 var(--serif);
}
.block-photo img { width: 100%; border-radius: 6px; }
.caption-input {
  width: 100%; margin-top: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
  font: italic 16px/1.4 var(--serif);
}
.block-tools { display: flex; justify-content: flex-end; gap: 2px; margin-top: 4px; }
.block-tools .icon-btn { width: 40px; height: 40px; color: var(--ink-soft); }
.block-tools .icon-btn:disabled { opacity: .3; }

.add-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 10px; justify-content: center;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.add-bar .btn { flex: 1; max-width: 220px; }
.save-note { text-align: center; color: var(--ink-faint); font-size: 13px; margin: 18px 0 0; }

/* --- Sheets, toasts --------------------------------------------------------------------- */

.sheet {
  width: min(520px, 100%); max-width: 100%; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 18px 18px 0 0;
  background: var(--page); color: var(--ink);
}
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet-body { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 6px; font: 600 21px/1.3 var(--serif); }
.sheet p { color: var(--ink-soft); margin: 6px 0 12px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 16px; }
.menu-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.menu-list button {
  width: 100%; min-height: 52px; padding: 0 12px; text-align: left;
  border: 0; border-radius: 10px; background: none; font-size: 17px; cursor: pointer;
}
.menu-list button:active { background: var(--accent-soft); }
.menu-list .danger { color: var(--danger); }
.share-link {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); font-size: 14px;
}
.cover-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 40vh; overflow: auto; }
.cover-pick button { padding: 0; border: 3px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
.cover-pick button[aria-pressed="true"] { border-color: var(--accent); }
.cover-pick img { aspect-ratio: 1; object-fit: cover; border-radius: 3px; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: 10px;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow);
}
.toast button { border: 0; background: none; color: var(--accent-soft); font-weight: 700; cursor: pointer; }

/* --- The shimmer: deep sea drifting to aqua, and a glint of light passing over -- */

.btn.primary, .fab, .trip-cover.blank {
  overflow: hidden; isolation: isolate;
  background-size: 220% 220%;
  animation: tide 9s ease-in-out infinite;
}
/* Holds the glint inside the button. Not .fab: it is already position: fixed,
   which does the same job, and must stay pinned to the corner. */
.btn.primary, .trip-cover.blank { position: relative; }
.btn.primary::after, .fab::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--sea-glint);
  transform: translateX(-130%);
  animation: glint 6s ease-in-out infinite;
}
.btn.primary > *, .fab > * { position: relative; }
.chapter .prose:first-of-type::first-letter {
  background: var(--ocean); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
@keyframes tide { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes glint { 0%, 55% { transform: translateX(-130%); } 100% { transform: translateX(130%); } }
@media (prefers-reduced-motion: reduce) {
  .btn.primary, .fab, .trip-cover.blank, .btn.primary::after, .fab::after { animation: none; }
}

/* --- Search: the same box, list and highlighting as Memos --------------------- */

.searchbar { position: relative; margin: 0; }
.search-input { font-size: 17px; padding-right: 44px; }
/* Sits inside the right-hand end of the box: the only thing that empties it. */
.clear-search {
  position: absolute; top: 1px; bottom: 1px; right: 1px; width: 44px;
  border: 0; border-radius: 0 10px 10px 0; background: transparent;
  color: var(--ink-faint); font-size: 24px; line-height: 1; cursor: pointer;
}
.result-count { margin: 0 2px; color: var(--ink-faint); font-size: 14px; }
.result-list {
  list-style: none; margin: 0; padding: 0; overflow: hidden;
  background: var(--page); border: 1px solid var(--line); border-radius: var(--radius);
}
.result-list li + li { border-top: 1px solid var(--line); }
.result-row { display: block; padding: 12px 14px; color: inherit; text-decoration: none; }
.result-row:active, .result-row:focus-visible { background: var(--accent-soft); }
.row-top { display: flex; align-items: baseline; gap: 10px; }
.row-title {
  flex: 1; min-width: 0; font: 600 17px/1.3 var(--serif);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-date { flex: 0 0 auto; color: var(--ink-faint); font-size: 13px; }
.row-snippet {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-top: 3px; color: var(--ink-soft); font: 15px/1.45 var(--serif);
}
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
mark.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.empty-results { color: var(--ink-soft); text-align: center; padding: 30px 10px; }
.more-wrap { text-align: center; margin: 4px 0; }

/* Opening a day from a search: how many matches, Next match, Clear. */
.find-bar {
  position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 9;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
  margin: 0; padding: 8px 14px; font-size: 14px; color: var(--ink-soft);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.find-bar .find-count { flex: 1 1 100%; }
.find-bar .btn { min-height: 38px; padding: 0 14px; font-size: 14px; }
@media (min-width: 480px) { .find-bar .find-count { flex: 1 1 auto; } }

.day-input { max-width: 220px; }
