:root {
  --bg: #111111;
  --sidebar-bg: #111111;
  --card: #1a1a1a;
  --input-bg: #222222;
  --border: #2c2c2c;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-secondary: #fbbf24;
  --accent-glow: rgba(249, 115, 22, 0.18);
  --text: #f5f5f5;
  --muted: #9ca3af;
  --online: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --msg-self: rgba(249, 115, 22, 0.14);
  --msg-other: #1a1a1a;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --sidebar-bg: #ffffff;
  --card: #ffffff;
  --input-bg: #f4f4f5;
  --border: #e4e4e7;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-secondary: #f59e0b;
  --accent-glow: rgba(234, 88, 12, 0.12);
  --text: #18181b;
  --muted: #71717a;
  --msg-self: rgba(249, 115, 22, 0.1);
  --msg-other: #ffffff;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 265px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.15rem 1rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.15rem;
  padding: 0.25rem 0;
}

.brand-logo {
  width: 185px;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  display: block;
}

.theme-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s ease;
}

.theme-btn:hover {
  border-color: var(--accent);
}

.profile-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 1.25rem;
}

.profile-box label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.profile-box input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.88rem;
  outline: none;
}

.profile-box input:focus {
  border-color: var(--accent);
}

.section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  padding: 0 0.4rem;
  margin-bottom: 0.5rem;
}

.channel-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.channel-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.channel-btn:hover {
  background: var(--card);
  color: var(--text);
}

.channel-btn.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.custom-channel-form {
  display: flex;
  gap: 0.35rem;
  margin-bottom: auto;
}

.custom-channel-form input {
  flex: 1;
  min-width: 0;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.82rem;
  outline: none;
}

.custom-channel-form input:focus {
  border-color: var(--accent);
}

.custom-channel-form button {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}

.custom-channel-form button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.telemetry {
  margin-top: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.telemetry-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.telemetry-row span:first-child {
  color: var(--muted);
}

.telemetry-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text);
  font-size: 0.72rem;
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.chat-header {
  height: 60px;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header-left h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.ephemeral-pill {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--input-bg);
  border: 1px solid var(--border);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.share-btn {
  font-size: 0.72rem;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--online);
}

.status-badge.offline {
  color: var(--danger);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* Messages Stream */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-logo-big {
  width: 190px;
  height: auto;
  border-radius: 16px;
  margin-bottom: 1rem;
  user-select: none;
}

.empty-state h3 {
  color: var(--text);
  margin-bottom: 0.4rem;
  font-size: 1.05rem;
}

.empty-state p {
  font-size: 0.85rem;
  line-height: 1.5;
}

.msg-item {
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  background: var(--msg-other);
  border: 1px solid var(--border);
  max-width: 78%;
  align-self: flex-start;
}

.msg-item.self {
  background: var(--msg-self);
  border-color: rgba(249, 115, 22, 0.4);
  align-self: flex-end;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
}

.msg-author {
  font-weight: 700;
  color: var(--accent);
}

.msg-time {
  color: var(--muted);
  font-size: 0.7rem;
}

.msg-content {
  font-size: 0.92rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Composer */
.chat-composer {
  padding: 0.65rem 1.5rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--card);
}

.typing-indicator {
  min-height: 1.1rem;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-style: italic;
}

.composer-form {
  display: flex;
  gap: 0.65rem;
}

.composer-form input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
}

.composer-form input:focus {
  border-color: var(--accent);
}

.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: #111111;
  border: none;
  padding: 0 1.4rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.send-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

@media (max-width: 720px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem;
  }
  .telemetry {
    display: none;
  }
  .hero-logo-big {
    width: 130px;
  }
}
