@font-face { font-family: Fraunces; src: url(/fonts/fraunces.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(/fonts/instrument-sans.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }

/* Three themes. Each sets the same tokens. */
:root, [data-theme="pflaume"] {
  --bg: #1d1320; --surface: #2a1c2e; --raise: #38263c; --line: #4a3550;
  --text: #f1e6d6; --dim: #b59fae; --accent: #e0a82e; --on-accent: #241505;
  --mine: #e0a82e; --on-mine: #241505; --theirs: #38263c; --on-theirs: #f1e6d6;
  --danger: #ff8a73; --minus: #7fb8d6;
  --h0: #e0a82e; --h1: #f1e6d6; --h2: #e58fb0; --h3: #8fc7a4; --h4: #ff8a73; --h5: #7fb8d6;
}
[data-theme="papier"] {
  --bg: #f3ecdf; --surface: #fffaf0; --raise: #e9dfcc; --line: #d6c8ae;
  --text: #1f2a44; --dim: #6a6f80; --accent: #d9482b; --on-accent: #fffaf0;
  --mine: #1f2a44; --on-mine: #f3ecdf; --theirs: #fffaf0; --on-theirs: #1f2a44;
  --danger: #b3261e; --minus: #2f6f8f;
  --h0: #d9482b; --h1: #1f2a44; --h2: #a0407a; --h3: #3f7d57; --h4: #b3261e; --h5: #2f6f8f;
}
[data-theme="moos"] {
  --bg: #18211b; --surface: #223026; --raise: #2c3d31; --line: #3d5343;
  --text: #ece5d3; --dim: #9fb0a0; --accent: #ef7d5d; --on-accent: #23100a;
  --mine: #ef7d5d; --on-mine: #23100a; --theirs: #2c3d31; --on-theirs: #ece5d3;
  --danger: #ffb199; --minus: #86b9d8;
  --h0: #ef7d5d; --h1: #ece5d3; --h2: #e6c36a; --h3: #9bd0a6; --h4: #ffb199; --h5: #86b9d8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 "Instrument Sans", system-ui, sans-serif;
  overscroll-behavior: none; }
#app { height: 100dvh; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column;
  border-inline: 1px solid var(--line); }
main { flex: 1; min-height: 0; display: flex; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font: 600 1.7rem/1.1 Fraunces, serif; margin: 0; letter-spacing: -.01em; }
h2 { font: 600 1.15rem/1.2 Fraunces, serif; margin: 26px 0 4px; }
p { margin: 0; }
.icon { display: block; flex: none; }

.view { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view.center { align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 32px; }
.mark { width: 72px; height: 72px; display: grid; place-items: center; background: var(--accent);
  color: var(--on-accent); font: 700 2.6rem Fraunces, serif; border-radius: 22px 22px 22px 6px; }
.top { padding: 18px 18px 12px; padding-top: max(18px, env(safe-area-inset-top)); }
.list { flex: 1; overflow-y: auto; min-height: 0; }
.list.pad { padding: 4px 18px 28px; display: flex; flex-direction: column; gap: 12px; }
.empty, .hint { color: var(--dim); font-size: .9rem; }
.empty { padding: 28px 18px; }
.prose { white-space: pre-wrap; }
.banner { background: var(--raise); color: var(--text); font-size: .85rem; padding: 7px 18px;
  border-bottom: 1px solid var(--line); }

/* tabs: words with a marker, no icons */
.tabs { display: flex; border-top: 1px solid var(--line); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 13px 4px 12px; color: var(--dim); text-decoration: none;
  font-size: .88rem; font-weight: 500; position: relative; }
.tabs a.on { color: var(--text); }
.tabs a.on::before { content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 3px;
  background: var(--accent); border-radius: 0 0 3px 3px; }

/* chat list */
.avatar { flex: none; border-radius: 34% 34% 34% 12%; display: grid; place-items: center; color: #fff;
  font-family: Fraunces, serif; font-weight: 600; background-size: cover; background-position: center 22%; }
.avatar-wrap { position: relative; }
.dot { position: absolute; right: -2px; bottom: -2px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg); }
.chat-row { display: flex; gap: 14px; align-items: center; width: 100%; padding: 12px 18px; }
.list.pad .chat-row { padding-inline: 0; }
.chat-row:active { background: var(--surface); }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-line { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.chat-line strong { font-weight: 600; }
.chat-line time, time { color: var(--dim); font-size: .78rem; flex: none; }
.snippet { color: var(--dim); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; border-radius: 6px; flex: none; }

/* conversation */
.chat-top { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 6px;
  padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-head { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.chat-head-text { display: flex; flex-direction: column; min-width: 0; }
.chat-head-text strong { font: 600 1.12rem/1.2 Fraunces, serif; }
.status { color: var(--dim); font-size: .8rem; min-height: 1.1em; }
.status.live { color: var(--accent); }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--dim); flex: none; }
.icon-btn:active { background: var(--raise); }
.messages { flex: 1; overflow-y: auto; min-height: 0; padding: 12px 12px 6px; display: flex; flex-direction: column; }
.day { align-self: center; color: var(--dim); font-size: .76rem; margin: 14px 0 8px; letter-spacing: .04em; text-transform: uppercase; }
.row { display: flex; margin-top: 9px; position: relative; }
.row.cont { margin-top: 3px; }
.row.me { justify-content: flex-end; }
.row.system { justify-content: center; margin: 12px 0; }
.row.system span { font-size: .8rem; color: var(--dim); border-block: 1px solid var(--line); padding: 4px 12px; }
.bubble { max-width: min(78%, 520px); padding: 8px 12px 6px; border-radius: 18px; cursor: pointer;
  overflow-wrap: anywhere; position: relative; }
.them .bubble { background: var(--theirs); color: var(--on-theirs); border-bottom-left-radius: 5px; }
.me .bubble { background: var(--mine); color: var(--on-mine); border-bottom-right-radius: 5px; }
[data-theme="papier"] .them .bubble { box-shadow: inset 0 0 0 1px var(--line); }
.row.cont.them .bubble { border-top-left-radius: 5px; }
.row.cont.me .bubble { border-top-right-radius: 5px; }
.bubble p { white-space: pre-wrap; }
.meta { display: flex; gap: 5px; justify-content: flex-end; align-items: center; font-size: .68rem; opacity: .7;
  margin-top: 2px; }
.ticks { letter-spacing: -.25em; padding-right: .25em; }
.ticks.read { opacity: 1; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.photo { display: block; max-width: 100%; height: auto; max-height: 340px; width: auto; border-radius: 12px;
  margin-bottom: 4px; background: rgba(128, 128, 128, .25); }
.quote { border-left: 3px solid currentColor; padding: 2px 8px; margin-bottom: 5px; font-size: .85rem;
  opacity: .85; display: flex; flex-direction: column; min-width: 0; flex: 1; }
.quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flash .bubble { outline: 2px solid var(--accent); outline-offset: 2px; }
.typing .bubble { display: flex; gap: 5px; padding: 13px 14px; cursor: default; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .35; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 30% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .6; } }
.menu { position: absolute; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; display: flex; flex-direction: column; min-width: 190px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.me .menu { right: 0; } .them .menu { left: 0; }
.menu button { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; }
.menu button:active { background: var(--raise); }
.composer { border-top: 1px solid var(--line); background: var(--surface);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea { flex: 1; resize: none; background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 9px 13px; max-height: 140px; min-height: 42px; scrollbar-width: none; }
.send { width: 42px; height: 42px; flex: none; display: grid; place-items: center; background: var(--accent);
  color: var(--on-accent); border-radius: 14px 14px 14px 5px; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px; }
.reply-bar .grow { flex: 1; color: var(--dim); font-size: .88rem; }
.pick { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; }
.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); display: grid; place-items: center; z-index: 20; }
.viewer img, .viewer video { max-width: 100%; max-height: 100dvh; }
.clip { position: relative; display: block; }
.tile .clip { height: 100%; }
.play { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); }
.play::after { content: ""; position: absolute; left: 21px; top: 15px; border-style: solid; border-width: 11px 0 11px 17px;
  border-color: transparent transparent transparent #fff; }
video.photo { width: 100%; height: auto; max-height: 60dvh; }

/* forms and admin */
.segments { display: flex; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: none; }
.segments button { padding: 8px 0 10px; color: var(--dim); font-weight: 500; white-space: nowrap; border-bottom: 3px solid transparent; }
.segments button.on { color: var(--text); border-bottom-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label { font-size: .82rem; font-weight: 600; color: var(--dim); }
input[type="text"], input[type="number"], textarea, select { background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 11px 16px; border-radius: 12px;
  font-weight: 600; text-align: center; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.quiet { border-color: transparent; background: none; }
.btn:disabled { opacity: .6; }
.link { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: .9rem; align-self: flex-start; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.sticky { position: sticky; bottom: -28px; background: var(--bg); padding: 12px 0 16px; border-top: 1px solid var(--line); margin-top: 8px; }
.check { display: flex; gap: 10px; align-items: center; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.slider { display: flex; flex-direction: column; gap: 2px; }
.slider-head { display: flex; justify-content: space-between; font-weight: 600; font-size: .92rem; }
.slider output { font-variant-numeric: tabular-nums; color: var(--dim); }
.slider input { width: 100%; accent-color: var(--accent); height: 28px; }
.ends { display: flex; justify-content: space-between; font-size: .76rem; color: var(--dim); }
progress { width: 100%; accent-color: var(--accent); height: 10px; }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 8px; }
.scroll-x { overflow-x: auto; }
.radar { width: 100%; max-width: 380px; display: block; margin: 0 auto; }
.radar-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-area { fill: var(--accent); fill-opacity: .32; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.radar-dot { fill: var(--accent); }
.radar-label { fill: var(--dim); font-size: 11px; }
.network, .history { display: block; min-width: 600px; width: 100%; }
.edge { stroke: var(--line); opacity: .55; }
.edge.plus { stroke: var(--accent); opacity: .95; }
.edge.minus { stroke: var(--minus); opacity: .95; stroke-dasharray: 5 4; }
.node { fill: var(--accent); stroke: var(--accent); stroke-width: 1; }
.net-head { fill: var(--text); font: 600 13px Fraunces, serif; text-anchor: middle; }
.net-label { fill: var(--dim); font-size: 10px; opacity: .7; }
.net-label.on { fill: var(--text); opacity: 1; font-weight: 600; }
.hist { fill: none; stroke-width: 2; stroke-linejoin: round; }
.hist-label { font-size: 12px; }
.hist.h0 { stroke: var(--h0); } .hist-label.h0 { fill: var(--h0); }
.hist.h1 { stroke: var(--h1); } .hist-label.h1 { fill: var(--h1); }
.hist.h2 { stroke: var(--h2); } .hist-label.h2 { fill: var(--h2); }
.hist.h3 { stroke: var(--h3); } .hist-label.h3 { fill: var(--h3); }
.hist.h4 { stroke: var(--h4); stroke-dasharray: 5 4; } .hist-label.h4 { fill: var(--h4); }
.hist.h5 { stroke: var(--h5); } .hist-label.h5 { fill: var(--h5); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; }
.facts div { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.facts span { font-size: .76rem; color: var(--dim); }
.facts div:last-child:nth-child(odd) { grid-column: span 2; }
.memory { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 4px 0 8px; }
.memory p { flex: 1; min-width: 0; }
.kind { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); width: 64px; flex: none; }
.thought { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; display: flex; flex-direction: column; gap: 2px; }
.thought .said { color: var(--dim); font-size: .88rem; }
.timings { width: 100%; border-collapse: collapse; font-size: .85rem; }
.timings td { padding: 5px 6px 5px 0; border-bottom: 1px solid var(--line); }
.timings .num { text-align: right; font-variant-numeric: tabular-nums; }

/* gallery, settings, overlays */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tile { position: relative; aspect-ratio: 1; background: var(--raise); overflow: hidden; border-radius: 6px; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile span { position: absolute; left: 0; bottom: 0; right: 0; font-size: .7rem; padding: 12px 6px 4px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
.saved { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; }
.saved p { white-space: pre-wrap; }
.swatches { display: flex; flex-direction: column; gap: 8px; }
.swatch { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.swatch.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip { width: 44px; height: 30px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; }
.chip i { width: 14px; height: 14px; border-radius: 50%; }
.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 10px; font-size: .9rem; z-index: 30; max-width: 86vw; }
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 25; }
.sheet { background: var(--surface); width: 100%; max-width: 760px; padding: 22px 18px max(18px, env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; display: flex; flex-direction: column; gap: 18px; }
