/* Notebook: paper-toned, calm, modern. One accent (clay). */
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --paper: #f3ede2;        /* warm off-white, leaning beige */
  --surface: #faf7f1;
  --surface-2: #efe8dc;
  --ink: #2b2620;
  --ink-soft: #5b5248;
  --muted: #968b7d;
  --hairline: #e6ddcf;
  --accent: #b4705a;       /* clay */
  --accent-soft: #f0dfd6;
  --accent-ink: #fffaf6;
  --danger: #a94b3a;
  --shadow: 0 1px 2px rgb(74 52 30 / .05), 0 6px 24px -8px rgb(74 52 30 / .10);
  --radius: 22px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-h: 76px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f1c18; --surface: #282420; --surface-2: #322d27; --ink: #f1e9dd; --ink-soft: #cfc4b5;
    --muted: #9a8f82; --hairline: #3a342d; --accent: #d79478; --accent-soft: #3d2d26; --accent-ink: #1f1c18;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px -10px rgb(0 0 0 / .5);
  }
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0 auto; max-width: 620px; color: var(--ink); background: var(--paper);
  font: 400 16.5px/1.55 var(--sans); font-feature-settings: "cv11", "ss01";
  padding: env(safe-area-inset-top) 20px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, .serif { font-family: var(--serif); font-optical-sizing: auto; font-weight: 500; letter-spacing: -.01em; }
h1 { font-size: 2rem; line-height: 1.15; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 10px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- surfaces ---- */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 20px; margin: 14px 0;
  box-shadow: var(--shadow); animation: rise .35s ease both;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* ---- day header ---- */
.day-head { display: flex; align-items: center; gap: 4px; padding: 28px 0 10px; }
.date-label { flex: 1; text-align: center; position: relative; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
#date-title { font-family: var(--serif); font-size: 1.85rem; font-weight: 500; line-height: 1.2; }
#date-sub { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
#date-pick { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.icon { width: 44px; height: 44px; border-radius: 50%; font-size: 1.5rem; line-height: 1; color: var(--muted); display: grid; place-items: center; transition: background .2s, color .2s; }
.icon:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon:disabled { opacity: .25; cursor: default; }
.icon.small { width: 30px; height: 30px; font-size: 1.05rem; }

/* ---- mood / energy ---- */
.scale-block + .scale-block { margin-top: 18px; }
.scale-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.scale-label { font-weight: 550; color: var(--ink-soft); font-size: .95rem; }
.scale-val { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.scale { display: flex; justify-content: space-between; align-items: center; position: relative; padding: 4px 2px; }
.scale::before { content: ""; position: absolute; left: 14px; right: 14px; top: 50%; height: 2px; background: var(--hairline); border-radius: 2px; }
.scale button {
  position: relative; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: .72rem; font-weight: 600; color: transparent; font-variant-numeric: tabular-nums;
}
.scale button::before {
  content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--hairline); transition: all .22s cubic-bezier(.3,1.4,.5,1);
}
.scale button span { position: relative; }
.scale button.on::before { background: var(--accent-soft); border-color: var(--accent-soft); }
.scale button[aria-checked="true"] { color: var(--accent-ink); }
.scale button[aria-checked="true"]::before { width: 28px; height: 28px; background: var(--accent); border-color: var(--accent); }
.scale button:active::before { transform: scale(.85); }

/* ---- gratitude ---- */
.gratitude { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: g; }
.gratitude li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--hairline); animation: rise .3s ease both; }
.gratitude li::before { counter-increment: g; content: counter(g); font-family: var(--serif); font-style: italic; color: var(--accent); width: 1.2em; flex: none; }
.gratitude li span { flex: 1; }
.inline-form { display: flex; gap: 8px; }

/* ---- inputs ---- */
.field, .inline-form input, input[type="password"], select, input[type="date"].field {
  width: 100%; border: 1px solid transparent; background: var(--surface-2); border-radius: 14px; padding: 12px 14px; outline: none;
  transition: border-color .2s, background .2s;
}
.field:focus, .inline-form input:focus, input[type="password"]:focus, select:focus { border-color: var(--accent); background: var(--surface); }
textarea#text {
  width: 100%; border: 0; background: transparent; resize: none; outline: none; padding: 0; min-height: 200px;
  font-size: 1.05rem; line-height: 1.75; color: var(--ink);
}
textarea#text::placeholder, input::placeholder { color: var(--muted); }
.btn {
  background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 0 20px; min-height: 48px; font-weight: 600;
  transition: transform .12s, filter .2s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.97); }
.btn.round { width: 48px; padding: 0; font-size: 1.4rem; flex: none; }
.btn.quiet { background: var(--surface-2); color: var(--ink); }
.pill {
  background: var(--accent-soft); color: var(--accent); padding: 8px 14px; border-radius: 999px; font-size: .86rem; font-weight: 600; cursor: pointer;
  transition: transform .12s;
}
.pill:active { transform: scale(.96); }

/* ---- photos ---- */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { aspect-ratio: 1; overflow: hidden; border-radius: 14px; background: var(--surface-2); animation: rise .3s ease both; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.thumb:hover img { transform: scale(1.03); }

/* ---- empty states ---- */
.empty { text-align: center; padding: 18px 8px 6px; color: var(--muted); }
.empty .serif { display: block; font-style: italic; font-size: 1.1rem; color: var(--ink-soft); margin-bottom: 2px; }

.status { text-align: center; min-height: 1.5em; transition: opacity .3s; }
.banner { background: var(--accent-soft); color: var(--accent); padding: 10px 14px; border-radius: 14px; margin-top: 16px; font-size: .9rem; }

/* ---- history / lists ---- */
.page-head { padding: 32px 0 6px; }
.page-head p { margin: 6px 0 0; }
.history { list-style: none; padding: 0; margin: 0; }
.entry-card {
  display: block; width: 100%; text-align: left; background: var(--surface); border-radius: var(--radius); padding: 16px 18px; margin: 12px 0;
  box-shadow: var(--shadow); transition: transform .15s; animation: rise .35s ease both;
}
.entry-card:active { transform: scale(.99); }
.entry-card strong { display: block; font-family: var(--serif); font-weight: 500; font-size: 1.12rem; }
.entry-card .meta { display: block; margin-top: 2px; }
.entry-card p { margin: 8px 0 0; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; display: block; margin: 28px auto 0; padding: 12px; }

/* ---- shares ---- */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; }
.segmented button { padding: 9px 4px; border-radius: 11px; font-size: .9rem; color: var(--ink-soft); transition: background .2s, color .2s; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(74 52 30 / .12); font-weight: 600; }
.stack { display: grid; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.label { font-size: .82rem; color: var(--muted); font-weight: 550; margin-bottom: 4px; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: .86rem; display: inline-flex; align-items: center; gap: 4px; }
.chip button { width: 22px; height: 22px; border-radius: 50%; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--hairline); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .22s cubic-bezier(.3,1.4,.5,1); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.created { background: var(--accent-soft); border-radius: 16px; padding: 14px; }
.created code { display: block; word-break: break-all; font-size: .82rem; margin: 6px 0 10px; color: var(--ink); }
.share-item { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--hairline); }
.share-item:last-child { border-bottom: 0; }
.share-item strong { font-weight: 600; }
.badge { font-size: .72rem; font-weight: 600; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }
.badge.active { background: var(--accent-soft); color: var(--accent); }
.danger { color: var(--danger); font-weight: 600; font-size: .9rem; padding: 6px 2px; }

/* ---- bottom nav (floating, never covers content thanks to body padding) ---- */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; gap: 4px; padding: 6px; border-radius: 999px; height: calc(var(--nav-h) - 22px);
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px -8px rgb(74 52 30 / .25), 0 0 0 1px var(--hairline); z-index: 5;
}
.tabs button { padding: 0 20px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .92rem; transition: background .2s, color .2s; }
.tabs button.active { background: var(--accent); color: var(--accent-ink); }

/* ---- photo viewer ---- */
dialog { border: 0; border-radius: var(--radius); padding: 14px; background: var(--surface); color: var(--ink); width: min(94vw, 620px); box-shadow: var(--shadow); }
dialog[open] { animation: rise .25s ease both; }
dialog::backdrop { background: rgb(30 22 14 / .6); backdrop-filter: blur(4px); }
#viewer-img { width: 100%; max-height: 64vh; object-fit: contain; border-radius: 14px; display: block; margin-bottom: 12px; background: var(--surface-2); }
.viewer-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* ---- login + share viewer ---- */
body.login { display: grid; place-items: center; min-height: 100dvh; padding-bottom: 20px; }
.login-card { text-align: center; width: min(340px, 100%); animation: rise .5s ease both; }
.brand { font-family: var(--serif); font-size: 2.6rem; font-weight: 450; letter-spacing: -.02em; margin: 18px 0 4px; }
.tagline { font-family: var(--serif); font-style: italic; color: var(--ink-soft); margin: 0; font-size: 1.05rem; }
.login-card form { display: grid; gap: 10px; margin-top: 36px; }
.login-card img { border-radius: 22px; box-shadow: var(--shadow); }
.error { color: var(--danger); min-height: 1.4em; margin: 0; font-size: .9rem; }
.mark { font-family: var(--serif); font-size: 1.05rem; color: var(--ink-soft); padding-top: 22px; }
.mark em { color: var(--muted); font-size: .9rem; }
body.viewer { padding-bottom: 40px; }
.entry-full h2 { font-size: 1.4rem; }
.entry-full .text { white-space: pre-wrap; line-height: 1.75; font-size: 1.03rem; }
.facts { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.fact { background: var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: .85rem; color: var(--ink-soft); }
