:root {
  color-scheme: light dark;
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0284c7;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --lock: #f1f5f9;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 12px rgb(15 23 42 / 4%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --panel: #111827;
    --ink: #e5e7eb;
    --muted: #94a3b8;
    --line: #1f2937;
    --accent: #38bdf8;
    --accent-ink: #062033;
    --danger: #f87171;
    --lock: #0f172a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

code, .pageid {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  background: var(--lock);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
  word-break: break-all;
}

/* ---------- chrome ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 650; text-decoration: none; color: var(--ink);
}

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.inline { display: inline; margin: 0; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

.foot {
  border-top: 1px solid var(--line);
  padding: 1.5rem 1.25rem; text-align: center;
  color: var(--muted); font-size: 0.85rem;
}
.foot p { margin: 0; }

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit; font-size: 0.9rem;
  text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.83rem; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* ---------- landing ---------- */

.hero { text-align: center; padding: 2rem 0 2.5rem; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.7rem); line-height: 1.15; margin: 0 0 0.75rem; letter-spacing: -0.02em; }
.lede { color: var(--muted); max-width: 46ch; margin: 0 auto 1.25rem; }
.cta { color: var(--muted); }

.steps {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 2.5rem;
}
.steps article {
  position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}
.steps h3 { margin: 0.5rem 0 0.35rem; font-size: 1.05rem; }
.steps p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.num {
  display: inline-grid; place-items: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 0.85rem; font-weight: 700;
}

.stats { display: flex; gap: 2rem; justify-content: center; margin-bottom: 2.5rem; }
.stats div { text-align: center; }
.stats strong { display: block; font-size: 1.5rem; }
.stats span { color: var(--muted); font-size: 0.85rem; }

/* Distinct from `.note` (an item's annotation, which is pre-wrapped) —
   reusing that name here inherited `white-space: pre-wrap` and rendered the
   template's own indentation as blank lines. */
.privacy {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 1.1rem 1.25rem;
}
.privacy h3 { margin-top: 0; }
.privacy p { margin-bottom: 0; color: var(--muted); font-size: 0.93rem; }

/* ---------- log page ---------- */

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.danger { margin: 0.9rem 0 0; }

/* Masonry via CSS columns rather than grid rows.
   `grid-template-rows: masonry` is still not broadly supported, and a plain
   grid sizes every row to its tallest card — which visibly broke the card
   bodies out of alignment when one item had a note and its neighbour did not. */
.grid {
  columns: 3 260px;
  column-gap: 1rem;
}
.card {
  break-inside: avoid;
  margin-bottom: 1rem;
}

.card {
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
/* The media box has to shrink for masonry to work — without this a flex child
   refuses to get shorter than its content. */
.card > * { flex-shrink: 0; }
.card .body { flex: 1 1 auto; }
.card.locked { border-style: dashed; }

.media {
  background: var(--lock);
  aspect-ratio: 4 / 3;
  display: grid;
  /* `minmax(0, 1fr)` keeps an oversized image from widening the grid track
     and pushing its siblings out of alignment. */
  grid-template-columns: minmax(0, 1fr);
}
.media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media a { display: block; height: 100%; min-width: 0; }

.placeholder {
  display: grid; place-content: center; gap: 0.4rem;
  width: 100%; height: 100%; padding: 1rem;
  color: var(--muted); text-align: center;
  overflow: hidden;
}
.placeholder.lock { color: var(--accent); }
.placeholder.file span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem; word-break: break-all;
}

.body { padding: 0.9rem 1rem; flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.title { margin: 0; font-size: 1rem; line-height: 1.35; }
.note { margin: 0; color: var(--muted); font-size: 0.9rem; white-space: pre-wrap; }

/* Push the metadata and download link to the bottom so that cards in a row
   line up regardless of whether one has a note and the next does not. */
.stamp { margin-top: auto; padding-top: 0.35rem; }

.stamp {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin: 0; color: var(--muted); font-size: 0.78rem;
  align-items: center;
}
.kind { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.7rem; }
.badge.private {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 0.05rem 0.5rem; font-weight: 600;
}
.download { margin: 0.2rem 0 0; }

/* ---------- inline editor ---------- */

.editor { border-top: 1px solid var(--line); padding: 0.5rem 1rem 0.75rem; }
.editor summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.editor form { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.75rem; }
.editor label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }

input[type="text"], textarea {
  width: 100%; padding: 0.45rem 0.6rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
  font: inherit; font-size: 0.9rem; resize: vertical;
}
input:focus-visible, textarea:focus-visible, .btn:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- auth ---------- */

.auth { max-width: 34rem; margin: 2rem auto; }
.auth h1 { font-size: 1.5rem; }
.auth .lede { margin-inline: 0; }
.authform { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; }
.authform label { font-size: 0.85rem; color: var(--muted); }
.authform .btn { align-self: flex-start; }

.error {
  background: color-mix(in srgb, var(--danger) 12%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line));
  color: var(--danger);
  border-radius: 8px; padding: 0.6rem 0.8rem; font-size: 0.9rem;
}

.hint { margin-top: 1.5rem; color: var(--muted); font-size: 0.88rem; }
.hint summary { cursor: pointer; }

/* ---------- misc ---------- */

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty h1, .empty h2 { color: var(--ink); }
.more { text-align: center; margin-top: 1.5rem; }

@media (max-width: 480px) {
  .wrap { padding: 1.25rem 0.9rem 3rem; }
  .stats { gap: 1.25rem; }
  .grid { columns: 1; }
}