: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;
}

.sidebar-links {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  font-size: 0.72rem;
}

.sidebar-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.sidebar-links a:hover {
  color: var(--accent);
}

.empty-guides {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.empty-guides a {
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.empty-guides a:hover {
  border-color: var(--accent);
}

/* Documentation / Legal / Article Pages */
body.doc-page {
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
  display: block;
}

.doc-wrapper {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 4rem;
}

.blog-hero {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  margin-bottom: 2.25rem;
}

.blog-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.85rem;
}

.blog-hero h1 {
  font-size: 2.15rem;
  line-height: 1.25;
  margin-bottom: 0.85rem;
  letter-spacing: -0.02em;
}

.blog-hero p {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
  max-width: 760px;
}

.blog-section-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.article-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.article-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.article-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.article-cat {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article-card h2 {
  font-size: 1.15rem;
  color: var(--text);
  line-height: 1.38;
  margin-bottom: 0.65rem;
}

.article-card p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 1.15rem;
  flex: 1;
}

.article-read-more {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.doc-header a.logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.doc-header img {
  width: 150px;
  height: auto;
  border-radius: 10px;
}

.doc-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.doc-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.doc-nav a:hover,
.doc-nav a.active {
  color: var(--accent);
}

.doc-nav a.cta-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: #111111;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-weight: 700;
}

.doc-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.25rem;
  margin-bottom: 2rem;
  line-height: 1.75;
}

.doc-card h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.doc-card h2 {
  font-size: 1.35rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.doc-card h3 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.doc-card p {
  color: var(--muted);
  margin-bottom: 1rem;
  font-size: 0.96rem;
}

.doc-card ul,
.doc-card ol {
  color: var(--muted);
  margin-left: 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.doc-card li {
  margin-bottom: 0.5rem;
}

.doc-card strong {
  color: var(--text);
}

.doc-card code {
  background: var(--input-bg);
  border: 1px solid var(--border);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--accent-secondary);
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.guide-item {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-decoration: none;
  display: block;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.guide-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.guide-item h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  color: var(--text);
  font-size: 1rem;
}

.guide-item p {
  margin-bottom: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.doc-footer {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.doc-footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.doc-footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.doc-footer-links a:hover {
  color: var(--accent);
}

@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;
  }
}
