:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2026;
  --muted: #5b6573;
  --border: #d8dde4;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --notice-bg: #fff4d6;
  --ok-bg: #e3f4e6;
  --error-bg: #fde7e5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1d2127;
    --text: #e6e9ee;
    --muted: #9aa5b4;
    --border: #353c46;
    --accent: #6ea8ff;
    --accent-text: #0b1a33;
    --danger: #ff8a80;
    --notice-bg: #3a3320;
    --ok-bg: #1d3524;
    --error-bg: #3d2220;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.bar nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 0 0 16px; }
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
label { display: block; margin: 12px 0 4px; font-size: 0.9rem; color: var(--muted); }
input, select {
  width: 100%; padding: 10px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
}
button, .button {
  display: inline-block; margin-top: 14px; padding: 10px 16px; font: inherit; font-weight: 600; text-decoration: none;
  color: var(--accent-text); background: var(--accent); border: 0; border-radius: 8px; cursor: pointer;
}
button.danger { background: var(--danger); }
button.link { margin: 0; padding: 0; font-weight: 400; color: var(--accent); background: none; text-decoration: underline; }
form.inline { display: inline; margin: 0; }
.row { display: flex; gap: 8px; align-items: end; }
.row button { margin-top: 0; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { margin: 0; }
.filters button { margin: 0; }
.flash, .notice { padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.flash.success { background: var(--ok-bg); }
.flash.error { background: var(--error-bg); }
.notice { background: var(--notice-bg); }
.count, .empty { color: var(--muted); }
.messages { list-style: none; margin: 0; padding: 0; }
.message { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0 0 10px; }
.message header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.sender { font-weight: 700; }
.badge { padding: 0 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.8rem; color: var(--muted); }
.badge.direct { color: var(--accent); border-color: var(--accent); }
time { margin-left: auto; font-size: 0.85rem; color: var(--muted); }
.text { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.receptions { list-style: none; margin: 6px 0 0; padding: 0; font-size: 0.85rem; color: var(--muted); }
.pagination { display: flex; justify-content: space-between; align-items: center; margin: 16px 0; }
.qr { text-align: center; }
.qr svg { max-width: 100%; height: auto; background: #fff; padding: 4px; }
.key { text-align: center; overflow-wrap: anywhere; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.codes code, .key code { font-size: 1.05rem; }
