:root {
  --bg: #000000;
  --sb-bg: #000000;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-hi: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.09);
  --border-hi: rgba(255, 255, 255, 0.2);
  --fg: #ffffff;
  --fg-soft: #d4d4d8;
  --muted: #8e8e93;
  --accent: #ffffff;
  --accent-fg: #000000;
  --font: "Inter", "Vazirmatn", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
html[data-theme="light"] {
  --bg: #ffffff;
  --sb-bg: #ffffff;
  --glass: rgba(12, 14, 20, 0.04);
  --glass-hi: rgba(12, 14, 20, 0.08);
  --border: rgba(12, 14, 20, 0.09);
  --border-hi: rgba(12, 14, 20, 0.2);
  --fg: #090b10;
  --fg-soft: #27272a;
  --muted: #6e6e73;
  --accent: #090b10;
  --accent-fg: #ffffff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
button, input, textarea { font-family: inherit; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}

/* Iconic MOHIVX Mascot (Exact Desktop Match) */
.mvx-mascot {
  width: 34px;
  height: 24px;
  border-radius: 12px;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.16);
}
.mvx-mascot::before, .mvx-mascot::after {
  content: "";
  width: 3.5px;
  height: 5.5px;
  border-radius: 99px;
  background: #000000;
}
html[data-theme="light"] .mvx-mascot { background: #090b10; }
html[data-theme="light"] .mvx-mascot::before, html[data-theme="light"] .mvx-mascot::after { background: #ffffff; }

/* Right Sidebar — Pure #000000 OLED + Hairline + Liquid Glass Active Pill */
.sb {
  width: 264px;
  flex-shrink: 0;
  background: var(--sb-bg);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: width 0.22s ease, opacity 0.2s ease;
  z-index: 30;
}
.sb.collapsed {
  width: 0;
  overflow: hidden;
  border-inline-end: none;
  opacity: 0;
  pointer-events: none;
}
.sb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
  gap: 10px;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
}
.sb-brand-txt { display: flex; flex-direction: column; line-height: 1.2; }
.sb-brand-txt strong { font-size: 13.5px; font-weight: 700; letter-spacing: 0.03em; }
.sb-brand-txt span { font-size: 10.5px; color: var(--muted); }

.ico-btn {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ico-btn:hover { background: var(--glass-hi); color: var(--fg); }

.sb-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sb-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-soft);
  font-size: 13.5px;
  text-align: start;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.sb-item:hover { background: var(--glass); color: var(--fg); }
.sb-item.active {
  background: var(--glass-hi);
  border-color: var(--border-hi);
  color: var(--fg);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.sb-item.active::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg);
  flex-shrink: 0;
}
.sb-section-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 16px 14px 6px;
}
.sb-history-item {
  width: 100%;
  padding: 8px 14px;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.sb-history-item:hover { background: var(--glass); color: var(--fg); }

.sb-footer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sb-user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
}
.sb-user-meta { display: flex; flex-direction: column; min-width: 0; }
.sb-user-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-plan { font-size: 10.5px; color: var(--muted); }
.sb-foot-btns { display: flex; gap: 4px; flex-shrink: 0; }

/* Main Stage — Pure #000000 OLED */
.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}
.topbar {
  height: 54px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid var(--border-hi);
  background: var(--glass);
  color: var(--fg-soft);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.pill-btn:hover { background: var(--glass-hi); color: var(--fg); }
.pill-btn.solid { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
.pill-btn.danger { border-color: rgba(239, 68, 68, 0.45); color: #f87171; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg); }

.chat-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}
.chat-split.canvas-open { grid-template-columns: minmax(0, 1fr) minmax(320px, 0.88fr); }
.chat-col { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-col.is-empty { justify-content: center; align-items: center; padding-bottom: 10vh; }

.empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding: 0 20px;
  text-align: center;
}
.empty-hero h1 { font-size: clamp(22px, 2.8vw, 28px); font-weight: 600; letter-spacing: -0.02em; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 24px;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.chat-col.is-empty .chat-log { display: none; }

.msg-row { display: flex; flex-direction: column; }
.msg-row.user { align-items: flex-end; }
.msg-row.assistant { align-items: flex-start; }
.msg-bubble {
  max-width: 85%;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.user .msg-bubble {
  background: var(--glass-hi);
  border: 1px solid var(--border-hi);
  padding: 10px 16px;
  border-radius: 22px;
}
.msg-row.assistant .msg-bubble {
  background: var(--glass);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 22px;
}
.msg-actions { display: flex; gap: 6px; margin-top: 8px; }
.msg-act-btn {
  padding: 4px 11px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}
.msg-act-btn:hover { color: var(--fg); border-color: var(--border-hi); }

/* Bottom Composer Pill — Identical to MOHIVX Desktop App */
.composer-wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 20px;
  flex-shrink: 0;
}
.composer-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9999px;
  background: var(--glass);
  border: 1px solid var(--border-hi);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.composer-pill input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  padding: 6px 4px;
  color: var(--fg);
}
.composer-pill input::placeholder { color: var(--muted); }
.send-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}
.send-circle:disabled { opacity: 0.4; cursor: default; }

/* Canvas Split Panel */
.canvas-panel {
  border-inline-start: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.canvas-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}
.canvas-editor {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--fg);
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  resize: none;
  outline: none;
  direction: ltr;
  text-align: left;
}
.canvas-preview { flex: 1; width: 100%; border: none; background: #ffffff; }

/* Sub-panels */
.subpanel {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 40px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.subpanel h2 { font-size: 20px; font-weight: 600; }
.subpanel p { font-size: 13.5px; color: var(--muted); line-height: 1.7; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card-box {
  padding: 16px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.byok-box {
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}
.byok-box input { flex: 1; background: transparent; border: none; outline: none; font-size: 13px; }
.row-wrap { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .sb { position: fixed; inset-block: 0; inset-inline-start: 0; }
  .chat-split.canvas-open { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
