:root {
  --sky: #d6ebf7;
  --sky-deep: #b9dcf0;
  --paper: #f4fafd;
  --ink: #13264a;
  --ink-soft: #3d5075;
  --sun: #ffc53d;
  --coral: #ff7b6b;
  --leaf: #3f9c6c;
  --lilac: #b7a4f2;
  --sea: #6fb7e0;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Literata", Georgia, serif;
  --gutter: clamp(16px, 4vw, 48px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --sky: #0f1d38;
    --sky-deep: #1c3463;
    --paper: #14264a;
    --ink: #eaf4fb;
    --ink-soft: #a9bddb;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 20; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font: 700 0.95rem var(--display); text-decoration: none; }
.skip:focus { top: 12px; }
#r-title:focus { outline: none; }
body {
  margin: 0; background: var(--sky); color: var(--ink);
  font: 400 1.0625rem/1.65 var(--body);
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.05; margin: 0; letter-spacing: -0.02em; }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: calc(18px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 18px max(var(--gutter), env(safe-area-inset-left));
}
.mark { display: flex; align-items: center; gap: 10px; font: 800 1.15rem var(--display); text-decoration: none; letter-spacing: -0.02em; }
.mark-sun { width: 20px; height: 20px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 5px color-mix(in srgb, var(--sun) 35%, transparent); }
.top nav { display: flex; gap: 22px; font: 500 0.95rem var(--display); }
.top nav a { text-decoration: none; border-bottom: 2px solid var(--sun); }
.link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; border-bottom: 2px solid var(--coral); }

/* Hero */
.hero { position: relative; padding: 0 var(--gutter); }
.hero-copy { max-width: 680px; padding: clamp(16px, 4vw, 40px) 0 0; position: relative; z-index: 2; pointer-events: none; }
.hero h1 { font-size: clamp(2.4rem, 6.2vw, 4.4rem); font-weight: 800; text-wrap: balance; }
.hero-copy p { font-size: 1.1rem; color: var(--ink-soft); margin: 18px 0 0; max-width: 46ch; }
.map-wrap { position: relative; margin: -2vw calc(var(--gutter) * -1) 0; }
#map { display: block; width: 100%; height: auto; }
.map-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.map-scroll::-webkit-scrollbar { display: none; }
.map-inner { position: relative; width: 100%; }
.pin .hit { fill: transparent; }
.land { fill: var(--sky-deep); stroke: var(--paper); stroke-width: 0.6; }
.sun-glow { fill: var(--sun); opacity: 0.28; }
.sun-core { fill: var(--sun); }
.pin { cursor: pointer; }
.pin .halo { fill: var(--c); opacity: 0.3; transform-box: fill-box; transform-origin: center; animation: pulse 3.2s ease-out infinite; animation-delay: var(--d); }
.pin .dot { fill: var(--c); stroke: var(--paper); stroke-width: 2; transition: transform 0.2s; transform-box: fill-box; transform-origin: center; }
.pin:hover .dot, .pin:focus-visible .dot { transform: scale(1.5); }
.pin.dim { opacity: 0.15; pointer-events: none; }
@keyframes pulse { 0% { transform: scale(0.6); opacity: 0.5; } 100% { transform: scale(2.4); opacity: 0; } }
.map-note { position: absolute; right: var(--gutter); bottom: 8px; margin: 0; font-size: 0.85rem; color: var(--ink-soft); font-style: italic; }
.tip {
  position: absolute; z-index: 5; width: max-content; max-width: min(260px, 70vw); pointer-events: none; padding: 10px 14px;
  background: var(--ink); color: var(--paper); border-radius: 12px; font: 500 0.9rem/1.3 var(--display);
  transform: translate(-50%, calc(-100% - 16px)); opacity: 0; transition: opacity 0.15s;
}
.tip.on { opacity: 1; }
.tip.below { transform: translate(-50%, 18px); }
@media (prefers-color-scheme: dark) { .tip { background: var(--paper); color: var(--ink); } }

/* Feed */
.feed-head { padding: clamp(40px, 7vw, 80px) var(--gutter) 20px; display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: end; justify-content: space-between; }
.feed-head h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: 700 0.9rem var(--display); padding: 8px 16px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--ink); border: 2px solid var(--ink);
}
.chip[aria-pressed="true"] { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); color: #13264a; }
.chip[data-all][aria-pressed="true"] { color: var(--paper); }

.feed {
  padding: 0 var(--gutter); display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  grid-auto-flow: dense;
}
.tile {
  --c: var(--sun); position: relative; text-align: left; font: inherit; cursor: pointer;
  background: var(--paper); color: var(--ink); border: 0; border-radius: 28px 28px 28px 6px;
  padding: 0; overflow: hidden; display: flex; flex-direction: column;
  transition: transform 0.2s;
}
@media (hover: hover) { .tile:hover { transform: translateY(-4px) rotate(-0.4deg); } }
.tile.wide { grid-column: span 2; }
.tile.solid { background: var(--c); color: #13264a; border-radius: 6px 28px 28px 28px; }
.tile img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: var(--sky-deep); }
.tile-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tile h3 { font-size: 1.35rem; font-weight: 700; text-wrap: balance; }
.tile.wide h3 { font-size: 1.75rem; }
.tile.wide img { aspect-ratio: 2 / 1; }
.tile p { margin: 0; font-size: 0.95rem; line-height: 1.55; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile.solid p { color: #13264a; }
.tile-foot { margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; align-items: center; font: 500 0.85rem var(--display); color: var(--ink-soft); }
.tile.solid .tile-foot { color: #13264a; }
.topic { display: inline-flex; align-items: center; gap: 7px; }
.topic::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.tile.solid .topic::before { background: #13264a; }
.tile .heart { position: absolute; top: 12px; right: 12px; }
.empty { grid-column: 1 / -1; padding: 40px 0; font-size: 1.2rem; }

.heart {
  font: 700 0.9rem var(--display); cursor: pointer; border: 0; border-radius: 999px; padding: 8px 14px;
  background: color-mix(in srgb, var(--paper) 90%, transparent); color: var(--ink);
}
.heart::before { content: "♡ "; color: var(--coral); }
.heart[aria-pressed="true"]::before { content: "♥ "; }
.heart[aria-pressed="true"] { background: var(--coral); color: #13264a; }
.heart[aria-pressed="true"]::before { color: #13264a; }
.heart.pop { animation: pop 0.35s; }
@keyframes pop { 50% { transform: scale(1.25); } }

.btn {
  display: inline-block; font: 700 1rem var(--display); text-decoration: none; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 999px; padding: 14px 26px;
}
.btn:hover { background: var(--coral); color: #13264a; }
.more-wrap { text-align: center; margin: 36px 0 0; }
.more-wrap[hidden] { display: none; }

/* Daily pick */
.daily { margin: clamp(32px, 6vw, 64px) var(--gutter) 0; }
.daily[hidden] { display: none; }
.daily h2 { font-size: 1.2rem; margin-bottom: 12px; }
.daily-card {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); width: 100%; text-align: left; cursor: pointer;
  background: var(--paper); color: var(--ink); border: 0; border-radius: 36px 36px 36px 8px; overflow: hidden; font: inherit; padding: 0;
}
.daily-card:hover .daily-img img { transform: scale(1.03); }
.daily-img { min-height: 260px; background: var(--c, var(--sun)); overflow: hidden; }
.daily-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s; }
.daily-text { padding: clamp(22px, 4vw, 44px); display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.daily-text h3 { font-size: clamp(1.6rem, 3.6vw, 2.6rem); text-wrap: balance; }
.daily-text p { margin: 0; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.daily-text .topic { font: 500 0.9rem var(--display); color: var(--ink-soft); }
.tools { display: flex; gap: 8px; flex: 1 1 280px; max-width: 480px; }
.tools input {
  flex: 1; min-width: 0; font: 400 1rem var(--body); padding: 9px 18px; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
}
#loved[aria-pressed="true"] { --c: var(--coral); }
#loved span { opacity: 0.7; }
.heart.plain::before { content: ""; }
.reader-nav { display: flex; justify-content: space-between; margin: 24px 28px 0; padding-top: 16px; border-top: 2px solid var(--sky); }
.reader-nav button { font: 500 0.95rem var(--display); background: none; border: 0; color: var(--ink-soft); cursor: pointer; padding: 4px 0; }
.reader-nav button:hover { color: var(--ink); }
.reader-nav button:disabled { opacity: 0.3; cursor: default; }

/* Mood */
.mood { margin: clamp(40px, 7vw, 80px) var(--gutter) 0; }
.mood h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin-bottom: 16px; }
.mood-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.mood-btns .chip { font-size: 1.05rem; padding: 12px 22px; }
.mood-out { margin-top: 20px; display: grid; gap: 10px; max-width: 760px; }
.mood-out:empty { display: none; }
.pick {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer; color: #13264a;
  background: var(--c); border: 0; border-radius: 22px 22px 22px 6px; padding: 16px 22px;
  animation: rise 0.3s ease-out backwards; animation-delay: var(--d);
}
.pick:hover { filter: brightness(1.05); }
.pick strong { display: block; font: 700 1.2rem/1.2 var(--display); }
.pick span { font: 500 0.88rem var(--display); opacity: 0.8; }
.mood-more { justify-self: start; background: none; border: 0; color: var(--ink); font: 700 0.95rem var(--display); cursor: pointer; border-bottom: 2px solid var(--sun); padding: 2px 0; }
.hp { position: absolute; left: -9999px; }
.share select { font: 400 1rem var(--body); padding: 12px 14px; border: 2px solid #13264a; border-radius: 14px; background: #fff9e6; color: #13264a; width: 100%; }
.form-msg { margin: 0; min-height: 1.5em; font-weight: 600; }

/* Pins drop onto the map once, in sequence, when the page opens. */
.pin .dot { animation: drop 0.5s cubic-bezier(.3,1.6,.5,1) backwards; animation-delay: calc(0.6s + var(--i) * 45ms); }
@keyframes drop { from { transform: translateY(-30px) scale(0); opacity: 0; } }

/* Share */
.share {
  margin: clamp(56px, 9vw, 110px) var(--gutter) 0; padding: clamp(24px, 5vw, 56px);
  background: var(--sun); color: #13264a; border-radius: 40px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 32px 56px;
}
.share h2 { font-size: clamp(2rem, 5vw, 3.4rem); margin-bottom: 14px; }
.share p { margin: 0; max-width: 40ch; }
.share form { display: grid; gap: 14px; }
.share label { display: grid; gap: 6px; font: 700 0.9rem var(--display); }
.share input, .share textarea {
  font: 400 1rem var(--body); padding: 12px 14px; border: 2px solid #13264a; border-radius: 14px;
  background: #fff9e6; color: #13264a; width: 100%;
}
.share .btn { justify-self: start; background: #13264a; color: #fff9e6; }
.share .btn:hover { background: var(--coral); color: #13264a; }

footer { padding: 56px var(--gutter) calc(40px + env(safe-area-inset-bottom)); color: var(--ink-soft); font-size: 0.9rem; }
footer p { margin: 4px 0; max-width: 60ch; }

/* Reader */
dialog { max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain; border: 0; padding: 0; background: transparent; max-width: min(640px, 94vw); width: 100%; color: var(--ink); }
dialog::backdrop { background: color-mix(in srgb, #13264a 60%, transparent); backdrop-filter: blur(4px); }
dialog article { position: relative; background: var(--paper); border-radius: 32px; overflow: hidden; padding-bottom: 28px; }
dialog[open] article { animation: rise 0.28s ease-out; }
@keyframes rise { from { transform: translateY(24px) scale(0.97); opacity: 0; } }
.reader-img img { width: 100%; max-height: 300px; object-fit: cover; display: block; }
.reader-meta { margin: 24px 28px 8px; font: 500 0.9rem var(--display); color: var(--ink-soft); }
dialog h3 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 28px 14px; text-wrap: balance; }
dialog article > p:not(.reader-meta) { margin: 0 28px 22px; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 28px; }
.reader-actions .heart { border: 2px solid var(--ink); }
.close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; font-size: 1.6rem; line-height: 1; background: var(--paper); color: var(--ink); }

@media (max-width: 760px) {
  .share { grid-template-columns: 1fr; border-radius: 28px; }
  .tile.wide { grid-column: auto; }
  .daily-card { grid-template-columns: 1fr; }
  .daily-img { min-height: 200px; order: -1; }
  .top nav a { display: none; }
  .mood-btns .chip { font-size: 0.95rem; padding: 10px 16px; }
  .share { margin-inline: 12px; }
  .map-note { position: static; padding: 0 var(--gutter); margin-top: 4px; }
  .map-inner { width: 250%; }
  .map-scroll { padding: 0 0 6px; }
  .hero-copy { pointer-events: auto; }
}
@media (max-width: 380px) {
  .mark { font-size: 1rem; gap: 8px; }
  .mark-sun { width: 16px; height: 16px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--sun) 35%, transparent); }
}
.top nav .link, .mark { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
