/* ============================================================
   MindFeed — a private feed for your brain
   Theme: "midnight notebook" — warm charcoal, parchment ink,
   a single amber accent (the desk lamp that never turns off).
   ============================================================ */

:root {
  /* light: "parchment desk" */
  --bg:        #F7F5F0;
  --bg-2:      #EFEBE3;
  --surface:   #FFFFFF;
  --surface-2: #FBF9F5;
  --line:      #DDD6C8;
  --line-soft: #E8E2D6;
  --ink:       #24211A;
  --ink-dim:   #5C564A;
  --ink-faint: #8E8677;
  --accent:    #B8791A;
  --accent-2:  #8F5E12;
  --accent-soft: rgba(184, 121, 26, 0.13);
  --danger:    #C0523A;
  --on-accent: #FFFFFF;
  --scrim:     rgba(20, 18, 14, 0.88);
  --composer-shadow: 0 -2px 30px rgba(0,0,0,0.08);

  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;

  --rail: 56px;          /* width of the timestamp rail */
  --col: 660px;          /* max content width */
  --radius: 14px;
}

html[data-theme="dark"] {
  /* dark: "midnight notebook" */
  --bg:        #15130E;
  --bg-2:      #1B1812;
  --surface:   #221F17;
  --surface-2: #2A2618;
  --line:      #36311F;
  --line-soft: #2A2618;
  --ink:       #ECE4D3;
  --ink-dim:   #B5AB95;
  --ink-faint: #847B68;
  --accent:    #E2A53C;
  --accent-2:  #F0C172;
  --accent-soft: rgba(226, 165, 60, 0.13);
  --danger:    #D67857;
  --on-accent: #15130E;
  --scrim:     rgba(8, 7, 5, 0.92);
  --composer-shadow: 0 -2px 30px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* faint ambient glow from the top, like a lamp */
  background:
    radial-gradient(120% 60% at 50% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button { font-family: inherit; cursor: pointer; }
::selection { background: var(--accent-soft); }

/* ---- app shell ---- */
.shell {
  max-width: calc(var(--col) + var(--rail));
  margin: 0 auto;
  padding: 0 16px 160px;
  position: relative;
}

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 18px 0 12px;
  background: linear-gradient(var(--bg) 72%, transparent);
  backdrop-filter: blur(2px);
}
.brandrow {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.wordmark {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
}
.lamp {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 14px 2px rgba(226,165,60,0.5);
  animation: pulse 3.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.65; }
  50%      { opacity: 1; }
}
.tagline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  margin-left: auto;
  text-align: right;
}
.tagline b { color: var(--accent); font-weight: 500; }

.searchwrap { position: relative; }
.searchwrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }
.search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 11px;
  padding: 11px 14px 11px 40px;
  font-size: 15px;
  font-family: var(--sans);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search::placeholder { color: var(--ink-faint); }

/* ---- tag chips ---- */
.tagbar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 12px 0 4px;
  scrollbar-width: none;
}
.tagbar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  white-space: nowrap;
  transition: all .13s;
}
.chip:hover { color: var(--ink); border-color: var(--ink-faint); }
.chip.active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.chip .n { opacity: 0.55; margin-left: 5px; }

/* ---- the timeline feed ---- */
.feed { position: relative; padding-top: 10px; }
.feed::before {
  /* the rail line that runs through the whole stream */
  content: "";
  position: absolute;
  left: calc(var(--rail) - 1px);
  top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(var(--line) 0 70%, transparent);
}

.entry {
  position: relative;
  padding-left: var(--rail);
  margin-bottom: 22px;
  animation: rise .35s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.entry .node {
  position: absolute;
  left: calc(var(--rail) - 5px);
  top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.entry.inbound .node { background: var(--accent); }
.entry .stamp {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--ink-faint);
  position: absolute;
  left: 0;
  top: 2px;
  width: calc(var(--rail) - 16px);
  text-align: right;
}
.entry .stamp .day { color: var(--ink-dim); display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 13px 15px;
  position: relative;
  transition: border-color .15s;
}
.card:hover { border-color: var(--line); }
.card .body { white-space: pre-wrap; word-break: break-word; }
.card .body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 1px 5px;
}
.card .body pre {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
}
.card .body pre code { background: none; border: none; padding: 0; font-size: 13px; }
.card .body .htag {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.card .body .htag:hover { text-decoration: underline; }

.media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.media img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 9px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  display: block;
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
}
.src {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.src.inbound { color: var(--accent); }
.del {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.card:hover .del { opacity: 1; }
.del:hover { color: var(--danger); }

/* ---- compose bar ---- */
.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: linear-gradient(transparent, var(--bg) 28%);
  padding: 20px 16px 18px;
}
.composer-inner {
  max-width: calc(var(--col) + var(--rail));
  margin: 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 8px 8px 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  box-shadow: var(--composer-shadow), 0 0 0 1px var(--accent-soft);
}
.composer-inner:focus-within { border-color: var(--accent); }
.compose-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 180px;
  padding: 7px 0;
}
.compose-input::placeholder { color: var(--ink-faint); }
.cbtn {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-dim);
  display: grid; place-items: center;
  transition: all .15s;
}
.cbtn:hover { color: var(--ink); border-color: var(--ink-faint); }
.cbtn.send {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.cbtn.send:hover { background: var(--accent-2); }
.cbtn.send:disabled { opacity: 0.4; cursor: default; }
.thumbs { display: flex; gap: 6px; padding: 0 0 6px 0; flex-wrap: wrap; }
.thumb { position: relative; }
.thumb img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb button {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none;
  font-size: 11px; line-height: 1; display: grid; place-items: center;
}

/* ---- empty / loading states ---- */
.note {
  padding-left: var(--rail);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 13px;
  padding-top: 24px;
}
.note b { color: var(--ink-dim); font-weight: 500; }
.loadmore {
  margin: 8px 0 0 var(--rail);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 9px;
}
.loadmore:hover { color: var(--ink); border-color: var(--ink-faint); }

/* ---- login overlay ---- */
.gate {
  position: fixed; inset: 0;
  background: var(--bg);
  display: grid; place-items: center;
  z-index: 100;
  padding: 24px;
}
.gate-card {
  width: 100%; max-width: 340px;
  text-align: center;
}
.gate .wordmark { justify-content: center; font-size: 26px; margin-bottom: 6px; }
.gate p { color: var(--ink-faint); font-family: var(--mono); font-size: 12px; margin: 0 0 22px; }
.gate input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--sans);
  outline: none;
  margin-bottom: 10px;
}
.gate input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gate button {
  width: 100%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 11px;
  padding: 12px;
  font-weight: 700;
  font-size: 15px;
  transition: background .15s;
}
.gate button:hover { background: var(--accent-2); }
.gate .err { color: var(--danger); font-family: var(--mono); font-size: 12px; min-height: 16px; margin-top: 10px; }

.iconbtn {
  background: none; border: 1px solid var(--line);
  color: var(--ink-faint); border-radius: 9px;
  width: 32px; height: 32px; display: grid; place-items: center;
  transition: all .15s;
}
.iconbtn:hover { color: var(--ink); border-color: var(--ink-faint); }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: var(--scrim);
  display: grid; place-items: center;
  cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 10px; }

/* ---- responsive ---- */
@media (max-width: 560px) {
  :root { --rail: 46px; }
  .shell { padding: 0 12px 150px; }
  .entry .stamp { font-size: 9.5px; }
  .tagline { display: none; }
  .wordmark { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .entry, .lamp { animation: none; }
}
