/* 1q Chat — Liquid Glass + Metallic UI */

:root {
  --bg-deep: #080b14;
  --bg: #0d1120;
  --bg-2: #111828;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-2: rgba(255, 255, 255, 0.09);
  --glass-hover: rgba(255, 255, 255, 0.12);
  --glass-active: rgba(255, 255, 255, 0.16);
  --border: rgba(255, 255, 255, 0.1);
  --border-bright: rgba(255, 255, 255, 0.2);
  --accent: #4a9eff;
  --accent-dim: rgba(74, 158, 255, 0.18);
  --accent-glow: rgba(74, 158, 255, 0.35);
  --text: #dde4f0;
  --text-dim: rgba(221, 228, 240, 0.55);
  --text-muted: rgba(221, 228, 240, 0.3);
  --danger: #ff4a6e;
  --danger-dim: rgba(255, 74, 110, 0.15);
  --success: #4aff9e;
  --warn: #ffb84a;
  --metallic-start: rgba(200, 215, 230, 0.14);
  --metallic-mid: rgba(120, 145, 170, 0.08);
  --metallic-end: rgba(180, 200, 220, 0.12);
  --shine: rgba(255, 255, 255, 0.07);
  --topbar-h: 56px;
  --sidebar-w: 270px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --blur: blur(24px) saturate(160%);
  --blur-sm: blur(12px) saturate(140%);
  --shadow: 0 8px 32px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-sm: 0 4px 16px rgba(0,0,0,0.35);
  --glow-accent: 0 0 20px rgba(74,158,255,0.25), 0 0 40px rgba(74,158,255,0.1);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* ── Background gradient ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(74,158,255,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(120,80,255,0.06) 0%, transparent 60%),
    linear-gradient(180deg, #080b14 0%, #0a0e1a 100%);
}

/* ── Glass panel mixin ── */
.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Layout ── */
#app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  height: 100vh;
  gap: 0;
}

/* ── Top Bar ── */
#topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), var(--shadow-sm);
}

/* Metallic shine on topbar */
#topbar::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
  pointer-events: none;
  border-radius: 0;
}

#logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #a0c8ff 0%, #ffffff 40%, #7aacff 70%, #c0d8ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 8px rgba(74,158,255,0.4));
  flex-shrink: 0;
  user-select: none;
  position: relative;
}

#logo::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(74,158,255,0.5), transparent);
}

/* Server input area */
#server-wrap {
  position: relative;
  flex: 0 0 260px;
}

#server-input {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#server-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim), var(--glow-accent);
}

#server-input::placeholder { color: var(--text-muted); }

#server-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #141b2d;
  backdrop-filter: var(--blur);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 200;
  overflow: hidden;
  display: none;
}

#server-dropdown.open { display: block; }

.server-option {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.server-option:hover { background: var(--glass-hover); color: var(--text); }

.server-option .remove-server {
  margin-left: auto;
  opacity: 0;
  font-size: 11px;
  color: var(--danger);
  padding: 2px 4px;
  border-radius: 3px;
  transition: opacity 0.15s;
}

.server-option:hover .remove-server { opacity: 1; }

#connect-btn {
  padding: 7px 16px;
  background: linear-gradient(135deg, rgba(74,158,255,0.25) 0%, rgba(74,158,255,0.12) 100%);
  border: 1px solid rgba(74,158,255,0.35);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

#connect-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 50%);
  pointer-events: none;
}

#connect-btn:hover {
  background: linear-gradient(135deg, rgba(74,158,255,0.35) 0%, rgba(74,158,255,0.2) 100%);
  box-shadow: var(--glow-accent);
}

/* Username area */
#username-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  min-width: 120px;
}

#username-display {
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

#username-display:hover { color: var(--text); }

/* Status dot */
#status-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
  position: relative;
}

#status-dot.gray  { background: #606878; box-shadow: 0 0 6px rgba(96,104,120,0.4); }
#status-dot.green { background: #4aff9e; box-shadow: 0 0 8px rgba(74,255,158,0.6), 0 0 16px rgba(74,255,158,0.3); }
#status-dot.yellow { background: #ffb84a; box-shadow: 0 0 8px rgba(255,184,74,0.6), 0 0 16px rgba(255,184,74,0.3); animation: pulse 1.2s infinite; }
#status-dot.red   { background: #ff4a6e; box-shadow: 0 0 8px rgba(255,74,110,0.6), 0 0 16px rgba(255,74,110,0.3); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 3D depth ring on status dot */
#status-dot::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
}

#spacer { flex: 1; }

/* Settings cog */
#settings-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.2s;
  flex-shrink: 0;
}

#settings-btn:hover { background: var(--glass-hover); color: var(--text); border-color: var(--border-bright); }
#settings-btn svg { width: 16px; height: 16px; transition: transform 0.4s; }
#settings-btn.open svg { transform: rotate(60deg); }

/* Settings panel */
#settings-panel {
  position: absolute;
  top: calc(var(--topbar-h) + 4px);
  right: 16px;
  width: 280px;
  background: #111828;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.03);
  z-index: 300;
  overflow: hidden;
  display: none;
  animation: slideDown 0.2s ease;
}

#settings-panel.open { display: block; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.settings-header {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  padding: 11px 16px;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.settings-row label { flex: 1; font-size: 13px; color: var(--text-dim); }
.settings-row:hover { background: var(--glass); }

/* ── Sidebar ── */
#sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.sidebar-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(74,158,255,0.05);
}

.sidebar-tab:hover:not(.active) { color: var(--text-dim); background: var(--glass); }

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
}

.sidebar-section.active { display: flex; flex-direction: column; }

.sidebar-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 14px 8px;
  flex-shrink: 0;
}

.sidebar-section-header .title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-section-header .count {
  font-size: 11px;
  color: var(--text-muted);
}

/* Room list items */
.room-item {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
  gap: 10px;
  position: relative;
}

.room-item:hover { background: var(--glass-hover); }
.room-item.active { background: var(--accent-dim); }
.room-item.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.room-item .room-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--glass-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  font-family: monospace;
}

.room-item .room-info { flex: 1; overflow: hidden; }
.room-item .room-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-item .room-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

.badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-local  { background: rgba(255,184,74,0.15); color: var(--warn); border: 1px solid rgba(255,184,74,0.2); }
.badge-server { background: rgba(74,255,158,0.12); color: var(--success); border: 1px solid rgba(74,255,158,0.2); }
.badge-lock   { background: var(--glass); color: var(--text-muted); border: 1px solid var(--border); }

.room-gear {
  opacity: 0;
  padding: 4px;
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.room-item:hover .room-gear { opacity: 1; }
.room-gear:hover { background: var(--glass-hover); color: var(--text); }
.room-gear svg { width: 14px; height: 14px; }

/* No rooms placeholder */
.sidebar-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* Create room button */
#create-room-bar {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#create-room-btn {
  width: 100%;
  padding: 9px 14px;
  background: linear-gradient(135deg, rgba(74,158,255,0.15) 0%, rgba(74,158,255,0.07) 100%);
  border: 1px solid rgba(74,158,255,0.25);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

#create-room-btn::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(74,158,255,0.4), transparent);
}

#create-room-btn:hover {
  background: linear-gradient(135deg, rgba(74,158,255,0.25) 0%, rgba(74,158,255,0.12) 100%);
  box-shadow: 0 0 16px rgba(74,158,255,0.2);
}

#create-room-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Main chat area ── */
#main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#no-room {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
}

#no-room .big-logo {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -4px;
  background: linear-gradient(135deg, rgba(160,200,255,0.3) 0%, rgba(255,255,255,0.15) 50%, rgba(122,172,255,0.2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 30px rgba(74,158,255,0.15));
}

#no-room p { font-size: 14px; color: var(--text-muted); }

/* Room header */
#room-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: var(--blur-sm);
  flex-shrink: 0;
}

#room-header .room-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

#room-header .room-id-tag {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--glass-2);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
}

#room-header .spacer { flex: 1; }

#room-header .online-count {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

#room-header .online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px rgba(74,255,158,0.5);
}

#storage-indicator {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

/* Messages area */
#messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg {
  display: flex;
  flex-direction: column;
  padding: 4px 10px 4px 0;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  position: relative;
  gap: 1px;
}

.msg:hover { background: rgba(255,255,255,0.025); }

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.msg-username {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.msg-username.self { color: #b06fff; }

.msg-time {
  font-size: 11px;
  color: var(--text-muted);
}

.msg-content {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
  line-height: 1.5;
  white-space: pre-wrap;
}

.msg-content.deleted {
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
}

.msg-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 4px;
  background: #1a2340;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 5px;
  box-shadow: var(--shadow-sm);
}

.msg:hover .msg-actions { display: flex; }

.msg-action-btn {
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  transition: all 0.15s;
  border: none;
  background: none;
}

.msg-action-btn:hover { background: var(--glass-hover); color: var(--text); }
.msg-action-btn.danger:hover { color: var(--danger); }

/* System messages */
.msg-system {
  text-align: center;
  padding: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Typing indicator */
#typing-indicator {
  padding: 4px 18px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 22px;
  font-style: italic;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

.typing-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Input area */
#input-area {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: var(--blur-sm);
  flex-shrink: 0;
}

#msg-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#msg-input-wrap:focus-within {
  border-color: rgba(74,158,255,0.4);
  box-shadow: 0 0 0 2px rgba(74,158,255,0.08);
}

#msg-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  font-family: inherit;
}

#msg-input::placeholder { color: var(--text-muted); }

#send-btn {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, rgba(74,158,255,0.3) 0%, rgba(74,158,255,0.15) 100%);
  border: 1px solid rgba(74,158,255,0.35);
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#send-btn:hover {
  background: linear-gradient(135deg, rgba(74,158,255,0.45) 0%, rgba(74,158,255,0.25) 100%);
  box-shadow: var(--glow-accent);
}

#send-btn svg { width: 16px; height: 16px; }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #111828;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.04);
  width: 440px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
  position: relative;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Metallic shine on modal */
.modal::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  pointer-events: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  transition: all 0.15s;
}

.modal-close:hover { background: var(--glass-hover); color: var(--text); }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

/* Form elements */
.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input, .form-select, .form-textarea {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
  cursor: pointer;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='rgba(255,255,255,0.4)' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-select option { background: #111828; color: var(--text); }

/* Radio group */
.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-option {
  flex: 1;
  min-width: 80px;
  padding: 8px 12px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s;
  user-select: none;
}

.radio-option:hover { background: var(--glass-hover); color: var(--text); }
.radio-option.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle {
  width: 36px; height: 20px;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toggle.on {
  background: rgba(74,158,255,0.3);
  border-color: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: all 0.2s;
}

.toggle.on::after {
  left: 18px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.toggle-label { font-size: 13px; color: var(--text-dim); }

/* Checkbox */
.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-box {
  width: 16px; height: 16px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s;
}

.checkbox-box.checked {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.checkbox-box.checked::after {
  content: '✓';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--accent);
}

.checkbox-label { font-size: 13px; color: var(--text-dim); }

/* Textarea for custom word list */
.form-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: monospace;
  font-size: 12px;
}

/* Sub-indent for child options */
.sub-option {
  margin-left: 24px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.15);
  border-left: 2px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Buttons */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(74,158,255,0.4) 0%, rgba(74,158,255,0.2) 100%);
  border-color: rgba(74,158,255,0.5);
  color: #b8d8ff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(74,158,255,0.55) 0%, rgba(74,158,255,0.3) 100%);
  box-shadow: var(--glow-accent);
}

.btn-ghost {
  background: var(--glass);
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-ghost:hover { background: var(--glass-hover); color: var(--text); }

.btn-danger {
  background: var(--danger-dim);
  border-color: rgba(255,74,110,0.3);
  color: var(--danger);
}

.btn-danger:hover { background: rgba(255,74,110,0.25); box-shadow: 0 0 12px rgba(255,74,110,0.2); }

.btn-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ── Auth modal (register / set username) ── */
#auth-modal .modal-body { gap: 12px; }

/* ── Error/info toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a2340;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 1000;
  transition: transform 0.3s ease;
  white-space: nowrap;
  pointer-events: none;
}

#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { border-color: rgba(255,74,110,0.4); color: var(--danger); }
#toast.success { border-color: rgba(74,255,158,0.3); color: var(--success); }

/* ── Admin panel ── */
#admin-panel {
  position: fixed; inset: 0;
  background: #080b14;
  z-index: 600;
  display: none;
  flex-direction: column;
}

#admin-panel.open { display: flex; }

#admin-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  flex-shrink: 0;
}

#admin-topbar .title {
  font-size: 15px;
  font-weight: 700;
  color: var(--danger);
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-left: 20px;
}

.admin-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.admin-tab.active { background: var(--glass-2); color: var(--text); }
.admin-tab:hover:not(.active) { background: var(--glass); }

#admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
  vertical-align: top;
}

.admin-table tr:hover td { background: var(--glass); }

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #app {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  #sidebar { display: none; }
}

/* ── Password-join modal ── */
#password-join-modal .modal-body { gap: 12px; }

/* ── Light mode (periwinkle) ── */

body.light {
  --bg-deep: #c8cce8;
  --bg: #d4d8f0;
  --bg-2: #dde1f8;
  --glass: rgba(255, 255, 255, 0.45);
  --glass-2: rgba(255, 255, 255, 0.62);
  --glass-hover: rgba(255, 255, 255, 0.72);
  --glass-active: rgba(255, 255, 255, 0.82);
  --border: rgba(90, 110, 200, 0.18);
  --border-bright: rgba(90, 110, 200, 0.32);
  --text: #181b2e;
  --text-dim: rgba(24, 27, 46, 0.68);
  --text-muted: rgba(24, 27, 46, 0.38);
  --danger: #d42b50;
  --danger-dim: rgba(212, 43, 80, 0.1);
  --success: #1a9e5c;
  --warn: #c07010;
  --metallic-start: rgba(255, 255, 255, 0.55);
  --metallic-mid: rgba(200, 210, 240, 0.3);
  --metallic-end: rgba(230, 235, 255, 0.45);
  --shine: rgba(255, 255, 255, 0.35);
  --shadow: 0 8px 32px rgba(80, 90, 160, 0.18), 0 2px 8px rgba(80, 90, 160, 0.1);
  --shadow-sm: 0 4px 16px rgba(80, 90, 160, 0.14);
  --blur: blur(24px) saturate(140%);
}

body.light::before {
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(120, 160, 255, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(160, 120, 255, 0.09) 0%, transparent 60%),
    linear-gradient(180deg, #c8cce8 0%, #d0d4ee 100%);
}

body.light #topbar {
  background: rgba(255, 255, 255, 0.38);
  border-bottom-color: rgba(90, 110, 200, 0.2);
}

body.light #sidebar {
  background: rgba(255, 255, 255, 0.28);
  border-right-color: rgba(90, 110, 200, 0.18);
}

body.light #server-input,
body.light #msg-input-wrap,
body.light .form-input,
body.light .form-select,
body.light .form-textarea {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(90, 110, 200, 0.22);
  color: var(--text);
}

body.light #server-input::placeholder,
body.light #msg-input::placeholder { color: rgba(24, 27, 46, 0.35); }

body.light #server-dropdown {
  background: #dde1f5;
  border-color: rgba(90, 110, 200, 0.3);
}

body.light .server-option { color: var(--text-dim); }
body.light .server-option:hover { background: rgba(255,255,255,0.5); }

body.light #settings-panel,
body.light .modal {
  background: #dde1f6;
  border-color: rgba(90, 110, 200, 0.3);
}

body.light .settings-row:hover { background: rgba(255,255,255,0.35); }

body.light .room-item:hover { background: rgba(255,255,255,0.45); }
body.light .room-item.active { background: rgba(74, 158, 255, 0.15); }

body.light #input-area,
body.light #room-header {
  background: rgba(255, 255, 255, 0.3);
}

body.light .msg:hover { background: rgba(255,255,255,0.35); }

body.light .msg-actions {
  background: #dde1f6;
  border-color: rgba(90, 110, 200, 0.25);
}

body.light #admin-panel { background: #d4d8f0; }

body.light #admin-topbar {
  background: rgba(255,255,255,0.35);
  border-bottom-color: rgba(90,110,200,0.2);
}

body.light .admin-table th { border-bottom-color: rgba(90,110,200,0.2); }
body.light .admin-table td { border-bottom-color: rgba(90,110,200,0.1); }
body.light .admin-table tr:hover td { background: rgba(255,255,255,0.3); }

body.light #logo {
  background: linear-gradient(135deg, #2a5cc8 0%, #1a3a9e 40%, #4a7aff 70%, #2040b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 8px rgba(74,100,255,0.3));
}

body.light .badge-local  { background: rgba(180,120,0,0.12); color: var(--warn); border-color: rgba(180,120,0,0.2); }
body.light .badge-server { background: rgba(26,158,92,0.12); color: var(--success); border-color: rgba(26,158,92,0.2); }
body.light .badge-lock   { background: rgba(90,110,200,0.1); color: var(--text-muted); }

body.light #no-room .big-logo {
  background: linear-gradient(135deg, rgba(60,100,220,0.25) 0%, rgba(40,60,180,0.12) 50%, rgba(80,120,255,0.18) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body.light .form-select option { background: #dde1f6; color: var(--text); }

body.light .radio-option {
  background: rgba(255,255,255,0.35);
  border-color: rgba(90,110,200,0.2);
  color: var(--text-dim);
}
body.light .radio-option:hover { background: rgba(255,255,255,0.55); }
body.light .radio-option.selected {
  background: rgba(74,158,255,0.15);
  border-color: var(--accent);
  color: #1a6ad4;
}

body.light .btn-ghost {
  background: rgba(255,255,255,0.35);
  border-color: rgba(90,110,200,0.22);
  color: var(--text-dim);
}
body.light .btn-ghost:hover { background: rgba(255,255,255,0.55); }

body.light #toast {
  background: #dde1f6;
  border-color: rgba(90,110,200,0.3);
}

body.light .sub-option {
  background: rgba(255,255,255,0.2);
  border-left-color: rgba(90,110,200,0.25);
}

/* ── Delete confirm tooltip ── */
.delete-confirm {
  font-size: 12px;
  color: var(--warn);
  padding: 2px 0;
}
