:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --border: #d9dde3;
  --accent: #1f5fd6;
  --accent-text: #ffffff;
  --danger: #b42318;
  --highlight: #fff4c2;
  --live: #0b6b3a;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --border: #2a2f3a;
    --accent: #6ea0ff;
    --accent-text: #0f1115;
    --danger: #ff8a80;
    --highlight: #3a3212;
    --live: #6fd39b;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); }
h1, h2 { line-height: 1.25; }
button, input, textarea { font: inherit; color: inherit; }
input, textarea { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.6rem; }
textarea { font-family: var(--mono); resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button, .button-link {
  display: inline-block; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius); padding: 0.35rem 0.8rem; color: inherit; text-decoration: none; white-space: nowrap;
}
button:disabled { opacity: 0.6; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.link { border: none; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
button.danger { color: var(--danger); }
a { color: var(--accent); }

.page { max-width: 760px; margin: 0 auto; padding: 1rem; }
.page.wide { max-width: 1100px; }
.page.narrow { max-width: 420px; padding-top: 15vh; }
.bar {
  position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  padding: 0.6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar h1 { margin: 0; font-size: 1.1rem; flex: 1 1 12rem; overflow-wrap: anywhere; }
.status::before { content: "●"; margin-right: 0.3rem; color: var(--muted); }
.status[data-state="live"]::before { color: var(--live); }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; }
.banner { padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--highlight); }
.mono { font-family: var(--mono); }

form.stack { display: grid; gap: 0.75rem; }
label { display: grid; gap: 0.25rem; font-weight: 600; }

.composer { display: grid; gap: 0.5rem; margin: 1rem 0; }
.composer-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.75rem; }
.section { margin: 1.5rem 0 0.5rem; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.posts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.8rem; transition: background-color 1.5s ease; }
.post.fresh { background: var(--highlight); transition: none; }
.post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; font-size: 0.9rem; }
.post-author { font-weight: 600; }
.badge { font-size: 0.75rem; border: 1px solid currentColor; color: var(--live); border-radius: 999px; padding: 0 0.45rem; }
.post-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.post-text { margin: 0.4rem 0 0; font-family: var(--mono); font-size: 0.92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-file { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 0.4rem; overflow-wrap: anywhere; }
.thumb { display: block; max-width: 100%; max-height: 240px; border-radius: 4px; border: 1px solid var(--border); }
.uploads { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.upload { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.upload progress { flex: 1 1 8rem; }
.dropping { outline: 3px dashed var(--accent); outline-offset: -8px; }

.toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); max-width: calc(100% - 2rem);
  background: var(--text); color: var(--bg); padding: 0.6rem 1rem; border-radius: var(--radius);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.row-links { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; font-size: 0.9rem; }
.pin-field { display: flex; gap: 0.5rem; }
details.manage { margin-top: 0.4rem; }
details.manage form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
details.manage input { width: auto; flex: 1 1 10rem; }
