/* ================= Reverie — themes ================= */
:root {
  --radius: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --maxw: 760px;
  --thread-x: 26px;
}

[data-theme="film"] {
  color-scheme: light;
  --bg: #efe5d3; --bg2: #e6d8bf;
  --ink: #3a2c22; --ink-soft: #7a6553; --ink-faint: #a8937d;
  --accent: #b4603a; --accent-2: #d89a5b; --accent-ink: #fff8ee;
  --card: #f8f1e4; --card-border: rgba(90, 60, 30, .14);
  --card-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 10px 24px -14px rgba(70, 40, 15, .45);
  --thread: linear-gradient(to bottom, transparent, #c9a77f 6%, #c9a77f 94%, transparent);
  --node: #b4603a; --glow: rgba(216, 120, 60, .55); --low: #8a8f9a;
  --head-font: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --body-font: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --head-weight: 600; --body-size: 18px;
  --field: #fbf6ec; --overlay: rgba(58, 40, 25, .45);
  --photo-filter: sepia(.18) saturate(.92) contrast(.98);
  --era-tint: rgba(180, 96, 58, .07);
}
[data-theme="night"] {
  color-scheme: dark;
  --bg: #060914; --bg2: #101a3a;
  --ink: #e7eaff; --ink-soft: #a5acd6; --ink-faint: #6c74a3;
  --accent: #a9bcff; --accent-2: #f1d6ff; --accent-ink: #0a0f24;
  --card: rgba(255, 255, 255, .055); --card-border: rgba(190, 205, 255, .14);
  --card-shadow: 0 0 0 1px rgba(255,255,255,.02) inset, 0 20px 40px -24px rgba(0,0,0,.9);
  --thread: linear-gradient(to bottom, transparent, rgba(169,188,255,.55) 6%, rgba(241,214,255,.5) 94%, transparent);
  --node: #cfd9ff; --glow: rgba(169, 188, 255, .8); --low: #4c557e;
  --head-font: "Fraunces", Georgia, serif;
  --body-font: "Inter", system-ui, sans-serif;
  --head-weight: 400; --body-size: 16px;
  --field: rgba(255,255,255,.06); --overlay: rgba(2, 4, 12, .66);
  --photo-filter: saturate(.9) brightness(.95);
  --era-tint: rgba(169, 188, 255, .06);
}
[data-theme="mist"] {
  color-scheme: light;
  --bg: #f5f2f7; --bg2: #ebe6f1;
  --ink: #463f55; --ink-soft: #7f7791; --ink-faint: #b0a9c0;
  --accent: #a77fa8; --accent-2: #7fa6b8; --accent-ink: #fff;
  --card: rgba(255, 255, 255, .62); --card-border: rgba(140, 120, 170, .14);
  --card-shadow: 0 24px 48px -30px rgba(110, 80, 140, .45);
  --thread: linear-gradient(to bottom, transparent, #d4bfd9 6%, #b9d3dc 94%, transparent);
  --node: #a77fa8; --glow: rgba(200, 150, 205, .75); --low: #a9b4c4;
  --head-font: "EB Garamond", Georgia, serif;
  --body-font: "Inter", system-ui, sans-serif;
  --head-weight: 400; --body-size: 16px;
  --field: rgba(255,255,255,.7); --overlay: rgba(70, 55, 90, .3);
  --photo-filter: saturate(.85) brightness(1.03);
  --era-tint: rgba(167, 127, 168, .07);
  --radius: 22px;
}

/* ================= base ================= */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); transition: background-color .8s var(--ease); -webkit-text-size-adjust: 100%; }
body {
  color: var(--ink); font-family: var(--body-font); font-size: var(--body-size); line-height: 1.6;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--head-font); font-weight: var(--head-weight); line-height: 1.15; margin: 0; letter-spacing: .005em; }
[data-theme="mist"] h1, [data-theme="mist"] h2, [data-theme="mist"] h3 { font-style: italic; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ================= ambient background ================= */
#ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.amb { position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s var(--ease); }
.amb-base { opacity: 1; background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%); }
.amb-grain {
  inset: -10%; opacity: .0; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .22 0 0 0 0 .15 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="film"] .amb-grain { opacity: .55; animation: grain 1.2s steps(4) infinite; }
[data-theme="mist"] .amb-grain { opacity: .12; }
.amb-vignette { background: radial-gradient(130% 100% at 50% 40%, transparent 55%, rgba(60,35,15,.28)); }
[data-theme="film"] .amb-vignette { opacity: 1; }
[data-theme="night"] .amb-vignette { opacity: .6; background: radial-gradient(130% 100% at 50% 30%, transparent 50%, rgba(0,0,0,.6)); }
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(-3%,2%)} 50%{transform:translate(2%,-3%)} 75%{transform:translate(-2%,-1%)} 100%{transform:translate(0,0)} }

.amb-leak i { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; filter: blur(70px); opacity: .5; }
.amb-leak i:nth-child(1) { background: radial-gradient(circle, rgba(255,150,80,.75), transparent 65%); top: -35vmax; right: -30vmax; animation: drift1 26s ease-in-out infinite alternate; }
.amb-leak i:nth-child(2) { background: radial-gradient(circle, rgba(235,110,120,.45), transparent 65%); bottom: -40vmax; left: -35vmax; animation: drift2 32s ease-in-out infinite alternate; }
[data-theme="film"] .amb-leak { opacity: 1; }

.amb-stars::before, .amb-stars::after {
  content: ""; position: absolute; top: 0; left: 0; width: 1px; height: 1px; border-radius: 50%;
  box-shadow: var(--stars);
}
.amb-stars::after { top: 2000px; }
[data-theme="night"] .amb-stars { opacity: 1; }
.amb-stars.s1 { animation: rise 240s linear infinite; }
.amb-stars.s2 { animation: rise 160s linear infinite, twinkle 7s ease-in-out infinite alternate; }
.amb-stars.s3 { animation: rise 110s linear infinite, twinkle 4.5s ease-in-out infinite alternate; }
[data-theme="night"] .amb-base { background:
  radial-gradient(60% 40% at 80% 10%, rgba(120,90,200,.22), transparent 70%),
  radial-gradient(70% 50% at 10% 90%, rgba(40,90,170,.25), transparent 70%),
  linear-gradient(to bottom, var(--bg2), var(--bg) 75%); }
@keyframes rise { from { transform: translateY(0); } to { transform: translateY(-2000px); } }
@keyframes twinkle { from { filter: brightness(.6); } to { filter: brightness(1.3); } }

.amb-mist i { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .7; }
.amb-mist i:nth-child(1) { width: 60vmax; height: 60vmax; background: #e8cfe6; top: -20vmax; left: -15vmax; animation: drift1 30s ease-in-out infinite alternate; }
.amb-mist i:nth-child(2) { width: 55vmax; height: 55vmax; background: #cfe2ea; top: 30vh; right: -25vmax; animation: drift2 36s ease-in-out infinite alternate; }
.amb-mist i:nth-child(3) { width: 45vmax; height: 45vmax; background: #f3e1cf; bottom: -20vmax; left: 10vw; animation: drift1 40s ease-in-out infinite alternate-reverse; }
.amb-mist i:nth-child(4) { width: 35vmax; height: 35vmax; background: #dcd6f2; top: 20vh; left: 30vw; animation: drift2 28s ease-in-out infinite alternate-reverse; opacity: .5; }
[data-theme="mist"] .amb-mist { opacity: 1; }
@keyframes drift1 { from { transform: translate(0,0) scale(1); } to { transform: translate(6vw,8vh) scale(1.12); } }
@keyframes drift2 { from { transform: translate(0,0) scale(1.05); } to { transform: translate(-8vw,-6vh) scale(.95); } }

@media (prefers-reduced-motion: reduce) {
  *, .amb, .amb * , .amb::before, .amb::after { animation: none !important; transition: none !important; }
}

/* ================= buttons & fields ================= */
.btn {
  appearance: none; border: 1px solid var(--card-border); background: var(--card); color: var(--ink);
  padding: .62em 1.1em; border-radius: 999px; cursor: pointer; font-size: .92rem; line-height: 1.2;
  transition: transform .15s var(--ease), background .3s, box-shadow .3s; display: inline-flex; align-items: center; gap: .45em;
  -webkit-tap-highlight-color: transparent; font-family: var(--body-font);
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 8px 22px -10px var(--glow); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.danger { color: #b3413a; }
[data-theme="night"] .btn.danger { color: #ff9b94; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.small { font-size: .8rem; padding: .45em .85em; }
.icon-btn { appearance: none; border: 0; background: transparent; color: var(--ink-soft); width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.icon-btn:hover { background: var(--era-tint); color: var(--ink); }
.icon-btn svg, .btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

label.field { display: block; margin: 0 0 1.1rem; }
label.field > span, .field-label { display: block; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .35rem; font-family: var(--body-font); }
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--card-border); background: var(--field); border-radius: calc(var(--radius) * .7);
  padding: .75em .9em; outline: none; transition: border-color .2s, box-shadow .2s; font-size: 1rem;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--era-tint); }
textarea.input { min-height: 9em; resize: vertical; line-height: 1.65; font-family: var(--body-font); font-size: var(--body-size); }
.row { display: flex; gap: .7rem; }
.row > * { flex: 1; min-width: 0; }
.hint { font-size: .85rem; color: var(--ink-soft); margin: .2rem 0 1rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; margin: .6rem 0; font-size: .95rem; cursor: pointer; }
.check input { margin-top: .3em; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }

.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg button { appearance: none; border: 1px solid var(--card-border); background: var(--field); border-radius: 999px; padding: .5em .9em; font-size: .85rem; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ================= header ================= */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .3rem;
  padding: calc(env(safe-area-inset-top) + .5rem) .8rem .5rem 1.1rem;
  backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--card-border) 60%, transparent);
}
.brand { flex: 1; min-width: 0; }
.brand h1 { font-size: 1.55rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-size: .75rem; color: var(--ink-soft); letter-spacing: .14em; text-transform: uppercase; margin-top: -.1rem; }

.toolbar { position: sticky; top: calc(env(safe-area-inset-top) + 64px); z-index: 15; padding: .4rem 1rem .6rem; max-width: var(--maxw); margin: 0 auto; }
.search { display: flex; align-items: center; gap: .4rem; background: var(--field); border: 1px solid var(--card-border); border-radius: 999px; padding: .1rem .3rem .1rem .9rem; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.search > svg, .prompt-card > svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; color: var(--ink-soft); }
.prompt-card > svg { width: 22px; height: 22px; color: var(--accent); }
.search input { flex: 1; border: 0; background: transparent; outline: none; padding: .55em 0; font-size: .95rem; }
.decades { display: flex; gap: .35rem; overflow-x: auto; padding: .55rem 0 0; scrollbar-width: none; }
.decades::-webkit-scrollbar { display: none; }
.decades button { flex: none; appearance: none; border: 1px solid var(--card-border); background: var(--card); border-radius: 999px; padding: .3em .8em; font-size: .78rem; cursor: pointer; color: var(--ink-soft); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.decades button.on { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

/* ================= timeline ================= */
main { max-width: var(--maxw); margin: 0 auto; padding: .5rem 1rem 8rem; position: relative; }
.timeline { position: relative; padding-left: calc(var(--thread-x) + 22px); }
.timeline::before { content: ""; position: absolute; left: var(--thread-x); top: 0; bottom: 0; width: 2px; background: var(--thread); border-radius: 2px; }
[data-theme="night"] .timeline::before { box-shadow: 0 0 12px rgba(169,188,255,.35); }

.era {
  margin: 2.4rem 0 1.4rem calc(-1 * (var(--thread-x) + 22px)); padding: 1.2rem 1.2rem 1rem calc(var(--thread-x) + 22px);
  background: linear-gradient(to right, var(--era-tint), transparent 85%); border-radius: var(--radius); position: relative;
}
.era::before { content: ""; position: absolute; left: calc(var(--thread-x) - 7px); top: 1.55rem; width: 16px; height: 16px; border-radius: 4px; transform: rotate(45deg); background: var(--bg); border: 2px solid var(--node); }
.era h2 { font-size: 1.9rem; }
.era .era-years { color: var(--ink-soft); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; }
.era .era-note { color: var(--ink-soft); font-style: italic; margin: .3rem 0 0; }
.era details { margin-top: .6rem; }
.era summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.chapter-text { white-space: pre-wrap; margin-top: .6rem; }

.year { position: relative; margin: 2rem 0 .9rem; display: flex; align-items: baseline; gap: .6rem; }
.year::before { content: ""; position: absolute; left: calc(-22px - 5px); top: .55em; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--node); }
.year b { font-family: var(--head-font); font-size: 1.6rem; font-weight: var(--head-weight); }
.year span { color: var(--ink-soft); font-size: .85rem; }

.memory {
  position: relative; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 1rem 1.1rem 1.05rem; margin: 0 0 1.1rem; box-shadow: var(--card-shadow); cursor: pointer;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(14px); transition: opacity .7s var(--ease), transform .7s var(--ease), box-shadow .3s;
}
.memory.in { opacity: 1; transform: none; }
[data-theme="film"] .memory:nth-of-type(odd).in { transform: rotate(-.35deg); }
[data-theme="film"] .memory:nth-of-type(even).in { transform: rotate(.3deg); }
.memory::before { content: ""; position: absolute; left: calc(-22px - 4px - 1px); top: 1.35rem; width: 8px; height: 8px; border-radius: 50%; background: var(--node); opacity: .7; }
.memory[data-feel="2"]::before { width: 12px; height: 12px; left: calc(-22px - 6px - 1px); top: 1.2rem; opacity: 1; box-shadow: 0 0 0 4px color-mix(in srgb, var(--glow) 35%, transparent), 0 0 22px 4px var(--glow); }
.memory[data-feel="1"]::before { opacity: 1; box-shadow: 0 0 12px 2px var(--glow); }
.memory[data-feel="-1"]::before { background: var(--low); opacity: .8; }
.memory[data-feel="-2"]::before { background: transparent; border: 2px solid var(--low); width: 10px; height: 10px; left: calc(-22px - 5px - 1px); }
.memory[data-feel="2"] { box-shadow: var(--card-shadow), 0 0 0 1px color-mix(in srgb, var(--glow) 40%, transparent); }
.memory:hover { box-shadow: var(--card-shadow), 0 0 0 1px var(--card-border); }
.memory .when { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.memory .when .lock { opacity: .7; display: inline-flex; }
.memory .when .lock svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.memory h3 { font-size: 1.45rem; margin: .2rem 0 .15rem; }
.memory .where { color: var(--ink-soft); font-size: .9rem; }
.memory .excerpt { margin: .5rem 0 0; color: var(--ink); opacity: .88; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thumbs { display: flex; gap: .5rem; margin-top: .75rem; }
.thumb { position: relative; flex: 1; max-width: 33%; aspect-ratio: 1; border-radius: calc(var(--radius) * .6); overflow: hidden; background: var(--era-tint); }
.thumb img { width: 100%; height: 100%; object-fit: cover; filter: var(--photo-filter); opacity: 0; transition: opacity .6s; }
.thumb img.ok { opacity: 1; }
.thumb .badge { position: absolute; inset: auto .35rem .35rem auto; background: rgba(0,0,0,.45); color: #fff; border-radius: 999px; padding: .1rem .45rem; font-size: .7rem; font-family: system-ui, sans-serif; }
.thumb.audio { display: grid; place-items: center; color: var(--accent); }
.thumb.audio svg { width: 34%; height: 34%; stroke: currentColor; fill: none; stroke-width: 1.4; }
[data-theme="film"] .thumb { border-radius: 2px; background: #fff; padding: 5px; box-shadow: 0 4px 10px -4px rgba(60,35,15,.4); }
[data-theme="film"] .thumb img { border-radius: 1px; }

.empty { text-align: center; padding: 3rem 1rem; }
.empty h2 { font-size: 2.2rem; margin-bottom: .6rem; }
.empty p { color: var(--ink-soft); max-width: 30rem; margin: .4rem auto 1.4rem; }
.prompt-card { margin: 1.2rem 0 1.6rem; padding: 1rem 1.1rem; border-radius: var(--radius); border: 1px dashed var(--card-border); color: var(--ink-soft); cursor: pointer; display: flex; gap: .8rem; align-items: center; }
.prompt-card q { font-family: var(--head-font); font-size: 1.25rem; color: var(--ink); quotes: "“" "”"; font-style: italic; flex: 1; }
.nudge { margin: .2rem 0 1rem; padding: .8rem 1rem; border-radius: var(--radius); background: var(--era-tint); font-size: .9rem; display: flex; gap: .8rem; align-items: center; justify-content: space-between; }

.fab {
  position: fixed; right: max(1.2rem, env(safe-area-inset-right)); bottom: calc(1.3rem + env(safe-area-inset-bottom)); z-index: 30;
  width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer;
  box-shadow: 0 14px 30px -10px var(--glow), 0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent); display: grid; place-items: center;
  transition: transform .2s var(--ease);
}
.fab:active { transform: scale(.94); }
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }

/* ================= sheets ================= */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: var(--overlay); opacity: 0; transition: opacity .35s var(--ease); }
.sheet-wrap.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 760px; max-height: 94vh; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 24px 24px 0 0; box-shadow: 0 -20px 60px -20px rgba(0,0,0,.5);
  transform: translateY(40px); transition: transform .45s var(--ease); position: relative;
  padding: 0 1.2rem calc(2rem + env(safe-area-inset-bottom));
}
[data-theme="night"] .sheet { background: linear-gradient(to bottom, #111936, #080c1c); border: 1px solid var(--card-border); border-bottom: 0; }
[data-theme="mist"] .sheet { background: linear-gradient(to bottom, #fbf8fc, #f1ecf5); }
[data-theme="film"] .sheet { background: #f3eadb; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .4rem; padding: .8rem 1.2rem .7rem; margin: 0 -1.2rem .6rem; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.sheet-head::before { content: ""; position: absolute; top: .4rem; left: 50%; width: 42px; height: 4px; margin-left: -21px; border-radius: 4px; background: var(--card-border); }
.sheet-head h2 { flex: 1; font-size: 1.5rem; padding-top: .4rem; }
.sheet-head .btn { margin-top: .4rem; }
.sheet section { margin: 1.4rem 0; }
.sheet section > h3 { font-size: 1.25rem; margin-bottom: .6rem; }
@media (min-width: 800px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 24px; max-height: 88vh; }
}

/* memory detail */
.detail .when { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.detail h1 { font-size: 2.3rem; margin: .3rem 0 .3rem; }
.detail .where { color: var(--ink-soft); }
.detail .story { margin-top: 1.2rem; font-size: calc(var(--body-size) * 1.04); }
.detail .story p { margin: 0 0 1em; }
.gallery { display: grid; gap: .8rem; margin-top: 1.2rem; }
.gallery figure { margin: 0; }
.gallery img, .gallery video { width: 100%; border-radius: calc(var(--radius) * .7); filter: var(--photo-filter); background: var(--era-tint); min-height: 80px; }
[data-theme="film"] .gallery img { border-radius: 2px; border: 8px solid #fff; box-shadow: 0 8px 20px -10px rgba(60,35,15,.5); }
.gallery audio { width: 100%; }
.gallery figcaption { font-size: .88rem; color: var(--ink-soft); margin-top: .35rem; font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: 1rem; }
.chip { font-size: .8rem; padding: .25em .7em; border-radius: 999px; background: var(--era-tint); color: var(--ink-soft); border: 1px solid var(--card-border); }
.meta-line { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; margin-top: 1rem; color: var(--ink-soft); font-size: .88rem; }
.wider { margin-top: 1.8rem; padding: 1.1rem 1.1rem 1rem; border-radius: var(--radius); background: var(--era-tint); border: 1px solid var(--card-border); }
.wider h3 { font-size: 1.25rem; display: flex; align-items: center; gap: .5rem; }
.wider .ai-tag { font-family: var(--body-font); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; border: 1px solid var(--card-border); border-radius: 999px; padding: .1em .6em; color: var(--ink-soft); font-style: normal; }
.wider .txt { white-space: pre-wrap; margin: .6rem 0; font-size: .95rem; }
.wider .src { font-size: .8rem; color: var(--ink-soft); }
.wider .src a { word-break: break-word; }

/* editor */
.media-list { display: grid; gap: .7rem; margin: .4rem 0 1rem; }
.media-item { display: flex; gap: .7rem; align-items: center; background: var(--card); border: 1px solid var(--card-border); border-radius: calc(var(--radius) * .7); padding: .5rem; }
.media-item .mthumb { width: 58px; height: 58px; border-radius: 8px; overflow: hidden; flex: none; background: var(--era-tint); display: grid; place-items: center; color: var(--ink-soft); font-size: .7rem; }
.media-item .mthumb img { width: 100%; height: 100%; object-fit: cover; }
.media-item input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: .9rem; }
.media-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e0483e; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.feel { display: grid; grid-template-columns: repeat(5, 1fr); gap: .3rem; }
.feel button { appearance: none; border: 1px solid var(--card-border); background: var(--field); border-radius: 12px; padding: .55rem .2rem; font-size: .72rem; cursor: pointer; line-height: 1.2; color: var(--ink-soft); }
.feel button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.privacy { display: grid; gap: .45rem; }
.privacy button { appearance: none; text-align: left; border: 1px solid var(--card-border); background: var(--field); border-radius: 14px; padding: .65rem .9rem; cursor: pointer; }
.privacy button b { display: block; font-weight: 600; font-size: .92rem; }
.privacy button small { color: var(--ink-soft); font-size: .8rem; }
.privacy button.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--era-tint); }
.progress { font-size: .85rem; color: var(--ink-soft); }
.sendbox { background: var(--field); border: 1px solid var(--card-border); border-radius: 12px; padding: .8rem .9rem; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; white-space: pre-wrap; max-height: 14rem; overflow: auto; }

/* themes picker */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.theme-card { appearance: none; border: 2px solid transparent; border-radius: 16px; padding: 0; overflow: hidden; cursor: pointer; text-align: left; background: none; }
.theme-card.on { border-color: var(--accent); }
.theme-card .sw { height: 84px; position: relative; }
.theme-card .sw.film { background: radial-gradient(circle at 80% 10%, #f4b07a 0, transparent 50%), #efe5d3; }
.theme-card .sw.night { background: radial-gradient(1px 1px at 20% 30%, #fff, transparent), radial-gradient(1px 1px at 70% 60%, #fff, transparent), radial-gradient(1.5px 1.5px at 40% 80%, #dfe6ff, transparent), radial-gradient(circle at 80% 0%, #3a2d7a, transparent 60%), #070b1a; }
.theme-card .sw.mist { background: radial-gradient(circle at 20% 20%, #e8cfe6, transparent 55%), radial-gradient(circle at 80% 70%, #cfe2ea, transparent 55%), #f5f2f7; }
.theme-card .sw::after { content: ""; position: absolute; left: 18px; top: 14px; bottom: 14px; width: 2px; border-radius: 2px; background: currentColor; opacity: .6; }
.theme-card .sw.film { color: #b4603a; } .theme-card .sw.night { color: #a9bcff; } .theme-card .sw.mist { color: #a77fa8; }
.theme-card span { display: block; padding: .45rem .6rem; font-size: .82rem; background: var(--card); color: var(--ink); }

/* auth */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 2rem 1.2rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth h1 { font-size: 3.2rem; text-align: center; }
.auth .tag { text-align: center; color: var(--ink-soft); margin: .3rem 0 2rem; font-style: italic; font-family: var(--head-font); font-size: 1.25rem; }
.tabs { display: flex; gap: .3rem; margin-bottom: 1.4rem; justify-content: center; flex-wrap: wrap; }
.tabs button { appearance: none; border: 0; background: none; padding: .4em .8em; border-radius: 999px; cursor: pointer; color: var(--ink-soft); font-size: .9rem; }
.tabs button.on { background: var(--era-tint); color: var(--ink); }
.err { color: #b3413a; font-size: .9rem; margin: .4rem 0 .8rem; min-height: 1.2em; }
[data-theme="night"] .err { color: #ff9b94; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 1.15rem; letter-spacing: .06em; text-align: center; padding: 1.1rem; border-radius: 14px; background: var(--card); border: 1px dashed var(--accent); line-height: 1.9; word-spacing: .3em; user-select: all; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(6rem + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 80; background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 999px; font-size: .9rem; opacity: 0; transition: all .35s var(--ease); pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* popover */
.pop { position: absolute; right: .8rem; top: calc(100% + .3rem); background: var(--bg); border: 1px solid var(--card-border); border-radius: 16px; box-shadow: 0 20px 40px -20px rgba(0,0,0,.45); padding: .4rem; min-width: 220px; z-index: 40; }
[data-theme="night"] .pop { background: #0f1631; }
.pop button { display: flex; width: 100%; gap: .7rem; align-items: center; appearance: none; border: 0; background: none; padding: .7rem .8rem; border-radius: 10px; cursor: pointer; text-align: left; font-size: .95rem; }
.pop button:hover { background: var(--era-tint); }
.pop hr { border: 0; border-top: 1px solid var(--card-border); margin: .3rem .4rem; }
.pop svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-soft); }

.list-row { display: flex; align-items: center; gap: .6rem; padding: .7rem .2rem; border-bottom: 1px solid var(--card-border); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row small { color: var(--ink-soft); display: block; }
.edition { padding: 1rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--card-border); background: var(--card); margin-bottom: .8rem; }
.edition h3 { font-size: 1.3rem; }
.edition p { margin: .3rem 0 .8rem; color: var(--ink-soft); font-size: .92rem; }

/* print (used by the offline export) */
@media print {
  #ambient, .top, .toolbar, .fab, .viewer-bar { display: none !important; }
  html, body { background: #fff !important; color: #111 !important; }
  .memory { break-inside: avoid; box-shadow: none !important; opacity: 1 !important; transform: none !important; background: #fff !important; }
}
