/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0a0f;
  --surface: rgba(22, 22, 35, 0.8);
  --surface2: rgba(30, 30, 48, 0.6);
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text: #e8e8f0;
  --muted: #7a7a95;
  --accent: #7c6cf0;
  --accent2: #a8a0ff;
  --accent-glow: rgba(124, 108, 240, 0.25);
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.1);
  --yellow: #fbbf24;
  --yellow-bg: rgba(251, 191, 36, 0.1);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.1);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", -apple-system, "SF Pro Display", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.shell {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 16px calc(40px + var(--safe-bottom));
}

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 56px 0 36px;
  position: relative;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 300px;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.logout-btn {
  position: absolute;
  top: 16px;
  right: 0;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.logout-btn:hover {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-bg);
}

.eyebrow {
  position: relative;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 12px;
  font-weight: 600;
}

.hero h1 {
  position: relative;
  z-index: 1;
  font-size: clamp(32px, 8vw, 48px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, var(--accent2) 50%, var(--blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  position: relative;
  z-index: 1;
  color: var(--muted);
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

[hidden] {
  display: none !important;
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.3s;
}

.card:hover {
  border-color: var(--border-hover);
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.card h2 svg {
  color: var(--accent2);
  flex-shrink: 0;
}

/* ── Env ────────────────────────────────────────────────────────────────── */
.env-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.env-item {
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.env-item.ok { border-left: 3px solid var(--green); }
.env-item.err { border-left: 3px solid var(--red); }

/* ── Mode Tabs ─────────────────────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
}

.mode-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.mode-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.mode-tab svg {
  flex-shrink: 0;
}

/* ── Project Picker ────────────────────────────────────────────────────── */
.project-picker {
  margin-bottom: 14px;
}

.picker-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--muted);
}

.project-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.project-item:hover {
  border-color: var(--accent);
  background: rgba(124, 108, 240, 0.05);
}

.project-item.selected {
  border-color: var(--accent);
  background: rgba(124, 108, 240, 0.12);
  box-shadow: 0 0 0 1px var(--accent), 0 2px 8px var(--accent-glow);
}

.proj-name {
  font-weight: 700;
  color: var(--accent2);
}

.proj-info {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.proj-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── History Mode Badge ────────────────────────────────────────────────── */
.hist-mode-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(96, 165, 250, 0.15);
  color: var(--blue);
  font-weight: 700;
  vertical-align: middle;
  margin-left: 4px;
}

/* ── Form ───────────────────────────────────────────────────────────────── */
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 14px 16px;
  resize: vertical;
  min-height: 100px;
  transition: all 0.25s;
  line-height: 1.6;
}

textarea::placeholder { color: var(--muted); opacity: 0.7; }

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), inset 0 0 0 1px var(--accent);
  background: rgba(30, 30, 48, 0.9);
}

.btn-row {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.25s;
  background: linear-gradient(135deg, var(--accent), #9b8afb);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
  -webkit-tap-highlight-color: transparent;
}

button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

button[type="submit"]:active:not(:disabled) {
  transform: translateY(0);
}

button[type="submit"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ── Pipeline ───────────────────────────────────────────────────────────── */
.pipeline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pipe-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  flex: 1;
  min-width: 0;
  transition: all 0.3s;
}

.pipe-step.running {
  border-color: var(--blue);
  background: var(--blue-bg);
}

.pipe-step.done {
  border-color: var(--green);
  background: var(--green-bg);
}

.pipe-step.error {
  border-color: var(--red);
  background: var(--red-bg);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

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

.pipe-step.running .pipe-icon::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--blue);
  animation: spin 1s linear infinite;
}

.pipe-icon {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.pipe-step.done .pipe-icon { background: var(--green); }
.pipe-step.running .pipe-icon { background: var(--blue); }
.pipe-step.error .pipe-icon { background: var(--red); }

.pipe-label {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.pipe-status {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

.pipe-arrow {
  color: var(--muted);
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.5;
}

.pipe-round {
  font-size: 12px;
  color: var(--yellow);
  padding: 4px 14px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 20px;
  white-space: nowrap;
  background: var(--yellow-bg);
}

.conclusion {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface2);
  border-left: 3px solid var(--border);
  line-height: 1.5;
}

.conclusion.completed { border-left-color: var(--green); background: var(--green-bg); }
.conclusion.error { border-left-color: var(--red); background: var(--red-bg); }
.conclusion.running { border-left-color: var(--blue); background: var(--blue-bg); }
.conclusion.completed_with_issues { border-left-color: var(--yellow); background: var(--yellow-bg); }

/* ── Logs ───────────────────────────────────────────────────────────────── */
.badge {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  animation: pulse 2s infinite;
}

.badge.done {
  background: var(--muted);
  animation: none;
}

.log-scroll {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overscroll-behavior: contain;
}

.log-entry {
  display: grid;
  grid-template-columns: 64px 56px 1fr;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface2);
  align-items: baseline;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.log-entry:first-child {
  border-color: var(--border-hover);
}

.log-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.log-phase {
  font-weight: 700;
  text-transform: capitalize;
  font-size: 12px;
}

.log-entry.opus .log-phase { color: var(--accent2); }
.log-entry.sonnet .log-phase { color: var(--blue); }
.log-entry.codex .log-phase { color: var(--yellow); }
.log-entry.system .log-phase { color: var(--muted); }

.log-msg {
  word-break: break-word;
  line-height: 1.4;
}

/* ── Agents ─────────────────────────────────────────────────────────────── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.agent-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  transition: all 0.3s;
}

.agent-card h3 {
  font-size: 14px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-card.running { border-color: var(--blue); }
.agent-card.done { border-color: var(--green); }
.agent-card.running h3::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); animation: pulse 1.5s infinite; }
.agent-card.done h3::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.agent-status {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}

.agent-output {
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
}

.agent-empty {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* ── Preview ────────────────────────────────────────────────────────────── */
.preview-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-frame {
  width: 100%;
  height: 480px;
  border: none;
  background: #fff;
  display: block;
}

/* ── History ────────────────────────────────────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.history-item:hover {
  border-color: var(--accent);
  background: rgba(124, 108, 240, 0.05);
  transform: translateX(2px);
}

.history-item:active {
  transform: translateX(0);
}

.hist-name {
  font-weight: 700;
  color: var(--accent2);
}

.hist-req {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-status {
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.hist-status.completed { background: var(--green-bg); color: var(--green); }
.hist-status.running { background: var(--blue-bg); color: var(--blue); }
.hist-status.error { background: var(--red-bg); color: var(--red); }
.hist-status.queued { background: rgba(136, 136, 160, 0.15); color: var(--muted); }
.hist-status.completed_with_issues { background: var(--yellow-bg); color: var(--yellow); }

.hist-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

/* ── Page Tabs ─────────────────────────────────────────────────────────── */
.page-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px;
}

.page-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.page-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }

.page-tab.active {
  background: linear-gradient(135deg, var(--accent), #9b8afb);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* ── Chat ──────────────────────────────────────────────────────────────── */
.chat-fullcard {
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
  min-height: 70vh;
  position: relative;
}

.chat-topbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 14px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.25s;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%237a7a95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.chat-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.chat-tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent2);
}

.chat-session-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  max-height: 300px;
  overflow-y: auto;
}

.chat-session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.chat-session-item:hover {
  border-color: var(--accent);
  background: rgba(124, 108, 240, 0.05);
}

.chat-session-item .sess-model {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.chat-session-item .sess-model.opus { background: rgba(168, 160, 255, 0.15); color: var(--accent2); }
.chat-session-item .sess-model.sonnet { background: var(--blue-bg); color: var(--blue); }
.chat-session-item .sess-model.codex { background: var(--yellow-bg); color: var(--yellow); }

.chat-session-item .sess-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-item .sess-count { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.chat-session-item .sess-del {
  width: 28px; height: 28px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; display: flex; align-items: center;
  justify-content: center; border-radius: 6px; transition: all 0.2s; flex-shrink: 0;
}
.chat-session-item .sess-del:hover { background: var(--red-bg); color: var(--red); }

/* Sidebar overlay */
.chat-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 85%;
  height: 100%;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}

.chat-close-btn:hover { color: var(--text); border-color: var(--border-hover); }

.chat-sidebar .chat-session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  max-height: unset;
}

/* Empty state */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
}

.chat-messages {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 500px;
  overscroll-behavior: contain;
}

.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), #9b8afb);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-msg.thinking {
  align-self: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-style: italic;
}

@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

.chat-msg.thinking .dots span {
  animation: dot-pulse 1.4s ease-in-out infinite;
}
.chat-msg.thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-msg.thinking .dots span:nth-child(3) { animation-delay: 0.4s; }

.chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 14px;
  resize: none;
  min-height: unset;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.25s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #9b8afb);
  color: #fff;
  cursor: pointer;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.chat-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .shell { padding: 0 12px calc(24px + var(--safe-bottom)); }

  .hero { padding: 40px 0 24px; }
  .hero h1 { font-size: 32px; }
  .subtitle { font-size: 12px; }

  .card { padding: 16px; border-radius: 14px; }
  .card h2 { font-size: 14px; margin-bottom: 12px; }

  .pipeline {
    flex-direction: column;
    gap: 8px;
  }

  .pipe-arrow { display: none; }

  .pipe-step {
    min-width: unset;
    padding: 10px 14px;
  }

  .agent-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .history-item {
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 12px 14px;
  }

  .hist-req {
    grid-column: 1 / -1;
    order: 3;
  }

  .hist-time { display: none; }

  .log-entry {
    grid-template-columns: 52px 1fr;
    gap: 4px;
    padding: 8px 10px;
  }

  .log-time { display: none; }
  .log-phase { font-size: 11px; }

  .preview-frame { height: 360px; }

  textarea {
    font-size: 16px; /* prevent zoom on iOS */
    min-height: 80px;
  }

  button[type="submit"] {
    padding: 16px 24px;
    font-size: 16px;
  }

  .page-tab { font-size: 13px; padding: 10px 12px; }

  .chat-fullcard { min-height: 60vh; }
  .chat-messages { min-height: 250px; max-height: 400px; padding: 12px; }
  .chat-msg { max-width: 90%; font-size: 13px; }
  .chat-input { font-size: 16px; }
  .chat-input-wrap { padding: 10px 12px; }
  .chat-sidebar { width: 260px; }
  .chat-topbar { padding: 10px 12px; }
  .chat-tool-btn span { display: none; }
  .chat-select { font-size: 13px; }

  .mode-tab { font-size: 12px; padding: 10px 10px; }

  .project-item {
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
  }
  .proj-time { display: none; }
}

@media (max-width: 380px) {
  .hero h1 { font-size: 28px; }
  .env-grid { flex-direction: column; }
  .pipe-step { gap: 8px; }
}
