:root {
  --bg: #0a0b0e;
  --surface: #12141a;
  --surface-2: #191c24;
  --border: #262a36;
  --text: #eceef4;
  --muted: #8e95a9;
  --accent: #4f8cff;
  --accent-hover: #3b78f0;
  --success: #2dd4bf;
  --danger: #f87171;
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
  overflow-y: auto;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}

.brand-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.brand-subtitle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-btn.active {
  background: rgba(79, 140, 255, 0.14);
  color: var(--accent);
  border-color: rgba(79, 140, 255, 0.35);
  font-weight: 500;
}

.nav-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
}

.sidebar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.sidebar-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.session-item {
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.session-item.active {
  background: var(--surface-2);
  color: var(--text);
  border-left: 3px solid var(--accent);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.status-line {
  display: flex;
  justify-content: space-between;
}

/* Main Panel */
.main-panel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.tab-view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.tab-view.active {
  display: flex;
}

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

.view-header h1 {
  font-size: 1.15rem;
  font-weight: 600;
}

.muted-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Quick Prompts */
.quick-prompts {
  padding: 0.65rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  background: var(--bg);
}

.chip {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.38rem 0.75rem;
  border-radius: 99px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Chat Timeline */
.chat-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.msg-bubble {
  max-width: 82%;
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  line-height: 1.5;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.msg-assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.tool-calls-box {
  margin-bottom: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tool-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
}

.tool-pill summary {
  cursor: pointer;
  color: var(--success);
}

.tool-pill pre {
  margin-top: 0.4rem;
  white-space: pre-wrap;
  color: var(--text);
  max-height: 200px;
  overflow-y: auto;
}

.live-activity-bar {
  padding: 0.5rem 1.5rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chat-composer {
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
}

.chat-composer textarea {
  flex: 1;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  resize: none;
}

.chat-composer textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Panels & Cards */
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
}

.browser-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card h3 {
  font-size: 0.98rem;
  font-weight: 600;
}

.card h4 {
  font-size: 0.88rem;
  color: var(--muted);
}

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

.subtabs {
  display: flex;
  gap: 0.4rem;
}

.subtab-btn {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.subtab-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Inputs & Buttons */
.input-text, .input-select, .code-textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  font-family: var(--font-sans);
}

.code-textarea {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.45;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary, .btn-small {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.btn-small {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.url-bar-form, .inline-form {
  display: flex;
  gap: 0.5rem;
}

.url-bar-form input, .inline-form input {
  flex: 1;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 360px;
  overflow-y: auto;
}

.list-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.8rem;
  font-size: 0.84rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.code-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  max-height: 440px;
  overflow-y: auto;
}

.screenshot-frame {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.screenshot-frame img {
  width: 100%;
  height: auto;
  display: block;
}

.empty-state {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem;
  text-align: center;
}
