*,
*::before,
*::after{
  box-sizing:border-box;
  margin:0;
  padding:0;
}

:root{
  --bg:#050712;
  --bg-elevated:#0b0f1e;
  --bg-elevated-soft:#101426;
  --border:#22263a;
  --accent:#e66ad8;
  --accent2:#5bd4ff;
  --accent3:#6dffb5;
  --text:#f5f4ff;
  --muted:#9ba1c7;
  --danger:#ff5c7a;
  --owner-grad:linear-gradient(135deg,#ff7ad9,#ffffff,#5bd4ff);
  --mod-grad:linear-gradient(135deg,#5bd4ff,#6dffb5);
  --ann-grad:linear-gradient(135deg,#c75bff,#ff5c7a);
}

body{
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background:radial-gradient(circle at top,#1b1635,#050712);
  color:var(--text);
  height:100vh;
  overflow:hidden;
  padding-top:32px; /* space for top announcement bar */
}

.layout{
  display:flex;
  height:calc(100vh - 32px);
}

.sidebar{
  width:280px;
  background:linear-gradient(180deg,#090b16,#050712 40%);
  border-right:1px solid var(--border);
  padding:16px 14px;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.sidebar-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.logo{
  font-weight:700;
  letter-spacing:0.03em;
}

.badge{
  font-size:0.75rem;
  padding:2px 6px;
  border-radius:999px;
  margin-left:4px;
  background:var(--owner-grad);
  color:#050712;
}

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

.nav-btn{
  border:none;
  border-radius:12px;
  padding:8px 10px;
  text-align:left;
  background:transparent;
  color:var(--muted);
  font-size:0.9rem;
  cursor:pointer;
  transition:background 0.15s, color 0.15s, transform 0.05s;
}

.nav-btn:hover{
  background:#15182b;
  color:var(--text);
}

.nav-btn.active{
  background:#181c35;
  color:var(--text);
}

.side-panel{
  flex:1;
  overflow:auto;
  padding-top:6px;
}

.panel-title{
  font-size:0.8rem;
  text-transform:uppercase;
  letter-spacing:0.12em;
  color:var(--muted);
  margin-bottom:4px;
}

.subsection{
  margin-top:8px;
}

.subsection-title{
  font-size:0.78rem;
  color:var(--muted);
  margin-bottom:4px;
}

.player-list{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.player-row{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 8px;
  border-radius:10px;
  cursor:pointer;
}

.player-row:hover{
  background:#16192b;
}

.avatar{
  width:28px;
  height:28px;
  border-radius:50%;
  object-fit:cover;
  background:#111320;
}

.main{
  flex:1;
  display:flex;
  flex-direction:column;
  padding:16px 16px 10px;
}

.main-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
}

.room-title{
  font-weight:600;
}

.room-sub{
  font-size:0.8rem;
  color:var(--muted);
}

.conn-badge{
  font-size:0.78rem;
  color:var(--muted);
}

.messages{
  flex:1;
  overflow-y:auto;
  padding:10px 4px 10px 0;
  border-radius:16px;
  background:radial-gradient(circle at top left,#151835,#080914);
  border:1px solid rgba(255,255,255,0.05);
}

.msg-row{
  display:flex;
  padding:6px 12px;
  gap:8px;
}

.msg-row.self{
  justify-content:flex-end;
}

.msg-body{
  max-width:70%;
}

.msg-header{
  display:flex;
  align-items:baseline;
  gap:6px;
  margin-bottom:2px;
}

.msg-username{
  font-size:0.86rem;
  font-weight:600;
}

.msg-meta{
  font-size:0.72rem;
  color:var(--muted);
}

.msg-bubble{
  padding:8px 12px;
  border-radius:18px;
  font-size:0.9rem;
  background:#111425;
  border:1px solid rgba(255,255,255,0.06);
  word-wrap:break-word;
  white-space:pre-wrap;
  box-shadow:0 6px 16px rgba(0,0,0,0.4);
}

.msg-row.self .msg-bubble{
  background:#151a33;
}

.msg-bubble.owner{
  background:rgba(10,10,20,0.9);
  border-image:var(--owner-grad) 1;
  border-width:1px;
  border-style:solid;
  border-radius:18px;
}

.msg-bubble.mod{
  background:rgba(8,16,20,0.9);
  border-image:var(--mod-grad) 1;
  border-width:1px;
  border-style:solid;
}

.msg-bubble.whisper{
  background:rgba(102,51,153,0.4);
}

.msg-img{
  max-width:260px;
  max-height:260px;
  border-radius:14px;
  display:block;
}

.msg-actions{
  margin-top:3px;
  font-size:0.72rem;
  display:flex;
  gap:4px;
}

.msg-act-btn{
  border:none;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
}

.msg-act-btn:hover{
  color:var(--text);
}

.input-bar{
  display:flex;
  align-items:center;
  gap:6px;
  margin-top:8px;
}

.input-bar input[type="text"]{
  flex:1;
  background:#080a15;
  border-radius:999px;
  border:1px solid #22263a;
  padding:9px 14px;
  color:var(--text);
  font-size:0.9rem;
}

.file-label{
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
  border-radius:999px;
  background:#101426;
  border:1px solid #22263a;
  font-size:1.1rem;
}

.file-label input{
  display:none;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn{
  border-radius:999px;
  border:1px solid transparent;
  padding:7px 14px;
  font-size:0.85rem;
  cursor:pointer;
}

.primary-btn{
  background:var(--owner-grad);
  color:#050712;
}

.secondary-btn{
  background:#12162a;
  color:var(--text);
  border-color:#22263a;
}

.ghost-btn{
  background:transparent;
  color:var(--muted);
  border-color:#22263a;
}

.danger-btn{
  background:var(--danger);
  color:#fff;
}

.full{
  width:100%;
}

.muted{
  color:var(--muted);
}

.sm{
  font-size:0.8rem;
}

.hidden{
  display:none !important;
}

.tool-block{
  margin-top:10px;
}

.tool-label{
  font-size:0.78rem;
  color:var(--muted);
  margin-bottom:4px;
}

.tool-row{
  display:flex;
  gap:6px;
}

.tool-row input,
.tool-row select,
#msg-size-select{
  flex:1;
  background:#080a15;
  border-radius:10px;
  border:1px solid #22263a;
  padding:6px 8px;
  color:var(--text);
  font-size:0.85rem;
}

#owner-ann-input{
  width:100%;
  background:#080a15;
  border-radius:12px;
  border:1px solid #22263a;
  padding:6px 8px;
  color:var(--text);
  font-size:0.85rem;
}

.top-ann-bar{
  position:fixed;
  top:0;
  left:0;
  right:0;
  height:32px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:0.8rem;
  background:var(--ann-grad);
  color:#050712;
  z-index:10;
  box-shadow:0 4px 12px rgba(0,0,0,0.5);
}

.modal-backdrop{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.7);
  z-index:20;
}

.modal{
  background:#080a15;
  border-radius:16px;
  padding:16px 18px 14px;
  width:320px;
  box-shadow:0 20px 40px rgba(0,0,0,0.6);
  border:1px solid #2a3050;
}

.modal-wide{
  width:640px;
}

.modal h2{
  font-size:1.05rem;
  margin-bottom:6px;
}

.modal label{
  display:block;
  font-size:0.8rem;
  margin-top:6px;
  margin-bottom:2px;
}

.modal input,
.modal textarea,
.modal select{
  width:100%;
  background:#050712;
  border-radius:10px;
  border:1px solid #22263a;
  padding:6px 8px;
  color:var(--text);
  font-size:0.86rem;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:10px;
}

.error-text{
  font-size:0.78rem;
  color:var(--danger);
  min-height:1em;
  margin-top:3px;
}

.gallery-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(140px,1fr));
  gap:8px;
  max-height:420px;
  overflow:auto;
}

.gallery-grid img{
  width:100%;
  border-radius:10px;
  object-fit:cover;
}

.modal-header-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:8px;
}

/* message size variants */
body.msg-size-small .msg-body{
  max-width:55%;
}
body.msg-size-small .msg-bubble{
  padding:5px 9px;
  font-size:0.82rem;
}

body.msg-size-medium .msg-body{
  max-width:65%;
}
body.msg-size-medium .msg-bubble{
  padding:7px 11px;
  font-size:0.88rem;
}

body.msg-size-large .msg-body{
  max-width:72%;
}
body.msg-size-large .msg-bubble{
  padding:9px 14px;
  font-size:0.94rem;
}

/* Force rounded input bar for safety */
.input-bar input[type="text"]{
  border-radius:18px !important;
}

/* === OWNER AURA MODE === */

/* Owner-only input bar aura */
.owner-ui .input-bar{
  background: linear-gradient(135deg,#ff6ec7,#b47cff,#6affff);
  border-radius:22px !important;
  padding:4px;
  box-shadow:0 0 22px rgba(180,124,255,0.8);
}

/* Keep inner controls still dark and readable */
.owner-ui .input-bar input[type="text"],
.owner-ui .input-bar .file-label,
.owner-ui .input-bar .primary-btn{
  background:#050712;
  border-radius:18px !important;
  box-shadow:none;
}

/* Owner-only message bubble aura */
.owner-ui .msg-bubble.owner{
  position:relative;
  border-radius:18px;
  padding:10px 14px;
  background:
    linear-gradient(#0b0d13cc,#0b0d13cc) padding-box,
    linear-gradient(135deg,#ff6ec7,#b47cff,#6affff) border-box;
  border:2px solid transparent;
  box-shadow:0 0 25px rgba(180,124,255,0.8);
}

/* Owner avatar ring (self only) */
.owner-ui .avatar.me-avatar{
  border:3px solid transparent;
  background:
    linear-gradient(#0b0d13,#0b0d13) padding-box,
    linear-gradient(135deg,#ff6ec7,#b47cff,#6affff) border-box;
  border-radius:50%;
  box-shadow:0 0 18px rgba(180,124,255,0.7);
}


/* Owner name (visible to everyone) */
.msg-username.owner-name{
  background:linear-gradient(135deg,#ff6ec7,#b47cff,#6affff);
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
}

/* Owner self extra glow (only on owner device) */
.owner-ui .msg-username.owner-self{
  text-shadow:0 0 10px rgba(180,124,255,0.8);
}


/* === ChatLoom 3.0 status dots === */
.avatar-wrap{
  position:relative;
  display:inline-block;
}
.status-dot{
  position:absolute;
  bottom:-2px;
  right:-2px;
  width:12px;
  height:12px;
  border-radius:50%;
  border:2px solid #050712;
  box-shadow:0 0 6px rgba(0,0,0,0.6);
}
.status-dot.online{
  background:#4dffff;
  box-shadow:0 0 8px #4dffff;
}
.status-dot.idle{
  background:#b47cff;
  box-shadow:0 0 8px #b47cff;
}
.status-dot.offline{
  background:#ff6ec7;
  opacity:0.5;
}


/* Auth modal tabs */
.auth-tabs{
  display:flex;
  gap:8px;
  margin-bottom:12px;
}
.auth-tab{
  flex:1;
  padding:6px 8px;
  border-radius:8px;
  border:1px solid #22263a;
  background:#080a15;
  color:var(--muted);
  font-size:0.85rem;
  cursor:pointer;
  text-align:center;
}
.auth-tab.active{
  background:#11162a;
  color:var(--text);
  border-color:#3b4265;
}
.auth-panel{
  margin-top:4px;
}


/* === V12 Glitch popup overlay for -666 === */
.glitch-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.glitch-modal.hidden {
  display: none;
}

.glitch-inner {
  background: #050505;
  color: #f5f5f5;
  padding: 16px 20px;
  border-radius: 16px;
  width: min(420px, 90%);
  transform: rotate(-1deg);
  position: relative;
  box-shadow: 0 0 40px rgba(255,255,255,0.2);
  overflow: hidden;
}

.glitch-header {
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 8px;
  color: #ffffff;
  opacity: 0.8;
}

.glitch-message {
  font-size: 14px;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.glitch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.glitch-actions button {
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  background: #ffffff;
  color: #000000;
  border-radius: 8px;
}

.glitch-pop {
  animation: glitch-pop 0.12s steps(2, end);
}

@keyframes glitch-pop {
  0%   { transform: scale(1.05) translate(-4px, 3px) rotate(-2deg); }
  50%  { transform: scale(0.98) translate(3px, -2px) rotate(1deg); }
  100% { transform: scale(1) translate(0,0) rotate(-1deg); }
}

/* === V12 D1E TERMINAL tweaks (rely on existing modal styles) === */
#d1e-modal .modal {
  background: #050505;
  color: #f5f5f5;
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(255,255,255,0.15);
}

#d1e-modal h2 {
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#d1e-modal .void-note {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 8px;
}

#d1e-modal textarea {
  width: 100%;
  resize: vertical;
  background: #050505;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  color: #f5f5f5;
  padding: 6px 8px;
  font-size: 13px;
}

#d1e-modal .void-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

