/* Base layout */

:root {
  --bg: #050712;
  --bg-elevated: #0d1020;
  --bg-elevated-soft: #12152a;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.12);
  --accent-strong: #82b3ff;
  --text: #f5f6ff;
  --text-muted: #9ba3c2;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 999px;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.55);
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #13173a 0, #050712 45%, #000 100%);
  color: var(--text);
  height: 100%;
}

body {
  min-height: 100vh;
}

/* Layout */

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

body.sidebar-collapsed .layout {
  grid-template-columns: 72px minmax(0, 1fr);
}

/* Sidebar */

.sidebar {
  background: linear-gradient(180deg, #070918 0%, #02030a 100%);
  border-right: 1px solid var(--border-subtle);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar-header {
  padding-inline: 0.25rem;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  background: radial-gradient(circle at 20% 20%, #76a7ff, #3150b3 45%, #12142b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #eef3ff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.18s ease, color 0.18s ease, transform 0.08s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sidebar-footer {
  display: flex;
  justify-content: flex-start;
  padding-inline: 0.25rem;
}

/* Main */

.main {
  padding: 1rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

#topbar-title {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
}

/* Command bar */

.topbar-command {
  background: rgba(3, 5, 16, 0.8);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 0.6rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
}

.command-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Main grid */

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.1fr);
  gap: 1.5rem;
  align-items: flex-start;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.side-panel {
  position: sticky;
  top: 1rem;
}

/* Sections */

.section {
  display: none;
}

.section.active {
  display: block;
}

.section-header {
  margin-bottom: 0.75rem;
}

.section-header h2 {
  margin: 0 0 0.2rem;
}

.section-header .muted {
  margin: 0;
}

/* Cards */

.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.card-header {
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

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

.card-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.card-body {
  padding: 0.75rem 1rem 1rem;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr);
  gap: 1.25rem;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Inputs & buttons */

.input,
textarea.input,
select.input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(5, 7, 18, 0.95);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea.input {
  border-radius: 12px;
  resize: vertical;
  min-height: 3.5rem;
}

select.input {
  border-radius: 12px;
}

.input:focus,
textarea.input:focus,
select.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.35);
  background: rgba(8, 10, 26, 0.98);
}

.field-label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.btn {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: background 0.18s ease, border 0.18s ease, transform 0.08s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.btn.primary {
  background: linear-gradient(135deg, #4f8cff, #7b93ff);
  border-color: transparent;
  color: #f4f6ff;
  box-shadow: 0 10px 28px rgba(79, 140, 255, 0.5);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #6b9cff, #9baaff);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

.btn.small {
  padding: 0.28rem 0.6rem;
  font-size: 0.8rem;
}

.btn.tiny {
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
}

/* Chips */

.chip {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.2rem 0.65rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Kai log */

.kai-log-container {
  max-height: 440px;
  overflow: hidden;
}

.kai-log {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.kai-log-entry {
  font-size: 0.76rem;
  padding: 0.2rem 0;
  color: var(--text-muted);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.03);
}

/* Misc text */

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

.muted.small {
  font-size: 0.78rem;
}

.small {
  font-size: 0.85rem;
}

.bp-list {
  margin: 0.25rem 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.bp-list.small {
  font-size: 0.8rem;
}

/* Modules */

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

.module-card {
  background: var(--bg-elevated-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 0.7rem 0.8rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.module-card h4 {
  margin: 0;
  font-size: 0.9rem;
}

.module-card .btn {
  margin-top: 0.3rem;
}

/* Module frame */

.module-frame {
  width: 100%;
  height: 320px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #050712;
}

/* Workspaces */

.workspace-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.workspace-list li {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 0.55rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: rgba(12, 16, 36, 0.9);
}

.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.workspace-title {
  font-size: 0.85rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.badge.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* Omni Chat */

.omni-chat-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr);
  gap: 1.25rem;
}

@media (max-width: 980px) {
  .omni-chat-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.omni-chat-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.omni-chat-response {
  min-height: 140px;
  padding: 0.8rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* TTS select row */

.omni-tts-row {
  margin-top: 0.75rem;
}

.omni-tts-row .input {
  border-radius: 12px;
  height: 2.1rem;
  font-size: 0.8rem;
}
