/* ============================================================
   DevPilot Design System
   Restrained, professional. Inspired by Linear / Vercel aesthetics.
   ============================================================ */

:root {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-inset: #18181b;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;
  --accent: #18181b;
  --accent-fg: #ffffff;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}

::selection { background: rgba(37, 99, 235, .15); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* ---------- Shared primitives ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: 500 13.5px/1 var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover:not(:disabled) { background: #3f3f46; }
.btn-secondary { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: #a1a1aa; background: var(--bg-subtle); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--text-tertiary); }
.btn-danger-ghost:hover { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
}
.badge-idle { background: var(--bg-subtle); color: var(--text-secondary); }
.badge-running { background: var(--blue-soft); color: var(--blue); }
.badge-running .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,.12);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Landing page
   ============================================================ */

.landing-body { background: #ffffff; }

.lp-nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(24px, calc((100% - 1120px) / 2));
  height: 60px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.lp-logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.lp-logo-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--bg-inset); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.lp-nav-links { display: flex; align-items: center; gap: 6px; }

.lp-hero {
  max-width: 780px; margin: 0 auto;
  padding: 88px 24px 56px;
  text-align: center;
}
.lp-hero-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
  background: var(--bg-subtle);
  margin-bottom: 26px;
}
.lp-hero h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 5.5vw, 56px);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.08;
}
.lp-hero .sub {
  margin: 0 auto 40px; max-width: 560px;
  font-size: 17px; color: var(--text-secondary); line-height: 1.65;
}

.lp-composer {
  max-width: 660px; margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.lp-composer:focus-within { border-color: #a1a1aa; box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.lp-composer textarea {
  width: 100%; border: 0; outline: 0; resize: none;
  padding: 18px 20px 8px;
  font: 400 15px/1.6 var(--font);
  color: var(--text);
  background: transparent;
  min-height: 84px;
}
.lp-composer textarea::placeholder { color: var(--text-tertiary); }
.lp-composer-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 12px 20px;
}
.lp-composer-hint { font-size: 12px; color: var(--text-tertiary); }

.lp-templates {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin-top: 22px;
}
.lp-template-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.lp-template-chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--bg-subtle); }
.lp-template-chip i { font-size: 12px; color: var(--text-tertiary); }

.lp-section {
  max-width: 1120px; margin: 0 auto;
  padding: 72px 24px;
}
.lp-section-head { text-align: center; margin-bottom: 48px; }
.lp-section-head h2 { margin: 0 0 12px; font-size: 30px; font-weight: 700; letter-spacing: -.025em; }
.lp-section-head p { margin: 0; color: var(--text-secondary); font-size: 15.5px; }

.lp-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 860px) { .lp-features { grid-template-columns: 1fr; } }
.lp-feature {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  transition: box-shadow .2s, border-color .2s;
}
.lp-feature:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.lp-feature-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg-subtle);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text);
  margin-bottom: 16px;
}
.lp-feature h3 { margin: 0 0 8px; font-size: 15.5px; font-weight: 600; }
.lp-feature p { margin: 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }

.lp-projects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .lp-projects-grid { grid-template-columns: 1fr; } }
.lp-project-card {
  display: block;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  text-decoration: none; color: inherit;
  transition: box-shadow .2s, border-color .2s;
  position: relative;
}
.lp-project-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.lp-project-card h3 { margin: 0 0 6px; font-size: 14.5px; font-weight: 600; padding-right: 60px; }
.lp-project-card p { margin: 0 0 14px; font-size: 13px; color: var(--text-secondary); min-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-project-card .meta { font-size: 12px; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.lp-project-card .badge { position: absolute; top: 18px; right: 16px; }
.lp-empty {
  text-align: center; padding: 48px 20px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  color: var(--text-tertiary); font-size: 14px;
}

.lp-footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ============================================================
   Studio (workspace)
   ============================================================ */

.studio-body { background: var(--bg); overflow: hidden; }

.studio {
  display: flex; flex-direction: column;
  height: 100vh;
}

.studio-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.studio-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.studio-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.studio-header-right { display: flex; align-items: center; gap: 8px; }

.studio-main { display: flex; flex: 1; min-height: 0; }

/* Chat pane */
.chat-pane {
  width: 42%; min-width: 380px; max-width: 560px;
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
}
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px 18px 8px; scroll-behavior: smooth; }

.msg { margin-bottom: 16px; animation: msgIn .18s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 85%;
  background: var(--bg-inset); color: #fff;
  padding: 10px 15px; border-radius: 14px 14px 4px 14px;
  font-size: 13.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}

.msg-assistant .bubble {
  font-size: 13.5px; line-height: 1.65; color: var(--text);
  word-break: break-word;
}
.msg-assistant .bubble p { margin: 0 0 8px; }
.msg-assistant .bubble p:last-child { margin-bottom: 0; }
.msg-assistant .bubble pre {
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; overflow-x: auto;
  font: 12px/1.5 var(--mono);
}
.msg-assistant .bubble code { font-family: var(--mono); font-size: 12.5px; background: var(--bg-subtle); padding: 1px 5px; border-radius: 4px; }
.msg-assistant .bubble pre code { background: none; padding: 0; }
.msg-assistant .bubble ul, .msg-assistant .bubble ol { margin: 4px 0 8px; padding-left: 20px; }

/* Tool cards */
.tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  margin-bottom: 8px;
  overflow: hidden;
  font-size: 12.5px;
  animation: msgIn .18s ease-out;
}
.tool-card-head {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.tool-card-head:hover { background: var(--bg-subtle); }
.tool-card-icon {
  width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; flex-shrink: 0;
  background: var(--bg-subtle); color: var(--text-secondary);
}
.tool-card.ok .tool-card-icon { background: var(--green-soft); color: var(--green); }
.tool-card.fail .tool-card-icon { background: var(--red-soft); color: var(--red); }
.tool-card-label { font-weight: 500; color: var(--text); white-space: nowrap; }
.tool-card-detail { color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-family: var(--mono); font-size: 11.5px; }
.tool-card-chevron { color: var(--text-tertiary); font-size: 10px; transition: transform .15s; }
.tool-card.expanded .tool-card-chevron { transform: rotate(90deg); }
.tool-card-body {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 10px 12px;
  font: 11.5px/1.6 var(--mono);
  color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-all;
  max-height: 260px; overflow-y: auto;
}
.tool-card.expanded .tool-card-body { display: block; }

.working-indicator {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 2px; color: var(--text-secondary); font-size: 13px;
}

.done-banner {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0 16px;
  padding: 9px 13px;
  border-radius: var(--radius);
  background: var(--green-soft); color: var(--green);
  font-size: 12.5px; font-weight: 500;
}
.error-banner {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 4px 0 16px;
  padding: 10px 13px;
  border-radius: var(--radius);
  background: var(--red-soft); color: var(--red);
  font-size: 12.5px;
}

/* Composer */
.chat-composer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
.chat-composer-box {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  transition: border-color .15s, box-shadow .15s;
  overflow: hidden;
}
.chat-composer-box:focus-within { border-color: #71717a; box-shadow: 0 0 0 3px rgba(24,24,27,.06); }
.chat-composer textarea {
  width: 100%; border: 0; outline: 0; resize: none;
  padding: 12px 14px 4px;
  font: 400 13.5px/1.55 var(--font);
  background: transparent;
  max-height: 140px;
}
.chat-composer-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 8px 14px;
}
.chat-composer-hint { font-size: 11.5px; color: var(--text-tertiary); }
.send-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px;
  transition: background .15s, opacity .15s;
}
.send-btn:hover:not(:disabled) { background: #3f3f46; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn.stop { background: var(--red); }

/* Workspace pane */
.work-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.work-tabs {
  display: flex; align-items: center; gap: 2px;
  padding: 8px 12px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.work-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px 9px;
  border: 0; background: transparent;
  font: 500 13px var(--font); color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s;
}
.work-tab:hover { color: var(--text); }
.work-tab.active { color: var(--text); border-bottom-color: var(--text); }
.work-tab i { font-size: 11.5px; }
.work-tabs-actions { margin-left: auto; display: flex; gap: 6px; padding-bottom: 6px; }

.work-content { flex: 1; min-height: 0; position: relative; }
.work-view { position: absolute; inset: 0; display: none; }
.work-view.active { display: flex; flex-direction: column; }

.preview-frame-wrap { flex: 1; background: #fff; position: relative; }
.preview-frame-wrap iframe { width: 100%; height: 100%; border: 0; }
.preview-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(250,250,250,.92); backdrop-filter: blur(2px);
  color: var(--text-secondary); font-size: 13.5px;
  z-index: 5;
}
.preview-overlay .big-icon { font-size: 34px; color: var(--text-tertiary); }

/* Code view */
.code-view { display: flex; flex: 1; min-height: 0; }
.file-tree {
  width: 230px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow-y: auto;
  padding: 10px 8px;
}
.file-tree-head { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .05em; padding: 4px 8px 8px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 6px;
  font-size: 12.5px; color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .1s, color .1s;
}
.file-item:hover { background: var(--bg-subtle); color: var(--text); }
.file-item.active { background: var(--bg-subtle); color: var(--text); font-weight: 500; }
.file-item i { font-size: 11px; color: var(--text-tertiary); width: 13px; text-align: center; flex-shrink: 0; }
.file-item .size { margin-left: auto; font-size: 10.5px; color: var(--text-tertiary); }

.code-editor-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fbfbfb; }
.code-editor-path {
  padding: 8px 16px;
  font: 12px var(--mono); color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex; align-items: center; gap: 8px;
}
.code-editor-content {
  flex: 1; overflow: auto; margin: 0;
  padding: 16px 20px;
  font: 12.5px/1.65 var(--mono);
  color: var(--text);
  white-space: pre; tab-size: 2;
}
.code-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-tertiary); font-size: 13px;
}
.code-empty i { font-size: 30px; }

/* Toast */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px;
  background: var(--bg-inset); color: #fff;
  border-radius: var(--radius-lg);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Responsive */
@media (max-width: 900px) {
  .studio-main { flex-direction: column; }
  .chat-pane { width: 100%; max-width: none; min-width: 0; height: 50%; border-right: 0; border-bottom: 1px solid var(--border); }
  .file-tree { width: 170px; }
}

/* ============================================================
   Auth page
   ============================================================ */

.auth-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 32px;
  text-align: center;
}
.auth-title { margin: 0 0 8px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.auth-sub { margin: 0 0 28px; font-size: 13.5px; color: var(--text-secondary); }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field span { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }
.auth-field input {
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font: 400 14px var(--font);
  color: var(--text);
  background: var(--bg-elevated);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-field input:focus { border-color: #71717a; box-shadow: 0 0 0 3px rgba(24,24,27,.06); }
.auth-error {
  padding: 9px 13px;
  background: var(--red-soft); color: var(--red);
  border-radius: var(--radius);
  font-size: 12.5px;
}
.auth-submit { justify-content: center; padding: 11px; font-size: 14px; margin-top: 4px; }
.auth-switch { margin: 22px 0 0; font-size: 13px; color: var(--text-secondary); }
.auth-switch a { color: var(--text); font-weight: 500; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* User chip in nav */
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; color: var(--text-secondary);
  background: var(--bg-elevated);
}
.user-chip .avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-inset); color: #4ade80;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}

/* Version history panel */
.version-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 320px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  display: flex; flex-direction: column;
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.version-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13.5px;
}
.version-list { flex: 1; overflow-y: auto; padding: 10px; }
.version-item {
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.version-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.version-item .v-label { font-size: 12.5px; font-weight: 500; color: var(--text); margin-bottom: 4px; word-break: break-all; }
.version-item .v-meta { font-size: 11.5px; color: var(--text-tertiary); display: flex; align-items: center; justify-content: space-between; }
.version-empty { text-align: center; padding: 40px 16px; color: var(--text-tertiary); font-size: 13px; }

/* ============================================================
   Admin Console
   ============================================================ */

.admin-body { background: var(--bg); }
#admin-root { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  position: sticky; top: 0; height: 100vh;
}
.admin-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; color: var(--text);
  text-decoration: none; padding: 6px 8px 18px;
}
.admin-logo .logo-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--bg-inset); color: #4ade80;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 14px;
}
.admin-badge {
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
  background: var(--blue-soft); color: var(--blue);
  border-radius: 999px; padding: 2px 8px;
}
.admin-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: none; background: none;
  border-radius: var(--radius); cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  color: var(--text-secondary); text-align: left; text-decoration: none;
  transition: background .12s, color .12s;
}
.admin-nav-item:hover { background: var(--bg-subtle); color: var(--text); }
.admin-nav-item.active { background: var(--bg-subtle); color: var(--text); font-weight: 600; }
.admin-nav-item i { width: 16px; text-align: center; font-size: 13px; color: var(--text-tertiary); }
.admin-nav-item.active i { color: var(--text); }
.admin-sidebar-footer { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.admin-me {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; font-size: 12px; color: var(--text-tertiary);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.admin-me span { overflow: hidden; text-overflow: ellipsis; }

.admin-main { flex: 1; padding: 32px 40px 64px; max-width: 1080px; }
.admin-page-head { margin-bottom: 24px; }
.admin-page-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.admin-page-head p { margin: 0; color: var(--text-tertiary); font-size: 13px; }

.admin-loading { display: flex; justify-content: center; padding: 80px 0; color: var(--text-tertiary); font-size: 22px; }

.admin-forbidden {
  min-height: 100vh; width: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; color: var(--text-secondary);
}
.admin-forbidden i { font-size: 34px; color: var(--text-tertiary); }
.admin-forbidden h2 { margin: 4px 0 0; color: var(--text); }
.admin-forbidden p { margin: 0 0 12px; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; display: flex; gap: 13px; align-items: flex-start;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  background: var(--bg-subtle); color: var(--text-secondary);
}
.stat-icon.blue { background: var(--blue-soft); color: var(--blue); }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.stat-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.stat-sub { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }

/* panels */
.admin-panel {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 18px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.admin-panel-head { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.admin-panel-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.admin-panel-head h3 i { color: var(--text-tertiary); font-size: 12px; }

.admin-env { padding: 13px 18px; display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-secondary); }
.admin-env .ok { color: var(--green); }
.admin-env .dim { color: var(--text-tertiary); }

/* trend chart */
.trend-chart { display: flex; align-items: flex-end; gap: 10px; padding: 22px 18px 14px; height: 150px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; position: relative; }
.trend-bar { width: 100%; max-width: 44px; background: var(--bg-inset); border-radius: 4px 4px 2px 2px; min-height: 4px; opacity: .85; transition: opacity .12s; }
.trend-col:hover .trend-bar { opacity: 1; }
.trend-x { font-size: 10.5px; color: var(--text-tertiary); font-family: var(--mono); }
.trend-v { position: absolute; top: -4px; font-size: 10.5px; color: var(--text-tertiary); font-family: var(--mono); }

/* tables */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; padding: 10px 16px; font-size: 11.5px; font-weight: 600;
  color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border); background: var(--bg-subtle);
}
.admin-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(0,0,0,.014); }
.admin-table .mono { font-family: var(--mono); font-size: 12.5px; }
.admin-table .dim { color: var(--text-tertiary); font-size: 12px; }

.pill {
  display: inline-flex; align-items: center; padding: 2px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: var(--bg-subtle); color: var(--text-secondary);
}
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }

.row-actions { text-align: right; white-space: nowrap; }
.icon-btn {
  width: 28px; height: 28px; border: 1px solid transparent; border-radius: 6px;
  background: none; cursor: pointer; color: var(--text-tertiary); font-size: 12.5px;
  transition: all .12s;
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.icon-btn .on { color: var(--blue); }

.proj-link { color: var(--text); text-decoration: none; font-weight: 500; }
.proj-link:hover { color: var(--blue); }
.proj-link i { font-size: 10px; color: var(--text-tertiary); margin-left: 3px; }

.admin-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.admin-search { position: relative; flex: 1; max-width: 340px; }
.admin-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: 12px; }
.admin-search .input { padding-left: 34px; width: 100%; }

.admin-pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-secondary);
}

/* settings */
.setting-list { display: flex; flex-direction: column; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row-col { flex-direction: column; align-items: stretch; gap: 8px; }
.setting-info label { font-size: 13.5px; font-weight: 600; display: block; }
.setting-info p { margin: 3px 0 0; font-size: 12px; color: var(--text-tertiary); }
.setting-num { width: 110px; text-align: right; }
.setting-text { width: 300px; }
.setting-textarea { width: 100%; resize: vertical; font-family: var(--font); }
.settings-actions { display: flex; justify-content: flex-end; padding-bottom: 24px; }

/* switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; cursor: pointer;
  background: var(--border-strong); transition: background .15s;
}
.switch .slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* toast */
.admin-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-inset); color: #fff; font-size: 13px; font-weight: 500;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-lg);
  z-index: 200; animation: toast-in .18s ease;
}
.admin-toast.ok i { color: #4ade80; }
.admin-toast.err i { color: #f87171; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* announcement banner (all pages) */
.announce-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg-inset); color: #e4e4e7; font-size: 12.5px;
  padding: 8px 16px; text-align: center;
}
.announce-banner i { color: #4ade80; font-size: 11px; }

/* quota chip (studio header) */
.quota-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-tertiary);
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 11px;
}
.quota-chip i { font-size: 10.5px; }
.quota-chip.warn { color: var(--amber); background: var(--amber-soft); border-color: #fde68a; }

/* ============================================================
   v4: image attachments (vision input)
   ============================================================ */

.attach-strip {
  display: flex; gap: 8px; padding: 10px 12px 0;
}
.attach-thumb {
  position: relative; width: 56px; height: 56px;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
  flex-shrink: 0;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb button {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff; font-size: 10px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.attach-thumb button:hover { background: rgba(0,0,0,.85); }

.attach-btn {
  width: 30px; height: 30px; border: none; border-radius: 7px;
  background: none; color: var(--text-tertiary); cursor: pointer;
  font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s; margin-right: auto;
}
.attach-btn:hover { background: var(--bg-subtle); color: var(--text); }

.bubble-imgs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.bubble-imgs img {
  max-width: 160px; max-height: 120px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.2); object-fit: cover; display: block;
}
