* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #1b1e24; color: #e6e8ec; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body:not(.is-admin) .admin-only { display: none !important; }

#widget { position: relative; display: flex; flex-direction: column; height: 100%; overflow: hidden; }

header { display: flex; align-items: center; gap: 4px; padding: 2px 6px; background: #23272f; border-bottom: 1px solid #2e333d; }
header .title { font-weight: 600; font-size: 13px; flex: 1; }
header button.icon { width: 24px; height: 24px; }
header button.icon svg { width: 15px; height: 15px; }
.dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 2px; }
.dot.on { background: #3fb950; }
.dot.off { background: #f85149; }

button { font: inherit; cursor: pointer; }
button.icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #aeb4c0; }
button.icon:hover { background: #2e333d; color: #fff; }
button.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button.link { border: 0; background: none; color: #7aa2ff; padding: 0; }

#menu { position: absolute; top: 29px; left: 0; right: 0; z-index: 5; padding: 12px; background: #23272f; border-bottom: 1px solid #2e333d; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.35); }
#menu-user { display: flex; justify-content: space-between; align-items: center; }
.admin-panel { display: flex; flex-direction: column; gap: 6px; }
.admin-panel label { color: #8a93a6; font-size: 12px; }
textarea { resize: vertical; }

#pinned { display: flex; align-items: center; gap: 6px; margin: 8px 8px 0; padding: 6px 8px; border: 1px solid #3a404c; border-left: 3px solid #7aa2ff; border-radius: 6px; background: #20242b; font-size: 13px; }
#pinned-text { flex: 1; word-break: break-word; }
#pinned button.icon { width: 26px; height: 26px; }
#pinned button.icon svg { width: 16px; height: 16px; }

#messages { flex: 1; overflow-y: auto; padding: 8px 4px; overscroll-behavior: contain; }
.msg { position: relative; display: flex; gap: 10px; padding: 6px 8px; border-radius: 6px; }
.msg:hover { background: #22262d; }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; }
.body { min-width: 0; flex: 1; }
.head { display: flex; align-items: baseline; gap: 6px; }
.who { font-weight: 600; color: #fff; }
.badge { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: #e5484d; color: #fff; }
.time { color: #6b7385; font-size: 11px; }
.text { color: #d2d6dd; word-wrap: break-word; overflow-wrap: anywhere; }
a { color: #7aa2ff; }
.actions { display: none; position: absolute; top: 4px; right: 6px; gap: 2px; }
.is-admin .msg:hover .actions { display: flex; }
.actions button.icon { width: 26px; height: 26px; background: #2e333d; font-size: 13px; }
.actions button.ban { width: auto; padding: 0 8px; background: #3a2226; color: #ff8080; font-size: 12px; font-weight: 600; }
.actions button.ban:hover { background: #e5484d; color: #fff; }
@media (hover: none) { .is-admin .msg .actions { display: flex; } }

button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

@media (max-width: 640px) {
  html, body { font-size: 15px; }
  header { padding: 2px 6px; }
  header .title { font-size: 14px; }
  button.icon { width: 40px; height: 40px; }
  button.icon svg { width: 22px; height: 22px; }
  header button.icon { width: 30px; height: 30px; }
  header button.icon svg { width: 18px; height: 18px; }
  #menu { top: 35px; }
  #messages { padding: 6px 2px; -webkit-overflow-scrolling: touch; }
  .msg { gap: 10px; padding: 7px 10px; }
  .msg:hover { background: none; }
  .avatar { width: 36px; height: 36px; font-size: 16px; }
  .time { font-size: 12px; }
  .is-admin .msg .actions { position: static; align-self: center; }
  .actions button.icon { width: 32px; height: 32px; }
  .actions button.ban { height: 32px; }
  #emoji-panel { grid-template-columns: repeat(7, 1fr); margin: 0 6px; }
  #emoji-panel button { font-size: 24px; padding: 6px; }
  footer { padding: 8px 8px 10px; }
  input, textarea { padding: 11px 12px; border-radius: 10px; }
  form button:not(.icon) { padding: 11px 16px; }
}
.admin-panel button.secondary { background: #2e333d; color: #c9cfda; }
.sys { color: #8a93a6; font-size: 12px; font-style: italic; padding: 4px 10px; }

#emoji-panel { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 6px; margin: 0 8px; background: #23272f; border: 1px solid #2e333d; border-radius: 8px; }
#emoji-panel button { border: 0; background: none; font-size: 20px; padding: 4px; border-radius: 6px; }
#emoji-panel button:hover { background: #2e333d; }

footer { padding: 8px; border-top: 1px solid #2e333d; background: #1f2329; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
form { margin: 0; }
#login { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 6px; }
#composer { display: flex; align-items: center; gap: 4px; }

input, textarea { flex: 1; min-width: 0; padding: 9px 11px; border-radius: 8px; border: 1px solid #2e333d; background: #15181d; color: inherit; font: inherit; font-size: 16px; outline: none; }
input:focus, textarea:focus { border-color: #3b6ef5; }
form button:not(.icon), .admin-panel button { padding: 8px 14px; border: 0; border-radius: 8px; background: #3b6ef5; color: #fff; font-weight: 600; }
.admin-panel button.danger { background: #3a2226; color: #ff8080; }
button.send { color: #7aa2ff; }
#cooldown { min-width: 40px; text-align: center; color: #8a93a6; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.error { color: #ff7070; margin: 0; font-size: 12px; min-height: 0; }
.error:empty { display: none; }
.muted { color: #8a93a6; margin: 0; font-size: 12px; }
#footer-note { text-align: center; }
#locked-note { display: none; text-align: center; }
body.locked #locked-note { display: block; }
body.locked.is-admin #locked-note { margin-top: 6px; }
body.locked:not(.is-admin) #composer { display: none !important; }
