/* CupLab Desktop — macOS-style agent shell */
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;600;700&display=swap');

:root {
  --sidebar-w: 232px;
  --agent-w: 380px;
  --bg: #f8fafc;
  --bg2: #eff6ff;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.76);
  --glass-border: rgba(255, 255, 255, 0.72);
  --sidebar-bg: var(--glass);
  --panel-bg: rgba(255, 255, 255, 0.82);
  --agent-bg: var(--glass);
  --border: rgba(148, 163, 184, 0.35);
  --border-strong: #dbe4ef;
  --text: #0f172a;
  --muted: #475569;
  --muted-light: #64748b;
  --primary: #1e40af;
  --primary-soft: rgba(239, 246, 255, 0.85);
  --teal: #0d9488;
  --teal-soft: rgba(204, 251, 241, 0.85);
  --accent: #3b82f6;
  --cta: #f59e0b;
  --radius: 12px;
  --font: 'Fira Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --shadow-soft: 0 8px 24px rgba(30, 64, 175, 0.08);
  --blur: blur(18px) saturate(1.25);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: #eef4ff;
  -webkit-font-smoothing: antialiased;
}

/* 与 landing .page-bg 同系 aurora + 点阵 */
.app-page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(59, 130, 246, 0.24), transparent 55%),
    radial-gradient(ellipse 60% 45% at 95% 5%, rgba(13, 148, 136, 0.18), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(245, 158, 11, 0.12), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, #eef4ff 45%, #f8fafc 100%);
}
.app-page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(30, 64, 175, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 88%);
}
.app-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(64px);
  opacity: 0.5;
  animation: app-blob-float 14s ease-in-out infinite;
}
.app-blob-a { width: 360px; height: 360px; background: #93c5fd; top: -60px; right: 12%; }
.app-blob-b { width: 280px; height: 280px; background: #5eead4; bottom: 18%; left: -40px; animation-delay: -5s; }
.app-blob-c { width: 220px; height: 220px; background: #fcd34d; top: 40%; right: -30px; animation-delay: -9s; opacity: 0.32; }

@keyframes app-blob-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(0, 16px) scale(1.03); }
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--agent-w);
  height: 100vh;
  width: 100vw;
  transition: grid-template-columns 0.2s ease;
  background: transparent;
}

.app.sidebar-collapsed { --sidebar-w: 52px; }
.app.agent-collapsed { --agent-w: 48px; }
.app.agent-resizing { transition: none; }
.app.agent-resizing .agent-resize-handle { background: rgba(59, 130, 246, 0.35); }
.app.agent-resizing .shell-frame {
  pointer-events: none;
}
.agent-resize-shield {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  cursor: col-resize;
  touch-action: none;
}
.agent-resize-shield.active { display: block; }

.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  padding-bottom: 12px;
  margin-bottom: 4px;
}
.panel-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
}
.panel-toggle:hover { background: rgba(0,0,0,0.06); color: var(--text); }

.sidebar-collapsed .brand-text-wrap,
.sidebar-collapsed .brand-sub,
.sidebar-collapsed .nav-item .label,
.sidebar-collapsed .sidebar-foot,
.sidebar-collapsed .sidebar-archive .label {
  display: none;
}
.sidebar-collapsed .sidebar-top { justify-content: center; }
.sidebar-collapsed .brand { padding: 8px 0; justify-content: center; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 8px; }
.sidebar-collapsed #toggle-sidebar svg { transform: rotate(180deg); }

.agent-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.agent-head-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.agent-archive-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--teal);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.agent-archive-link:hover { color: var(--primary); }
.agent-collapsed .agent-compose,
.agent-collapsed .agent-log,
.agent-collapsed .agent-context,
.agent-collapsed .agent-status,
.agent-collapsed .agent-head-row h2,
.agent-collapsed .agent-head-sub,
.agent-collapsed .agent-archive-link,
.agent-collapsed .agent-badge {
  display: none;
}
.agent-collapsed .agent-head {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 4px;
}
.agent-collapsed #toggle-agent svg { transform: rotate(180deg); }

.nav-item.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px 12px;
  min-width: 0;
  flex: 1;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.brand-text { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: var(--primary-soft); color: var(--primary); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.12), rgba(59, 130, 246, 0.08));
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.15);
}
.nav-item.active svg { opacity: 1; }

.sidebar-foot {
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.sidebar-archive {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px dashed rgba(59, 130, 246, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-archive:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.55);
}
.sidebar-collapsed .sidebar-archive {
  justify-content: center;
  padding: 9px 8px;
}

/* ── Workspace ── */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: transparent;
}

.workspace-head {
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-soft);
}
.workspace-head-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.workspace-back {
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(8px);
  padding: 5px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
}
.workspace-back:hover { border-color: var(--accent); color: var(--primary); background: var(--primary-soft); }
.workspace-title { font-size: 15px; font-weight: 600; }
.workspace-meta { font-size: 12px; color: var(--muted); display:flex; align-items:center; gap:10px; }
.workspace-link-btn {
  border: none; background: transparent; color: var(--primary); font: inherit;
  font-size: 12px; font-weight: 600; cursor: pointer; padding: 0;
}
.workspace-link-btn:hover { text-decoration: underline; }

.membership-modal {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: grid; place-items: center; z-index: 1000;
}
.membership-modal[hidden] { display: none !important; }
.membership-dialog {
  background: linear-gradient(180deg, #eef4ff 0%, #e0edff 52%, #e6faf5 100%);
  border: 1px solid rgba(147, 197, 253, 0.85);
  border-radius: 12px;
  padding: 24px 22px;
  width: min(400px, 92vw);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
  box-sizing: border-box;
  max-width: 100%;
}
.membership-dialog h3 { font-size: 16px; margin-bottom: 8px; color: #1e3a8a; font-weight: 700; }
.membership-dialog p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(191, 219, 254, 0.75);
}
.membership-dialog label { display:block; font-size:11px; color:#1e3a8a; font-weight:600; margin-bottom:6px; }
.membership-dialog input {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  margin-bottom: 14px;
  box-shadow: inset 0 1px 2px rgba(30, 64, 175, 0.06);
}
.membership-actions { display:flex; gap:8px; flex-wrap:wrap; }
.membership-actions .btn {
  border: 1px solid rgba(191, 219, 254, 0.95);
  background: rgba(255, 255, 255, 0.9);
  color: #1e3a8a;
}

.workspace-body {
  flex: 1;
  overflow: hidden;
  padding: 0;
  min-height: 0;
}

.workspace-embed {
  display: flex;
  flex-direction: column;
  background: transparent;
}

.shell-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
}

/* ── Agent panel ── */
.agent-panel {
  position: relative;
  background: var(--agent-bg);
  border-left: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: -8px 0 28px rgba(30, 64, 175, 0.06);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.agent-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  margin-left: -3px;
  cursor: col-resize;
  z-index: 20;
  touch-action: none;
}
.agent-resize-handle:hover {
  background: rgba(59, 130, 246, 0.2);
}
.agent-collapsed .agent-resize-handle {
  display: none;
  pointer-events: none;
}

.agent-head {
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(10px);
}
.agent-sheet-grip {
  display: none;
  width: 40px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.32);
}
.agent-head h2 {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-head-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.18), rgba(59, 130, 246, 0.18));
  font-size: 13px;
}
.agent-head-sub {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}
.agent-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--teal), var(--accent));
  color: #fff;
}
.agent-status { font-size: 11px; color: var(--muted); margin-top: 4px; }

.agent-context {
  flex-shrink: 0;
  margin: 12px 16px 0;
  padding: 12px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  font-size: 12px;
  backdrop-filter: blur(10px);
}
.agent-context strong { display: block; margin-bottom: 2px; }
.agent-empty-guide {
  display: grid;
  gap: 8px;
  color: var(--muted);
}
.agent-empty-title {
  color: var(--text);
  font-weight: 700;
}
.agent-empty-guide ol {
  margin-left: 18px;
  line-height: 1.55;
}
.agent-match-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.agent-match-kicker {
  font-size: 10px;
  font-weight: 700;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.agent-match-title {
  margin-top: 2px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}
.agent-match-pill {
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
}
.agent-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.agent-step {
  position: relative;
  padding: 7px 8px;
  border-radius: 9px;
  background: rgba(241, 245, 249, 0.85);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}
.agent-step-num {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  font-size: 10px;
  font-weight: 800;
}
.agent-step.is-current {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.18);
}
.agent-step.is-current .agent-step-num {
  background: var(--primary);
  color: #fff;
}
.agent-step.is-done {
  background: rgba(204, 251, 241, 0.72);
  color: var(--teal);
}
.agent-step.is-done .agent-step-num {
  background: var(--teal);
  color: #fff;
}
.agent-context-hint {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.agent-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-log:empty::before {
  content: "这里会显示 AI 分析对话。先在赛程列表选择一场比赛，再在下方输入问题。";
  display: block;
  padding: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.34);
  font-size: 12px;
  line-height: 1.55;
}

.msg {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.55;
}
.msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.msg.agent {
  align-self: flex-start;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 3px;
  backdrop-filter: blur(8px);
}
.msg .who { font-size: 10px; font-weight: 600; opacity: 0.65; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

.msg.pending .body {
  opacity: 0.75;
  font-style: italic;
}

.msg.agent .body > :first-child { margin-top: 0; }
.msg.agent .body > :last-child { margin-bottom: 0; }
.msg.agent .body p { margin: 0.45em 0; }
.msg.agent .body ul,
.msg.agent .body ol { margin: 0.45em 0; padding-left: 1.25em; }
.msg.agent .body li { margin: 0.2em 0; }
.msg.agent .body h1,
.msg.agent .body h2,
.msg.agent .body h3 {
  font-size: 1.05em;
  font-weight: 700;
  margin: 0.65em 0 0.3em;
}
.msg.agent .body code {
  font-size: 0.92em;
  background: rgba(15, 23, 42, 0.07);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.msg.agent .body pre {
  margin: 0.55em 0;
  padding: 10px 12px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 11px;
  line-height: 1.45;
}
.msg.agent .body pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.msg.agent .body blockquote {
  margin: 0.45em 0;
  padding-left: 10px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.msg.agent .body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin: 0.45em 0;
}
.msg.agent .body th,
.msg.agent .body td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}
.msg.user .body { white-space: pre-wrap; word-break: break-word; }

.agent-compose {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(12px);
}
.agent-quick-prompts {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.agent-quick-prompts::-webkit-scrollbar { display: none; }
.agent-quick-prompts button {
  flex: 0 0 auto;
  border: 1px solid rgba(13, 148, 136, 0.22);
  background: rgba(204, 251, 241, 0.55);
  color: var(--teal);
  border-radius: 999px;
  padding: 5px 9px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.agent-quick-prompts button:hover {
  background: rgba(204, 251, 241, 0.85);
  border-color: rgba(13, 148, 136, 0.36);
}
.agent-compose textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.72);
}
.agent-actions { display: flex; gap: 8px; }
.agent-actions .btn { flex: 1; }

/* ── Components ── */
.btn {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--accent); background: var(--primary-soft); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--primary), var(--accent)); }
.btn-teal {
  background: linear-gradient(135deg, var(--teal), #14b8a6);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.match-list { display: flex; flex-direction: column; gap: 6px; }
.match-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.match-row:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(30,64,175,0.08); }
.match-row.selected { border-color: var(--primary); background: var(--primary-soft); }
.match-teams { font-weight: 600; font-size: 14px; }
.match-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pick-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 1100px) { .split-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }

.pred-hero {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0d9488 100%);
  color: #fff;
  border: none;
}
.pred-hero .pick { font-size: 28px; font-weight: 700; margin: 8px 0; }
.pred-hero .probs { opacity: 0.85; font-size: 13px; }

.factor-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.factor-table th, .factor-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.factor-table th { color: var(--muted); font-weight: 600; font-size: 11px; }

.form-grid { display: grid; gap: 12px; max-width: 520px; }
.form-grid label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.hint { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ── Mobile H5 (≤768px): shell layout ── */
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 490;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
}

html.mobile-nav-open .mobile-backdrop,
html.mobile-agent-open .mobile-backdrop {
  display: block;
}

.btn-mobile-menu,
.btn-mobile-agent {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.btn-mobile-agent {
  width: auto;
  padding: 0 12px;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
}

.btn-mobile-agent svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  html,
  body {
    overflow: hidden;
  }

  .btn-mobile-menu,
  .btn-mobile-agent {
    display: inline-flex;
  }

  .app {
    display: flex !important;
    flex-direction: column;
    grid-template-columns: unset !important;
    height: 100dvh;
    height: 100vh;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 520;
    pointer-events: auto;
    width: min(288px, 88vw);
    max-width: 100%;
    transform: translateX(-105%);
    transition: transform 0.26s ease;
    box-shadow: none;
    padding-top: max(16px, env(safe-area-inset-top));
  }

  html.mobile-nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.18);
  }

  .sidebar .panel-toggle#toggle-sidebar {
    display: none;
  }

  .workspace {
    flex: 1;
    min-height: 0;
    width: 100%;
  }

  .workspace-head {
    height: auto;
    min-height: 48px;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .workspace-head-main {
    flex: 1;
    min-width: 0;
  }

  .workspace-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .workspace-meta {
    width: 100%;
    order: 3;
    font-size: 11px;
    flex-wrap: wrap;
    gap: 6px;
  }

  #workspace-meta-text {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
  }

  .workspace-body {
    flex: 1;
    min-height: 0;
  }

  .agent-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: min(82dvh, 680px) !important;
    max-height: calc(100dvh - 48px);
    z-index: 600;
    border-left: none;
    border-top: 1px solid var(--glass-border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.15);
    transform: translateY(calc(100% + 24px));
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .agent-sheet-grip {
    display: block;
  }

  .agent-head {
    padding: 10px 14px 12px;
  }

  .agent-context {
    margin: 10px 14px 0;
  }

  .agent-steps {
    grid-template-columns: 1fr;
  }

  .agent-log {
    padding: 10px 14px;
  }

  .agent-compose {
    padding: 10px 14px max(14px, env(safe-area-inset-bottom));
  }

  html.mobile-agent-open .agent-panel {
    transform: translateY(0);
  }

  .app.agent-collapsed .agent-panel {
    /* on mobile, collapsed = hidden sheet; ignore 48px strip */
    width: 100% !important;
  }

  .agent-resize-handle {
    display: none !important;
  }

  .agent-compose textarea {
    font-size: 16px;
  }

  .agent-actions .btn {
    min-height: 44px;
  }

  .btn-mobile-agent-fab {
    display: none;
  }
}

@media (min-width: 769px) {
  .mobile-backdrop {
    display: none !important;
  }
}

