/* ============================================================
   Message in a Bottle
   The sea (WebGL) is the stage. Everything the user reads or
   touches sits on a glass surface over it — never naked on water.
   ============================================================ */

:root {
  --ink: #3a2c20;          /* note text on paper */
  --ink-soft: #6a5742;
  --paper: #f1e6cd;
  --paper-edge: #e2d2ad;

  --fg: #e8eef6;           /* text on glass, night */
  --fg-dim: rgba(232, 238, 246, 0.62);
  --fg-faint: rgba(232, 238, 246, 0.4);
  --gold: #f0cd8c;
  --gold-deep: #b3791f;

  --glass: rgba(6, 12, 28, 0.46);
  --glass-edge: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(6, 12, 28, 0.62);
  --field: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.14);

  --font-msg: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-ui: "Spectral", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease-tide: cubic-bezier(0.37, 0, 0.34, 1);
  --shadow-card: 0 30px 80px -30px rgba(0, 0, 0, 0.75), 0 2px 10px -4px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-ui);
  color: var(--fg);
  background: linear-gradient(to bottom, #070d22, #0b1733 36%, #0c2138 72%, #06101f);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ============================================================
   The sea
   ============================================================ */
.sea { position: fixed; inset: 0; z-index: 0; display: block; width: 100%; height: 100%; }
/* transparent overlay for the shimmer + splash ripples (created by ocean.js) */
.sea-fx { position: fixed; inset: 0; z-index: 2; display: block; width: 100%; height: 100%; pointer-events: none; }

.grain {
  position: fixed; inset: -50%; z-index: 1;
  width: 200%; height: 200%;
  pointer-events: none; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainshift 6s steps(4) infinite;
}
@keyframes grainshift {
  0% { transform: translate(0, 0); } 25% { transform: translate(-4%, 3%); }
  50% { transform: translate(3%, -2%); } 75% { transform: translate(-2%, -3%); } 100% { transform: translate(0, 0); }
}

/* ============================================================
   Shared glass + buttons
   ============================================================ */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.25s var(--ease-tide), background 0.3s ease, border-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.btn--primary {
  color: #12192a;
  background: var(--gold);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 28px -14px rgba(240, 205, 140, 0.9);
}
.btn--primary:hover:not(:disabled) { background: #f6d9a0; transform: translateY(-1px); }
.btn--primary:disabled { opacity: 0.42; cursor: default; box-shadow: none; }
.btn--ghost {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.3); }

/* ============================================================
   Stage + the writing card
   ============================================================ */
.stage {
  position: relative;
  z-index: 5; /* above .counter so the reader/calm scrims cover it */
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding:
    max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  /* The stage covers the whole viewport but is mostly empty. Without this, its
     empty areas sit above the corner buttons and swallow real clicks. Let the
     empty space pass through; its children opt back in below. */
  pointer-events: none;
}
.stage > * { pointer-events: auto; }

.writer {
  width: min(400px, 100%);
  margin-top: 10vh; /* sit a little low so the horizon and its light stay open */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: opacity 0.9s var(--ease-tide), transform 0.9s var(--ease-tide), filter 0.9s var(--ease-tide);
}

.writer__whisper {
  margin: 0 0 -2px;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--fg-dim);
  text-align: center;
}

.card {
  width: 100%;
  padding: 14px 16px 12px;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.writer__input {
  width: 100%;
  min-height: 3.4em;
  max-height: 34vh;
  resize: none;
  border: 1px solid transparent;
  border-radius: 12px;
  outline: none;
  background: var(--field);
  color: var(--fg);
  font-family: var(--font-msg);
  font-size: clamp(1.1rem, 3.8vw, 1.4rem);
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
  caret-color: var(--gold);
  padding: 10px 12px;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.writer__input::placeholder { color: var(--fg-faint); font-style: italic; }
.writer__input:focus { background: rgba(255, 255, 255, 0.09); border-color: rgba(240, 205, 140, 0.45); }
.writer__input:disabled { color: var(--fg); -webkit-text-fill-color: var(--fg); opacity: 1; }

.writer__note {
  margin: -6px 0 0;
  min-height: 0;
  font-size: 0.86rem;
  font-style: italic;
  color: var(--gold);
  text-align: center;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.4s ease, max-height 0.4s ease;
}
.writer__note.is-shown { opacity: 1; max-height: 3em; }

.writer__actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.writer__actions .btn { flex: 1 1 0; max-width: 220px; }

.writer__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -2px;
}
.writer__count {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: transparent;
  font-variant-numeric: tabular-nums;
  transition: color 0.4s ease;
}
.writer__count.is-near { color: var(--fg-dim); }
.writer__count.is-limit { color: var(--gold); }
.writer__anon {
  margin-left: auto;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
}

/* --- The thrown bottle (animated by JS / WAAPI) -------------- */
.drift { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.bottle--out {
  position: fixed;
  left: 50%; top: 52%;
  width: 38px; height: 96px;
  margin-left: -19px; margin-top: -48px;
  opacity: 0;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='120' viewBox='0 0 48 120'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23cfe6e0' stop-opacity='0.95'/%3E%3Cstop offset='1' stop-color='%238cc0b8' stop-opacity='0.85'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='19' y='4' width='10' height='12' rx='2' fill='%238a6a44'/%3E%3Cpath d='M19 16 h10 v8 c0 3 7 7 7 16 v60 c0 8-4 12-12 12 h-7 c-8 0-12-4-12-12 v-60 c0-9 7-13 7-16 z' fill='url(%23g)' stroke='%23e3f4ee' stroke-opacity='0.5' stroke-width='1.4'/%3E%3Crect x='16' y='62' width='16' height='30' rx='3' fill='%23efe4c6'/%3E%3Cpath d='M18 66 h12 M18 72 h12 M18 78 h9' stroke='%23bda77e' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35));
}

/* --- Sea hint (watching) — a glass pill so it reads on water -- */
.sea-hint {
  position: fixed;
  left: 50%;
  bottom: clamp(96px, 18vh, 200px);
  transform: translateX(-50%) translateY(6px);
  margin: 0;
  z-index: 6;
  max-width: 86vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  font-family: var(--font-msg);
  font-style: italic;
  font-size: clamp(1.05rem, 3.6vw, 1.3rem);
  color: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s var(--ease-tide), transform 0.9s var(--ease-tide);
}
.sea-hint.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- The discoverable glint (button over the canvas sparkle) -- */
.glint {
  position: fixed; z-index: 7;
  width: 72px; height: 72px;
  transform: translate(-50%, -50%);
  padding: 0; border: none; border-radius: 50%;
  background: transparent; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.glint[hidden] { display: none; }
.glint::before {
  content: ""; position: absolute; inset: 22px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 240, 200, 0.55), rgba(255, 220, 150, 0) 70%);
}
.glint::after {
  content: ""; position: absolute; inset: 14px; border-radius: 50%;
  border: 1px solid rgba(255, 226, 158, 0.5);
  animation: glintPulse 1.8s var(--ease-tide) infinite;
}
.glint:hover::after { border-color: rgba(255, 236, 190, 0.9); }
.glint:focus-visible { outline: none; }
.glint:focus-visible::after { border-color: rgba(255, 244, 214, 1); inset: 8px; }
@keyframes glintPulse { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(1.6); opacity: 0; } }

/* ============================================================
   Reader — the stranger's note on aged paper
   ============================================================ */
.reader {
  position: fixed; z-index: 8; inset: 0;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at center, rgba(4, 10, 20, 0.55), rgba(4, 10, 20, 0.8));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.reader[hidden] { display: none; }

.reader__paper {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 44px 36px 32px;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 50%),
    radial-gradient(100% 100% at 80% 100%, rgba(150, 120, 70, 0.18), rgba(150, 120, 70, 0) 55%),
    linear-gradient(160deg, var(--paper), var(--paper-edge));
  border-radius: 5px 8px 6px 7px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 30px 70px -24px rgba(0, 0, 0, 0.7), 0 4px 14px -6px rgba(0, 0, 0, 0.4);
  transform: rotate(-1.1deg);
  animation: unfurl 0.85s var(--ease-tide) both;
}
.reader__paper::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: 0 0 0 1px rgba(120, 92, 52, 0.18) inset; pointer-events: none;
}
@keyframes unfurl {
  from { opacity: 0; transform: rotate(-1.1deg) translateY(26px) scale(0.96); }
  to   { opacity: 1; transform: rotate(-1.1deg) translateY(0) scale(1); }
}
.reader__from {
  margin: 0 0 18px;
  font-size: 0.66rem; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-soft); text-align: center;
}
.reader__body {
  margin: 0 0 14px;
  font-family: var(--font-msg);
  font-size: clamp(1.45rem, 5.4vw, 1.95rem);
  font-weight: 500; font-style: italic; line-height: 1.42;
  text-align: center; word-break: break-word; overflow-wrap: anywhere;
}
.reader__stat {
  margin: 0 0 22px;
  text-align: center;
  font-size: 0.8rem; font-style: italic;
  letter-spacing: 0.02em; color: var(--ink-soft);
}
.reader__actions {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: 10px; margin: 0 0 22px;
}
.vote, .keep {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-ui); font-size: 0.82rem;
  color: var(--ink-soft);
  background: rgba(106, 87, 66, 0.06);
  border: 1px solid rgba(106, 87, 66, 0.28);
  border-radius: 999px; padding: 8px 14px; cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.2s var(--ease-tide);
}
.vote:hover, .keep:hover { border-color: rgba(106, 87, 66, 0.5); }
.vote:active, .keep:active { transform: scale(0.96); }
.vote:focus-visible, .keep:focus-visible, .report:focus-visible { outline: 2px solid var(--ink-soft); outline-offset: 2px; }
.vote__n { font-variant-numeric: tabular-nums; }
.vote--up.is-on { background: rgba(200, 150, 60, 0.18); border-color: rgba(190, 140, 50, 0.7); color: #7a5a1e; }
.vote--down.is-on { background: rgba(90, 100, 120, 0.16); border-color: rgba(90, 100, 120, 0.6); color: #455066; }
.keep:hover { border-color: rgba(180, 120, 40, 0.6); color: #7a5a1e; }
.keep:disabled { background: rgba(200, 150, 60, 0.18); border-color: rgba(190, 140, 50, 0.6); color: #7a5a1e; cursor: default; }
.report {
  margin-left: 2px;
  font-family: var(--font-ui); font-size: 0.8rem;
  color: rgba(106, 87, 66, 0.55);
  background: none; border: none; cursor: pointer; padding: 6px;
}
.report:hover { color: #9a3b2e; }
.report:disabled { color: #7a8a5a; cursor: default; }
.reader__dismiss {
  display: block; margin: 0 auto;
  font-family: var(--font-ui); font-size: 0.8rem; letter-spacing: 0.1em;
  color: var(--ink-soft); background: none;
  border: 1px solid rgba(106, 87, 66, 0.34); border-radius: 999px;
  padding: 9px 20px; cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.reader__dismiss:hover { background: rgba(106, 87, 66, 0.1); color: var(--ink); border-color: rgba(106, 87, 66, 0.5); }
.reader__dismiss:focus-visible { outline: 2px solid var(--ink-soft); outline-offset: 3px; }

/* ============================================================
   Calm — soft empty state (glass pill)
   ============================================================ */
.calm {
  position: fixed; z-index: 8; inset: 0;
  display: grid; place-items: center; padding: 24px;
}
.calm[hidden] { display: none; }
.calm__line {
  margin: 0 0 18px;
  padding: 18px 26px;
  border-radius: 20px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-family: var(--font-msg);
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  font-style: italic; line-height: 1.5;
  color: var(--fg); text-align: center;
  animation: surface 1.1s var(--ease-tide) both;
}
@keyframes surface { from { opacity: 0; } to { opacity: 1; } }
.calm__again {
  display: block; margin: 0 auto;
  font-family: var(--font-ui); font-size: 0.9rem; font-weight: 500;
  color: #12192a; background: var(--gold);
  border: none; border-radius: 999px; padding: 12px 24px; cursor: pointer;
}
.calm__again:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ============================================================
   Corners — counter (bottom-left) and controls (top-right)
   ============================================================ */
.counter {
  position: fixed; z-index: 4;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; align-items: baseline; gap: 7px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  user-select: none; pointer-events: none;
}
.counter__num { font-size: 0.95rem; font-weight: 500; color: var(--gold); font-variant-numeric: tabular-nums; }
.counter__label { font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-dim); }

.controls {
  position: fixed; z-index: 3;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex; gap: 8px;
}
.book {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  color: var(--fg);
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 999px; cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.25s var(--ease-tide);
}
.book svg { width: 20px; height: 20px; display: block; }
.book:hover { background: var(--glass-strong); border-color: rgba(240, 205, 140, 0.5); transform: translateY(-1px); }
.book:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Return-loop banner */
.return-banner {
  position: fixed; z-index: 9;
  top: max(16px, env(safe-area-inset-top)); left: 50%;
  transform: translate(-50%, -16px);
  max-width: min(90vw, 460px);
  text-align: center;
  font-family: var(--font-msg); font-style: italic;
  font-size: clamp(1rem, 3.4vw, 1.2rem);
  color: #1a2238;
  background: linear-gradient(180deg, #f3e7cd, #e7d4ac);
  border-radius: 999px; padding: 11px 22px;
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.7);
  opacity: 0; pointer-events: none;
  transition: opacity 0.9s var(--ease-tide), transform 0.9s var(--ease-tide);
}
.return-banner[hidden] { display: none; }
.return-banner.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   The notebook — a journal on cream paper. The paper is opaque,
   so it reads the same over a day or night sky.
   ============================================================ */
.sheet {
  position: fixed; z-index: 10; inset: 0;
  display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse at center, rgba(4, 10, 20, 0.55), rgba(4, 10, 20, 0.82));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sheet[hidden] { display: none; }
.sheet__card {
  --j-paper: #f4ecd9;
  --j-paper-2: #eee4cd;
  --j-ink: #2b251d;
  --j-ink-soft: #7a6c58;
  --j-line: #d9cbab;
  --j-accent: #8b3a2f;
  width: min(520px, 100%);
  max-height: min(86vh, 760px);
  display: flex; flex-direction: column;
  padding: 26px 24px 18px;
  color: var(--j-ink);
  background: var(--j-paper);
  border: 1px solid var(--j-line);
  border-radius: 22px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.85), 0 2px 12px -6px rgba(0, 0, 0, 0.5);
  animation: surface 0.6s var(--ease-tide) both;
  text-align: left;
}
.journal__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding-bottom: 16px; border-bottom: 1px solid var(--j-line);
}
.journal__title {
  margin: 0;
  font-family: var(--font-msg); font-style: italic; font-weight: 500;
  font-size: 2.1rem; line-height: 1.05; letter-spacing: -0.01em;
  color: var(--j-ink);
}
.journal__count {
  margin: 7px 0 0;
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--j-ink-soft);
}
.journal__close {
  flex: none; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  font-family: var(--font-ui); font-size: 1.35rem; line-height: 1;
  color: var(--j-ink); background: transparent;
  border: 1px solid var(--j-line); border-radius: 12px; cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.journal__close:hover { background: rgba(43, 37, 29, 0.06); border-color: var(--j-ink-soft); }
.journal__close:focus-visible { outline: 2px solid var(--j-accent); outline-offset: 2px; }

.tally {
  list-style: none; margin: 0; padding: 14px 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  border-bottom: 1px solid var(--j-line);
}
.tally__row { display: flex; flex-direction: column; gap: 4px; }
.tally__num { font-family: var(--font-msg); font-size: 1.5rem; font-weight: 500; line-height: 1; color: var(--j-ink); font-variant-numeric: tabular-nums; }
.tally__label { font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--j-ink-soft); }

/* the entries — each kept bottle, newest first */
.kept-list {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 16px;
  margin: 0; padding: 24px 2px 8px;
}
.kept-list[hidden] { display: none; }
.entry {
  position: relative;
  padding: 22px 16px 14px;
  background: var(--j-paper-2);
  border: 1px solid var(--j-line);
  border-radius: 12px;
}
.entry__date {
  position: absolute; top: -12px; right: 14px;
  padding: 5px 9px;
  font-family: var(--font-mono); font-size: 0.6rem; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--j-accent); background: var(--j-paper);
  border: 1px solid var(--j-line); border-radius: 6px;
}
.entry__body {
  margin: 0 0 12px;
  font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.65;
  color: var(--j-ink);
  word-break: break-word; overflow-wrap: anywhere;
}
.entry__foot {
  margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--j-ink-soft);
}
.entry__origin::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0;
  border-radius: 50%; background: var(--j-accent); opacity: 0.7; vertical-align: middle;
}
.entry__mark { font-size: 0.9rem; color: var(--j-accent); opacity: 0.75; }
.sheet__foot {
  margin: 0; padding: 26px 4px 10px;
  font-family: var(--font-mono); font-size: 0.74rem; line-height: 1.65; letter-spacing: 0.02em;
  color: var(--j-ink-soft);
}

/* ============================================================
   State visibility — driven by body[data-state]
   ============================================================ */
body[data-state="tossing"] .writer,
body[data-state="watching"] .writer,
body[data-state="seeking"] .writer {
  opacity: 0; transform: translateY(10px); filter: blur(2px); pointer-events: none;
}
body:not([data-state="writing"]) .writer { pointer-events: none; }
body[data-state="writing"] .writer { pointer-events: auto; }
body[data-state="reading"] .controls,
body[data-state="tossing"] .controls,
body[data-state="watching"] .controls,
body[data-state="seeking"] .controls { opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }

/* ============================================================
   Daylight — a bright sky needs light glass and dark text
   (ocean.js sets body[data-sky])
   ============================================================ */
body[data-sky="day"] {
  --fg: #17324a;
  --fg-dim: rgba(23, 50, 74, 0.72);
  --fg-faint: rgba(23, 50, 74, 0.5);
  --glass: rgba(255, 255, 255, 0.5);
  --glass-edge: rgba(255, 255, 255, 0.7);
  --glass-strong: rgba(255, 255, 255, 0.66);
  --field: rgba(255, 255, 255, 0.42);
  --line: rgba(23, 50, 74, 0.18);
  --shadow-card: 0 30px 80px -30px rgba(0, 30, 60, 0.45), 0 2px 10px -4px rgba(0, 30, 60, 0.2);
}
body[data-sky="day"] .writer__whisper { text-shadow: 0 1px 12px rgba(255, 255, 255, 0.7); }
body[data-sky="day"] .writer__input:focus { background: rgba(255, 255, 255, 0.6); border-color: rgba(179, 121, 31, 0.5); }
body[data-sky="day"] .writer__input { caret-color: var(--gold-deep); }
body[data-sky="day"] .counter__num { color: var(--gold-deep); }
body[data-sky="day"] .btn--ghost { color: #17324a; background: rgba(255, 255, 255, 0.55); border-color: rgba(23, 50, 74, 0.38); }
body[data-sky="day"] .btn--ghost:hover { background: rgba(255, 255, 255, 0.78); border-color: rgba(23, 50, 74, 0.55); }
body[data-sky="day"] .book:hover { border-color: rgba(179, 121, 31, 0.5); }
body[data-sky="day"] .writer__count.is-limit { color: var(--gold-deep); }
body[data-sky="day"] .writer__note { color: var(--gold-deep); }

/* ============================================================
   Motion-reduced & small screens
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .grain, .glint::after { animation: none !important; }
  .reader__paper, .calm__line, .sheet__card { animation: none !important; opacity: 1 !important; }
  .writer { transition-duration: 0.2s; }
  .return-banner { transition-duration: 0.2s; }
}

@media (max-width: 480px) {
  .tally { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 18px 16px 14px; border-radius: 18px; }
  .writer__actions { flex-direction: column; }
  .writer__actions .btn { max-width: none; }
  .writer__anon { font-size: 0.68rem; }
  .reader__paper { padding: 40px 26px 28px; }
}

@media (max-height: 560px) {
  .writer { gap: 8px; }
  .writer__whisper { display: none; }
  .writer__input { min-height: 3.6em; }
}

/* ============================================================
   The veil — a bottle strangers downvoted arrives covered
   ============================================================ */
.reader__paper.is-veiled .reader__body,
.reader__paper.is-veiled .reader__stat,
.reader__paper.is-veiled .reader__actions,
.reader__paper.is-veiled .reader__dismiss { display: none; }
.reader__veil { text-align: center; padding: 8px 0 6px; }
.reader__veil[hidden] { display: none; }
.reader__veil-line {
  margin: 0 0 18px;
  font-family: var(--font-msg); font-style: italic;
  font-size: 1.25rem; line-height: 1.4; color: var(--ink-soft);
}
.reader__veil-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn--ink { color: var(--ink); background: rgba(106, 87, 66, 0.06); border: 1px solid rgba(106, 87, 66, 0.34); }
.btn--ink:hover { background: rgba(106, 87, 66, 0.12); }
.btn--ink:focus-visible { outline-color: var(--ink-soft); }
