/* ============================================================================
   The look: a deep-teal sidebar
   with cream type, solid paper to read on, and memories as a stream you can
   read in place. Palette: teal #2F94A6 · deep #1A6E7C · ground #12414B ·
   cream #F2EADA · amber #E0A43B · terracotta #CF5535 · ink #1B2A30.
   ============================================================================ */

:root {
  --s-paper: #FCFAF5;
  --s-paper-2: #F4EFE4;
  --s-hover: #F3EEE3;
  --s-line: #E6DECD;
  --s-ink: #1B2A30;
  --s-ink-2: #3F5056;
  --s-muted: #6C7A7E;
  --s-teal: #2F94A6;
  --s-deep: #1A6E7C;
  --s-ground: #12414B;
  --s-terra: #CF5535;
  --s-name: "Hanken Grotesk", var(--font-ui);
}
@media (prefers-color-scheme: dark) {
  :root:not(.os-linux) {
    --s-paper: #16252B;
    --s-paper-2: #1C2E35;
    --s-hover: #1D3038;
    --s-line: #2A424B;
    --s-ink: #EFE7D6;
    --s-ink-2: #D2C9B6;
    --s-muted: #96A3A6;
    --s-deep: #86CBD6;
  }
}

/* Sidebar: re-tokened, so every existing sidebar rule turns cream-on-teal. */
.sidebar,
html.os-linux .sidebar {
  --ink-1: rgba(250, 244, 232, 0.96);
  --ink-2: rgba(250, 244, 232, 0.76);
  --ink-3: rgba(250, 244, 232, 0.52);
  --bg-elevated: rgba(255, 255, 255, 0.08);
  --bg-active: var(--s-teal);
  --hairline-1: rgba(255, 255, 255, 0.10);
  --accent: #FFFFFF;
  background: var(--s-ground);
  color: var(--ink-1);
  border-right: 0;
}
.sidebar-item.is-active { color: #FFFFFF; font-weight: 600; }

/* Solid paper to read on, over the window's vibrancy. */
#main-host { background: var(--s-paper); }
#main-host .main { --ink-1: var(--s-ink); --ink-2: var(--s-ink-2); --ink-3: var(--s-muted); --hairline-1: var(--s-line); }
#main-host .main-header__title { font-family: "Newsreader", Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }

/* ---- The stream ------------------------------------------------------------ */

.stream { display: flex; flex-direction: column; padding: 4px 0 24px; }

.s-day { position: relative; display: flex; justify-content: center; margin: 14px 0 6px; }
.s-day::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--s-line); }
.s-day span {
  position: relative; padding: 3px 12px; border-radius: 999px;
  background: var(--s-paper); border: 1px solid var(--s-line);
  font-size: 12px; font-weight: 600; color: var(--s-ink-2);
}

.smsg {
  display: grid; grid-template-columns: 52px minmax(0, 1fr);
  padding: 8px 20px 8px 12px; border-radius: 8px; cursor: pointer; outline: none;
}
.smsg:hover, .smsg:focus-visible { background: var(--s-hover); }
.smsg.is-current { background: color-mix(in oklab, var(--s-teal) 10%, var(--s-paper)); }
.smsg__gutter { display: flex; justify-content: center; align-items: flex-start; padding-top: 2px; }

/* A memory's place in the tree: a dot starts a thread, a hook answers one. */
.snode {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 18px; height: 22px;
}
/* The menu bar's two marks, in the dashboard's teal: the reply's hook is the
   same colour, lighter, ending in a smaller dot. Depth is the tree's to show. */
.snode--root { color: var(--s-teal); }
.snode--reply { color: color-mix(in oklab, var(--s-teal) 60%, var(--s-paper)); }

.smsg__head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.smsg__gist { font-size: 15px; color: var(--s-ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smsg__head time { font-size: 12px; color: var(--s-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.smsg__num { margin-left: auto; flex-shrink: 0; white-space: nowrap; font-size: 11px; color: var(--s-muted); font-variant-numeric: tabular-nums; }
.smsg__images { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; font-size: 11px; color: var(--s-muted); font-variant-numeric: tabular-nums; }
.smsg__images svg { display: block; }
/* A memory's images, small, under its words. The box has a size before the picture
   arrives, so the list doesn't jump as rows scroll in. */
.smsg__thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.smsg__thumb {
  display: block; width: 108px; height: 72px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--s-line); background: var(--s-paper-2);
}
.smsg--child .smsg__thumb { width: 84px; height: 56px; }
.smsg__re { margin-top: 2px; font-size: 12.5px; color: var(--s-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.smsg__text {
  margin-top: 3px; font-size: 15px; line-height: 1.47; color: var(--s-ink);
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden;
}
.smsg__text code {
  font-family: var(--font-mono); font-size: 12.5px; padding: 1px 5px; border-radius: 4px;
  background: var(--s-paper-2); border: 1px solid var(--s-line); color: var(--s-terra);
}
.scode {
  margin: 6px 0 2px; padding: 10px 12px; border-radius: 8px;
  background: var(--s-paper-2); border: 1px solid var(--s-line);
  font-family: var(--font-mono); font-size: 12.5px; white-space: pre-wrap;
}
.slink { color: var(--s-deep); text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--s-deep) 40%, transparent); }
.sptr {
  font-family: var(--font-mono); font-size: 12px; padding: 1px 6px; border-radius: 5px;
  background: color-mix(in oklab, var(--s-deep) 10%, transparent); color: var(--s-deep);
}
.smsg__more { margin-top: 2px; padding: 0; border: 0; background: none; color: var(--s-deep); font-weight: 600; font-size: 13px; cursor: pointer; }
.smsg__more[hidden] { display: none; }
.smsg__replies { margin-top: 4px; font-size: 13px; font-weight: 700; color: var(--s-deep); }

/* ---- Threads as a tree, like a file manager ------------------------------- */

.smsg__gutter { gap: 2px; justify-content: flex-end; align-items: center; padding-right: 8px; padding-top: 0; height: 22px; }
.smsg { grid-template-columns: 52px minmax(0, 1fr); }
.stwisty {
  width: 22px; height: 22px; margin-top: 7px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 5px; background: none; color: var(--s-muted); cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}
.stwisty:hover { background: var(--s-paper-2); color: var(--s-ink); }
.stwisty.is-open svg { transform: rotate(90deg); }
.stwisty svg { transition: transform 120ms ease; }
.stwisty--leaf { cursor: default; }
@media (prefers-reduced-motion: reduce) { .stwisty svg { transition: none; } }

.smsg__replies {
  display: inline-block; padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--s-deep);
}
.smsg__replies:hover { text-decoration: underline; }

/* Each level indents and hangs from a guide line, as folders do. */
.stree { position: relative; margin-left: 34px; padding-left: 14px; }
.stree::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 18px;
  border-left: 1px solid var(--s-line);
}
.stree__node { position: relative; }
.stree__node::before {
  content: ""; position: absolute; left: -14px; top: 22px; width: 12px;
  border-top: 1px solid var(--s-line);
}
.smsg--child { grid-template-columns: 48px minmax(0, 1fr); padding-top: 6px; padding-bottom: 6px; }
.smsg--child .smsg__gist, .smsg--child .smsg__text { font-size: 14px; }
.smsg__gutter .stwisty { margin-top: 0; }
.smsg.is-here { background: color-mix(in oklab, var(--s-teal) 12%, var(--s-paper)); box-shadow: inset 2px 0 0 var(--s-teal); }
.s-tree-err { margin: 4px 0 8px 52px; color: var(--s-terra); font-size: 13px; }

/* Deep threads keep their shape without squeezing the words out: indentation
   stops growing after three levels, and tightens in a narrow window. */
.stree .stree .stree .stree { margin-left: 12px; padding-left: 10px; }
@media (max-width: 720px) {
  .stree { margin-left: 20px; padding-left: 8px; }
  .stree .stree .stree { margin-left: 8px; padding-left: 6px; }
}

/* A deep thread never scrolls the page sideways; its words wrap instead. */
#main-host .main-body { overflow-x: hidden; }
.smsg, .smsg__body, .stree__node { min-width: 0; }
.smsg__head, .smsg__text { overflow-wrap: anywhere; }

/* The memory last read stays marked behind the modal and after it. */
.smsg.is-read { background: var(--s-hover); border-radius: 8px; }

/* Reading one memory. */
.memory-modal {
  width: min(760px, calc(100vw - 48px));
  max-height: calc(100vh - 72px);
  padding: 0;
  border: 1px solid var(--s-line);
  border-radius: 12px;
  background: var(--s-paper);
  color: var(--s-ink);
  box-shadow: 0 24px 70px rgba(10, 30, 36, 0.32);
  overflow: hidden;
}
.memory-modal[open] { display: flex; }
.memory-modal::backdrop { background: rgba(14, 40, 47, 0.38); }
.memory-modal__panel {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: calc(100vh - 72px);
  padding: 26px 30px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.memory-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  padding: 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--s-muted);
  cursor: pointer;
}
.memory-modal__close:hover { background: var(--s-hover); color: var(--s-ink); }
.memory-modal__close:focus-visible,
.memory-modal__id:focus-visible { outline: 2px solid var(--s-teal); outline-offset: 1px; }
.memory-modal__head { display: flex; gap: 12px; align-items: flex-start; padding-right: 28px; }
.memory-modal__head .snode { flex: none; margin-top: 2px; }
.memory-modal__titles { min-width: 0; display: grid; gap: 3px; }
.memory-modal__gist {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.memory-modal__text {
  font-size: 15px;
  line-height: 1.55;
  color: var(--s-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.memory-modal__images {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.memory-modal__image {
  margin: 0;
}
/* The width and height attributes hold the place while the bytes load. */
.memory-modal__image img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--s-line);
  border-radius: 6px;
}
.memory-modal__image--withdrawn {
  padding: 14px 16px;
  border: 1px dashed var(--s-line);
  border-radius: 6px;
}
.memory-modal__image.memory-modal__image--withdrawn figcaption {
  margin-top: 0;
  opacity: 0.85;
}
.memory-modal__image figcaption {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}
.memory-modal__text code {
  font-size: 13px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--s-paper-2);
}
.memory-modal__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--s-line);
  font-size: 12px;
  color: var(--s-muted);
}
.memory-modal__id {
  padding: 2px 6px;
  border: 1px solid var(--s-line);
  border-radius: 4px;
  background: transparent;
  color: var(--s-ink-2);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  cursor: pointer;
}
.memory-modal__id:hover { background: var(--s-hover); }
.memory-modal__actions { display: flex; align-items: center; gap: 8px; }
.memory-modal__reply {
  padding: 3px 10px;
  border: 1px solid var(--s-line);
  border-radius: 5px;
  background: transparent;
  color: var(--s-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.memory-modal__reply:hover { background: var(--s-hover); }
.memory-modal__reply:focus-visible { outline: 2px solid var(--s-teal); outline-offset: 1px; }
.memory-modal__status { margin: 0; color: var(--s-muted); }
@media (max-width: 600px) {
  .memory-modal { width: calc(100vw - 24px); }
  .memory-modal__gist { font-size: 18px; }
  .memory-modal__panel { padding: 22px 18px 14px; }
}

/* The line under the list: "Loading more…" while a page comes, then how many are shown. */
.stream-pager { padding: 8px 0 32px; text-align: center; font-size: var(--fs-micro, 12px); color: var(--ink-3); min-height: 1px; }
