:root {
  --bg: #ffffff; --panel: #f4f5f7; --line: #e3e5e8; --text: #1b1d21; --muted: #6b7280;
  --accent: #2563eb; --accent-text: #ffffff; --danger: #dc2626; --ok: #16a34a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1d21; --panel: #26282d; --line: #34373d; --text: #e8e9ec; --muted: #9aa0aa;
    --accent: #4f8cff; --accent-text: #0b0c0e; --danger: #f87171; --ok: #4ade80;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header { display: flex; align-items: center; gap: 8px; padding: 12px 16px 6px; }
h1 { font-size: 16px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); }
#status { color: var(--muted); font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; min-height: 40px;
}
button:active { filter: brightness(.95); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.icon { background: transparent; border: none; padding: 6px 10px; color: var(--accent); font-size: 15px; }
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.composer { padding: 6px 16px 12px; }
textarea, input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; outline: none;
}
textarea { resize: none; }
textarea:focus, input:focus { border-color: var(--accent); }
.row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.grow { flex: 1; }
#list { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); }
.item { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.item:active { background: var(--panel); }
.item .body { flex: 1; min-width: 0; }
.meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; margin-bottom: 2px; }
.meta .me { color: var(--accent); }
.text { white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.thumb { max-width: 100%; max-height: 180px; border-radius: 8px; display: block; }
.file { display: flex; align-items: center; gap: 10px; }
.file .glyph { width: 30px; height: 36px; border: 2px solid var(--muted); border-radius: 3px 9px 3px 3px; flex: none; }
.file .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.del { background: transparent; border: none; color: var(--muted); padding: 4px 8px; min-height: 0; align-self: flex-start; }
.empty { color: var(--muted); text-align: center; padding: 48px 24px; }
.view { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.view p { margin: 0; color: var(--muted); }
.view label { font-size: 13px; color: var(--muted); }
.warn { color: var(--danger) !important; font-size: 13px; }
#flash {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 14px;
  opacity: 0; transition: opacity .15s; pointer-events: none; max-width: 90vw;
}
#flash.show { opacity: .94; }
