* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px Arial, Helvetica, sans-serif; color: #222; background: #fff; }
.chat { display: flex; flex-direction: column; width: 100%; height: 100%; height: 100dvh; border: 1px solid #aaa; }
header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; background: #e8e8e8; background: linear-gradient(#fafafa,#e8e8e8); border-bottom: 1px solid #b9b9b9; }
header strong { font-size: 13px; }
#status { font-size: 11px; color: #777; text-align: right; }
#status.online { color: #32713c; }
#messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 8px; background: white; overflow-wrap: anywhere; }
.line { line-height: 18px; padding: 1px 0; white-space: pre-wrap; }
.nick { font-weight: bold; }
#composer { flex: 0 0 auto; border-top: 1px solid #bbb; padding: 6px; background: #eee; }
textarea { display: block; width: 100%; min-height: 46px; resize: none; border: 1px solid #a5a5a5; border-radius: 0; padding: 5px; font: inherit; color: #222; background: #fff; }
textarea:focus { outline: 1px solid #777; outline-offset: -1px; }
.controls { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 5px; }
#nickname { color: #666; font-size: 11px; }
button { border: 1px solid #999; border-radius: 0; background: linear-gradient(#fff,#dedede); color: #222; font: bold 12px Arial, sans-serif; padding: 4px 16px; cursor: pointer; }
button:active { background: #ddd; }
button:disabled { opacity: .55; cursor: default; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 600px) { textarea { font-size: 16px; } }

/* v0.1.1: nickname control only. */
.nick-controls { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
#changeNick { font-size: 11px; font-weight: normal; padding: 2px 6px; }

/* v0.1.2: account control and login dialog only. */
#accountButton { font-size: 11px; font-weight: normal; padding: 2px 6px; }
#loginDialog { border: 1px solid #999; border-radius: 0; padding: 12px; width: 300px; max-width: calc(100% - 24px); background: #eee; color: #222; font: inherit; }
#loginDialog::backdrop { background: rgba(0,0,0,.3); }
#loginForm { display: flex; flex-direction: column; gap: 6px; }
#loginForm label { margin-top: 4px; }
#loginForm input { width: 100%; border: 1px solid #999; border-radius: 0; padding: 5px; font: inherit; }
#loginForm p { margin: 3px 0; font-size: 11px; color: #555; }
.login-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* v0.1.3: optional online-user panel only. */
.header-controls { display: flex; align-items: center; gap: 8px; }
#usersButton { font-size: 11px; font-weight: normal; padding: 2px 6px; white-space: nowrap; }
#usersPanel[hidden] { display: none; }
#usersPanel { flex: 0 1 auto; min-height: 0; max-height: 30%; overflow-y: auto; border-top: 1px solid #bbb; background: #fafafa; padding: 6px 8px; }
#usersSummary { color: #666; font-size: 11px; }
#usersList { list-style: none; margin: 4px 0 0; padding: 0; }
#usersList li { line-height: 18px; overflow-wrap: anywhere; }

/* v0.1.11: compact rounded channel-role badges, before names. */
.role-badge { display: inline-flex; align-items: center; justify-content: center; height: 15px; vertical-align: middle; margin-right: 4px; padding: 0 5px; border-radius: 4px; font: bold 9px/1 Arial, sans-serif; color: #fff; white-space: nowrap; text-align: center; }
.role-staff { background: #2458bd; }
.role-admin { background: #c62828; }
.role-mod { background: #297037; }
.role-pro { background: #e67e22; }
.role-bot { background: #8039b0; }

/* v0.1.7: signup controls only; same classic dialog styling. */
#signupButton { font-size: 11px; font-weight: normal; padding: 2px 6px; }
#signupDialog { border: 1px solid #999; border-radius: 0; padding: 12px; width: 300px; max-width: calc(100% - 24px); background: #eee; color: #222; font: inherit; }
#signupDialog::backdrop { background: rgba(0,0,0,.3); }
#signupForm { display: flex; flex-direction: column; gap: 6px; }
#signupForm label { margin-top: 4px; }
#signupForm input { width: 100%; border: 1px solid #999; border-radius: 0; padding: 5px; font: inherit; }
#signupForm p { margin: 3px 0; font-size: 11px; color: #555; }
#signupError { color: #a12b28 !important; }
#signupError:empty { display: none; }


/* v0.1.9: classic upper-right icon tabs and their dropdowns only. */
header { position: relative; padding-right: 0; }
.header-controls { min-width: 0; gap: 6px; }
#status { overflow-wrap: anywhere; }
.header-tabs { display: flex; flex: 0 0 auto; align-self: stretch; margin: -7px 0; }
.header-tabs .icon-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 25px; min-height: 30px; padding: 3px 0; border: 0; border-left: 1px solid #c6c6c6; border-radius: 0; background: linear-gradient(#fafafa,#e6e6e6); color: #555; }
.header-tabs .icon-tab svg { width: 14px; height: 14px; fill: currentColor; }
.tab-arrow { width: 0; height: 0; border-left: 3px solid transparent; border-right: 3px solid transparent; border-top: 4px solid #999; }
.header-tabs .icon-tab:not(:disabled):hover, .header-tabs .icon-tab[aria-expanded="true"] { background: #ddd; }
#usersPanel, #settingsPanel { position: absolute; z-index: 2; top: 100%; right: 0; width: 190px; max-width: calc(100vw - 2px); max-height: min(40vh, 300px); overflow-y: auto; border: 1px solid #aaa; background: #fafafa; }
#settingsPanel { padding: 2px 0; }
#settingsPanel[hidden], #settingsPanel button[hidden] { display: none; }
#settingsPanel button { display: block; width: 100%; text-align: left; padding: 5px 9px; border: 0; background: transparent; font: 12px Arial, sans-serif; }
#settingsPanel button:not(:disabled):hover, #settingsPanel button:focus-visible { background: #e5e5e5; }

/* v0.1.15: keep long channel topics from displacing the header tabs. */
#roomTopic { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-controls { flex-shrink: 0; max-width: 70%; }

/* v0.1.18: green text for bot trivia questions only. */
.trivia-question { color: #297037; }

/* Hover timestamps: overlay only, no reserved space. */
.line { position: relative; }
.line[data-timestamp]:hover::after {
    content: attr(data-timestamp);
    position: absolute;
    top: 1px;
    right: 0;
    z-index: 1;
    font: 11px/18px Arial, sans-serif;
    color: #666;
    background: #fff;
    padding-left: 5px;
    white-space: nowrap;
    pointer-events: none;
}

/* NODN v1 — visual layer only. Existing role colors and hover timestamps stay intact. */
:root { color-scheme: dark; --bg: #060e19; --panel: #0b1a2a; --edge: #1a526c; --accent: #42dbff; --muted: #92aabf; }
body { background: var(--bg); color: #e4eff9; font: 14px/1.55 system-ui, -apple-system, sans-serif; }
.chat { border: 0; position: relative; overflow: hidden; }
header { min-height: 47px; padding: 8px 0 8px 14px; background: linear-gradient(180deg,#102a3e,#091726); border-bottom: 1px solid var(--edge); }
header strong { font-size: 14px; color: #d9f6ff; }
#status { color: var(--muted); }
#status.online { color: #76e4a7; }
#messages { background: var(--bg); padding: 12px 14px; scrollbar-color: #25627e #06101b; }
.line { line-height: 22px; padding: 2px 0; }
.line[data-timestamp]:hover::after { background: #060e19; color: #91acc3; line-height: 22px; }
.trivia-question { color: #82e49c; }
#composer { background: #0a1725; border-top: 1px solid var(--edge); padding: 10px 12px; }
textarea, #loginForm input, #signupForm input { background: #07101b; color: #e9f6ff; border: 1px solid #28546e; border-radius: 5px; padding: 9px 10px; }
textarea:focus, input:focus { outline: 1px solid var(--accent); outline-offset: 0; }
textarea::placeholder { color: #839bb1; }
#nickname { color: #92b7ce; }
button { background: linear-gradient(#163e56,#0b2438); border: 1px solid #267494; border-radius: 4px; color: #d9f6ff; padding: 6px 14px; }
button:not(:disabled):hover { background: #17445c; }
#send { color: #e9fcff; background: linear-gradient(#087b9e,#075471); border-color: #31c6ea; }
#send:not(:disabled):hover { background: #0b8eb1; }
.header-tabs { margin: -8px 0; }
.header-tabs .icon-tab { width: 37px; border-left: 1px solid #1d465e; background: #0c1c2c; color: #7fcee8; }
.header-tabs .icon-tab:not(:disabled):hover, .header-tabs .icon-tab[aria-expanded="true"] { background: #173c50; }
.tab-arrow { border-top-color: #659cb5; }
#usersPanel, #settingsPanel { background: #0b1b2b; border: 1px solid #28536c; color: #e4eff9; }
#usersPanel { padding: 12px; }
#usersSummary { color: #7ed8ee; font-size: 11px; letter-spacing: .05em; }
#usersList li { line-height: 24px; }
#settingsPanel button { color: #d9f6ff; }
#settingsPanel button:not(:disabled):hover, #settingsPanel button:focus-visible { background: #17374a; }
#loginDialog, #signupDialog { background: #0d1d2e; color: #e4eff9; border: 1px solid #28789b; border-radius: 8px; }
#loginForm p, #signupForm p { color: #a5bbcf; }
#signupError { color: #ff9b9b !important; }
#loginDialog::backdrop, #signupDialog::backdrop { background: rgba(1,7,14,.78); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wide-layout #usersPanel { top: 47px; }
@media(min-width:720px) {
  .wide-layout .chat { display: grid; grid-template-columns: minmax(0,1fr) 200px; grid-template-rows: 47px minmax(0,1fr) auto; }
  .wide-layout header { grid-column: 1/-1; grid-row: 1; z-index: 3; }
  .wide-layout #messages { grid-column: 1; grid-row: 2; }
  .wide-layout #composer { grid-column: 1; grid-row: 3; }
  .wide-layout #usersPanel { position: static; grid-column: 2; grid-row: 2/4; width: auto; max-width: none; max-height: none; border: 0; border-left: 1px solid var(--edge); background: linear-gradient(#0b1827,#08131f); }
  .wide-layout #usersPanel::before { content: 'ONLINE USERS'; display: block; color: #d8f2ff; font-size: 11px; font-weight: 800; letter-spacing: .12em; margin-bottom: 4px; }
  .wide-layout #usersList li { border-bottom: 1px solid #162938; padding: 4px 0; }
  .wide-layout #usersButton { display: none; }
}
@media(max-width:480px) { body { font-size: 13px; } #messages { padding: 8px; } #composer { padding: 7px; } }
