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

:root {
  --bg:          #E8EBF5;
  --bg2:         #FFFFFF;
  --bg3:         #F2F4FB;
  --bg4:         #E4E8F5;
  --accent:      #3B7DE8;
  --accent2:     #7C5CBF;
  --accent-pale: rgba(59,125,232,0.08);
  --text:        #1A1A2E;
  --text2:       #7580A0;
  --border:      rgba(0,0,0,0.07);
  --border2:     rgba(0,0,0,0.11);
  --user-bg:     #EAF0FE;
  --ai-bg:       #FFFFFF;
  --danger-red:  #E53E3E;
  --warn:        #E8923B;
  --warn-pale:   rgba(232,146,59,0.14);
  --danger-pale: rgba(229,62,62,0.12);
  --radius:      14px;
  --radius-lg:   22px;
  --bento-gap:   10px;
  --sidebar-w:   268px;
  --shadow:      0 8px 40px rgba(59,80,160,0.13), 0 1px 4px rgba(0,0,0,0.06);
  --shadow-sm:   0 2px 16px rgba(59,80,160,0.09), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(59,80,160,0.07);
  --font-head:   'Syne', system-ui, sans-serif;
  --font-body:   'DM Sans', system-ui, sans-serif;
  --text-secondary: var(--text2);
  --surface2:    var(--bg3);
  --surface3:    var(--bg4);
}

html, body {
  height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
}

/* ── Login Page ── */
#login-page {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  flex-direction: row;
  justify-content: center;   /* center the two-column group so it doesn't drift on wide screens */
  background: var(--bg);
}
#login-page.visible { display: flex; }

/* ── Login page two-column layout ── */
.lp-left {
  /* cap width (660px inner + 56/36 padding) so the left panel hugs the divider
     instead of growing to fill a wide desktop and leaving a huge gap */
  flex: 0 1 752px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 36px 32px 56px;
  overflow: hidden;
}
.lp-right {
  width: 500px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 64px;
  overflow-y: auto;
  border-left: 1px solid var(--border2);
}

/* Welcome layer + Chat window — stacked layers in lp-left-inner */
.lp-left-inner {
  position: relative;
  width: 100%;
  max-width: 660px;
  height: min(74vh, 540px);
}
.lp-cover,
.lp-chat-window {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--bg2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.lp-cover.lp-layer-on,
.lp-chat-window.lp-layer-on { opacity: 1; pointer-events: auto; }
.lp-chat-window {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
  display: flex;
  flex-direction: row;
  text-align: left;
}

/* Cover layer content — product hero */
.lp-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px 40px;
  font-family: var(--font-body);
  background:
    radial-gradient(120% 80% at 50% 0%, var(--accent-pale) 0%, transparent 55%),
    var(--bg2);
}
.lp-cover-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.lp-cover-logo {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  object-fit: contain;
}
.lp-cover-title {
  font-family: var(--font-head);
  font-size: clamp(1.55rem, 2.4vw, 2.05rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.18;
  letter-spacing: -0.03em;
  text-align: center;
  min-height: 2.36em;
}
/* blinking caret on the element currently being typed */
.lp-cover-title .lp-caret,
.lp-cover-tagline .lp-caret {
  border-right: 2px solid var(--accent);
  margin-left: 1px;
  animation: lp-blink 0.9s steps(1) infinite;
}
@keyframes lp-blink { 50% { border-color: transparent; } }
.lp-cover-tagline {
  font-size: 15px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.01em;
  min-height: 1.2em;
}
.lp-tag-accent { color: var(--accent); }
.lp-cover-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 430px;
}
.lp-cover-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.lp-cover-feature.lp-reveal-on {
  opacity: 1;
  transform: none;
}
.lp-cf-icon {
  font-size: 1.45rem;
  flex-shrink: 0;
  line-height: 1;
}
.lp-cf-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}
.lp-cf-text b {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.lp-cf-text span {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.45;
}
.lp-cover-hint {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.lp-cover-hint.lp-reveal-on { opacity: 0.7; }

/* Sidebar */
.lp-chat-sidebar {
  width: 148px;
  flex-shrink: 0;
  background: var(--bg3);
  border-right: 1px solid var(--border2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lp-sidebar-header {
  padding: 12px 12px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text2);
  border-bottom: 1px solid var(--border2);
  font-family: var(--font-body);
}
.lp-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.lp-sidebar-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  cursor: default;
  border-radius: 8px;
  margin: 0 4px;
  transition: background 0.15s;
}
.lp-sidebar-item.active { background: var(--accent-pale); }
.lp-sidebar-icon { font-size: 0.85rem; flex-shrink: 0; }
.lp-sidebar-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  font-family: var(--font-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lp-sidebar-item.active .lp-sidebar-name { color: var(--accent); font-weight: 600; }
.lp-sidebar-new {
  margin: 6px 8px 10px;
  padding: 6px 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text2);
  font-family: var(--font-body);
  cursor: default;
  background: none;
}

/* Main chat area */
.lp-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}
.lp-chat-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border2);
  min-height: 44px;
  flex-shrink: 0;
}
.lp-chat-menu-btn {
  font-size: 1rem;
  color: var(--text2);
  padding: 4px 6px;
  border-radius: 8px;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: default;
}
.lp-chat-tool-select {
  padding: 4px 8px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg2);
  flex-shrink: 0;
  font-family: var(--font-body);
  cursor: default;
  pointer-events: none;
}
.lp-session-title {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-body);
}

.lp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: var(--bg2);
}

/* User bubble */
.lp-msg-user {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 8px;
}
.lp-msg-bubble {
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  max-width: 78%;
  line-height: 1.55;
  font-size: 0.875rem;
}
.lp-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-bottom: 2px;
  border: 1px solid var(--border2);
}

/* AI bubble */
.lp-msg-ai { display: flex; align-items: flex-start; gap: 8px; }
.lp-msg-ai .lp-msg-avatar {
  background: #2d2d3d;
  border-color: #2d2d3d;
  margin-top: 2px;
  padding: 3px;
}
.lp-ai-body {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 14px;
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.lp-ai-text { color: var(--text); font-size: 0.875rem; line-height: 1.55; font-family: var(--font-body); }
.lp-ai-step { color: var(--accent); font-size: 0.82rem; line-height: 1.4; font-family: 'JetBrains Mono', monospace; }

/* Result card */
.lp-result-card {
  margin-top: 6px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
  font-family: var(--font-body);
}
.lp-result-header {
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg3);
  border-bottom: 1px solid var(--border2);
}
.lp-result-qr-row {
  display: flex;
  border-bottom: 1px solid var(--border2);
}
.lp-result-qr-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 10px;
  border-right: 1px solid var(--border2);
}
.lp-result-qr-item:last-child { border-right: none; }
.lp-qr-placeholder {
  width: 54px; height: 54px;
  flex-shrink: 0;
  border: 2px solid var(--text);
  border-radius: 4px;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 3px, var(--border2) 3px, var(--border2) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, var(--border2) 3px, var(--border2) 4px);
}
.lp-result-qr-label { font-size: 0.75rem; font-weight: 600; color: var(--text); }
.lp-result-qr-sub   { font-size: 0.68rem; color: var(--text2); }
.lp-result-qr-row.single { justify-content: center; }
.lp-result-qr-row.single .lp-result-qr-item { max-width: 160px; border-right: none; }
.lp-result-actions { display: flex; flex-direction: column; gap: 5px; padding: 10px 14px 12px; }
.lp-result-btn {
  padding: 6px 12px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg2);
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  cursor: default;
}
.lp-result-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Chat footer */
.lp-chat-footer {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border2);
  background: var(--bg2);
  flex-shrink: 0;
}
.lp-chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg3);
  outline: none;
  resize: none;
  line-height: 1.5;
}
.lp-chat-send-btn {
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-body);
  white-space: nowrap;
  flex-shrink: 0;
  border: none;
  cursor: default;
}

/* Hide left panel on small screens */
@media (max-width: 860px) {
  .lp-left { display: none; }
  .lp-right { width: 100%; padding: 40px 24px; }
  .lp-right::before { display: none; }
}

/* Login card */
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-logo { height: 48px; width: auto; margin-bottom: 18px; }
.login-title {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
  letter-spacing: -1px;
}
.login-subtitle {
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 32px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 500;
}
.login-error { width: 100%; color: var(--danger-red); font-size: 12px; min-height: 18px; margin-bottom: 2px; }
.login-lbl {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--text2);
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.login-card input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,125,232,0.12);
}
.login-card input::placeholder { color: var(--text2); opacity: 0.6; }
.login-submit {
  width: 100%;
  margin-top: 24px;
  padding: 13px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  border: none;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-head);
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 18px rgba(59,125,232,0.30);
}
.login-submit:hover { opacity: 0.88; transform: translateY(-1px); box-shadow: 0 8px 26px rgba(59,125,232,0.38); }
.login-submit:active { transform: translateY(0); }
.login-submit:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: none; }
.login-switch { margin-top: 18px; font-size: 12px; color: var(--text2); text-align: center; }
.login-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.login-switch a:hover { text-decoration: underline; }

/* ── App Layout — bento grid container ── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  padding: var(--bento-gap);
  gap: var(--bento-gap);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 55% 45% at 5% 95%, rgba(59,125,232,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 95% 5%, rgba(124,92,191,0.06) 0%, transparent 55%);
}

/* ── Sidebar — left bento cell ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  transition: width .22s ease, min-width .22s ease, opacity .18s ease, border-width .22s ease;
}
#app.sidebar-hidden #sidebar {
  width: 0; min-width: 0; opacity: 0; pointer-events: none; border-width: 0;
}

#sidebar-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#sidebar-header h1 {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.8px;
}
#sidebar-header p {
  font-size: 10px;
  color: var(--text2);
  margin-top: 2px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-weight: 500;
}

#new-session-btn {
  margin: 12px 12px 8px;
  padding: 9px 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  border: none;
  border-radius: 11px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-head);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.3px;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 3px 14px rgba(59,125,232,0.28);
  flex-shrink: 0;
}
#new-session-btn:hover {
  opacity: 0.90;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59,125,232,0.38);
}
#new-session-btn:active { transform: translateY(0); }

#session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.session-group-label {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text2);
  margin: 14px 8px 6px;
  letter-spacing: 0.2px;
}

/* Session items as micro bento cards */
.session-item {
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 3px;
  font-size: 12px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  cursor: pointer;
}
.session-item:hover { background: var(--bg3); border-color: var(--border); color: var(--text); }
.session-item.active {
  background: rgba(59,125,232,0.07);
  border-color: rgba(59,125,232,0.22);
  color: var(--accent);
}

.session-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  padding: 2px;
}
.session-pin { font-size: 10px; flex-shrink: 0; }
/* @-mention badge: someone @-mentioned you in this session while you were elsewhere */
.session-mention {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; flex-shrink: 0;
  background: var(--danger-red); color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 1;
}
.session-meta { font-size: 10px; color: var(--text2); flex-shrink: 0; }
.session-menu-btn {
  visibility: hidden;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  transition: background 0.12s, color 0.12s;
}
.session-item:hover .session-menu-btn,
.session-item.active .session-menu-btn { visibility: visible; }
.session-menu-btn:hover { background: var(--bg4); color: var(--text); }

/* Context menu */
#session-ctx-menu {
  position: fixed;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 13px;
  box-shadow: var(--shadow);
  z-index: 200;
  min-width: 160px;
  overflow: hidden;
}
#session-ctx-menu button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  text-align: left;
  background: none;
  border: none;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}
#session-ctx-menu button:hover { background: var(--bg3); }
#session-ctx-menu .danger { color: var(--danger-red); }

/* Sidebar tabs */
#sidebar-tabs {
  flex-shrink: 0;
  display: flex;
  border-top: 1px solid var(--border);
  padding: 6px;
  gap: 4px;
}
.tab-btn {
  flex: 1;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 11px;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  border-radius: 8px;
}
.tab-btn:hover { background: var(--bg3); color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  background: rgba(59,125,232,0.08);
}

/* Deploy panel */
#deploy-panel { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
#deploy-panel.visible { display: flex; }
#deploy-content { flex: 1; overflow-y: auto; padding: 10px 8px; }
.status-badge { display:inline-block; padding:1px 7px; border-radius:20px; font-size:10px; font-weight:700; margin-left:5px; }
.status-badge.running { background:#e6f9ee; color:#1a8a45; }
.status-badge.stopped { background:#fef2f2; color:#b91c1c; }
.deploy-section h3 {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--text2);
  padding: 8px 4px 6px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.deploy-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text2);
  padding: 10px 4px 5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.deploy-group-label:first-child { padding-top: 4px; }
.deploy-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 12px;
}
.deploy-item .name { font-weight: 600; color: var(--text); font-size: 13px; }
.deploy-item.active {
  background: rgba(59,125,232,0.13);
  border-color: rgba(59,125,232,0.45);
  border-left: 3px solid var(--accent);
}
.deploy-item.active .name { color: var(--accent); }
.deploy-item .meta { color: var(--text2); margin-top: 2px; font-size: 11px; }
.deploy-item .actions { display: flex; gap: 4px; margin-top: 8px; }
.deploy-item .actions button {
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--text2);
  font-size: 11px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.deploy-item .actions button:hover {
  color: var(--accent);
  border-color: rgba(59,125,232,0.35);
  background: rgba(59,125,232,0.05);
}

/* ── Main — right bento cell ── */
#main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Topbar */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: transparent;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#back-btn {
  display: none;
  align-items: center;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
#back-btn:hover { color: var(--text); background: var(--bg3); }
#menu-btn { display: none; }
#sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; background: none; border: none;
  color: var(--text2); font-size: 16px; cursor: pointer;
  border-radius: 7px; transition: background .15s, color .15s; flex-shrink: 0;
}
#sidebar-collapse-btn:hover { background: var(--bg3); color: var(--text); }
/* Floating expand button — visible only when sidebar is collapsed */
#sidebar-expand-btn {
  display: none; position: fixed; left: calc(var(--bento-gap) + 4px); top: 50%;
  transform: translateY(-50%); z-index: 50;
  width: 22px; height: 48px; background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 0 8px 8px 0; color: var(--text2); font-size: 14px; cursor: pointer;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm); transition: color .15s, background .15s;
}
#sidebar-expand-btn:hover { background: var(--bg3); color: var(--accent); }
#app.sidebar-hidden #sidebar-expand-btn { display: flex; }
#app.sidebar-hidden #sidebar-collapse-btn { display: none; }

/* Tool selector styled as a mini bento chip */
#tool-select {
  padding: 6px 28px 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 9px;
  font-size: 12px;
  font-family: var(--font-head);
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237580A0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#tool-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,125,232,0.10);
}

/* Title + group widget stay together, left-aligned; the wrapper takes the flex space
   so the right-side buttons (Code/Stop/avatar) are still pushed to the right. */
.titlebar-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
#session-title {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 13px;
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.1px;
}

#cancel-btn {
  display: none;
  padding: 5px 14px;
  background: rgba(229,62,62,0.07);
  color: var(--danger-red);
  border: 1px solid rgba(229,62,62,0.22);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-head);
  letter-spacing: 0.3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
#cancel-btn:hover { background: rgba(229,62,62,0.14); border-color: rgba(229,62,62,0.4); }

/* ── Messages ── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
/* ── Welcome Page ─────────────────────────────────────────────────────────── */
#welcome-page {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.wlc-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 28px; width: 100%; max-width: 640px;
}
.wlc-top { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.wlc-logo { height: 48px; width: auto; opacity: .9; }
.wlc-title { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.2; letter-spacing: -.3px; }
.wlc-sub { font-size: 14px; color: var(--text2); line-height: 1.6; }
.wlc-input-card {
  width: 100%; background: var(--bg2);
  border: 1.5px solid var(--border2); border-radius: 18px;
  padding: 16px 16px 12px; box-shadow: 0 4px 24px rgba(59,125,232,0.07);
}
.wlc-input-card textarea {
  width: 100%; background: none; border: none; outline: none; resize: none;
  font-size: 15px; color: var(--text); line-height: 1.6;
  font-family: inherit; min-height: 80px;
}
.wlc-input-card textarea::placeholder { color: var(--text2); opacity: .7; }
.wlc-input-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.wlc-attach-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.wlc-attach-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--border2);
  background: none; color: var(--text2); font-size: 20px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s; flex-shrink: 0;
}
.wlc-attach-btn:hover { border-color: var(--accent); color: var(--accent); }
.wlc-start-btn {
  padding: 8px 22px; background: var(--accent); color: #fff;
  border: none; border-radius: 10px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: opacity .15s; white-space: nowrap; flex-shrink: 0;
}
.wlc-start-btn:hover { opacity: .88; }
.wlc-chips {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%;
}
.wlc-chip {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 7px 16px; font-size: 13px;
  color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.wlc-chip:hover { background: var(--accent-pale); border-color: var(--accent); color: var(--accent); }

.msg-wrap { display: flex; margin-bottom: 16px; gap: 10px; }
.msg-wrap.user { flex-direction: row-reverse; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border: 1px solid var(--border2);
}
.msg-wrap.user .avatar { background: var(--user-bg); }
.msg-wrap.ai   .avatar { background: var(--bg3); }
.avatar-img { border-radius: 50%; object-fit: cover; background: transparent; }

.bubble {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg-wrap.user .bubble {
  background: var(--user-bg);
  border: 1px solid rgba(59,125,232,0.16);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #2556B8;
}
.msg-wrap.ai .bubble {
  background: var(--ai-bg);
  border: 1px solid var(--border2);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-card);
}

/* Tool badges */
.tool-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-head);
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 5px;
  margin-bottom: 8px;
  border: 1px solid;
  text-transform: uppercase;
}
.tool-badge.claude { color: #B84A1A; border-color: rgba(184,74,26,0.22); background: rgba(184,74,26,0.07); }
.tool-badge.gemini { color: #1A5FC8; border-color: rgba(26,95,200,0.22); background: rgba(26,95,200,0.07); }
.tool-badge.codex    { color: #0A7A44; border-color: rgba(10,122,68,0.22);  background: rgba(10,122,68,0.07);  }
.tool-badge.deepseek { color: #4F46E5; border-color: rgba(79,70,229,0.22);  background: rgba(79,70,229,0.07);  }

/* Bubble content */
.bubble h1,.bubble h2,.bubble h3 { margin: 14px 0 7px; color: var(--text); font-family: var(--font-head); }
.bubble h1 { font-size: 18px; } .bubble h2 { font-size: 16px; } .bubble h3 { font-size: 14px; }
.bubble p  { margin: 6px 0; }
.bubble ul,.bubble ol { margin: 6px 0 6px 20px; }
.bubble li { margin: 3px 0; }
.bubble pre {
  margin: 10px 0;
  border-radius: 10px;
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border2);
}
.bubble code:not(pre code) {
  background: #EEF0F8;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: Menlo, Monaco, 'Consolas', 'Liberation Mono', monospace;
  color: #c0392b;
}
.bubble pre code { font-size: 12px; }
.bubble blockquote { border-left: 3px solid var(--accent2); padding-left: 12px; color: var(--text2); }
.bubble table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 8px 0; display: block; overflow-x: auto; white-space: nowrap; }
.bubble th,.bubble td { border: 1px solid var(--border2); padding: 6px 10px; }
.bubble th { background: var(--bg3); font-family: var(--font-head); font-size: 12px; letter-spacing: 0.3px; }
.bubble a { color: var(--accent); text-decoration: none; }
.bubble a:hover { text-decoration: underline; }

/* ── Output files ── */
.output-files { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.output-file {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  overflow: hidden;
}
.output-file-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.output-file-row img.ftype { width: 16px; height: 16px; flex-shrink: 0; }
.output-file-name { flex: 1; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.output-file-actions { display: flex; gap: 4px; flex-shrink: 0; }
.output-file-actions button {
  background: var(--bg2);
  border: 1px solid var(--border2);
  cursor: pointer;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text2);
  font-family: var(--font-body);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.output-file-actions button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.output-img-preview {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: var(--bg3);
  cursor: zoom-in;
  display: block;
  border-top: 1px solid var(--border);
}

.deploy-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.deploy-actions button {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(59,125,232,0.30);
  background: rgba(59,125,232,0.06);
  color: var(--accent);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.deploy-actions button:hover { background: rgba(59,125,232,0.14); border-color: var(--accent); }

/* Streaming cursor */
.cursor::after { content: "▋"; animation: blink 0.8s step-end infinite; }
.ai-status {
  font-size: 11px;
  color: var(--text2);
  padding: 2px 0 6px;
  display: none;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: 0.2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Message action buttons */
.resend-btn {
  visibility: hidden;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  padding: 4px;
  border-radius: 6px;
  transition: opacity 0.12s, background 0.12s;
}
.resend-btn:hover { opacity: 1; background: var(--bg3); }
.msg-time-row {
  font-size: 10px;
  color: var(--text2);
  margin-bottom: 5px;
  width: 100%;
  padding: 0 40px;
  opacity: 0.55;
  letter-spacing: 0.2px;
}
.copy-btn {
  visibility: hidden;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  padding: 4px;
  border-radius: 6px;
  transition: opacity 0.12s, background 0.12s;
}
.copy-btn:hover { opacity: 1; background: var(--bg3); }
.msg-wrap:hover .copy-btn { visibility: visible; }
.user-actions { display: flex; align-items: center; align-self: center; margin-right: -4px; gap: 2px; }
.msg-wrap.user:hover .user-actions .resend-btn,
.msg-wrap.user:hover .user-actions .copy-btn { visibility: visible; }
.ai-actions { margin-top: 4px; display: flex; gap: 8px; align-items: center; }

.bubble-col { display: flex; flex-direction: column; align-items: flex-end; max-width: 72%; }
.bubble-col .bubble { max-width: 100%; }
.bubble-attachments { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; justify-content: flex-end; }
.bubble-sending .bubble { opacity: 0.6; }
.bubble-sending-dot { display: inline-block; font-size: 11px; color: var(--text-secondary); margin-left: 6px; animation: blink 1s step-start infinite; }
.bubble-failed .bubble { box-shadow: 0 0 0 1.5px var(--danger-red) inset; }
.retry-btn { font-size: 11px; color: var(--danger-red); background: none; border: none; cursor: pointer; padding: 2px 6px; margin-top: 4px; text-decoration: underline; }
.bubble-attachments .attach-chip { font-size: 11px; opacity: 0.8; cursor: default; }
.bubble-attachments .attach-chip .rm-attach { display: none; }

/* ── Pending attachments ── */
#pending-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; }
#pending-attachments:empty { display: none; }

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 3px 10px 3px 8px;
  font-size: 12px;
  color: var(--text2);
}
.attach-chip img { width: 14px; height: 14px; flex-shrink: 0; }
.attach-chip .rm-attach { cursor: pointer; margin-left: 2px; opacity: 0.5; line-height: 1; }
.attach-chip .rm-attach:hover { opacity: 1; color: var(--danger-red); }
.attach-chip.uploading { opacity: 0.75; }
.attach-chip.uploading::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 5px;
  border: 1.5px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.attach-chip.upload-err { border-color: rgba(229,62,62,0.35); color: var(--danger-red); }

/* ── Input area ── */
#input-area {
  padding: 12px 14px;
  background: transparent;
  border-top: 1px solid var(--border);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  flex-shrink: 0;
  position: relative;
}

/* Sticky "Discussing" mode bar (shown above the input when chat_at == discussing) */
#discuss-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm, 8px);
  background: color-mix(in srgb, var(--accent2) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent2) 40%, transparent);
  font-size: 12.5px;
}
#discuss-bar .db-label { color: var(--accent2); font-weight: 600; }
#discuss-exit-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border: none;
  border-radius: var(--radius-sm, 8px);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  min-height: 28px;
}
#discuss-exit-btn:hover { filter: brightness(1.08); }

/* @-mention autocomplete popup (sits above the input) */
.mention-popup {
  display: none; position: absolute; left: 14px; bottom: calc(100% - 4px);
  min-width: 200px; max-width: 320px; max-height: 240px; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.14); padding: 6px; z-index: 60;
}
.mention-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.mention-item.active, .mention-item:hover { background: var(--accent-pale); }
.mention-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; display: block; }
.mention-ai-av { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.mention-name { font-weight: 600; }
.mention-title { color: var(--text2); font-size: 12px; margin-left: auto; }
#input-row { display: flex; gap: 8px; align-items: stretch; }
#msg-input {
  flex: 1;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font-body);
  resize: none;
  min-height: 74px;
  max-height: 240px;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#msg-input:focus {
  outline: none;
  border-color: rgba(59,125,232,0.45);
  box-shadow: 0 0 0 3px rgba(59,125,232,0.08);
}
#msg-input::placeholder { color: var(--text2); opacity: 0.6; }

#send-btn {
  padding: 0 20px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-head);
  letter-spacing: 0.4px;
  cursor: pointer;
  align-self: stretch;
  min-width: 68px;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 3px 14px rgba(59,125,232,0.28);
}
#send-btn:hover { opacity: 0.88; transform: translateY(-1px); box-shadow: 0 7px 22px rgba(59,125,232,0.36); }
#send-btn:active { transform: translateY(0); }
#send-btn:disabled {
  background: var(--bg3);
  color: var(--text2);
  box-shadow: none;
  transform: none;
  cursor: default;
  border: 1px solid var(--border2);
}

#upload-btn {
  align-self: stretch;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: 12px;
  font-size: 22px;
  font-weight: 300;
  cursor: pointer;
  padding: 0 14px;
  line-height: 1;
  transition: border-color 0.2s, color 0.2s, background 0.15s;
}
#upload-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(59,125,232,0.05); }
#file-input { display: none; }

.user-profile-wrap:hover .dropdown-menu { display: block !important; }

/* ── Modals ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.visible { display: flex; }

/* Invite / members modal (group chat) */
.invite-modal { max-width: 440px; width: 92%; }
.iv-row { display: flex; gap: 10px; align-items: center; margin: 14px 0; }
.invite-modal .iv-email { flex: 1; min-width: 0; box-sizing: border-box; font-size: 16px; }
.iv-title-label,
.iv-roster-label { font-size: 11px; font-weight: 600; color: var(--text2); margin-bottom: 7px; }
.iv-titles { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.iv-chip {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 14px; padding: 3px 11px; font-size: 11.5px;
  color: var(--text2); cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.iv-chip:hover { background: var(--accent-pale); border-color: var(--accent); color: var(--accent); }
.iv-chip.active {
  background: var(--accent2); border-color: var(--accent2); color: #fff;
}
.iv-invite-btn {
  flex: none; padding: 11px 22px; font-size: 14px; font-weight: 700;
  font-family: var(--font-head); cursor: pointer; white-space: nowrap;
  background: var(--accent); color: #fff;
  border: none; border-radius: 10px;
  transition: opacity 0.15s, transform 0.12s;
}
.iv-invite-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.iv-error { color: var(--danger-red, #d33); font-size: 13px; min-height: 18px; margin: 8px 0; }
.iv-roster-label { margin-top: 8px; }
.iv-roster { margin-top: 4px; }
.iv-member { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border2); }
.iv-av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.iv-name { font-weight: 600; }
.iv-me {
  font-size: 10px; font-weight: 700; color: var(--accent);
  background: var(--accent-pale); border-radius: 6px; padding: 1px 6px; letter-spacing: 0.3px;
}
.iv-title { color: var(--text2); font-size: 12px; }
.iv-x { margin-left: auto; cursor: pointer; color: var(--danger-red, #d33); font-size: 18px; line-height: 1; padding: 0 4px; }
.session-shared { font-size: 11px; margin-left: 4px; opacity: 0.7; }

/* Chat-header group widget: members count + stacked avatars (shared/group sessions) */
.session-group { display: none; align-items: center; gap: 6px; cursor: pointer; flex-shrink: 0; }
.session-group .sg-count { font-size: 12px; font-weight: 600; color: var(--text2); }
.session-group .sg-avatars { display: inline-flex; align-items: center; }
.session-group .sg-av {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--bg2); background: var(--bg2); margin-left: -8px;
}
.session-group .sg-av:first-child { margin-left: 0; }
.session-group .sg-more { font-size: 11px; color: var(--text2); margin-left: 4px; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
}
.modal h2 {
  font-size: 17px;
  font-family: var(--font-head);
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}
.modal label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--text2);
  margin-bottom: 5px;
  margin-top: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.modal input:not([type=radio]):not([type=checkbox]),.modal select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 9px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.2s;
}
.modal input:not([type=radio]):not([type=checkbox]):focus,.modal select:focus { outline: none; border-color: var(--accent); }

/* iOS Build — distribution method cards */
#build-dist-selector { display: flex; flex-direction: column; gap: 8px; }
.dist-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--bg3);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dist-card:hover { border-color: var(--border); }
.dist-card.selected { border-color: var(--accent); background: var(--bg2); }
.dist-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dist-card input[type=radio] { flex-shrink: 0; accent-color: var(--accent); }
.dist-card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.dist-card-desc {
  font-size: 12px;
  font-weight: 400;
  color: var(--text2);
  line-height: 1.45;
  padding-left: 24px;
}
.dist-card-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: #10b98122;
  color: #10b981;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* My Profile / My Devices */
.pf-modal { max-width: 680px !important; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.pf-header { flex-shrink: 0; }
.pf-body { display: flex; gap: 16px; flex: 1; min-height: 0; margin-top: 4px; }
.pf-rail { flex: 0 0 150px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border); padding-right: 8px; }
.pf-rail-item { text-align: left; background: none; border: none; cursor: pointer; padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text2); min-height: 44px; }
.pf-rail-item:hover { background: var(--bg3); color: var(--text); }
.pf-rail-item.active { background: var(--accent-pale); color: var(--accent); }
.pf-panes { flex: 1; min-width: 0; overflow-y: auto; padding-right: 4px; }
.pf-pane[hidden] { display: none; }
.pf-footer { flex-shrink: 0; }
/* Subscription plan (display-only) */
.pf-plan-row { display: flex; gap: 8px; margin-top: 6px; }
.pf-plan-card { flex: 1; text-align: center; padding: 10px 6px; border: 1px solid var(--border); border-radius: 10px; font-size: 12px; font-weight: 700; color: var(--text2); background: var(--bg3); }
.pf-plan-card.active { border-color: var(--accent); color: var(--accent); background: var(--accent-pale); box-shadow: 0 0 0 2px rgba(59,125,232,0.15); }

/* Header */
.pf-header { display: flex; align-items: center; gap: 14px; padding: 4px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.pf-avatar-hero { width: 60px; height: 60px; border-radius: 50%; overflow: hidden; flex-shrink: 0; border: 2px solid var(--border2); box-shadow: var(--shadow-sm); position: relative; cursor: pointer; }
.pf-avatar-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-avatar-edit-overlay { position: absolute; inset: 0; border-radius: 50%; background: rgba(0,0,0,0.38); display: flex; align-items: center; justify-content: center; font-size: 16px; opacity: 0; transition: opacity .15s; }
.pf-avatar-hero:hover .pf-avatar-edit-overlay { opacity: 1; }
.pf-username { font-weight: 700; font-size: 16px; color: var(--text); }
.pf-useremail { font-size: 13px; color: var(--text2); margin-top: 3px; }

/* Avatar picker */
.pf-avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 2px; }
.pf-av { width: 100%; aspect-ratio: 1/1; border-radius: 50%; cursor: pointer; border: 2px solid transparent; object-fit: cover; transition: border-color .12s, transform .12s; }
.pf-av:hover { border-color: var(--border2); transform: scale(1.07); }
.pf-av.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,125,232,0.18); }

/* Section label */
.pf-section-label { font-size: 12px; font-weight: 600; color: var(--text2); }

/* Field row: input + action button */
.pf-field-row { display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.pf-field-row input { flex: 1; }
.pf-save-btn { background: var(--accent-pale); color: var(--accent); border: 1px solid rgba(59,125,232,0.22); border-radius: 10px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: background .15s; }
.pf-save-btn:hover { background: rgba(59,125,232,0.14); }

/* Hint text */
.pf-hint { font-size: 11px; color: var(--text2); min-height: 16px; margin-top: 4px; }

/* Devices section header */
.pf-devices-hdr { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; }
.pf-add-btn { background: var(--bg3); color: var(--accent); border: 1px solid var(--border2); border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .12s; }
.pf-add-btn:hover { background: var(--bg4); }

/* Device cards */
#pf-devices:empty::after { content: "No devices yet"; color: var(--text2); font-size: 13px; display: block; padding: 10px 0; }
.pf-device { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.pf-device-info { flex: 1; min-width: 0; }
.pf-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 4px; }
.pf-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.pf-edit { background: none; border: none; cursor: pointer; font-size: 11px; padding: 0 2px; opacity: 0.45; line-height: 1; flex-shrink: 0; }
.pf-edit:hover { opacity: 1; }
.pf-rename-input { font-size: 13px; font-weight: 600; border: 1px solid var(--accent); border-radius: 6px; padding: 2px 7px; background: var(--bg2); color: var(--text); outline: none; width: 150px; }
.pf-udid { font-size: 11px; color: var(--text2); font-family: monospace; word-break: break-all; margin-top: 2px; }
.pf-badge { font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; flex-shrink: 0; margin-left: auto; }
.pf-badge.ok { background: rgba(16,185,129,0.12); color: #059669; }
.pf-badge.pending { background: rgba(245,158,11,0.15); color: #b45309; }
.pf-badge.fail { background: rgba(239,68,68,0.12); color: #dc2626; cursor: pointer; }
.pf-del { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; flex-shrink: 0; line-height: 1; padding: 2px 4px; }
.pf-del:hover { color: var(--danger-red); }

/* Add device expandable */
.pf-add-box { margin-top: 10px; padding: 16px; background: var(--bg3); border: 1px solid var(--border); border-radius: 14px; }
.pf-qr-wrap { display: flex; justify-content: center; margin-bottom: 10px; }
.pf-qr-wrap canvas, .pf-qr-wrap img { border-radius: 10px; box-shadow: var(--shadow-sm); }
.pf-add-scan-hint { font-size: 12px; color: var(--text2); text-align: center; margin-bottom: 10px; }
.pf-link-row { display: flex; gap: 6px; }
.pf-link-input { flex: 1; font-size: 11px; font-family: monospace; }
.pf-copy-btn { background: var(--bg4); border: 1px solid var(--border2); border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--text); flex-shrink: 0; transition: background .12s, color .12s; }
.pf-copy-btn:hover { background: var(--accent-pale); color: var(--accent); }
.pf-or-divider { text-align: center; font-size: 11px; color: var(--text2); margin: 12px 0 10px; position: relative; }
.pf-or-divider::before, .pf-or-divider::after { content: ''; position: absolute; top: 50%; width: 36%; height: 1px; background: var(--border2); }
.pf-or-divider::before { left: 0; }
.pf-or-divider::after { right: 0; }

/* Footer */
.pf-settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pf-settings-row:last-of-type { border-bottom: none; }
.pf-settings-info { display: flex; flex-direction: column; gap: 2px; }
.pf-settings-title { font-size: 13px; font-weight: 600; color: var(--text); }
.pf-settings-desc { font-size: 11px; color: var(--text2); }
.pf-toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.pf-toggle input { opacity: 0; width: 0; height: 0; }
.pf-toggle-slider { position: absolute; inset: 0; background: var(--border2); border-radius: 22px; cursor: pointer; transition: background .2s; }
.pf-toggle-slider::before { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .2s; }
.pf-toggle input:checked + .pf-toggle-slider { background: var(--accent); }
.pf-toggle input:checked + .pf-toggle-slider::before { transform: translateX(18px); }
.pf-footer { justify-content: space-between !important; }
.pf-logout-btn { background: none; border: 1px solid var(--border2); color: var(--danger-red); border-radius: 10px; padding: 8px 18px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s; }
.pf-logout-btn:hover { background: rgba(229,62,62,0.07); }
.modal-actions { display: flex; gap: 8px; margin-top: 22px; justify-content: flex-end; }
.modal-actions button {
  padding: 9px 20px;
  border-radius: 9px;
  border: none;
  font-size: 13px;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
}
.btn-primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%); color: #fff; }
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-cancel { background: var(--bg3); color: var(--text2); border: 1px solid var(--border2) !important; }
.btn-cancel:hover { background: var(--bg4); color: var(--text); }
.name-chip {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; cursor: pointer;
  background: var(--bg3); color: var(--text2); border: 1px solid var(--border2);
  transition: all 0.15s;
}
.name-chip:hover { background: var(--bg4); color: var(--text); border-color: var(--accent); }
.name-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.app-name-hint { font-size: 11px; min-height: 16px; margin-bottom: 6px; transition: color 0.2s; }
.app-name-hint.available { color: #4caf50; }
.app-name-hint.taken { color: #f44336; }
.app-name-hint.checking { color: var(--text2); }

#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 10; }

#list-user-profile { display: none !important; }

/* ── Mobile ── */
@media (max-width: 640px) {
  #app {
    position: relative;
    overflow: hidden;
    padding: 0;
    gap: 0;
  }
  #sidebar {
    position: absolute;
    inset: 0;
    width: 100%;
    min-width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  #sidebar.has-user #list-user-profile { display: flex !important; }
  #sidebar-header { padding: 14px 16px; }
  #menu-btn { display: none !important; }
  #sidebar-collapse-btn { display: none !important; }
  #sidebar-expand-btn { display: none !important; }
  #sidebar-overlay { display: none !important; }
  #content-area { display: none; }
  #main { border-radius: 0; border: none; box-shadow: none; }
  #app.in-chat #sidebar { display: none; }
  #app.in-chat #content-area { display: flex; width: 100%; }
  #app.in-chat #main { display: flex; }
  /* Mobile: code panel overlays as full-screen drawer */
  #code-panel {
    position: fixed !important;
    top: 0; right: -100%; bottom: 0;
    width: 100% !important; min-width: unset !important;
    border-radius: 0; z-index: 60;
    transition: right 0.25s cubic-bezier(.4,0,.2,1);
  }
  #code-panel.open { right: 0; animation: none; }
  #back-btn { display: flex !important; }
  #session-list { padding: 0; }
  .session-item {
    padding: 14px 12px;
    min-height: 64px;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    margin-bottom: 0;
    border-left: none;
    border-right: none;
    border-top: none;
  }
  .session-item:hover { background: var(--bg3); }
  .session-label { font-size: 14px; color: var(--text); }
  .session-menu-btn { visibility: visible; font-size: 20px; padding: 4px 8px; }
  .session-group-label { margin: 16px 12px 6px; }
  #tool-select { max-width: 88px; font-size: 12px; padding: 4px 6px; }
  .bubble { max-width: 88%; }
  .login-card { padding: 36px 24px; }
  #msg-input, .login-card input, .modal input:not([type=radio]):not([type=checkbox]), .modal select { font-size: 16px; }
}

/* ── Project Status Bar ── */
#project-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
#project-bar.visible { display: flex; }

.module-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.module-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700; font-family: var(--font-head);
  letter-spacing: 0.3px;
  background: rgba(59,125,232,0.1); color: var(--accent);
  border: 1px solid rgba(59,125,232,0.2);
}
.module-badge.inactive {
  background: var(--bg4); color: var(--text2);
  border-color: var(--border2); opacity: 0.6;
}
.module-badge::before { content: attr(data-check); }

.proj-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.proj-action-btn {
  padding: 4px 11px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--text);
  font-size: 12px; font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.proj-action-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.proj-action-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.proj-action-btn.primary:hover { opacity: 0.88; }

/* Contextual guide buttons below AI messages */
.guide-actions {
  margin-top: 10px; display: flex; gap: 7px; flex-wrap: wrap;
}
.guide-btn {
  padding: 5px 13px;
  border-radius: 8px;
  border: 1px solid rgba(59,125,232,0.25);
  background: rgba(59,125,232,0.06);
  color: var(--accent);
  font-size: 12px; font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.guide-btn:hover { background: rgba(59,125,232,0.14); border-color: var(--accent); }

@media (max-width: 640px) {
  #project-bar { padding: 6px 10px; }
  .proj-actions { margin-left: 0; }
}

/* ── Preview Modal ── */
#preview-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,12,30,0.72);
  z-index: 80;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#preview-modal.visible { display: flex; }

.preview-inner {
  --preview-w: 1100px;
  width: min(var(--preview-w), calc(100vw - 40px));
  height: 90vh;
  background: var(--bg2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
#preview-resize-handle {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transition: background 0.15s;
}
#preview-resize-handle:hover, #preview-resize-handle.active {
  background: var(--accent);
  opacity: 0.35;
}

.preview-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-url-bar {
  flex: 1; overflow: hidden;
  font-size: 12px; font-family: monospace;
  color: var(--text2);
  white-space: nowrap; text-overflow: ellipsis;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 7px;
  padding: 4px 10px;
}
.preview-header-btns { display: flex; gap: 6px; flex-shrink: 0; }
.preview-header-btns button {
  padding: 4px 11px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--text2);
  font-size: 12px; font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.preview-header-btns button:hover { background: var(--bg4); color: var(--text); }
.preview-header-btns .close-btn { color: var(--danger-red); }
.preview-header-btns .close-btn:hover { background: rgba(229,62,62,0.08); }

.preview-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; flex: 1;
  color: var(--text2); font-size: 14px;
}
.preview-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#preview-iframe {
  flex: 1; border: none; width: 100%; display: none;
}

/* Preview error / status panel (replaces bare red text dumped over the spinner) */
.preview-error {
  display: none; flex: 1;
  align-items: center; justify-content: center;
  padding: 24px; background: var(--bg3);
}
.preview-error.visible { display: flex; }
.preview-error-card {
  max-width: 460px; width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 34px 30px; text-align: center;
  box-shadow: var(--shadow-card);
  animation: previewErrIn 0.18s ease-out;
}
@keyframes previewErrIn {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
.preview-error-icon {
  width: 60px; height: 60px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; border-radius: 50%;
  background: var(--bg3);
}
.preview-error.kind-fixing .preview-error-icon { background: var(--accent-pale); }
.preview-error.kind-env    .preview-error-icon { background: var(--warn-pale); }
.preview-error-title {
  font-family: var(--font-head);
  font-size: 18px; font-weight: 600; color: var(--text);
  margin-bottom: 10px;
}
.preview-error-msg {
  font-size: 13.5px; line-height: 1.65; color: var(--text2);
  margin-bottom: 24px; white-space: pre-wrap;
}
.preview-error-actions { display: flex; gap: 10px; justify-content: center; }
.preview-error-actions button {
  min-height: 42px; padding: 0 20px;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border2);
  transition: filter 0.15s, background 0.15s;
}
.preview-error-retry {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.preview-error-retry:hover { filter: brightness(1.06); }
.preview-error-close { background: var(--bg3); color: var(--text); }
.preview-error-close:hover { background: var(--bg4); }

@media (max-width: 640px) {
  #preview-modal { padding: 0; }
  .preview-inner { border-radius: 0; height: 100vh; max-width: 100%; }
}

/* ── Code Panel ── */
/* ── Content area: chat + code panel side by side ── */
#content-area {
  flex: 1;
  display: flex;
  gap: var(--bento-gap);
  min-width: 0;
  overflow: hidden;
}

#code-panel {
  --cp-width: 460px;
  width: var(--cp-width);
  min-width: var(--cp-width);
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: none;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
#code-panel.open {
  display: flex;
  animation: cpSlideIn 0.18s ease;
}
@keyframes cpSlideIn {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}

#cp-resize-handle {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transition: background 0.15s;
}
#cp-resize-handle:hover, #cp-resize-handle.active {
  background: var(--accent);
  opacity: 0.35;
}

#code-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg3);
}
#code-panel-header h3 {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
  letter-spacing: 0.3px;
}
.cp-tabs { display: flex; gap: 4px; }
.cp-tab {
  padding: 4px 12px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: none;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.cp-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#close-code-panel {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text2); padding: 2px 6px;
  border-radius: 6px; transition: color 0.12s;
}
#close-code-panel:hover { color: var(--text); }

/* ── Database Panel ─────────────────────────────────────────────────────────── */
#db-panel {
  --dp-width: 380px;
  width: var(--dp-width);
  min-width: 160px;
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: none;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
#db-panel.open {
  display: flex;
  animation: cpSlideIn 0.18s ease;
}
#dp-resize-handle {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transition: background 0.15s;
}
#dp-resize-handle:hover, #dp-resize-handle.active {
  background: var(--accent);
  opacity: 0.35;
}
#db-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg3);
}
#db-panel-header h3 {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
  letter-spacing: 0.3px;
}
.dp-db-tabs { display: flex; gap: 4px; }
.dp-db-tab {
  padding: 4px 12px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: none;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.dp-db-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
/* Redis view: top (db) / middle (Filter|Raw) / bottom (results) — mirrors the SQL panel */
#dp-redis-section { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
#dp-redis-top { flex-shrink: 0; border-bottom: 1px solid var(--border2); padding-bottom: 8px; }
#dp-redis-dbinfo {
  display: inline-flex; align-items: center; margin: 0 14px;
  padding: 2px 12px; border-radius: 20px; border: 1px solid var(--border2);
  background: var(--bg3); font-size: 12px; color: var(--text); font-family: var(--font-mono, monospace);
}
#dp-redis-query { flex-shrink: 0; display: flex; flex-direction: column; border-bottom: 1px solid var(--border2); }
.dp-redis-mode-btn {
  padding: 3px 10px; border-radius: 6px; border: 1px solid var(--border2);
  background: none; font-size: 11px; font-family: var(--font-body); color: var(--text2);
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
.dp-redis-mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#dp-redis-run-btn {
  margin-left: auto; padding: 4px 14px; border-radius: 7px; border: none;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  font-family: var(--font-body); cursor: pointer; transition: opacity 0.12s;
}
#dp-redis-run-btn:hover { opacity: 0.85; }
.dp-redis-mode-content { display: none; padding: 8px 12px; }
.dp-redis-mode-content.active { display: block; }
.dp-redis-mode-content input, .dp-redis-mode-content textarea {
  width: 100%; box-sizing: border-box; font-size: 12px; padding: 6px 8px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  border: 1px solid var(--border2); border-radius: 7px; background: var(--bg3); color: var(--text);
}
.dp-redis-mode-content textarea { resize: none; min-height: 54px; }
.dp-redis-mode-content input:focus, .dp-redis-mode-content textarea:focus {
  outline: none; border-color: var(--accent);
}
/* Results: master-detail — keys list scrolls in its own pane so VALUE stays visible below */
#dp-redis-results { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#dp-redis-results > .dp-section-label { flex-shrink: 0; }
#dp-redis-filter-results { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#dp-redis-raw-results { flex: 1; min-height: 0; overflow-y: auto; }
#dp-redis-keys { flex: 4 1 0; min-height: 0; overflow-y: auto; }
#dp-redis-value { flex: 6 1 0; min-height: 0; overflow-y: auto; }
.dp-redis-vlabel {
  flex-shrink: 0;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text2); padding: 8px 14px 4px; margin-top: 6px; border-top: 1px solid var(--border2);
}
#dp-redis-count { margin-left: 8px; font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text2); }
.dp-redis-key { display: flex; gap: 8px; align-items: center; padding: 6px 8px; cursor: pointer; border-bottom: 1px solid var(--border2); }
.dp-redis-key:hover { background: var(--bg3); }
.dp-redis-type { font-size: 11px; color: var(--text2); border: 1px solid var(--border2); border-radius: 5px; padding: 0 5px; }
.dp-redis-keyname { flex: 1; font-family: var(--font-mono, monospace); font-size: 12px; overflow-wrap: anywhere; }
.dp-redis-ttl { font-size: 11px; color: var(--text2); }
.dp-redis-vhdr { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); padding: 6px 8px; }
.dp-redis-vhdr-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dp-redis-pretty {
  flex-shrink: 0; padding: 2px 10px; border-radius: 6px; border: 1px solid var(--border2);
  background: none; color: var(--text2); font-size: 11px; font-family: var(--font-body);
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
.dp-redis-pretty:hover { background: var(--bg3); }
.dp-redis-pretty.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.dp-redis-pretty:disabled { opacity: 0.6; cursor: default; }
#dp-redis-value pre, #dp-redis-cmd-result pre { margin: 0; padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.dp-redis-note { font-size: 11px; color: var(--text2); padding: 4px 8px; }
#dp-redis-more, .dp-redis-vmore { flex-shrink: 0; margin: 6px 8px; border: 1px solid var(--border2); background: none; color: var(--text2); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
#close-db-panel {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text2); padding: 2px 6px;
  border-radius: 6px; transition: color 0.12s; flex-shrink: 0;
}
#close-db-panel:hover { color: var(--text); }

/* Tables section */
#dp-tables-section {
  height: 80px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
}
.dp-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text2);
  padding: 6px 14px 4px;
}
#dp-tables-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 12px 10px;
}
.dp-table-chip {
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.dp-table-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Query section */
#dp-query-section {
  height: 170px;
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.dp-mode-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dp-mode-btn {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: none;
  font-size: 11px;
  font-family: var(--font-body);
  color: var(--text2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.dp-mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#dp-run-btn {
  margin-left: auto;
  padding: 4px 14px;
  border-radius: 7px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: opacity 0.12s;
}
#dp-run-btn:hover { opacity: 0.85; }
#dp-run-btn:disabled { opacity: 0.4; cursor: default; }
.dp-mode-content { display: none; flex: 1; overflow: auto; }
.dp-mode-content.active { display: flex; flex-direction: column; }
#dp-raw-input {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  padding: 8px 12px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: var(--bg2);
  color: var(--text);
  line-height: 1.5;
  box-sizing: border-box;
}
#dp-raw-input:focus { outline: none; }
#dp-filter-table-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#dp-filter-table-row label {
  font-size: 11px;
  color: var(--text2);
  flex-shrink: 0;
}
#dp-filter-table {
  flex: 1;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  font-size: 12px;
}
#dp-filter-rows {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dp-filter-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.dp-filter-row select, .dp-filter-row input {
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  font-size: 11px;
}
.dp-filter-row select { flex-shrink: 0; }
.dp-filter-row input { flex: 1; min-width: 0; }
.dp-filter-row button {
  background: none; border: none; cursor: pointer;
  color: var(--text2); font-size: 14px; padding: 0 4px;
  flex-shrink: 0;
}
.dp-filter-row button:hover { color: var(--danger-red); }
#dp-filter-add {
  margin: 4px 10px 6px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px dashed var(--border2);
  background: none;
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  align-self: flex-start;
  flex-shrink: 0;
}
#dp-filter-add:hover { border-color: var(--accent); color: var(--accent); }
#dp-ai-mode { padding: 8px 10px; gap: 6px; }
.dp-ai-input-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
  flex-shrink: 0;
}
#dp-ai-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border2);
  border-radius: 8px;
  resize: none;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-body);
  background: var(--bg3);
  color: var(--text);
  box-sizing: border-box;
}
#dp-ai-input:focus { outline: none; border-color: var(--accent); }
#dp-ai-generate {
  padding: 4px 10px;
  border-radius: 7px;
  border: none;
  background: var(--accent-purple, #7C5CBF);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
#dp-ai-generate:disabled { opacity: 0.5; cursor: default; }
#dp-ai-preview {
  flex: 1;
  overflow: auto;
  background: var(--bg3);
  border-radius: 7px;
  border: 1px solid var(--border2);
  padding: 6px 10px;
  font-size: 11px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}
#dp-ai-preview:empty { display: none; }

/* Results section */
#dp-results-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#dp-results-inner {
  flex: 1;
  overflow: auto;
  padding: 0 0 8px;
}
/* Results label row with export button */
#dp-results-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 10px;
}
.dp-export-btn {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.dp-export-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Single-row vertical display (\G style) */
.dp-result-vertical {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dp-result-vertical th {
  width: 40%;
  padding: 5px 10px 5px 14px;
  text-align: right;
  font-weight: 600;
  color: var(--text2);
  font-size: 11px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}
.dp-result-vertical td {
  padding: 5px 14px 5px 10px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}
.dp-result-vertical tr:hover th,
.dp-result-vertical tr:hover td { background: var(--bg3); }

.dp-result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dp-result-table th {
  position: sticky;
  top: 0;
  background: var(--bg3);
  padding: 6px 10px;
  text-align: left;
  font-weight: 700;
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
  color: var(--text2);
  font-size: 11px;
}
.dp-result-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dp-result-table tr:hover td { background: var(--bg3); }
.dp-result-json {
  margin: 0;
  padding: 10px 14px;
  font-size: 11px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}
.dp-empty {
  color: var(--text2);
  font-size: 12px;
  padding: 16px 14px;
}
.dp-error {
  color: var(--danger-red);
  font-size: 12px;
  padding: 10px 14px;
  background: rgba(214,48,49,0.06);
  border-radius: 7px;
  margin: 8px 10px;
}
.dp-truncated {
  font-size: 11px;
  color: var(--text2);
  padding: 4px 14px;
  font-style: italic;
}

/* Mobile: hide db-panel */
@media (max-width: 768px) {
  #db-panel { display: none !important; }
}

/* ── Buddep Panel ─────────────────────────────────────────────────────────────── */
#buddep-panel {
  --bd-width: 420px;
  width: var(--bd-width);
  min-width: var(--bd-width);
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: none;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
#buddep-panel.open {
  display: flex;
  animation: cpSlideIn 0.18s ease;
}
#bd-resize-handle {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transition: background 0.15s;
}
#bd-resize-handle:hover, #bd-resize-handle.active {
  background: var(--accent);
  opacity: 0.35;
}
#buddep-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg3);
}
#bd-title {
  display: flex;
  flex-direction: column;
  margin-right: auto;
  min-width: 0;
}
#bd-appname {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-head);
}
#bd-url {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bd-url:hover { text-decoration: underline; }
.bd-tabs { display: flex; gap: 4px; flex-shrink: 0; }
.bd-tab {
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: none;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.bd-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#close-buddep-panel {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text2); padding: 2px 6px;
  border-radius: 6px; transition: color 0.12s; flex-shrink: 0;
}
#close-buddep-panel:hover { color: var(--text); }
.bd-content { display: none; flex: 1; overflow: auto; }
.bd-content.active { display: block; }
#bd-module-list {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bd-module-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg3);
  border-radius: 10px;
  border: 1px solid var(--border2);
}
.bd-module-icon { font-size: 18px; }
.bd-module-info { flex: 1; min-width: 0; }
.bd-module-name { font-size: 13px; font-weight: 600; color: var(--text); }
.bd-module-url { font-size: 11px; color: var(--accent); text-decoration: none; }
.bd-module-url:hover { text-decoration: underline; }
.bd-module-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.bd-status-deployed { background: #1a3d2b; color: #4caf50; }
.bd-status-not_started { background: var(--bg4); color: var(--text2); }
.bd-status-failed { background: #3d1a1a; color: #f44336; }
.bd-status-deploying, .bd-status-building { background: #1a2d3d; color: #64b5f6; }
.mod-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.mod-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  padding: 2px 6px; border-radius: 4px; color: #fff;
  opacity: 0.9;
}
.mod-badge-icon {
  background: none; padding: 2px 3px; border-radius: 3px;
  display: inline-flex; align-items: center;
}
#bd-deploy-list, #bd-build-list {
  flex: 0 0 36%;
  border-bottom: 1px solid var(--border);
  overflow-y: auto;
}
#bd-deploy-detail, #bd-build-detail {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 14px;
  font-size: 12px;
  color: var(--text2);
  min-height: 0;
}
.bd-detail-table {
  flex-shrink: 0;
  max-height: 32%;
  overflow-y: auto;
}
.bd-log-viewer {
  flex: 1;
  overflow: auto;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  min-height: 0;
}
#bd-deploys, #bd-builds {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
#bd-deploys.active, #bd-builds.active { display: flex; }
.bd-record-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.bd-record-item:hover { background: var(--bg3); }
.bd-record-item.active { background: var(--bg4); border-left: 3px solid var(--accent); }
.bd-record-title { font-weight: 600; color: var(--text); }
.bd-record-meta { color: var(--text2); font-size: 11px; margin-top: 2px; }

#cp-files, #cp-history { flex: 1; overflow: hidden; display: none; flex-direction: column; }
#cp-files.active, #cp-history.active { display: flex; }

/* File tab: tree + viewer split */
#cp-file-tree {
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
  min-height: 120px;
  max-height: 40%;
  padding: 8px 0;
}
.ft-dir, .ft-file {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; cursor: pointer;
  font-size: 13px; font-family: var(--font-body);
  transition: background 0.1s;
  user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ft-dir:hover, .ft-file:hover { background: var(--bg3); }
.ft-file.active { background: var(--accent-pale); color: var(--accent); }
.ft-icon { font-size: 13px; flex-shrink: 0; }
.ft-file > img, .ft-folder-icon { width: 14px; height: 14px; flex-shrink: 0; }
.ft-children { padding-left: 16px; }
.ft-dir .ft-toggle { font-size: 10px; color: var(--text2); flex-shrink: 0; }

#cp-file-viewer {
  flex: 1; overflow: auto; background: #f8f9fc;
  padding: 16px;
}
#cp-file-viewer pre {
  margin: 0; font-size: 12px; line-height: 1.6;
  white-space: pre;
}
#cp-file-viewer pre code {
  font-family: Menlo, Monaco, Consolas, 'Liberation Mono', monospace !important;
  font-size: 12px;
}
#cp-file-viewer .cp-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text2); font-size: 13px;
}
/* Rendered markdown (README / CHANGELOG / docs) — GitHub-like */
.cp-md { font-size: 14px; line-height: 1.65; color: var(--text); word-wrap: break-word; }
.cp-md h1, .cp-md h2 { border-bottom: 1px solid var(--border2); padding-bottom: .3em; margin: 1em 0 .6em; }
.cp-md h1 { font-size: 1.6em; } .cp-md h2 { font-size: 1.3em; } .cp-md h3 { font-size: 1.1em; margin: 1em 0 .5em; }
.cp-md p, .cp-md ul, .cp-md ol, .cp-md blockquote, .cp-md table { margin: 0 0 .8em; }
.cp-md ul, .cp-md ol { padding-left: 1.6em; }
.cp-md code { background: var(--surface2); padding: .15em .4em; border-radius: 4px; font-size: .88em;
  font-family: Menlo, Monaco, Consolas, monospace; }
.cp-md pre { background: var(--surface2); padding: 12px; border-radius: 6px; overflow: auto; margin: 0 0 .8em; }
.cp-md pre code { background: none; padding: 0; font-size: 12px; }
.cp-md a { color: var(--accent); }
.cp-md blockquote { border-left: 3px solid var(--border2); padding-left: 1em; color: var(--text2); }
.cp-md table { border-collapse: collapse; } .cp-md th, .cp-md td { border: 1px solid var(--border2); padding: 6px 10px; }
.cp-md img { max-width: 100%; }

/* History tab */
#cp-commit-list {
  overflow-y: auto;
  max-height: 40%;
  border-bottom: 1px solid var(--border);
  padding: 6px 0;
}
.cp-commit {
  padding: 8px 14px; cursor: pointer;
  transition: background 0.1s; border-bottom: 1px solid var(--border);
}
.cp-commit:hover { background: var(--bg3); }
.cp-commit.active { background: var(--accent-pale); }
.cp-commit-msg { font-size: 12.5px; font-weight: 600; color: var(--text); }
.cp-commit-meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.cp-commit-badge {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  font-size: 10px; font-weight: 700; font-family: var(--font-head);
  background: var(--accent-pale); color: var(--accent);
  margin-left: 6px;
}
#cp-diff-viewer {
  flex: 1; overflow: auto; padding: 12px 14px;
  font-size: 12px;
}
#cp-diff-viewer .cp-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text2); font-size: 13px;
}
/* diff2html overrides */
.d2h-wrapper { font-size: 12px !important; }
.d2h-file-header { font-size: 11px !important; padding: 6px 10px !important; }
.d2h-code-line { font-size: 12px !important; }
.d2h-code-side-linenumber { padding: 0 12px 0 8px !important; }
.d2h-code-line-prefix { min-width: 18px; display: inline-block; text-align: center; }

/* Code Panel button in topbar */
#code-panel-btn {
  display: none;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
#code-panel-btn:hover { background: var(--bg4); border-color: var(--accent); color: var(--accent); }
#code-panel-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

@media (max-width: 640px) {
  #code-panel { width: 100%; right: -100%; }
  #code-panel.open { right: 0; }
}

/* ── Break-lock bubble buttons ─────────────────────────────────────────────── */
.blb-btn {
  padding: 4px 12px; border-radius: 5px; border: none;
  cursor: pointer; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.blb-resend { background: #f9a825; color: #fff; }
.blb-resend:hover { background: #f57f17; }
.blb-dismiss { background: #eee; color: #666; }
.blb-dismiss:hover { background: #ddd; }

@media (max-width: 640px) {
  .pf-modal { max-width: 460px !important; }
  .pf-body { flex-direction: column; gap: 10px; }
  .pf-rail { flex-direction: row; flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 6px; overflow-x: auto; }
  .pf-rail-item { white-space: nowrap; padding: 8px 14px; }
  .pf-panes { overflow-y: visible; }
}

/* ── Profile usage chart ─────────────────────────────────────────────────── */
.pf-usage-tiles { display: flex; gap: 8px; margin: 6px 0 10px; }
.pf-usage-tile { flex: 1; text-align: center; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 8px 4px; }
.pf-usage-tile b { display: block; font-size: 18px; color: var(--text); }
.pf-usage-tile span { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: .4px; }
.pf-usage-chart { display: flex; align-items: flex-end; gap: 2px; height: 64px; padding: 4px; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; }
.pf-usage-bar { flex: 1; min-height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85; }
.pf-usage-bar.empty { background: var(--border2); opacity: .5; }
.pf-llm-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pf-llm-name { font-size: 13px; font-weight: 600; color: var(--text); }
.pf-llm-action { margin-left: auto; }
.pf-llm-state { font-size: 11px; color: var(--text2); background: var(--bg3); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.pf-llm-state.mine { color: var(--accent); border-color: var(--accent); }
.pf-llm-edit { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; }
.pf-llm-editbox { flex-basis: 100%; display: flex; gap: 8px; margin-top: 6px; }
.pf-llm-editbox input { flex: 1; }

/* ── Code Export & GitHub Sync ──────────────────────────────────────────── */
/* Match the Files/History (.cp-tab) look so the two buttons stay compact (no arrow icons) */
.cp-hdr-btn{padding:4px 12px;border-radius:7px;border:1px solid var(--border2);
  background:none;font-size:12px;font-family:var(--font-body);color:var(--text2);
  cursor:pointer;transition:background 0.12s,color 0.12s;}
.cp-hdr-btn:hover{background:var(--surface2);}
.modal-box{background:var(--bg2);border:1px solid var(--border2);border-radius:var(--radius-lg);
  padding:24px;box-shadow:var(--shadow);}
.modal-x{background:none;border:none;cursor:pointer;font-size:18px;color:var(--text2);
  padding:2px 6px;border-radius:6px;transition:color 0.12s;}
.modal-x:hover{color:var(--text);}
.gh-box{max-width:560px;width:92%;}
.gh-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;}
.gh-key{font-family:Menlo,Monaco,Consolas,'Liberation Mono',monospace;font-size:11.5px;line-height:1.55;
  color:var(--text2);background:var(--surface2);border:1px solid var(--border);
  border-radius:var(--radius);padding:8px 10px;word-break:break-all;max-height:120px;overflow:auto;}
.gh-warn{background:var(--surface2);border-left:3px solid var(--warn,#e0a000);padding:8px 12px;
  font-size:13px;margin:12px 0;border-radius:var(--radius);}
.gh-input{width:100%;font-size:16px;padding:10px;border:1px solid var(--border);
  border-radius:var(--radius);box-sizing:border-box;margin:8px 0;}
/* Keep the input itself at 16px (avoids iOS focus zoom) but show a smaller, muted placeholder */
.gh-input::placeholder{font-size:13px;color:var(--text2);}
.gh-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:12px;}
.gh-status-fail{color:var(--danger,#d33);font-size:13px;}
.gh-status-ok{color:var(--text2);font-size:13px;}
.gh-recent{margin:8px 0;display:flex;flex-direction:column;gap:8px;}
.gh-recent-row{display:flex;flex-direction:column;gap:1px;padding-bottom:7px;border-bottom:1px solid var(--border2);}
.gh-recent-row:last-child{border-bottom:none;padding-bottom:0;}
.gh-recent-msg{font-size:13px;color:var(--text);word-break:break-word;}
.gh-recent-status{font-size:12px;}
.gh-push-ok{color:var(--success,#22c55e);}
.gh-push-pending{color:var(--warning,#f59e0b);}

/* ── System notifications ── */
.notif-modal-card { max-width: 460px; width: 92%; }
.notif-modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.notif-modal-actions button { min-height: 40px; padding: 0 16px; border-radius: 10px; font-size: 14px; font-weight: 500; cursor: pointer; }
.notif-btn-secondary { border: 1px solid var(--border2); background: var(--bg3); color: var(--text); }
.notif-btn-secondary:hover { background: var(--bg4); }
.notif-item { border: 1px solid var(--border2); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.notif-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.notif-level { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; }
.notif-level.info     { background: var(--accent-pale); color: var(--accent); }
.notif-level.warning  { background: var(--warn-pale);   color: var(--warn); }
.notif-level.critical { background: var(--danger-pale); color: var(--danger-red); }
.notif-about { font-size: 11px; color: var(--text2); }
.notif-title { font-weight: 600; color: var(--text); }
.notif-body  { font-size: 13px; color: var(--text2); white-space: pre-wrap; margin-top: 2px; }
.notif-resp  { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.notif-resp button { min-height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; font-size: 13px; }
.notif-tab-toggle { width: 100%; min-height: 38px; border: 1px solid var(--border2); border-radius: 10px; background: var(--bg3); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
.notif-tab-toggle:hover { background: var(--bg4); }
.notif-dot { position: absolute; top: 0; right: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--danger-red); border: 1.5px solid var(--bg2); }
.notif-unread { background: var(--accent-pale); }
.fb-new-btn { width: 100%; min-height: 40px; border: 1px solid var(--border2); border-radius: 10px; background: var(--bg3); color: var(--text); font-weight: 500; cursor: pointer; margin-top: 10px; }
.fb-new-btn:hover { background: var(--bg4); }
.fb-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.fb-form input, .fb-form textarea { width: 100%; box-sizing: border-box; padding: 9px 11px; border: 1px solid var(--border2); border-radius: 8px; background: var(--bg2); color: var(--text); font-size: 14px; font-family: inherit; }
.fb-form input:focus, .fb-form textarea:focus { outline: none; border-color: var(--accent); }
.fb-form textarea { resize: vertical; }
.fb-img-hint { font-size: 11px; color: var(--text2); }
.fb-add-tile { width: 60px; height: 60px; border-radius: 8px; border: 1px dashed var(--border2); background: var(--bg2); color: var(--text2); font-size: 26px; font-weight: 300; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.fb-add-tile:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-pale); }
.fb-staged .fb-add-tile { width: 54px; height: 54px; }
.fb-staged { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-staged:empty { display: none; }
.fb-staged-item { position: relative; width: 54px; height: 54px; }
.fb-staged-item img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border2); }
.fb-staged-rm { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: none; background: var(--danger-red); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.fb-about-label { font-size: 11px; font-weight: 600; color: var(--text2); }
.fb-about-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-chip { background: var(--bg2); border: 1px solid var(--border2); border-radius: 14px; padding: 3px 11px; font-size: 11.5px; color: var(--text2); cursor: pointer; user-select: none; transition: background .15s, border-color .15s, color .15s; }
.fb-chip:hover { background: var(--accent-pale); border-color: var(--accent); color: var(--accent); }
.fb-chip.active { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.fb-form-actions, .fb-composer-actions { display: flex; gap: 8px; }
.fb-form-actions { margin-top: 2px; }
.fb-submit-btn, .fb-send-btn { min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.fb-cancel-btn { min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border2); background: var(--bg3); color: var(--text); cursor: pointer; }
.fb-btn-loading { pointer-events: none; opacity: 0.85; }
.fb-btn-loading::after { content: ''; display: inline-block; width: 11px; height: 11px; margin-left: 7px; vertical-align: -1px; border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
.fb-err { color: var(--danger-red); font-size: 12px; min-height: 14px; }
.fb-thread { display: flex; flex-direction: column; gap: 8px; }
.fb-head { display: flex; align-items: center; gap: 8px; }
.fb-about { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--accent-pale); color: var(--accent); }
.fb-status { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; }
.fb-status-open { background: var(--accent-pale); color: var(--accent); }
.fb-status-in_progress { background: var(--warn-pale); color: var(--warn); }
.fb-status-resolved { background: var(--bg3); color: var(--text2); }
.fb-status-withdrawn { background: var(--bg3); color: var(--text2); }
.fb-title { font-weight: 600; color: var(--text); }
.fb-body { font-size: 13px; color: var(--text2); white-space: pre-wrap; }
.fb-time { font-size: 11px; color: var(--text2); opacity: 0.75; }
.fb-shots { display: flex; gap: 6px; flex-wrap: wrap; }
.fb-shot { width: 60px; height: 60px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border2); background: var(--bg3) center / cover no-repeat; }
.fb-shot-loading { cursor: default; position: relative; }
.fb-shot-loading::after { content: ''; position: absolute; top: 50%; left: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 2px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
.fb-resolution { border: 1px solid var(--accent); border-radius: 8px; padding: 8px 10px; background: var(--accent-pale); font-size: 13px; }
.fb-replies { display: flex; flex-direction: column; gap: 7px; margin-top: 2px; }
.fb-reply { font-size: 12.5px; color: var(--text); line-height: 1.5; }
.fb-reply-time { font-size: 10px; color: var(--text2); opacity: 0.8; margin-right: 5px; }
.fb-reply-who { font-size: 11px; font-weight: 600; color: var(--text2); margin-right: 4px; }
.fb-reply-text { white-space: pre-wrap; word-break: break-word; }
.fb-composer { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.fb-composer-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.fb-link { background: none; border: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; }
.fb-link:hover { text-decoration: underline; }
.fb-link-danger { color: var(--danger-red); }
.fb-reply-box { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.fb-composer textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border2); border-radius: 8px; background: var(--bg2); color: var(--text); font-size: 14px; font-family: inherit; resize: vertical; }
/* reply composer: compact textarea (no blue focus ring) + smaller Send/Cancel */
#fb-reply-text { font-size: 12.5px; padding: 5px 8px; }
#fb-reply-text:focus { outline: none; border-color: var(--border2); }
.fb-composer-actions button { min-height: 26px; padding: 0 10px; font-size: 12.5px; }
