:root {
  --bg-space: #060811;
  --bg-surface: #0c101d;
  --bg-surface-elevated: #13192c;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 240, 255, 0.25);
  --cyan-neon: #00f0ff;
  --cyan-glow: rgba(0, 240, 255, 0.4);
  --violet-neon: #a855f7;
  --violet-glow: rgba(168, 85, 247, 0.35);
  --emerald-neon: #10b981;
  --rose-neon: #f43f5e;
  --amber-neon: #f59e0b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-space);
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
  line-height: 1.5;
}

code, pre, .mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Cosmic Canvas */
#cosmic-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.app-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(6, 8, 17, 0.85);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.brand-orbit-icon {
  width: 34px;
  height: 34px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-core {
  width: 10px;
  height: 10px;
  background: var(--cyan-neon);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--cyan-neon);
}

.icon-ring {
  position: absolute;
  width: 30px;
  height: 14px;
  border: 2px solid var(--cyan-neon);
  border-radius: 50%;
  transform: rotate(-25deg);
  box-shadow: 0 0 8px var(--cyan-glow);
  animation: spinRing 6s linear infinite;
}

@keyframes spinRing {
  0% { transform: rotate(-25deg) rotate(0deg); }
  100% { transform: rotate(-25deg) rotate(360deg); }
}

.nav-links {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover, .nav-link.active {
  color: var(--cyan-neon);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--cyan-glow);
  color: var(--cyan-neon);
}

.btn-primary {
  background: linear-gradient(135deg, #00f0ff 0%, #0284c7 50%, #7c3aed 100%);
  color: #040814;
  font-weight: 700;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 28px rgba(0, 240, 255, 0.55);
  color: #000;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--rose-neon);
}

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

/* IRC WORKSPACE LAYOUT */
.irc-container {
  display: grid;
  grid-template-columns: 280px 1fr 240px;
  height: calc(100vh - 65px);
  overflow: hidden;
  background: var(--bg-space);
}

/* Sidebar Channels & DMs */
.irc-sidebar-left {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

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

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 16px 20px 8px;
}

.channel-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.channel-nav-item:hover, .channel-nav-item.active {
  background: rgba(0, 240, 255, 0.07);
  color: var(--cyan-neon);
  border-left-color: var(--cyan-neon);
}

.channel-nav-item.active {
  font-weight: 600;
}

/* IRC Main Chat Stage */
.irc-main-stage {
  display: flex;
  flex-direction: column;
  background: rgba(12, 16, 29, 0.8);
  height: 100%;
  overflow: hidden;
}

.irc-chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8, 11, 20, 0.7);
  backdrop-filter: blur(8px);
}

.channel-topic {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--emerald-neon);
  padding: 4px 10px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.irc-messages-viewport {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: fadeInMsg 0.25s ease-out;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--cyan-neon);
  flex-shrink: 0;
}

.msg-bubble {
  flex: 1;
}

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

.msg-sender-nick {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
  cursor: pointer;
}

.msg-sender-nick:hover {
  color: var(--cyan-neon);
  text-decoration: underline;
}

.msg-timestamp {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.msg-text {
  font-size: 0.92rem;
  color: #cbd5e1;
  word-break: break-word;
}

.msg-action-del {
  font-size: 0.7rem;
  color: var(--rose-neon);
  cursor: pointer;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.message-row:hover .msg-action-del {
  opacity: 1;
}

.sys-message {
  background: rgba(0, 240, 255, 0.05);
  border-left: 2px solid var(--cyan-neon);
  padding: 6px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 0.8rem;
  color: var(--cyan-neon);
  font-family: 'JetBrains Mono', monospace;
}

/* Chat Input Bar */
.irc-composer-bar {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(8, 11, 20, 0.85);
  display: flex;
  gap: 12px;
}

.irc-input {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 11px 18px;
  color: #fff;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
}

.irc-input:focus {
  border-color: var(--cyan-neon);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.2);
}

/* Sidebar Right: Active Channel Members */
.irc-sidebar-right {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.2s;
}

.member-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.member-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald-neon);
  box-shadow: 0 0 6px var(--emerald-neon);
}

.member-dot.offline {
  background: var(--text-muted);
  box-shadow: none;
}

.role-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.role-owner {
  background: rgba(0, 240, 255, 0.15);
  color: var(--cyan-neon);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

.role-moderator {
  background: rgba(168, 85, 247, 0.15);
  color: var(--violet-neon);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* Modal Windows */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--cyan-glow);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px var(--cyan-glow);
  overflow: hidden;
  animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--cyan-neon);
}

/* Responsive */
@media (max-width: 960px) {
  .irc-container {
    grid-template-columns: 1fr;
  }
  .irc-sidebar-left, .irc-sidebar-right {
    display: none;
  }
  .irc-sidebar-left.mobile-open {
    display: flex;
    position: fixed;
    top: 65px;
    left: 0;
    width: 280px;
    height: calc(100vh - 65px);
    z-index: 90;
  }
}
