/* TAI Platform - Main Stylesheet */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; height: -webkit-fill-available; }
html, body { overscroll-behavior: none; }

:root {
  /* Claude warm palette */
  --bg: #2B2A27;
  --bg-secondary: #201D18;
  --bg-card: rgba(255,255,255,0.03);
  --bg-input: #1F1E1B;
  --sidebar: #201D18;
  --editor: #1A1815;
  --border: rgba(255,255,255,0.08);
  --border-light: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.14);
  --text: #E8E6E3;
  --text-dim: #9A9893;
  --text-bright: #F5F3F0;
  --text-white: #ffffff;
  --accent: #AE5630;
  --accent-light: #DA7756;
  --accent-glow: rgba(174,86,48,0.2);
  --cyan: var(--accent);
  --cyan-glow: var(--accent-glow);
  --green: #5C8A4D;
  --green-glow: rgba(92,138,77,0.15);
  --red: #C0392B;
  --yellow: #D4A843;
  --orange: #BD5D3A;
  --pink: #C0756B;
  --hover: rgba(255,255,255,0.04);
  --active: rgba(174,86,48,0.1);
  --gradient-primary: #AE5630;
  --gradient-warm: #C0392B;
  --gradient-cool: #5C8A4D;
  --gradient-purple: #AE5630;
  --shadow-glow: none;
  --shadow-card: 0 4px 16px rgba(0,0,0,0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ================================================================
   WELCOME / LANDING PAGE
   ================================================================ */
.welcome {
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Clean warm background — Claude style */
.welcome-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
}
.welcome-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 30%, rgba(174,86,48,0.06), transparent);
}

/* Grid pattern — hidden in Claude style */
.welcome-grid {
  display: none;
}

/* Floating particles — hidden in Claude style */
.particles {
  display: none;
}
.particle {
  display: none;
}

/* Sections */
.welcome-section {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
}

/* ---- HERO ---- */
.hero {
  text-align: center;
  max-width: 720px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(174,86,48,0.1);
  border: 0.5px solid rgba(174,86,48,0.2);
  border-radius: 100px;
  padding: 6px 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
  letter-spacing: 0.5px;
  margin-bottom: 32px;
  animation: fade-in 0.4s ease-out;
}
.hero-badge .pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: none;
}
@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.hero-logo {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: 10px;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 8px;
  animation: fade-in 0.4s ease-out 0.1s backwards;
  position: relative;
  -webkit-text-fill-color: var(--accent);
}
.hero-logo::after {
  display: none;
}

.hero-tagline {
  font-size: 18px;
  color: var(--text-dim);
  font-weight: 400;
  letter-spacing: 2px;
  margin-bottom: 24px;
  animation: fade-in 0.4s ease-out 0.15s backwards;
}

.hero-desc {
  font-size: 16px;
  color: var(--text);
  line-height: 1.7;
  max-width: 480px;
  margin: 0 auto 40px;
  animation: fade-in 0.4s ease-out 0.2s backwards;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-bottom: 48px;
  animation: fade-in-up 0.6s ease-out 0.4s backwards;
}
.stat-item {
  text-align: center;
}
.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}
.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* MCP feature cards */
.mcp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 640px;
  margin-bottom: 48px;
  animation: fade-in-up 0.6s ease-out 0.5s backwards;
}
.mcp-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 10px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  cursor: default;
}
.mcp-card:hover {
  background: rgba(174,86,48,0.06);
  border-color: rgba(174,86,48,0.2);
}
.mcp-card .mcp-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 18px;
}
.mcp-card:nth-child(1) .mcp-icon { background: rgba(174,86,48,0.1); }
.mcp-card:nth-child(2) .mcp-icon { background: rgba(174,86,48,0.08); }
.mcp-card:nth-child(3) .mcp-icon { background: rgba(92,138,77,0.1); }
.mcp-card:nth-child(4) .mcp-icon { background: rgba(192,117,107,0.1); }
.mcp-card:nth-child(5) .mcp-icon { background: rgba(189,93,58,0.1); }
.mcp-card:nth-child(6) .mcp-icon { background: rgba(212,168,67,0.1); }
.mcp-card:nth-child(7) .mcp-icon { background: rgba(174,86,48,0.08); }
.mcp-card:nth-child(8) .mcp-icon { background: rgba(174,86,48,0.1); }
.mcp-card .mcp-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Auth box */
.auth-container {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  animation: fade-in-up 0.6s ease-out 0.6s backwards;
}
.auth-box {
  background: var(--bg-input);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: 0 0.25rem 1.25rem rgba(0,0,0,0.06);
  position: relative;
  overflow: hidden;
}
.auth-box::before {
  display: none;
}

.auth-tabs {
  display: flex;
  margin-bottom: 28px;
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s;
  font-family: 'Inter', sans-serif;
}
.auth-tab.active {
  color: #fff;
  background: var(--accent);
}
.auth-tab:hover:not(.active) { color: var(--text); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form input {
  background: rgba(255,255,255,0.04);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text-bright);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
}
.auth-form input::placeholder { color: var(--text-dim); }
.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(174,86,48,0.15);
}
.auth-form .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  position: relative;
  overflow: hidden;
}
.auth-form .btn:hover {
  background: var(--orange);
}
.auth-form .btn:active { transform: scale(0.98); }

.auth-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
  text-align: center;
}

/* Powered by */
.powered-section {
  margin-top: 32px;
  text-align: center;
}
.powered-text {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.6;
}
.tech-stack {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 16px;
  opacity: 0.4;
}
.tech-tag {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
}

/* ---- MCP SHOWCASE SECTION ---- */
.mcp-showcase {
  min-height: auto;
  padding: 80px 24px;
}
.section-header {
  text-align: center;
  margin-bottom: 60px;
}
.section-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.section-title {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 16px;
  line-height: 1.2;
}
.section-desc {
  font-size: 16px;
  color: var(--text-dim);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.6;
}

.mcp-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 900px;
  width: 100%;
}
.mcp-feature {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  position: relative;
  overflow: hidden;
}
.mcp-feature::before {
  display: none;
}
.mcp-feature:hover {
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.04);
}
.mcp-feature:hover::before { display: none; }
.mcp-feature .feat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}
.mcp-feature:nth-child(1) .feat-icon { background: rgba(174,86,48,0.1); }
.mcp-feature:nth-child(2) .feat-icon { background: rgba(174,86,48,0.08); }
.mcp-feature:nth-child(3) .feat-icon { background: rgba(92,138,77,0.1); }
.mcp-feature:nth-child(4) .feat-icon { background: rgba(192,117,107,0.1); }
.mcp-feature:nth-child(5) .feat-icon { background: rgba(189,93,58,0.1); }
.mcp-feature:nth-child(6) .feat-icon { background: rgba(212,168,67,0.1); }
.mcp-feature .feat-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 8px;
}
.mcp-feature .feat-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}
.mcp-feature .feat-tag {
  display: inline-block;
  margin-top: 12px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-light);
  background: rgba(174,86,48,0.08);
  border: 0.5px solid rgba(174,86,48,0.15);
  border-radius: 4px;
  padding: 2px 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ================================================================
   IDE LAYOUT
   ================================================================ */
.ide {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
}

/* Title bar */
.titlebar {
  height: 42px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.titlebar .left { display: flex; align-items: center; gap: 12px; }
.titlebar .title {
  font-weight: 700;
  letter-spacing: 3px;
  font-size: 13px;
  color: var(--accent);
}
.titlebar .uid {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.03);
  padding: 2px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.titlebar .mcp-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--green);
  background: rgba(92,138,77,0.08);
  border: 0.5px solid rgba(92,138,77,0.15);
  padding: 3px 10px;
  border-radius: 100px;
}
.titlebar .mcp-status .mcp-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
}
.titlebar .right-btns {
  display: flex;
  gap: 6px;
}
.titlebar .tb-btn {
  background: transparent;
  color: var(--text-dim);
  border: 0.5px solid var(--border);
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  font-family: 'Inter', sans-serif;
}
.titlebar .tb-btn:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--border-hover);
}
.titlebar .tb-btn:active { transform: scale(0.98); }
.titlebar .tb-btn.preview-btn { border-color: rgba(92,138,77,0.2); color: var(--green); }
.titlebar .tb-btn.preview-btn:hover { background: rgba(92,138,77,0.08); }
.titlebar .tb-btn.chat-btn { border-color: rgba(174,86,48,0.2); color: var(--accent-light); }
.titlebar .tb-btn.chat-btn:hover { background: rgba(174,86,48,0.08); }
.titlebar .tb-btn.run-btn { border-color: rgba(174,86,48,0.2); color: var(--accent); }
.titlebar .tb-btn.run-btn:hover { background: rgba(174,86,48,0.08); }
.titlebar .tb-btn.stop-btn { border-color: rgba(192,57,43,0.25); color: var(--red); }
.titlebar .tb-btn.stop-btn:hover { background: rgba(192,57,43,0.1); }
.titlebar .tb-btn.subscribe-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 6px 14px;
  border-radius: 8px;
}
.titlebar .tb-btn.subscribe-btn:hover {
  background: var(--orange);
}
@keyframes sub-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}
@keyframes deployPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.1); filter: brightness(1.2); }
}

/* Main body */
.main-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ===== Activity Bar ===== */
.activity-bar {
  width: 44px;
  background: var(--bg-secondary);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  flex-shrink: 0;
}
.ab-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}
.ab-btn:hover {
  color: var(--text);
  background: var(--hover);
}
.ab-btn.active {
  color: var(--accent-light);
  background: var(--active);
}
.ab-btn svg {
  width: 20px;
  height: 20px;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 260px;
  background: var(--sidebar);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.sidebar-actions {
  display: flex;
  gap: 2px;
}
.sidebar-actions button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}
.sidebar-actions button:hover { background: var(--hover); color: var(--text-bright); }

/* MCP Tools Panel */
.mcp-tools-panel {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}
.mcp-tools-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mcp-tools-header .mcp-live {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-glow 2s ease-in-out infinite;
}
.mcp-tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.mcp-tool-tag {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.2s;
}
.mcp-tool-tag:hover {
  border-color: rgba(174,86,48,0.3);
  color: var(--accent-light);
  background: rgba(174,86,48,0.06);
}
.mcp-tool-tag.active {
  border-color: rgba(92,138,77,0.2);
  color: var(--green);
  background: rgba(92,138,77,0.06);
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  font-size: 13px;
  padding: 4px 0;
}
.file-tree::-webkit-scrollbar { width: 5px; }
.file-tree::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 3px; }

/* Version History Section */
.version-section {
  border-top: 1px solid var(--border);
}
.version-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}
.version-header:hover { color: var(--text-bright); }
.version-toggle { font-size: 10px; transition: transform 0.2s; }
.version-toggle.open { transform: rotate(90deg); }
.version-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 0 8px 8px;
}
.version-list::-webkit-scrollbar { width: 4px; }
.version-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }
.version-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s;
  gap: 6px;
}
.version-item:hover { background: rgba(255,255,255,0.04); color: var(--text-bright); }
.version-item .v-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.version-item .v-meta {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}
.version-item .v-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.version-item:hover .v-actions { opacity: 1; }
.version-item .v-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
}
.version-item .v-btn:hover { background: rgba(174,86,48,0.15); }
.version-item .v-btn.danger { color: var(--red); }
.version-item .v-btn.danger:hover { background: rgba(192,57,43,0.15); }
.version-empty {
  text-align: center;
  padding: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.tree-item {
  display: flex;
  align-items: center;
  padding: 5px 14px;
  cursor: pointer;
  gap: 6px;
  white-space: nowrap;
  user-select: none;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.tree-item:hover { background: var(--hover); }
.tree-item.active { background: var(--active); border-left-color: var(--accent); }
.tree-item .icon { font-size: 14px; flex-shrink: 0; width: 18px; text-align: center; }
.tree-item .name { overflow: hidden; text-overflow: ellipsis; }
.tree-item.dir .icon { color: var(--yellow); }
.tree-item.file .icon { color: var(--accent-light); }
.tree-children { padding-left: 16px; }

/* Context menu */
.ctx-menu {
  position: fixed;
  background: var(--bg-input);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 0;
  min-width: 180px;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  font-size: 13px;
}
.ctx-menu .item {
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}
.ctx-menu .item:hover { background: rgba(174,86,48,0.1); color: var(--text); }
.ctx-menu .sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== Resizer Handle ===== */
.resizer {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background 0.2s;
}
.resizer::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 1px;
  width: 3px;
  background: transparent;
  transition: background 0.2s;
}
.resizer:hover::after, .resizer.active::after {
  background: var(--accent);
}
.resizer:hover, .resizer.active {
  background: rgba(174,86,48,0.08);
}

/* ===== Editor Area ===== */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabs {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.tabs::-webkit-scrollbar { height: 0; }
.tab {
  padding: 9px 16px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active {
  background: var(--bg);
  color: var(--text-bright);
  border-bottom: 2px solid var(--accent);
  margin-bottom: -1px;
}
.tab:active { transform: scale(0.98); }
.tab .close { font-size: 14px; opacity: 0; padding: 0 2px; border-radius: 3px; }
.tab:hover .close { opacity: 0.5; }
.tab .close:hover { opacity: 1; background: rgba(255,255,255,.06); }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); display: none; }
.tab.modified .dot { display: block; }
.tab.modified .close { display: none; }

.editor-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.editor-content textarea {
  width: 100%;
  height: 100%;
  background: var(--editor);
  color: var(--text);
  border: none;
  padding: 14px 18px;
  font-family: 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.7;
  resize: none;
  outline: none;
  tab-size: 2;
}
.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
  gap: 8px;
}
.editor-empty::before {
  content: '{ }';
  font-size: 36px;
  font-family: 'JetBrains Mono', monospace;
  color: rgba(174,86,48,0.15);
  font-weight: 700;
}

/* Status bar */
.statusbar {
  height: 28px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  justify-content: space-between;
  flex-shrink: 0;
  border-top: 0.5px solid var(--border);
}
.statusbar .mcp-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 10px;
}
.statusbar .mcp-indicator .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
}

/* ===== Chat Panel ===== */
/* Overlay mode (fixed, slides in from right) */
.chat-overlay {
  position: fixed;
  right: 0;
  top: 42px;
  bottom: 0;
  width: 400px;
  background: var(--bg);
  border-left: 0.5px solid var(--border);
  display: none;
  flex-direction: column;
  z-index: 100;
}
.chat-overlay.open { display: flex; }

/* In-flow mode (flex child inside .main-body) */
.chat-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
  border-left: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s cubic-bezier(0.165, 0.85, 0.45, 1);
}
.chat-panel.open {
  width: 400px;
  border-left: 0.5px solid var(--border);
  overflow: visible;
}

.chat-resizer {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 101;
  background: transparent;
  transition: background 0.3s;
}
.chat-resizer:hover,
.chat-resizer.active {
  background: var(--accent);
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header .chat-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-header .chat-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-bright);
}
.chat-header .model-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--cyan);
  background: rgba(174,86,48,0.08);
  border: 1px solid rgba(174,86,48,0.15);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: 'JetBrains Mono', monospace;
}
/* Chat header title */
.chat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Mode selector (in send area) */
.chat-send-area {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mode-selector {
  position: relative;
}
.mode-selector-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  font-family: 'Inter', sans-serif;
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
}
.mode-selector-btn:hover {
  border-color: var(--border-hover);
  background: var(--hover);
}
.mode-selector-icon {
  font-size: 16px;
}
.mode-selector-label {
  font-weight: 600;
  color: var(--text);
}
.mode-selector-arrow {
  font-size: 8px;
  opacity: 0.5;
  transition: transform 0.2s;
}
.mode-selector.open .mode-selector-arrow {
  transform: rotate(180deg);
}

/* Mode dropdown menu */
.mode-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--bg-input);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 100;
}
.mode-selector.open .mode-menu {
  display: block;
}
.mode-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
  color: var(--text-dim);
  text-align: left;
}
.mode-menu-item:hover {
  background: rgba(174,86,48,0.08);
}
.mode-menu-item.active {
  background: rgba(174,86,48,0.06);
}
.mode-menu-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.mode-menu-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mode-menu-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.mode-menu-desc {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.7;
}
.mode-menu-item.active .mode-menu-name {
  color: var(--accent-light);
}
.mode-menu-item.active .mode-menu-desc {
  color: var(--accent-light);
  opacity: 0.8;
}
.mode-menu-check {
  font-size: 14px;
  color: var(--accent-light);
  font-weight: 700;
}

/* Ask Before Edits toggle */
.ask-before-toggle {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.ask-before-toggle:hover {
  border-color: rgba(255,165,2,0.4);
  background: rgba(255,165,2,0.08);
}
.ask-before-toggle.active {
  background: rgba(255,165,2,0.12);
  border-color: rgba(255,165,2,0.5);
  color: #D4A843;
}

/* Agent steps in chat */
/* Agent steps removed — replaced by tool call cards */

/* Agent mode indicator on input */
.chat-input-area.agent-mode .chat-input-wrap {
  border-color: rgba(174,86,48,0.3);
  background: rgba(174,86,48,0.04);
}
.agent-label {
  display: none;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 14px 0;
}
.chat-input-area.agent-mode .agent-label { display: block; }

.chat-header .close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}
.chat-header .close-btn:hover { background: var(--hover); color: var(--text-bright); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.05); border-radius: 2px; }

.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--bg-user-msg, #393937);
  color: var(--text);
  border: none;
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
}
.chat-msg.admin {
  align-self: flex-start;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 0;
  padding: 4px 0;
  max-width: 100%;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}
.chat-msg.user {
  border-bottom-right-radius: 4px;
}
.chat-msg.system {
  align-self: center;
  max-width: 90%;
  background: rgba(174,86,48,0.06);
  color: var(--accent-light);
  border: 0.5px solid rgba(174,86,48,0.1);
  font-size: 12px;
  padding: 8px 14px;
  text-align: center;
  border-radius: 20px;
  font-family: 'Inter', sans-serif;
}
.chat-msg .time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  opacity: 0.7;
}
.chat-msg pre {
  background: var(--bg-input);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
}
.chat-msg code {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 12px;
}
.chat-msg pre code { background: none; padding: 0; }
.chat-msg :not(pre) > code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
}
.chat-msg b { color: var(--accent-light); font-weight: 600; }
.chat-msg a { color: var(--accent-light); text-decoration: underline; word-break: break-all; }
.chat-msg a:hover { color: var(--accent); }
.chat-msg p { margin: 6px 0; }
.chat-msg .msg-paragraph + .msg-paragraph { margin-top: 10px; }
/* Scroll buttons */
.chat-scroll-btn {
  position: absolute;
  bottom: 80px;
  right: 16px;
  left: auto;
  transform: scale(0);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
}
.chat-scroll-btn.show {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}
.chat-scroll-btn:hover {
  background: var(--orange);
}
.chat-scroll-btn:active {
  transform: scale(0.92);
}
.chat-scroll-btn.chat-scroll-top {
  bottom: auto;
  top: 60px;
}
/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
  align-self: flex-start;
}
.typing-indicator .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-light);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}
/* Message timestamp hover reveal */
.chat-msg .time {
  transition: opacity 0.2s;
}

.code-block-wrap { position: relative; margin: 8px 0; }
.code-block-wrap .copy-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: #aaa; font-size: 11px; padding: 3px 10px;
  border-radius: 4px; cursor: pointer; z-index: 2;
  transition: all 0.2s;
}
.code-block-wrap .copy-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.code-block-wrap .copy-btn.copied { background: rgba(92,138,77,0.2); color: var(--green); border-color: rgba(92,138,77,0.3); }
.code-block-wrap .code-lang {
  position: absolute; top: 6px; left: 10px;
  font-size: 10px; color: #888; text-transform: uppercase;
}
.code-block-wrap pre { margin: 0; padding-top: 28px; }
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 0.6s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Quick actions toolbar */
.chat-quick-actions {
  display: none;
  padding: 8px 12px;
  border-top: 0.5px solid var(--border);
  gap: 6px;
  flex-wrap: wrap;
}
.chat-quick-actions.show { display: flex; }
.quick-btn {
  background: transparent;
  border: 0.5px solid var(--border);
  color: var(--text-dim);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}
.quick-btn:hover {
  background: rgba(174,86,48,0.08);
  color: var(--text);
  border-color: rgba(174,86,48,0.25);
}
/* Focused file chips */
.focused-files {
  display: flex;
  gap: 6px;
  padding: 8px 12px 0;
  flex-wrap: wrap;
  overflow-x: auto;
}
.focus-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--hover);
  border: 0.5px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  white-space: nowrap;
  cursor: default;
  transition: all 0.2s;
}
.focus-chip:hover {
  border-color: var(--border-hover);
}
.focus-chip .chip-icon {
  color: var(--text-dim);
  display: flex;
}
.focus-chip .chip-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
  border-radius: 3px;
  transition: all 0.15s;
}
.focus-chip .chip-remove:hover {
  color: var(--red);
  background: rgba(192,57,43,0.1);
}

/* Input divider */
.input-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

/* Auto-edit toggle */
.auto-edit-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.auto-edit-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text);
}
.auto-edit-toggle.active {
  background: rgba(174,86,48,0.08);
  border-color: rgba(174,86,48,0.25);
  color: var(--accent-light);
}
.auto-edit-toggle:active {
  transform: scale(0.98);
}

/* @ Mention dropdown */
.at-mention-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  margin-bottom: 4px;
  background: var(--bg-input);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 60;
  max-height: 240px;
  overflow-y: auto;
}
.at-mention-menu::-webkit-scrollbar { width: 4px; }
.at-mention-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }
.at-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
  text-align: left;
}
.at-mention-item:hover,
.at-mention-item.active {
  background: rgba(174,86,48,0.1);
}
.at-mention-item .at-icon {
  color: var(--text-dim);
  flex-shrink: 0;
  display: flex;
}
.at-mention-item .at-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chat input area — Claude Code style */
.chat-input-area {
  padding: 12px 16px 16px;
}
.chat-input-wrap {
  position: relative;
  background: var(--bg-input);
  border: 0.5px solid var(--border);
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0.25rem 1.25rem rgba(0,0,0,0.035);
}
.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(174,86,48,0.12);
}
.chat-input-wrap textarea {
  background: transparent;
  border: none;
  padding: 12px 14px 4px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: none;
  min-height: 20px;
  max-height: 150px;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
}
.chat-input-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 6px;
  gap: 4px;
}
.chat-input-tools {
  display: flex;
  align-items: center;
  gap: 2px;
}
.input-tool-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
}
.input-tool-btn:hover {
  background: rgba(174,86,48,0.12);
  color: var(--accent-light);
}
.input-tool-btn.active {
  color: var(--accent);
}
.input-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
}
.chat-input-focused-file {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  font-size: 11px;
  font-family: monospace;
  color: var(--text-dim);
  min-width: 0;
}
.chat-input-focused-file .file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--hover);
  border: 0.5px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}
.chat-input-focused-file .file-chip:hover {
  border-color: var(--accent);
}
.chat-input-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.input-mode-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}
.input-mode-btn:hover {
  background: rgba(174,86,48,0.08);
  color: var(--text);
}
.input-mode-btn.active {
  color: var(--accent);
}
.input-mode-btn svg {
  flex-shrink: 0;
}
.chat-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  font-family: 'Inter', sans-serif;
  flex-shrink: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-send-btn:hover {
  background: var(--orange);
}
.chat-send-btn:active {
  transform: scale(0.98);
}
.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.chat-attachment-preview {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  flex-wrap: wrap;
}
.attach-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(174,86,48,0.1);
  border: 1px solid rgba(174,86,48,0.2);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--accent-light);
}
.attach-tag .remove-attach {
  cursor: pointer;
  opacity: 0.6;
  font-size: 13px;
}
.attach-tag .remove-attach:hover { opacity: 1; }

/* Processing indicator */
.processing-bar {
  display: none;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: rgba(174,86,48,0.03);
}
.processing-bar.show { display: block; }
.processing-bar .label {
  font-size: 13px;
  color: var(--accent-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.processing-bar .label .spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-bar .bar-track {
  height: 2px;
  background: rgba(255,255,255,0.04);
  border-radius: 2px;
  overflow: hidden;
}
.processing-bar .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan), var(--accent));
  background-size: 200% 100%;
  border-radius: 2px;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Drop zone */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(174,86,48,0.08);
  border: 3px dashed var(--accent);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--accent-light);
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.drop-overlay.show { display: flex; }

/* Preview Panel */
.preview-panel {
  display: none;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: #fff;
  min-width: 0;
  position: relative;
}
/* Preview watermark overlay for trial users */
.preview-watermark {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 900;
  color: rgba(174,86,48,0.12);
  pointer-events: none;
  z-index: 5;
  letter-spacing: 8px;
  text-transform: uppercase;
  transform: rotate(-30deg);
  user-select: none;
}
.preview-panel.open { display: flex; width: 50%; flex-shrink: 0; flex-grow: 0; }
.preview-header {
  height: 38px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
}
.preview-header .url-bar {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text-dim);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
}
.preview-header .url-bar:focus { border-color: var(--accent); }
.preview-header button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}
.preview-header button:hover { background: var(--hover); color: var(--text-bright); }
.preview-iframe { flex: 1; border: none; background: #fff; width: 100%; }
.editor-area.with-preview { flex: 1; min-width: 300px; }

/* Welcome tips in chat */
.welcome-tips {
  background: linear-gradient(135deg, rgba(174,86,48,0.06), rgba(174,86,48,0.04));
  border: 1px solid rgba(174,86,48,0.1);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 12px 8px;
}
.welcome-tips .tips-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 14px;
}
.welcome-tips .tip-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.welcome-tips .tip-item:last-child { margin-bottom: 0; }
.welcome-tips .tip-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.welcome-tips .tip-item b { color: var(--text-bright); }
.welcome-tips .tips-templates {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(174,86,48,0.1);
}
.welcome-tips .tips-label {
  font-size: 12px;
  color: var(--accent-light);
  font-weight: 600;
  margin-bottom: 10px;
}
.welcome-tips .template-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.welcome-tips .template-btn {
  background: rgba(174,86,48,0.08);
  border: 1px solid rgba(174,86,48,0.18);
  color: var(--text);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}
.welcome-tips .template-btn:hover {
  background: rgba(174,86,48,0.2);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* ---- HOW IT WORKS STEPS ---- */
.steps-section {
  min-height: auto;
  padding: 80px 24px;
}
.steps-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 700px;
  width: 100%;
  position: relative;
}
.steps-grid::before {
  content: '';
  position: absolute;
  left: 28px;
  top: 40px;
  bottom: 40px;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), var(--cyan), var(--green));
  opacity: 0.3;
}
.step-item {
  display: flex;
  gap: 24px;
  padding: 28px 0;
  position: relative;
}
.step-num {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  font-family: 'JetBrains Mono', monospace;
}
.step-item:nth-child(1) .step-num { background: rgba(174,86,48,0.15); color: var(--accent-light); border: 2px solid rgba(174,86,48,0.3); }
.step-item:nth-child(2) .step-num { background: rgba(174,86,48,0.12); color: var(--cyan); border: 2px solid rgba(174,86,48,0.25); }
.step-item:nth-child(3) .step-num { background: rgba(92,138,77,0.12); color: var(--green); border: 2px solid rgba(92,138,77,0.25); }
.step-item:nth-child(4) .step-num { background: rgba(192,117,107,0.12); color: var(--pink); border: 2px solid rgba(192,117,107,0.25); }
.step-item:nth-child(5) .step-num { background: rgba(255,217,61,0.12); color: var(--yellow); border: 2px solid rgba(255,217,61,0.25); }
.step-item:nth-child(6) .step-num { background: rgba(174,86,48,0.15); color: var(--accent-light); border: 2px solid rgba(174,86,48,0.3); }
.step-content {
  flex: 1;
  padding-top: 4px;
}
.step-content h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 8px;
}
.step-content p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}
.step-content .step-tip {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  line-height: 1.6;
}
.step-content .step-tip b { color: var(--accent-light); }
.free-trial-banner {
  margin-top: 40px;
  text-align: center;
  background: linear-gradient(135deg, rgba(174,86,48,0.08), rgba(174,86,48,0.06));
  border: 1px solid rgba(174,86,48,0.15);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
}
.free-trial-banner h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.free-trial-banner p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}
.free-trial-banner .trial-highlight {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  background: rgba(92,138,77,0.08);
  border: 1px solid rgba(92,138,77,0.15);
  border-radius: 100px;
  padding: 6px 20px;
}

/* Mobile */
.mobile-menu-btn { display: none !important; }
.mobile-bottom-bar { display: none; }

/* ============ Tablet (768px) ============ */
@media (max-width: 768px) {
  /* ---- Welcome / Landing ---- */
  .welcome-section { padding: 24px 16px; min-height: auto; }
  .hero { padding: 0 4px; }
  .hero-badge { font-size: 10px; padding: 5px 12px; margin-bottom: 12px; }
  .hero-logo { font-size: 42px; letter-spacing: 4px; }
  .hero-tagline { font-size: 13px; letter-spacing: 1.5px; margin-bottom: 10px; }
  .hero-desc { font-size: 14px; margin-bottom: 16px; }
  .stats-bar { gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
  .stat-num { font-size: 20px; }
  .stat-label { font-size: 10px; }
  .mcp-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
  .mcp-card { padding: 12px 8px; }
  .mcp-card .mcp-icon { width: 28px; height: 28px; font-size: 14px; margin-bottom: 6px; }
  .mcp-card .mcp-label { font-size: 10px; }
  .auth-container { max-width: 100%; }
  .auth-box { padding: 20px 16px; border-radius: var(--radius-md); }
  .auth-tabs { margin-bottom: 20px; }
  .auth-tab { padding: 9px 6px; font-size: 13px; }
  .auth-form input { padding: 12px 14px; font-size: 16px; }
  .auth-form .btn { padding: 13px; font-size: 14px; min-height: 48px; }
  #verifyCode { font-size: 18px !important; letter-spacing: 6px !important; }
  .powered-section { margin-top: 20px; }
  .tech-stack { gap: 8px; flex-wrap: wrap; justify-content: center; }
  .mcp-showcase { padding: 40px 16px; }
  .section-badge { font-size: 10px; }
  .section-title { font-size: 22px; }
  .section-desc { font-size: 14px; }
  .mcp-features { grid-template-columns: 1fr; gap: 12px; }
  .mcp-feature { padding: 20px 16px; }
  .mcp-feature .feat-title { font-size: 14px; }
  .mcp-feature .feat-desc { font-size: 12px; }

  /* Steps */
  .steps-section { padding: 40px 16px; }
  .steps-grid::before { left: 24px; }
  .step-item { gap: 16px; padding: 20px 0; }
  .step-num { width: 48px; height: 48px; font-size: 18px; }
  .step-content h3 { font-size: 16px; }
  .step-content p { font-size: 13px; }
  .free-trial-banner { padding: 20px 16px; }
  .free-trial-banner h3 { font-size: 18px; }

  /* ---- IDE Layout ---- */
  .titlebar {
    padding: 0 14px;
    padding-top: env(safe-area-inset-top, 44px);
    height: calc(46px + env(safe-area-inset-top, 44px));
    background: rgba(32,29,24,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 0.5px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  }
  .titlebar .left { gap: 10px; min-width: 0; }
  .titlebar .title {
    font-size: 15px;
    letter-spacing: 2.5px;
    font-weight: 700;
  }
  .titlebar .uid {
    font-size: 10px;
    padding: 3px 10px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: 100px;
    background: rgba(174,86,48,0.06);
    border: 0.5px solid rgba(174,86,48,0.15);
    color: var(--accent-light);
    font-weight: 500;
  }
  .titlebar .mcp-status { display: none; }
  .titlebar .right-btns { gap: 8px; flex-shrink: 0; align-items: center; }
  .titlebar .tb-btn {
    padding: 7px 11px;
    font-size: 11px;
    border-radius: 10px;
    min-height: 34px;
    min-width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-menu-btn {
    display: inline-flex !important;
    font-size: 18px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: transparent;
    border: 0.5px solid var(--border);
  }
  .titlebar .preview-btn,
  .titlebar .chat-btn,
  .titlebar .download-btn,
  .titlebar .run-btn { display: none !important; }
  .titlebar .subscribe-btn .sub-text { display: none; }
  .titlebar .subscribe-btn {
    padding: 7px 11px;
    font-size: 15px;
    border-radius: 10px;
    min-height: 34px;
    min-width: 34px;
    width: 36px;
    height: 36px;
  }

  .main-body { flex-direction: column; }
  .activity-bar { display: none !important; }
  .resizer { display: none !important; }
  .sidebar {
    width: 100% !important; height: auto; max-height: 0; overflow: hidden;
    border-right: none; border-bottom: 0.5px solid var(--border);
    transition: max-height 0.3s cubic-bezier(0.165,0.85,0.45,1);
  }
  .sidebar.mobile-open { max-height: 50vh; overflow-y: auto; }
  .mcp-tools-panel { padding: 8px 12px; }
  .mcp-tool-list { gap: 3px; }
  .mcp-tool-tag { font-size: 9px; padding: 2px 6px; }
  .sidebar-header { padding: 8px 12px; font-size: 10px; }

  .editor-area { flex: 1; min-width: 0; }
  .editor-area.with-preview { min-width: 0; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 7px 12px; font-size: 11px; white-space: nowrap; }
  .editor-content textarea { font-size: 13px; padding: 10px 12px; }
  .statusbar { padding: 0 8px; font-size: 10px; height: 24px; }

  /* Preview full-screen on mobile */
  .preview-panel.open {
    position: fixed; top: calc(48px + env(safe-area-inset-top, 44px)); left: 0; right: 0; bottom: 0;
    width: 100% !important; z-index: 100; background: var(--bg);
  }
  .preview-header { padding: 0 8px; height: 34px; }
  .preview-header .url-bar { font-size: 11px; padding: 4px 8px; }

  /* ---- Chat full-screen on mobile ---- */
  .chat-overlay {
    width: 100% !important;
    top: calc(48px + env(safe-area-inset-top, 44px)) !important;
    border-left: none;
  }
  .chat-panel {
    position: fixed;
    right: 0;
    top: calc(48px + env(safe-area-inset-top, 44px));
    left: 0;
    width: 100% !important;
    height: auto;
    border-left: none;
    z-index: 100;
    overflow: visible;
  }
  .chat-panel:not(.open) {
    display: none;
  }
  .chat-header { padding: 10px 12px; }
  .chat-header .chat-title { font-size: 14px; }
  /* Mode selector — mobile adjustments */
  .mode-selector-btn {
    padding: 10px 12px;
    min-height: 40px;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
  }
  .mode-menu {
    min-width: 220px;
  }
  .mode-menu-item {
    padding: 12px 14px;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
  }
  .chat-header .close-btn { padding: 8px 12px; font-size: 22px; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }

  /* Chat messages — more space, better touch */
  .chat-messages { padding: 12px 10px; gap: 10px; }
  .chat-msg {
    max-width: 88%;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 14px;
    -webkit-user-select: text;
    user-select: text;
  }
  .chat-msg.admin::before { display: none; }
  .chat-msg pre { font-size: 11px; padding: 8px 10px; }
  .chat-msg pre code { font-size: 11px; }
  .code-block-wrap pre { padding-top: 26px; }
  .code-block-wrap .copy-btn { font-size: 10px; padding: 4px 8px; }
  .code-block-wrap .code-lang { font-size: 9px; }

  /* Chat input — full width on mobile */
  .chat-input-area {
    padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
  }
  .chat-input-wrap {
    width: 100%;
    border-radius: 16px;
  }
  .chat-input-wrap textarea {
    padding: 14px 16px 4px;
    font-size: 16px;
    min-height: 48px;
    max-height: 140px;
    line-height: 1.5;
    width: 100%;
  }
  .chat-input-bottom {
    padding: 4px 8px 8px;
  }
  .chat-send-btn {
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 10px;
    min-height: 36px;
    min-width: 36px;
  }
  .chat-input-tools .input-tool-btn {
    font-size: 20px;
    padding: 6px 10px;
    min-height: 40px;
    min-width: 40px;
    -webkit-tap-highlight-color: transparent;
  }
  /* Agent label on mobile */
  .chat-input-area.agent-mode .agent-label {
    font-size: 12px;
    padding: 6px 14px;
  }
  /* Auto-edit toggle compact on mobile */
  .auto-edit-toggle {
    padding: 4px 8px;
    font-size: 10px;
  }
  .auto-edit-toggle span { display: none; }
  /* Input divider */
  .input-divider { height: 14px; }
  /* Focus chips scrollable */
  .focused-files { padding: 6px 10px 0; gap: 4px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .focused-files::-webkit-scrollbar { display: none; }
  .focus-chip { font-size: 10px; padding: 2px 6px; }

  /* Quick actions — horizontal scroll on mobile */
  .chat-quick-actions {
    padding: 8px 10px;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .chat-quick-actions::-webkit-scrollbar { display: none; }
  .quick-btn {
    font-size: 12px;
    padding: 7px 14px;
    flex-shrink: 0;
    min-height: 36px;
  }

  /* Processing bar */
  .processing-bar { padding: 10px 12px; }
  .processing-bar .label { font-size: 12px; }

  /* Agent steps compact */
  /* agent-steps removed */

  /* Welcome tips mobile */
  .welcome-tips { padding: 14px; margin: 8px 4px; }
  .welcome-tips .tips-title { font-size: 13px; margin-bottom: 10px; }
  .welcome-tips .tip-item { font-size: 12px; gap: 8px; }
  .welcome-tips .tip-icon { font-size: 14px; }
  .welcome-tips .template-btns {
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .welcome-tips .template-btns::-webkit-scrollbar { display: none; }
  .welcome-tips .template-btn {
    font-size: 12px;
    padding: 8px 14px;
    min-height: 36px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  /* Scroll button positions on mobile */
  .chat-scroll-btn { bottom: 70px; right: 12px; }
  .chat-scroll-btn.chat-scroll-top { bottom: auto; top: 56px; }

  /* Mobile bottom bar */
  .mobile-bottom-bar {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(54px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(32,29,24,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 0.5px solid var(--border);
    box-shadow: 0 -1px 8px rgba(0,0,0,0.15);
    z-index: 150;
    align-items: center;
    justify-content: space-around;
    padding-left: 8px;
    padding-right: 8px;
  }
  .mobile-bottom-bar .mob-btn {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    background: none; border: none;
    color: var(--text-dim);
    font-size: 19px;
    padding: 6px 14px;
    cursor: pointer;
    transition: color 0.2s, transform 0.15s;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
    min-width: 52px;
    min-height: 44px;
    border-radius: 10px;
    position: relative;
  }
  .mobile-bottom-bar .mob-btn span { font-size: 9px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
  .mobile-bottom-bar .mob-btn.active {
    color: var(--accent-light);
    background: rgba(174,86,48,0.1);
  }
  .mobile-bottom-bar .mob-btn:active { transform: scale(0.92); }

  /* Adjust IDE for bottom bar */
  .ide { padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px)); }
  .chat-overlay { bottom: calc(54px + env(safe-area-inset-bottom, 0px)) !important; }
  .chat-panel.open { bottom: calc(54px + env(safe-area-inset-bottom, 0px)); }
  .preview-panel.open { bottom: calc(54px + env(safe-area-inset-bottom, 0px)); }

  /* System messages compact */
  .chat-msg.system { font-size: 11px; padding: 6px 12px; }
}

/* ============ Extra small (380px) ============ */
@media (max-width: 380px) {
  .hero-logo { font-size: 36px; letter-spacing: 3px; }
  .hero-tagline { font-size: 12px; }
  .stats-bar { gap: 12px; }
  .stat-num { font-size: 18px; }
  .mcp-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-box { padding: 16px 12px; }
  .titlebar .uid { display: none; }
  .chat-msg { max-width: 92%; font-size: 13px; }
  .chat-msg pre { font-size: 10px; }
  .mode-selector-btn { padding: 8px 10px; font-size: 12px; }
  .mode-menu { min-width: 190px; }
  .chat-send-btn { padding: 6px 12px; font-size: 13px; min-height: 34px; min-width: 34px; }
  .chat-input-wrap textarea { min-height: 44px; font-size: 16px; }
  .quick-btn { font-size: 11px; padding: 6px 10px; min-height: 34px; }
}

/* Mobile: hide language switcher when IDE is active */
@media (max-width: 768px) {
  body.ide-active #langSwitcher { display: none !important; }
}

/* ========== Subscription Popup Modal ========== */
.subscribe-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
}
.subscribe-popup-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.subscribe-popup {
  background: var(--bg-input);
  border: 0.5px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.165,0.85,0.45,1);
}
.subscribe-popup-overlay.show .subscribe-popup {
  transform: scale(1) translateY(0);
}
.subscribe-popup .popup-icon {
  font-size: 56px;
  margin-bottom: 16px;
  display: block;
  animation: pop-bounce 0.6s ease 0.3s both;
}
@keyframes pop-bounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.subscribe-popup .popup-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}
.subscribe-popup .popup-desc {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 24px;
}
.subscribe-popup .popup-features {
  text-align: left;
  margin-bottom: 24px;
}
.subscribe-popup .popup-feat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-bright);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.subscribe-popup .popup-feat-item:last-child { border-bottom: none; }
.subscribe-popup .popup-feat-item .feat-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
}
.subscribe-popup .popup-btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.165,0.85,0.45,1);
  font-family: inherit;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.subscribe-popup .popup-btn-primary:hover {
  background: var(--orange);
}
.subscribe-popup .popup-btn-secondary {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 8px;
}
.subscribe-popup .popup-btn-secondary:hover {
  color: var(--text);
}

/* ============ Markdown rendering styles ============ */
.md-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-bright);
  margin: 14px 0 6px 0;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  letter-spacing: 0.3px;
}
.md-section-title:first-child {
  margin-top: 0;
}
.md-check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0;
  padding: 3px 0;
  line-height: 1.5;
}
.md-check {
  color: var(--green);
  font-weight: bold;
  flex-shrink: 0;
  margin-top: 1px;
}
.md-list-item {
  margin: 3px 0;
  padding: 2px 0 2px 4px;
  line-height: 1.5;
}
.md-num {
  color: var(--accent-light);
  font-weight: 700;
  margin-right: 2px;
}
.md-image-wrap {
  margin: 10px 0;
  text-align: center;
}
.md-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: transform 0.2s;
}
.md-image:hover {
  transform: scale(1.02);
  border-color: var(--accent);
}
.md-image-caption {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
@media (max-width: 480px) {
  .subscribe-popup {
    padding: 28px 20px;
    border-radius: 16px;
  }
  .subscribe-popup .popup-icon { font-size: 44px; }
  .subscribe-popup .popup-title { font-size: 18px; }
}

/* Mobile: always show project actions (no hover on touch) */
@media (max-width: 768px) {
  .version-item .v-actions {
    opacity: 1;
  }
}

/* Mobile: compact MCP grid so auth form is visible without scrolling */
@media (max-width: 768px) {
  .mcp-grid {
    gap: 6px;
    padding: 8px 0;
    grid-template-columns: repeat(4, 1fr);
  }
  .mcp-card {
    padding: 6px 4px;
  }
  .mcp-card .mcp-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  .mcp-card .mcp-label {
    font-size: 9px;
  }
  .stats-bar {
    margin: 8px 0;
    gap: 4px;
  }
  .hero-desc {
    margin-bottom: 8px;
    font-size: 12px;
  }
}

/* Mobile: titlebar safe-area handled in main 768px block above */

/* ============ Tool Call Blocks (Claude Code Style) ============ */
.tool-call {
  margin: 2px 0;
  border: none;
  border-left: 2px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  max-width: 100%;
  align-self: flex-start;
  font-size: 13px;
  transition: border-color 0.2s;
}
.tool-call:hover { border-left-color: var(--text-dim); }
.tool-call.tc-success { border-left-color: var(--green); }
.tool-call.tc-error { border-left-color: var(--red); }

/* Status dot */
.tc-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.tc-dot.active { background: var(--orange); animation: pulse-glow 2s ease-in-out infinite; }
.tc-dot.done { background: var(--green); }
.tc-dot.err { background: var(--red); }

/* Diff lines inside tool call body */
.tc-body .diff-add, .code-block-wrap .diff-add { background: rgba(92,138,77,0.12); color: var(--green); display: block; }
.tc-body .diff-remove, .code-block-wrap .diff-remove { background: rgba(192,57,43,0.12); color: var(--red); display: block; }
.tc-body .diff-line { font-family: 'JetBrains Mono', monospace; font-size: 11px; line-height: 1.6; padding: 0 8px; white-space: pre-wrap; }
.tc-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.tc-header:hover { background: rgba(255,255,255,0.02); }
.tc-icon {
  font-size: 14px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  flex-shrink: 0;
}
.tc-icon.write { background: rgba(92,138,77,0.1); color: var(--green); }
.tc-icon.read { background: rgba(174,86,48,0.1); color: var(--accent-light); }
.tc-icon.bash { background: rgba(174,86,48,0.1); color: var(--cyan); }
.tc-icon.edit { background: rgba(255,157,67,0.1); color: var(--orange); }
.tc-type {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: capitalize;
  flex-shrink: 0;
}
.tc-file {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.tc-status {
  font-size: 12px;
  flex-shrink: 0;
  min-width: 16px;
  text-align: center;
}
.tc-status.spinning::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent, #AE5630);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.tc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-dim);
}
.tc-dot.active {
  background: var(--accent, #AE5630);
  animation: tcPulse 1.4s ease-in-out infinite;
}
.tc-dot.done { background: var(--green, #5C8A4D); }
.tc-dot.err { background: var(--red, #C0392B); }
@keyframes tcPulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}
.tc-toggle {
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.tool-call.open .tc-toggle { transform: rotate(90deg); }
.tc-body {
  display: none;
  border-top: 1px solid var(--border);
  max-height: 300px;
  overflow-y: auto;
}
.tool-call.open .tc-body { display: block; }
.tc-body pre {
  margin: 0;
  padding: 10px 14px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-input);
  overflow-x: auto;
  white-space: pre;
  font-family: 'JetBrains Mono', monospace;
}
.tc-body::-webkit-scrollbar { width: 4px; }
.tc-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }

/* IN/OUT blocks (Claude Code style) */
.tc-io {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 0.5px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
}
.tc-io:last-child { border-bottom: none; }
.tc-io-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  width: 28px;
  padding-top: 2px;
}
.tc-io.tc-in .tc-io-label { color: var(--accent-light, #AE5630); }
.tc-io.tc-out .tc-io-label { color: var(--green, #5C8A4D); }
.tc-io-content {
  margin: 0;
  padding: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  overflow-x: auto;
}
.tc-summary {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(92,138,77,0.03);
  border-top: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
}

/* ============ MCP Management ============ */
.mcp-server-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  transition: background 0.15s;
  margin-top: 4px;
}
.mcp-server-item:hover { background: rgba(255,255,255,0.03); }
.mcp-server-item .mcp-s-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mcp-server-item .mcp-s-dot.online { background: var(--green); }
.mcp-server-item .mcp-s-dot.offline { background: var(--red); }
.mcp-server-item .mcp-s-name {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mcp-server-item .mcp-s-tools {
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}
.mcp-server-item .mcp-s-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.15s;
}
.mcp-server-item:hover .mcp-s-remove { opacity: 1; }
.mcp-server-item .mcp-s-remove:hover { color: var(--red); background: rgba(255,107,107,0.1); }

/* ============ Media Search Quick Tags ============ */
.media-qtag {
  font-size: 11px;
  color: var(--accent-light);
  background: rgba(174,86,48,0.06);
  border: 1px solid rgba(174,86,48,0.12);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'JetBrains Mono', monospace;
}
.media-qtag:hover {
  background: rgba(174,86,48,0.15);
  border-color: rgba(174,86,48,0.3);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
}
.toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: #fff;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toast.success { background: rgba(74,222,128,0.9); color: #0a2010; }
.toast.error { background: rgba(248,113,113,0.9); color: #2a0a0a; }
.toast.info { background: rgba(74,158,255,0.9); color: #0a1020; }
.toast.warning { background: rgba(251,191,36,0.9); color: #2a2000; }
.toast.removing { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }
@media (max-width: 480px) {
  .toast-container { top: auto; bottom: 70px; right: 8px; left: 8px; max-width: none; }
}

/* ============ Mobile Keyboard & Visual Viewport Fix ============ */
@media (max-width: 768px) {
  /* When virtual keyboard opens, adjust chat input */
  .chat-overlay.keyboard-open,
  .chat-panel.keyboard-open {
    bottom: 0 !important;
  }
  .chat-overlay.keyboard-open .chat-input-area,
  .chat-panel.keyboard-open .chat-input-area {
    padding-bottom: 8px;
  }
  .chat-panel.keyboard-open {
    position: fixed;
  }

  /* Auth form: ensure OAuth buttons are compact on small screens */
  .auth-form .btn[onclick*="auth/github"],
  .auth-form .btn[onclick*="auth/google"],
  .auth-form .btn[onclick*="auth/line"] {
    padding: 11px;
    font-size: 13px;
    min-height: 44px;
  }

  /* Prevent body scroll when chat or modal is open */
  body.chat-open { overflow: hidden; }

  /* Fix iOS rubber-band scroll in chat messages */
  .chat-messages {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Ensure file tree is scrollable on mobile */
  .sidebar.mobile-open .file-tree {
    max-height: calc(50vh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Small phones: compact auth form */
@media (max-width: 380px) {
  .auth-form { gap: 10px; }
  .auth-form .btn[onclick*="auth/github"],
  .auth-form .btn[onclick*="auth/google"],
  .auth-form .btn[onclick*="auth/line"] {
    padding: 9px;
    font-size: 12px;
    min-height: 40px;
    margin-top: 4px !important;
  }
  .auth-form .btn[onclick*="doGuestTrial"] {
    padding: 10px;
    font-size: 13px;
  }
}
