:root {
  color-scheme: light dark;
  --fg: #1f2328; --muted: #59636e; --bg: #f6f8fa; --card: #ffffff; --line: #d1d9e0;
  --accent: #5865f2; --accent-fg: #ffffff; --warn: #9a6700; --badge: #eef0ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6edf3; --muted: #9198a1; --bg: #0d1117; --card: #161b22; --line: #30363d;
    --accent: #6e78f7; --accent-fg: #ffffff; --warn: #d29922; --badge: #252a4a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { border-radius: 50%; }
.username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 880px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 0 0 4px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.center { text-align: center; padding: 48px 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.welcome { max-width: 520px; margin: 32px auto; text-align: center; }
.welcome .button { margin-top: 8px; }
.empty { margin-top: 16px; }

.notice { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 8px; padding: 10px 14px; }

.button { display: inline-block; border: 1px solid var(--line); border-radius: 8px; padding: 8px 16px; font: inherit; cursor: pointer; text-decoration: none; background: var(--card); color: var(--fg); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.button.quiet { padding: 6px 12px; }
.button:disabled { opacity: 0.6; cursor: default; }
.button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.servers { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.server { display: flex; gap: 14px; align-items: flex-start; }
.server-body { min-width: 0; }
.server-body p { margin: 0 0 8px; font-size: 0.95rem; }
.server-icon { flex: none; width: 48px; height: 48px; border-radius: 12px; }
.initials { display: grid; place-items: center; background: var(--badge); font-weight: 700; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; background: var(--badge); }

.foot { display: flex; justify-content: center; gap: 20px; padding: 24px 16px; font-size: 0.9rem; }
.foot a { color: var(--muted); }

/* ---- Notices ---- */
.notice.ok { border-left-color: #1a7f37; }
.notice.error { border-left-color: #cf222e; }
@media (prefers-color-scheme: dark) { .notice.ok { border-left-color: #3fb950; } .notice.error { border-left-color: #f85149; } }

/* ---- Servers list (cards are links now) ---- */
a.server { color: inherit; text-decoration: none; height: 100%; }
a.server:hover { border-color: var(--accent); }
.servers > li { display: flex; }
.servers > li > a { flex: 1; }

/* ---- Server page ---- */
.server-head { margin-bottom: 12px; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); }
.server-title { display: flex; align-items: center; gap: 12px; }
.server-title h1 { margin: 0; overflow-wrap: anywhere; }
.server-title p { margin: 0; }
.server-title .server-icon { width: 40px; height: 40px; border-radius: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tab { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.queue-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
.queue-bar .schedule { margin: 0; }
.queue-pick select { margin-left: 4px; }
select, textarea, input[type=file] { font: inherit; color: inherit; }
select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
.label { display: block; font-weight: 600; margin-bottom: 6px; }
.small { font-size: 0.85rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.row.end { justify-content: flex-end; }
.add-form { margin-bottom: 20px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.section-head h2 { margin: 0; }
.button.small { padding: 4px 10px; font-size: 0.85rem; }
.button.icon { padding: 4px 8px; font-size: 0.85rem; min-width: 30px; }
.button.danger { color: #cf222e; }
@media (prefers-color-scheme: dark) { .button.danger { color: #f85149; } }

/* ---- Question lists ---- */
.questions { list-style: none; padding: 0; margin: 8px 0 16px; display: grid; gap: 8px; }
.question { display: flex; align-items: flex-start; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.question.dragging { opacity: 0.5; border-style: dashed; }
.handle { cursor: grab; color: var(--muted); user-select: none; padding-top: 2px; }
.q-pos { flex: none; min-width: 1.6em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.q-main { flex: 1; min-width: 0; }
.q-text { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.q-id { color: var(--muted); font-variant-numeric: tabular-nums; }
.q-meta { margin: 2px 0 0; }
.q-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.edit-form { flex: 1; display: grid; gap: 6px; }
.posted summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
.posted-list .question { padding: 8px 12px; }
@media (max-width: 600px) {
  .question { flex-wrap: wrap; }
  .q-actions { width: 100%; justify-content: flex-start; padding-left: 2.4em; }
  .handle { display: none; }
}

/* ---- Starter packs and import ---- */
.packs { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pack { display: flex; flex-direction: column; }
.pack h2 { margin-bottom: 4px; }
.pack p { margin: 0 0 8px; }
.pack .row { margin-top: auto; }
blockquote { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--line); color: var(--muted); overflow-wrap: anywhere; }
.preview { margin-top: 16px; }
.preview details { margin: 8px 0; }
.preview summary { cursor: pointer; }

/* ---- Settings ---- */
.settings { margin-bottom: 20px; }
section.settings > h2 { margin: 24px 0 8px; }
.choices { display: grid; gap: 8px; margin: 8px 0 16px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); }
.choice input { margin-top: 4px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-items: end; margin: 8px 0; }
.field { display: grid; gap: 4px; }
.field .label { margin: 0; }
.field select { width: 100%; }
.check { display: flex; gap: 8px; align-items: center; }
.channel-settings { margin-bottom: 12px; }
.channel-settings h3 { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; overflow-wrap: anywhere; }
.badge.warn { color: var(--warn); }

/* ---- Change log ---- */
.log { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.log-entry { display: grid; grid-template-columns: 11em 14em 1fr; gap: 4px 12px; align-items: baseline; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.log-who { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; overflow-wrap: anywhere; }
.log-what { overflow-wrap: anywhere; }
@media (max-width: 720px) { .log-entry { grid-template-columns: 1fr; } }
