:root{
  --bg:#111;
  --stroke:#222;
  --stroke2:#333;
  --text:#eee;
  --muted:rgba(255,255,255,.70);
  --yellow:#ffd400;
  --zebraA: rgba(0,0,0,0.0);
  --zebraB: rgba(255,255,255,0.035);
  --hl_bg:#3a0d0d;
  --hl_border:#a00000;
  --panel:#181818;
  --danger:#ff6d6d;
}

html,body{
  margin:0;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui, Segoe UI, Arial, sans-serif;
}

body{
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

#topbar{
  position:sticky;
  top:0;
  z-index:20;
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
  border-bottom:1px solid var(--stroke);
  background:var(--bg);
  flex-wrap:wrap;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:900;
}

.brand .dot{
  width:10px;height:10px;border-radius:999px;
  background:var(--yellow);
}

#btnHi,
#sendBtn,
.btn-secondary,
.btn-danger,
.mod-btn{
  border:1px solid #000;
  border-radius:10px;
  font-weight:900;
  cursor:pointer;
}

#btnHi,
#sendBtn{
  background:var(--yellow);
  color:#111;
  padding:7px 10px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08);
}

.btn-secondary{
  background:#2a2a2a;
  color:#fff;
  padding:7px 10px;
}

.btn-danger{
  background:#3a1515;
  color:#fff;
  border-color:#522;
  padding:7px 10px;
}

button:disabled{
  opacity:.45;
  cursor:not-allowed;
}

#status{
  margin-left:8px;
  font-size:12px;
  opacity:.75;
  display: none;
}

.topbar-actions{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:10px;
}

.settings-wrap{
  position:relative;
}

.settings-menu{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  width:260px;
  display:none;
  flex-direction:column;
  gap:12px;
  padding:12px;
  background:#161616;
  border:1px solid var(--stroke2);
  border-radius:12px;
  box-shadow:0 10px 24px rgba(0,0,0,.35);
  z-index:1000;
}

.settings-menu.open{
  display:flex;
}

.settings-section{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.settings-title{
  font-weight:900;
  font-size:13px;
}

.auth-chip-state{
  font-size:12px;
  color:var(--muted);
}

.auth-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

#composerBar{
  position:sticky;
  bottom:0;
  z-index:15;
  padding:12px 14px;
  border-top:1px solid var(--stroke);
  background:#141414;
}

.compose-row{
  display:flex;
  flex-direction:column;
  gap:10px;
}

#composeText{
  width:100%;
  min-height:64px;
  box-sizing:border-box;
  resize:vertical;
  border-radius:12px;
  border:1px solid var(--stroke2);
  background:#0f0f0f;
  color:var(--text);
  padding:12px;
  font:inherit;
}

.compose-footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.compose-actions{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}

.compose-actions label{
  display:flex;
  align-items:center;
  gap:6px;
  font-weight:700;
}

.compose-status{
  font-size:13px;
  color:var(--muted);
}
.compose-status.error{ color:#ff8f8f; }

#chat{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

#chat::after{
  content: "";
  display: block;
  height: 0px;
}

.msg{
  width:100%;
  box-sizing:border-box;
  padding: 6px 10px;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:nowrap;
  border:none;
  border-radius:0;
  background:var(--zebraA);
}
.msg.alt{ background:var(--zebraB); }
.msg.highlight{
  background:var(--hl_bg) !important;
  outline:1px solid var(--hl_border);
  outline-offset:-1px;
}
.msg.stale{ opacity:.55; }
.msg.deleted{ opacity:.32; filter:grayscale(1); }

.msg.system {
  background: rgba(145, 70, 255, 0.08);
  color: #ffff00;
  font-size: 16px;
  font-weight: bold;
  font-style: italic;
  padding: 6px 10px;
  border-top: 1px solid rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(0,0,0,0.4);
}
.msg.system .system-body { white-space: pre-wrap; line-height: 1.4; }
.msg.system:hover { background: rgba(255,255,255,0.05); }

.meta{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  flex: 0 0 auto;
}

.platform{ display:inline-flex; align-items:center; justify-content:center; }
.platform img{ width:18px; height:18px; opacity:.85; display:block; }

.badges{ display:inline-flex; align-items:center; gap:4px; }
.badge-img{ width:18px; height:18px; object-fit:contain; display:block; }
.badge{
  font-size:11px;
  padding:1px 6px;
  border-radius:999px;
  border:1px solid var(--stroke2);
  background:rgba(0,0,0,.25);
  opacity:.9;
}

.name{ font-size:14px; font-weight:900; line-height:1; }
.body{ min-width:0; flex:1 1 auto; word-break:break-word; }
.part-text{ display: inline; white-space: pre-wrap; }
.emote{ height:24px; width:auto; vertical-align:middle; margin: 0 3px; }
a.link { color: #ffff00; text-decoration: underline; }
a.link:hover { filter: brightness(1.1); }

.mod-menu{
  margin-left:auto;
  position:relative;
  flex:0 0 auto;
}

.mod-menu-toggle,
.mod-btn{
  background:#202020;
  color:#fff;
  border-color:#343434;
  padding:4px 8px;
  font-size:12px;
}

.mod-menu-toggle{
  border:1px solid #000;
  border-radius:10px;
  font-weight:900;
  cursor:pointer;
}

.mod-menu-panel{
  position:absolute;
  right:0;
  top:calc(100% + 6px);
  min-width:116px;
  display:none;
  flex-direction:column;
  gap:6px;
  padding:8px;
  background:#161616;
  border:1px solid var(--stroke2);
  border-radius:12px;
  box-shadow:0 10px 24px rgba(0,0,0,.35);
}

.mod-menu.open .mod-menu-panel{ display:flex; }

.mod-btn{
  width:100%;
  text-align:left;
}

@media (max-width: 980px) {
  .topbar-actions{
    width:100%;
    justify-content:flex-end;
  }
}

@media (max-width: 820px) {
  .msg{ align-items:flex-start; flex-wrap:wrap; }
  .mod-menu{ margin-left:24px; }
  .compose-footer{ align-items:flex-start; }
}

.name-mod-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.name-mod-toggle {
  cursor: pointer;
}

.mod-menu-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
}

.name-mod-menu.open .mod-menu-panel {
  display: flex;
  flex-direction: column;
}

#composeStatus {
  display: none;
}