:root {
  color-scheme: dark;
  --bg: #0b1220; --surface: #111a2c; --alt: #18233a; --border: #24324d;
  --text: #f1f5f9; --dim: #94a3b8; --accent: #d946ef; --accent-soft: rgba(217, 70, 239, 0.16);
  --ok: #22c55e; --bad: #ef4444; --warn: #f59e0b;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
h1 { font-size: 26px; letter-spacing: -0.3px; margin: 8px 0 4px; }
h2 { font-size: 16px; margin: 0 0 4px; }
h2.section { margin: 28px 0 8px; font-size: 12px; letter-spacing: 0.5px; color: var(--dim); text-transform: uppercase; }
a { color: var(--accent); }
.muted { color: var(--dim); margin: 4px 0 12px; }
.lead { color: var(--dim); max-width: 60ch; margin: 0 0 24px; }
.error { color: var(--bad); margin: 12px 0; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--text); font-size: 18px; font-weight: 700; cursor: pointer; padding: 4px; border-radius: 8px; }
main { width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 20px 40px; flex: 1; display: flex; flex-direction: column; }
section[hidden] { display: none; }
#room:not([hidden]) { flex: 1; display: flex; flex-direction: column; min-height: 0; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 10px 20px; min-height: 44px; font-weight: 600; }
.primary:disabled { opacity: 0.5; cursor: default; }
.ghost { background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; min-height: 40px; }
.ghost:hover { background: var(--alt); }
.danger { color: var(--bad); }
input[type="text"], textarea { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; min-height: 44px; width: 100%; }
textarea { resize: none; max-height: 140px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; }
.row input { flex: 1; letter-spacing: 1px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list button { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px; }
.list button:hover { border-color: var(--accent); }
.list .name { font-weight: 600; letter-spacing: 1.5px; }

.room-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.room-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-title .muted { margin: 0; font-size: 13px; }
.code { align-self: flex-start; background: none; border: 0; padding: 0; font-size: 22px; font-weight: 700; letter-spacing: 3px; }
.code:hover { color: var(--accent); }

.feed { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0 12px; min-height: 240px; max-height: calc(100vh - 290px); }
.empty { color: var(--dim); text-align: center; margin: 48px 16px; }
.item { max-width: 88%; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; }
.item.mine { align-self: flex-end; background: var(--accent-soft); }
.item .body { flex: 1; min-width: 0; }
.item .who { font-size: 11px; font-weight: 600; letter-spacing: 0.4px; color: var(--dim); text-transform: uppercase; }
.item .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.item .title { overflow-wrap: anywhere; }
.item .meta { font-size: 13px; color: var(--dim); }
.item .meta.bad { color: var(--bad); }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.item .actions button, .item .actions a.btn { background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; min-height: 36px; }
.item .actions button:hover, .item .actions a.btn:hover { border-color: var(--accent); }
.item .actions a.btn { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; font-size: 15px; }
.bar { height: 6px; border-radius: 3px; background: var(--alt); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.paused > i { background: var(--dim); }

.composer { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--border); padding-top: 12px; }
.composer textarea { flex: 1; }
.drop { position: fixed; inset: 0; background: rgba(11, 18, 32, 0.9); border: 3px dashed var(--accent); margin: 16px; border-radius: 24px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; z-index: 10; pointer-events: none; }
.drop[hidden] { display: none; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--alt); border: 1px solid var(--border); padding: 10px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: 0.2s; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
@media (max-width: 520px) { .item { max-width: 100%; } .room-head { flex-wrap: wrap; } }
