:root {
    --bg: #0e0f14;
    --panel: #171923;
    --text: #e8e9ef;
    --muted: #8a8fa3;
    --accent: #0fc3d2;
    --err: #ff7a7a;
    --bot: #9bb8ff;
    --mirc-white: #ffffff;
}
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f5f9;
        --panel: #ffffff;
        --text: #1b1d26;
        --muted: #5b6070;
        --accent: #0fc3d2;
        --err: #b3261e;
        --bot: #2a4fb3;
        --mirc-white: #1b1d26;
    }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
    display: flex;
    flex-direction: column;
}
.top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--panel);
    border-bottom: 1px solid #0003;
}
.brand { font-weight: 700; color: var(--accent); }
.state { color: var(--muted); flex: 1; }
button {
    background: var(--accent);
    color: #051512;
    border: 0;
    border-radius: 4px;
    padding: 6px 14px;
    font-weight: 600;
    cursor: pointer;
}
input {
    background: var(--bg);
    color: var(--text);
    border: 1px solid #0004;
    border-radius: 4px;
    padding: 6px 8px;
    font: inherit;
}
[hidden] { display: none !important; }

.login { flex: 1; display: grid; place-items: center; padding: 16px; }
.login form {
    width: min(360px, 100%);
    background: var(--panel);
    padding: 20px;
    border-radius: 8px;
    display: grid;
    gap: 12px;
}
.login h1 { font-size: 18px; margin: 0; }
.login label { display: grid; gap: 4px; }
.login label.check { display: flex; align-items: center; gap: 8px; }
.login fieldset { border: 1px solid #0003; border-radius: 6px; display: grid; gap: 8px; }
.error { color: var(--err); margin: 0; min-height: 1em; }
.info { color: var(--muted); margin: 0; }

.chat {
    flex: 1;
    display: grid;
    grid-template-columns: 180px 1fr 180px;
    min-height: 0;
}
.chat aside { background: var(--panel); overflow: auto; padding: 8px; }
.chat aside h2 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }
.chat ul { list-style: none; padding: 0; margin: 0; }
.chat li { padding: 3px 6px; border-radius: 4px; cursor: pointer; word-break: break-all; }
.chat li:hover { background: #0002; }
.chat li.active { background: var(--accent); color: #051512; }
.chat li.unread { font-weight: 700; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topic { padding: 6px 12px; color: var(--muted); border-bottom: 1px solid #0002; min-height: 2em; }
.log { flex: 1; overflow-y: auto; padding: 8px 12px; font-family: ui-monospace, Consolas, monospace; }
.line { white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
.line.info { color: var(--muted); }
.line.err { color: var(--err); }
.line.bot { color: var(--bot); }
.line.notice { color: var(--muted); font-style: italic; }
.line.action { color: #c49cff; }
.line.own { opacity: 0.85; }
.send { display: flex; gap: 8px; padding: 8px; border-top: 1px solid #0002; }
.send input { flex: 1; min-width: 0; }

.users li { cursor: default; }
.users .mode { color: var(--accent); display: inline-block; width: 1em; }
.time { color: var(--muted); }

/* Smileys */
.smile-btn { background: transparent; padding: 2px 6px; font-size: 18px; color: inherit; }
.smile-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 4px;
    padding: 8px;
    max-height: 160px;
    overflow-y: auto;
    background: var(--panel);
    border-top: 1px solid #0002;
}
.smile-panel button {
    background: transparent;
    color: inherit;
    padding: 4px;
    font-size: 20px;
    font-weight: 400;
    text-align: center;
}
.smile-panel button:hover { background: #0002; }
.smile-panel img { height: 24px; display: block; }
.smiley-gif { height: 1.6em; width: auto; vertical-align: middle; }

/* Topic */
.topic { white-space: pre-wrap; word-break: break-word; }

@media (max-width: 720px) {
    .chat { grid-template-columns: 1fr; }
    .chat aside.targets, .chat aside.users { max-height: 120px; }
}
