/* ============================================================
   EnginAIer — AEC MCP Platform
   Fresh redesign for Autodesk & AEC
   ============================================================ */

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

:root {
  --bg: #0c0c0f;
  --bg-elevated: #141419;
  --bg-card: #1a1a21;
  --border: rgba(255,255,255,0.08);
  --border-accent: rgba(99,102,241,0.3);

  --indigo: #6366f1;
  --indigo-dim: rgba(99,102,241,0.15);
  --violet: #8b5cf6;
  --violet-dim: rgba(139,92,246,0.15);
  --cyan: #06b6d4;
  --teal-dim: rgba(6,182,212,0.15);
  --teal: #14b8a6;
  --blue: #3b82f6;
  --blue-dim: rgba(59,130,246,0.15);
  --amber: #f59e0b;
  --slate: #64748b;
  --white: #f8fafc;
  --muted: #94a3b8;

  --accent: var(--indigo);
  --accent-dim: var(--indigo-dim);
  --grad-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --green: var(--indigo);
  --green-dim: var(--indigo-dim);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 12px;
  --radius-lg: 16px;
}

html { scroll-behavior: smooth; font-size: 16px; }
body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: rgba(12,12,15,0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.nav-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.1rem;
}
.nav-logo-icon {
  width: 28px; height: 28px;
  background: var(--grad-primary);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
}
.nav-logo-tag {
  color: var(--muted); font-weight: 500; font-size: 0.75rem; margin-left: 6px;
}

.brand-name { font-weight: inherit; color: inherit; }
.brand-ai {
  color: var(--indigo);
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ── Site Logo image variants ── */
.site-logo {
  display: block;
  object-fit: contain;
  object-position: left center;
  image-rendering: auto;
  -webkit-font-smoothing: antialiased;
}
/* Top nav bar (index.html, dark bg) */
.site-logo--nav {
  height: 44px;
  width: auto;
  max-width: min(220px, 42vw);
  mix-blend-mode: lighten;
}
/* Dashboard sidebar — wide logo; blend removes solid black PNG background */
.site-logo--sidebar {
  height: 44px;
  width: auto;
  max-width: 100%;
  mix-blend-mode: lighten;
}
.chat-brand {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 10px;
  padding: 2px 0;
  font-weight: 700;
  font-size: 0.95rem;
}
.site-logo--auth {
  height: 52px;
  width: auto;
  max-width: 280px;
  margin: 0 auto 4px;
  mix-blend-mode: lighten;
}
/* Welcome screen centre */
.site-logo--welcome {
  height: 56px;
  width: auto;
  max-width: min(320px, 85vw);
  margin: 0 auto;
  mix-blend-mode: lighten;
}
/* Footer */
.site-logo--footer {
  height: 36px;
  width: auto;
  max-width: 200px;
  opacity: 0.9;
  mix-blend-mode: lighten;
}
.site-logo--footer:hover { opacity: 1; }

.nav-links {
  display: flex; align-items: center; gap: 6px;
}
.nav-link {
  padding: 8px 14px; border-radius: 8px;
  font-size: 0.88rem; color: var(--muted);
  transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--white); background: rgba(255,255,255,0.05); }

.nav-actions { display: flex; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px;
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all 0.2s;
}
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--white); }
.btn-primary {
  background: var(--grad-primary);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  color: var(--white);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--indigo); color: var(--indigo); }

/* ---------- Hero ---------- */
.hero {
  padding: 100px 0 80px;
  text-align: center;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 100px;
  background: var(--indigo-dim);
  border: 1px solid var(--border-accent);
  font-size: 0.78rem; font-weight: 500; color: var(--indigo);
  margin-bottom: 28px;
}
.hero-badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--indigo); animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 800; line-height: 1.15; letter-spacing: -0.03em;
  margin-bottom: 20px;
}
.hero h1 .accent { color: var(--indigo); }
.hero-sub {
  font-size: 1.1rem; color: var(--muted);
  max-width: 560px; margin: 0 auto 36px; line-height: 1.7;
}
.hero-ctas { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 48px; }
.hero-ctas .btn { padding: 14px 28px; font-size: 0.95rem; }

.hero-stats {
  display: flex; gap: 48px; justify-content: center; flex-wrap: wrap;
}
.hero-stat strong { display: block; font-size: 1.5rem; color: var(--indigo); margin-bottom: 4px; }
.hero-stat span { font-size: 0.8rem; color: var(--slate); }

/* ---------- Sections ---------- */
.section { padding: 80px 0; }
.section-header { text-align: center; margin-bottom: 48px; }
.section-header .label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--indigo); margin-bottom: 12px;
}
.section-header h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 700; margin-bottom: 12px;
}
.section-header p { color: var(--muted); font-size: 0.95rem; }

/* ---------- How it works ---------- */
.how-steps {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 24px; margin-top: 48px;
}
.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  transition: border-color 0.2s, transform 0.2s;
}
.step-card:hover { border-color: var(--border-accent); transform: translateY(-4px); }
.step-num {
  width: 44px; height: 44px;
  background: var(--indigo-dim);
  color: var(--indigo);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
  margin: 0 auto 20px;
}
.step-card h4 { font-size: 1rem; margin-bottom: 8px; }
.step-card p { font-size: 0.88rem; color: var(--muted); }

/* ---------- Agents ---------- */
.agents-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 48px; }
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s, transform 0.2s;
}
.agent-card:hover { border-color: var(--border-accent); transform: translateY(-2px); }
.agent-card-header { display: flex; gap: 16px; margin-bottom: 16px; }
.agent-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.agent-icon.indigo { background: var(--blue-dim); }
.agent-icon.teal { background: var(--teal-dim); }
.agent-domain {
  display: inline-block; font-size: 0.65rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--indigo); background: var(--indigo-dim);
  padding: 4px 10px; border-radius: 6px; margin-bottom: 8px;
}
.agent-card h3 { font-size: 1rem; margin-bottom: 4px; }
.agent-card .desc { font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.agent-meta { display: flex; gap: 16px; margin: 16px 0; font-size: 0.78rem; color: var(--slate); }
.agent-meta strong { color: var(--white); }
.mcp-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.mcp-tag {
  font-size: 0.7rem; padding: 4px 10px; border-radius: 6px;
  background: rgba(255,255,255,0.06); color: var(--muted);
}

/* ---------- Architecture ---------- */
.arch-section { background: var(--bg-elevated); }
.arch-diagram {
  max-width: 600px; margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.arch-layer {
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: var(--indigo-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-weight: 600; color: var(--indigo);
}
.arch-arrow { text-align: center; color: var(--slate); font-size: 1.2rem; margin: 8px 0; }

/* ---------- MCP Marketplace ---------- */
.mcp-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin-top: 48px;
}
.mcp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s, transform 0.2s;
}
.mcp-card:hover { border-color: var(--border-accent); transform: translateY(-2px); }
.mcp-card-icon { font-size: 1.5rem; margin-bottom: 12px; }
.mcp-card h4 { font-size: 0.95rem; margin-bottom: 8px; }
.mcp-card p { font-size: 0.82rem; color: var(--muted); line-height: 1.5; margin-bottom: 16px; }
.mcp-card-meta { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; }
.mcp-card-meta .free { color: var(--indigo); }
.mcp-card.mcp-add {
  border-style: dashed;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
}
.mcp-card.mcp-add:hover { border-color: var(--indigo); color: var(--indigo); }

/* ---------- Pricing ---------- */
.pricing-section { background: var(--bg-elevated); }
.pricing-toggles {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-bottom: 32px;
}
.pricing-toggle {
  display: flex; justify-content: center; gap: 0;
  margin-bottom: 40px;
}
.pricing-toggle button {
  padding: 10px 24px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.pricing-toggle button:first-child { border-radius: 8px 0 0 8px; }
.pricing-toggle button:last-child { border-radius: 0 8px 8px 0; }
.pricing-toggle button.active {
  background: var(--indigo-dim);
  border-color: var(--indigo);
  color: var(--indigo);
}
.pricing-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 20px; margin-top: 32px;
}
.pricing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
}
.pricing-card.featured {
  border-color: var(--indigo);
  background: rgba(99,102,241,0.05);
}
.pricing-card h3 { font-size: 0.9rem; color: var(--muted); margin-bottom: 4px; }
.pricing-card .plan-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.pricing-card .price { font-size: 2rem; font-weight: 800; color: var(--indigo); }
.pricing-card .price span { font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.pricing-features { text-align: left; margin-top: 20px; }
.pricing-features li { font-size: 0.85rem; color: var(--muted); padding: 6px 0; }
.pricing-features li.pricing-estimate { font-size: 0.78rem; color: var(--slate); font-style: italic; }
.pricing-cta { width: 100%; margin-top: 20px; justify-content: center; }
.pricing-save {
  font-size: 0.7rem; font-weight: 600; color: var(--indigo);
  background: rgba(99,102,241,0.15); padding: 2px 6px; border-radius: 4px; margin-left: 4px;
}
.pricing-footnote {
  text-align: center; font-size: 0.8rem; color: var(--muted); margin-top: 24px; max-width: 640px; margin-left: auto; margin-right: auto;
}
.pricing-loading { text-align: center; color: var(--muted); grid-column: 1 / -1; }
.sidebar-billing-link {
  display: block; font-size: 0.75rem; color: var(--indigo); text-align: center; margin-top: 6px; text-decoration: none;
}
.sidebar-billing-link:hover { text-decoration: underline; }

.credit-topup {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0,0,0,0.15);
}
.credit-topup-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.credit-topup-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}
.credit-topup-select,
.credit-topup-custom {
  flex: 1;
  min-width: 64px;
  font-size: 0.75rem;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--white);
}
.credit-topup-custom { max-width: 72px; }
.credit-topup-btn { padding: 4px 8px !important; font-size: 0.72rem !important; }
.credit-topup-note {
  margin: 6px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
}

/* ---------- CTA ---------- */
.cta-section {
  padding: 80px 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-elevated) 100%);
}
.cta-section h2 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: 12px; }
.cta-section h2 .accent { color: var(--indigo); }
.cta-section p { color: var(--muted); margin-bottom: 24px; }
.cta-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.footer {
  padding: 48px 24px 32px;
  border-top: 1px solid var(--border);
}
.footer-grid {
  display: grid; grid-template-columns: 2fr repeat(4, 1fr);
  gap: 40px; max-width: 1100px; margin: 0 auto 40px;
}
.footer-brand .nav-logo { margin-bottom: 12px; }
.footer-brand p { font-size: 0.88rem; color: var(--muted); line-height: 1.6; }
.footer-col h5 { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.08em; }
.footer-col a { display: block; font-size: 0.88rem; color: var(--white); padding: 4px 0; }
.footer-col a:hover { color: var(--indigo); }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 24px; border-top: 1px solid var(--border);
  max-width: 1100px; margin: 0 auto;
}
.footer-bottom p { font-size: 0.82rem; color: var(--slate); }
.footer-badges { display: flex; gap: 10px; }
.footer-badge {
  font-size: 0.72rem; padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
}

/* ---------- Submit idea / Sell MCP ---------- */
.submit-cards {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 40px; margin-top: 48px; align-items: start;
}
.submit-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.submit-card-icon { font-size: 1.8rem; margin-bottom: 16px; }
.submit-card h4 { font-size: 1rem; margin-bottom: 16px; }
.submit-card ul { list-style: none; }
.submit-card li {
  font-size: 0.88rem; color: var(--muted);
  padding: 8px 0; padding-left: 20px;
  position: relative;
}
.submit-card li::before {
  content: '✓'; position: absolute; left: 0;
  color: var(--indigo); font-weight: 700;
}
.submit-form {
  display: flex; flex-direction: column; gap: 14px;
}
.submit-form input,
.submit-form textarea {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--white);
  font-size: 0.9rem;
  font-family: var(--font);
}
.submit-form input::placeholder,
.submit-form textarea::placeholder { color: var(--slate); }
.submit-form input:focus,
.submit-form textarea:focus {
  outline: none; border-color: var(--indigo);
}
.submit-form textarea { resize: vertical; min-height: 100px; }
@media (max-width: 768px) {
  .submit-cards { grid-template-columns: 1fr; }
}

/* ---------- Compare table ---------- */
.compare-table {
  width: 100%; max-width: 900px; margin: 48px auto 0;
  border-collapse: collapse; font-size: 0.88rem;
}
.compare-table th, .compare-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: center; }
.compare-table th { color: var(--muted); font-weight: 600; }
.compare-table th:first-child, .compare-table td:first-child { text-align: left; }
.compare-table .check-y { color: var(--indigo); }
.compare-table .check-n { color: var(--slate); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .how-steps { grid-template-columns: 1fr; }
  .agents-grid { grid-template-columns: 1fr; }
  .mcp-grid { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .pricing-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; gap: 16px; }
}

/* ---------- Auth ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99,102,241,0.18), transparent),
    var(--bg);
}

.auth-shell {
  width: 100%;
  max-width: 420px;
}

.auth-back {
  display: inline-block;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--muted);
}
.auth-back:hover { color: var(--white); }

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
}
.auth-brand-title { font-weight: 800; font-size: 1.1rem; }
.auth-brand-sub { font-size: 0.82rem; color: var(--slate); text-align: center; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--bg-elevated);
  border-radius: 10px;
}

.auth-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.auth-tab.active {
  background: var(--indigo-dim);
  color: var(--indigo);
}

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

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.auth-field input {
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--white);
  font-family: var(--font);
  font-size: 0.92rem;
}
.auth-field select {
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--white);
  font-family: var(--font);
  font-size: 0.92rem;
}
.auth-field select:focus { outline: none; border-color: var(--indigo); }

.auth-submit { width: 100%; margin-top: 4px; }

.auth-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.35);
  color: #fca5a5;
  font-size: 0.85rem;
}

.auth-note {
  font-size: 0.78rem;
  color: var(--slate);
  line-height: 1.5;
}

/* ---------- Credit meter ---------- */
.credit-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  min-width: 180px;
}
.credit-meter.low { border-color: rgba(245,158,11,0.45); }
.credit-meter.empty { border-color: rgba(248,113,113,0.45); }

.credit-meter-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}
.credit-meter-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.credit-meter.low .credit-meter-fill { background: linear-gradient(90deg, #f59e0b, #f97316); }
.credit-meter.empty .credit-meter-fill { background: #f87171; width: 0 !important; }

.credit-meter-label { color: var(--muted); white-space: nowrap; }
.credit-meter-value { font-weight: 700; color: var(--white); white-space: nowrap; }

.sidebar-signout {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--slate);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--font);
}
.sidebar-signout:hover { color: var(--white); }

/* ---------- Chat app (Claude-style) ---------- */
.chat-app {
  height: 100vh;
  overflow: hidden;
}

.chat-layout {
  display: flex;
  height: 100vh;
  background: var(--bg);
}

.chat-sidebar {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

/* Logo in sidebar — mobile drawer only (desktop uses chat-header-logo) */
.chat-sidebar-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-sidebar-head .site-logo--sidebar {
  height: 44px;
  width: auto;
  max-width: 100%;
}

/* Desktop — icons-only agent rail */
.chat-sidebar .chat-sidebar-label,
.chat-sidebar .mcp-group-label,
.chat-sidebar .mcp-item-body,
.chat-sidebar .mcp-item-badge,
.chat-sidebar .credit-meter,
.chat-sidebar .credit-topup,
.chat-sidebar .sidebar-billing-link,
.chat-sidebar .chat-user-info {
  display: none;
}

.chat-sidebar .mcp-list {
  flex: 1;
  padding: 6px 0;
  gap: 2px;
}

.chat-sidebar .mcp-group {
  gap: 2px;
}

.chat-sidebar .mcp-item {
  justify-content: center;
  padding: 10px 0;
  width: 56px;
  border-radius: 0;
}

.chat-sidebar .mcp-item-icon {
  margin: 0;
  font-size: 1.25rem;
}

.chat-sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-sidebar .chat-sidebar-foot {
  padding: 10px 0;
  align-items: center;
}

.chat-sidebar .chat-user {
  justify-content: center;
  width: 100%;
  padding: 0 8px;
}

.chat-sidebar .sidebar-signout {
  display: none;
}

/* Collapse toggle — hidden on desktop icon rail */
.sidebar-collapse-btn {
  display: none;
}

.chat-sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.chat-sidebar-label {
  padding: 14px 16px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--slate);
}

.mcp-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mcp-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mcp-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

.mcp-group-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.mcp-dropdown .mcp-group {
  padding: 0 4px;
}

.mcp-dropdown .mcp-group + .mcp-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.mcp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mcp-item:hover:not(:disabled) {
  background: rgba(255,255,255,0.05);
  color: var(--white);
}

.mcp-item.active {
  background: var(--indigo-dim);
  color: var(--white);
}

.mcp-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mcp-item-icon { font-size: 1.1rem; flex-shrink: 0; }

.mcp-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mcp-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: inherit;
}

.mcp-item-meta {
  font-size: 0.72rem;
  color: var(--slate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mcp-item-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--slate);
  flex-shrink: 0;
}

.mcp-item-badge.live {
  background: rgba(99,102,241,0.2);
  color: #a5b4fc;
}

.credit-meter--compact {
  min-width: 0;
  padding: 8px 10px;
}

.credit-meter--compact .credit-meter-bar { flex: 1; }

.chat-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-user-info {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
}

.chat-user-info div:first-child {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-user-info div:last-child {
  font-size: 0.72rem;
  color: var(--slate);
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--indigo-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--indigo);
  flex-shrink: 0;
}

.chat-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.chat-header {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(12,12,15,0.85);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 200;
  overflow: visible;
}

.chat-header-logo {
  display: none;
  align-items: center;
  flex-shrink: 0;
  margin-right: 4px;
}

.site-logo--header {
  height: 44px;
  width: auto;
  max-width: min(220px, 28vw);
  mix-blend-mode: lighten;
}

@media (min-width: 901px) {
  .chat-header-logo {
    display: flex;
  }
}

.chat-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--white);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.chat-header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: visible;
}

.mcp-selector-wrap {
  position: relative;
}

.mcp-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--white);
  font-family: var(--font);
  cursor: pointer;
  max-width: 100%;
  transition: background 0.15s, border-color 0.15s;
}

.mcp-selector:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
}

.mcp-selector-icon { font-size: 1.2rem; }

.mcp-selector-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.mcp-selector-name {
  font-weight: 700;
  font-size: 0.92rem;
}

.mcp-selector-meta {
  font-size: 0.72rem;
  color: var(--slate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.mcp-selector-chevron {
  color: var(--slate);
  font-size: 0.75rem;
}

.mcp-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 90vw);
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  z-index: 300;
}

.model-selector-wrap {
  position: relative;
  flex-shrink: 0;
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.model-selector:hover:not(:disabled) {
  border-color: rgba(99,102,241,0.4);
  color: var(--white);
}

.model-selector:disabled {
  opacity: 0.7;
  cursor: default;
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(280px, 85vw);
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  z-index: 300;
}

.model-dropdown-head {
  padding: 12px 14px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate);
}

.model-dropdown-list {
  padding: 0 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--white);
  font-family: var(--font);
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
}

.model-option:hover:not(:disabled) {
  background: rgba(255,255,255,0.05);
}

.model-option.active {
  background: var(--indigo-dim);
  color: var(--indigo);
}

.model-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.model-option-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--slate);
}

.model-dropdown-note {
  padding: 8px 14px 12px;
  font-size: 0.75rem;
  color: var(--slate);
  border-top: 1px solid var(--border);
}

.chat-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.8rem;
}

.chat-thread-wrap {
  flex: 1;
  overflow: hidden;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
}

.chat-thread-wrap.is-welcome .chat-thread {
  overflow-y: hidden;
}

.chat-thread-wrap.acc-layout {
  flex-direction: row;
  align-items: stretch;
}

.chat-thread-wrap.acc-layout .chat-thread-column {
  flex: 1 1 360px;
  min-width: 320px;
}

.chat-thread-wrap.acc-layout > .acc-browser-sidebar {
  display: flex !important;
  height: 100%;
  max-height: 100%;
}

/* When preview is open, shrink the sidebar and show preview + chat side by side */
.chat-thread-wrap.acc-layout.preview-open > .acc-browser-sidebar:not(.collapsed) {
  width: 220px;
  min-width: 200px;
}

/* ---------- ACC multi-document preview container ---------- */
.acc-preview-container {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: grid;
  overflow: hidden;
  border-left: 1px solid var(--border, #2a2a2a);
  border-right: 1px solid var(--border, #2a2a2a);
}

.acc-preview-container[hidden] { display: none !important; }

/* Grid layouts for 1 / 2 / 3 / 4 panes */
.acc-preview-container[data-count="1"] { grid-template: 1fr / 1fr; }
.acc-preview-container[data-count="2"] { grid-template: 1fr / 1fr 1fr; }
.acc-preview-container[data-count="3"] { grid-template: 1fr 1fr / 1fr 1fr; }
.acc-preview-container[data-count="3"] .acc-preview-pane:last-child { grid-column: 1 / -1; }
.acc-preview-container[data-count="4"] { grid-template: 1fr 1fr / 1fr 1fr; }

/* Individual pane (same structure as the old single panel) */
.acc-preview-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-surface, #1a1a1a);
  overflow: hidden;
  border-right: 1px solid var(--border, #2a2a2a);
  border-bottom: 1px solid var(--border, #2a2a2a);
}

.acc-preview-pane:last-child { border-right: none; }

/* When preview is open, split preview ↔ chat — user drags #preview-resize-handle */
.chat-thread-wrap.acc-layout.preview-open .acc-preview-container {
  flex: 0 0 58%;
  min-width: 280px;
  max-width: none;
}

.chat-thread-wrap.acc-layout.preview-open .chat-thread-column {
  flex: 1 1 320px;
  min-width: 320px;
  max-width: none;
  width: auto;
}

/* Use full column width for messages + composer when ACC preview is open */
.chat-thread-wrap.acc-layout.preview-open .chat-thread,
.chat-thread-wrap.acc-layout.preview-open .chat-composer {
  max-width: none;
  margin: 0;
}

.acc-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #2a2a2a);
  background: var(--bg-elevated, #222);
  min-height: 40px;
  flex-shrink: 0;
}

.acc-preview-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary, #aaa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.acc-preview-view-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.acc-preview-view-btn {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border, #444);
  background: var(--bg, #1a1a1a);
  color: var(--text-secondary, #aaa);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.4;
}

.acc-preview-view-btn:hover {
  background: var(--bg-hover, #333);
  color: var(--text, #fff);
}

.acc-preview-view-btn.active {
  background: #4338ca;
  border-color: #6366f1;
  color: #fff;
}

.acc-preview-view-badge {
  font-size: 0.68rem;
  color: var(--text-secondary, #888);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-preview-view-select {
  flex: 0 1 140px;
  min-width: 90px;
  max-width: 180px;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border, #444);
  background: var(--bg, #1a1a1a);
  color: var(--text, #e5e7eb);
  font-size: 0.72rem;
  cursor: pointer;
}

.acc-preview-view-select[hidden] { display: none !important; }

.acc-preview-view-select:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
}

.acc-preview-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.acc-preview-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary, #888);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.acc-preview-btn:hover {
  background: var(--bg-hover, #333);
  color: var(--text, #fff);
}

.acc-preview-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.acc-preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary, #888);
  font-size: 0.85rem;
  /* Overlay centred on the body — never sits beside stage as a flex sibling */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  pointer-events: none;
}

/* Explicit hide rule — overrides the display:flex above when [hidden] is set */
.acc-preview-loading[hidden] { display: none !important; }

.acc-preview-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border, #333);
  border-top-color: var(--accent, #4e8ef7);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.acc-preview-pdf {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.acc-preview-viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.acc-preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary, #888);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px;
}

.chat-thread-column {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-thread-column::-webkit-scrollbar { display: none; }

.chat-thread-wrap.acc-layout .chat-thread {
  max-width: none;
  margin: 0;
  width: 100%;
}

.chat-thread {
  flex: 1;
  max-width: 768px;
  margin: 0 auto;
  padding: 24px 20px 32px;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.chat-thread::-webkit-scrollbar { width: 8px; }
.chat-thread::-webkit-scrollbar-track { background: transparent; }
.chat-thread::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.chat-thread::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.22); }
.chat-thread::-webkit-scrollbar-corner { background: transparent; }

.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
  min-height: 0;
}

.chat-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--indigo-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 16px;
}

.chat-welcome h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.chat-welcome p {
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 420px;
  margin-bottom: 24px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 560px;
}

.chat-suggestion {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.chat-suggestion:hover {
  border-color: var(--indigo);
  color: var(--white);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.msg {
  display: flex;
  gap: 12px;
  width: 100%;
}

.msg-user {
  justify-content: flex-end;
}

.msg-user .msg-bubble {
  background: var(--indigo-dim);
  border: 1px solid rgba(99,102,241,0.25);
  color: var(--white);
  border-radius: 18px 18px 4px 18px;
  max-width: 85%;
}

.msg-agent .msg-body { flex: 1; min-width: 0; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-bubble {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--white);
}

.msg-agent .msg-bubble {
  padding: 2px 0;
}

/* Markdown in agent messages */
.msg-bubble--md .msg-md {
  display: flex;
  flex-direction: column;
  gap: 0.65em;
}

.msg-md .md-p {
  margin: 0;
}

.msg-md .md-h2,
.msg-md .md-h3,
.msg-md .md-h4 {
  margin: 0.25em 0 0.15em;
  font-weight: 600;
  line-height: 1.35;
  color: var(--white);
}

.msg-md .md-h2 { font-size: 1.05rem; }
.msg-md .md-h3 { font-size: 0.98rem; }
.msg-md .md-h4 { font-size: 0.92rem; }

.msg-md .md-ul,
.msg-md .md-ol {
  margin: 0;
  padding-left: 1.35em;
}

.msg-md .md-ul li,
.msg-md .md-ol li {
  margin: 0.2em 0;
}

.msg-md .md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.35em 0;
}

.msg-md .md-code {
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.86em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.msg-md .md-pre {
  margin: 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
}

.msg-md .md-pre code {
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-md a {
  color: #a5b4fc;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-md a:hover {
  color: #c7d2fe;
}

.msg-md .md-table-wrap {
  overflow-x: auto;
  margin: 0.15em 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.msg-md .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  line-height: 1.45;
}

.msg-md .md-table th,
.msg-md .md-table td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.msg-md .md-table th {
  background: rgba(99, 102, 241, 0.12);
  color: var(--white);
  font-weight: 600;
  white-space: nowrap;
}

.msg-md .md-table tr:last-child td {
  border-bottom: none;
}

.msg-md .md-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* ── Inline diagram previews (SVG / Mermaid) ── */
.msg-md .md-diagram {
  margin: 14px 0;
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 12px;
  background: var(--bg-elevated, #141419);
  overflow: hidden;
}

.msg-md .md-diagram-stage {
  padding: 12px;
  overflow: auto;
  max-height: 360px;
  cursor: zoom-in;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

.msg-md .md-diagram--expanded .md-diagram-stage {
  max-height: none;
  cursor: zoom-out;
}

.msg-md .md-diagram-svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 120px;
  max-height: 320px;
}

.msg-md .md-diagram--expanded .md-diagram-svg {
  max-height: none;
}

.msg-md .md-diagram--mermaid .mermaid {
  margin: 0;
  padding: 12px;
  background: transparent;
  font-size: 0.82rem;
}

.msg-md .md-diagram-caption {
  padding: 8px 12px;
  font-size: 0.72rem;
  color: var(--muted, #888);
  border-top: 1px solid var(--border, #2a2a2a);
  text-align: center;
}

.msg-md .md-diagram-error {
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #f87171;
  border-top: 1px solid var(--border, #2a2a2a);
}

.msg-pending {
  display: flex;
  align-items: center;
  min-height: 24px;
}

.msg-dots {
  display: inline-block;
  width: 32px;
  height: 8px;
  background: radial-gradient(circle, var(--slate) 2px, transparent 2px) 0 50% / 10px 8px repeat-x;
  animation: msg-dots 1s steps(3) infinite;
}

@keyframes msg-dots {
  to { background-position: 30px 50%; }
}

.msg-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.msg-tool-tag {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.msg-usage {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--slate);
}

/* ---------- Panel resize handles ---------- */
.resize-handle {
  display: none;
  flex-shrink: 0;
  width: 10px;
  min-width: 10px;
  align-self: stretch;
  background: transparent;
  cursor: col-resize;
  position: relative;
  z-index: 25;
  transition: background 0.15s;
  touch-action: none;
  user-select: none;
}

.resize-handle::after {
  content: '';
  position: absolute;
  inset: 4px 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  transition: background 0.15s;
}

.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: var(--indigo, #6366f1);
}

/* Only show handles when ACC panel is visible */
.chat-thread-wrap.acc-layout .resize-handle-acc,
.chat-thread-wrap.acc-layout .resize-handle-pw {
  display: flex;
}

/* Only show preview/chat handle when preview is open */
.chat-thread-wrap.acc-layout.preview-open .resize-handle-preview {
  display: flex;
}

.chat-composer-wrap {
  flex-shrink: 0;
  padding: 12px 16px 20px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  border-top: 1px solid var(--border, #2a2a2a);
}

.chat-composer {
  max-width: 768px;
  margin: 0 auto;
}

.chat-composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  transition: border-color 0.15s;
}

.chat-composer-box:focus-within {
  border-color: rgba(99,102,241,0.45);
}

.chat-composer textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--white);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
  padding: 6px 0;
}

.chat-composer textarea:focus { outline: none; }
.chat-composer textarea::placeholder { color: var(--slate); }

.chat-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--grad-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

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

.chat-composer-hint {
  margin-top: 8px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--slate);
}

.sheet-template-bar {
  max-width: 768px;
  margin: 0 auto 8px;
}

.sheet-template-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 12px;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--white);
}

.sheet-template-chip-icon { font-size: 0.9rem; }
.sheet-template-chip-text {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-template-chip-clear {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}
.sheet-template-chip-clear:hover { color: var(--white); }

.project-docs-bar {
  max-width: 768px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.project-docs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.project-doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--white);
}

.project-doc-chip-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgba(16, 185, 129, 0.95);
}

.project-doc-chip-text {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-doc-chip-clear {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}
.project-doc-chip-clear:hover { color: var(--white); }

.project-docs-clear-all {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 4px 6px;
}
.project-docs-clear-all:hover { color: var(--white); }

.project-doc-category {
  flex-shrink: 0;
  max-width: 120px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--white);
  font-size: 0.72rem;
  padding: 0 8px;
}

/* ---------- ACC browser sidebar (vertical tree) ---------- */
.acc-browser-sidebar {
  width: 300px;
  min-width: 260px;
  max-width: 360px;
  flex-shrink: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  min-height: 0;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}

.acc-browser-sidebar[hidden] {
  display: none !important;
}

.acc-browser-sidebar.collapsed {
  width: 32px;
  min-width: 32px;
  max-width: 32px;
  cursor: pointer;
}

.acc-browser-sidebar.collapsed .acc-browser-title span:last-child,
.acc-browser-sidebar.collapsed .acc-browser-body,
.acc-browser-sidebar.collapsed .acc-selected-bar {
  display: none;
}

.acc-browser-sidebar.collapsed .acc-browser-head {
  justify-content: center;
  align-items: center;
  padding: 8px 2px;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 4px;
  border-bottom: none;
}

.acc-browser-sidebar.collapsed .acc-browser-title {
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.acc-browser-sidebar.collapsed .acc-browser-title-icon {
  font-size: 1rem;
  line-height: 1;
}

.acc-browser-sidebar.collapsed .acc-browser-toggle {
  transform: rotate(180deg);
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.acc-browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.acc-browser-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.acc-new-issue-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.acc-new-issue-btn:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--white);
}
.acc-browser-sidebar.collapsed .acc-new-issue-btn { display: none; }

/* ── Issue Modal ─────────────────────────────────────────── */
.issue-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.issue-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1001;
  width: min(520px, calc(100vw - 32px));
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  overflow: hidden;
}
.issue-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.issue-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  margin: 0;
}
.issue-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.issue-modal-close:hover { background: var(--bg-surface); color: var(--white); }
.issue-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.issue-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.issue-field-row {
  display: flex;
  gap: 12px;
}
.issue-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.issue-required { color: #f87171; }
.issue-input, .issue-select, .issue-textarea {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 8px 10px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.15s;
}
.issue-input:focus, .issue-select:focus, .issue-textarea:focus {
  border-color: var(--accent);
}
.issue-textarea { resize: vertical; min-height: 64px; }
.issue-select { appearance: auto; cursor: pointer; }
.issue-linked-file {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}
.issue-error {
  font-size: 0.82rem;
  color: #f87171;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: 6px;
  padding: 8px 12px;
}
.issue-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.issue-btn-cancel {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.issue-btn-cancel:hover { background: var(--bg-surface); color: var(--text); }
.issue-btn-submit {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 20px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.issue-btn-submit:hover { opacity: 0.88; }
.issue-btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Toast notification */
.issue-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #16a34a;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.issue-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
/* ── End Issue Modal ────────────────────────────────────── */

.acc-browser-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--white);
  min-width: 0;
}

.acc-browser-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 8px;
  flex-shrink: 0;
}

.acc-browser-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 10px 10px;
  overflow: hidden;
}

.acc-browser-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.acc-field-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate);
  margin: 0;
}

.acc-select {
  width: 100%;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--white);
  font-size: 0.78rem;
  padding: 0 8px;
}

.acc-tree-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}

.acc-tree {
  height: 100%;
  overflow-y: auto;
  padding: 6px 4px 8px;
}

.acc-browser-empty {
  margin: 0;
  padding: 12px 10px;
  font-size: 0.75rem;
  color: var(--slate);
  line-height: 1.45;
}

.acc-tree-node {
  display: block;
}

.acc-tree-children {
  margin-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  padding-left: 4px;
}

.acc-tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--white);
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.76rem;
  min-height: 28px;
}

.acc-tree-row:hover { background: rgba(255, 255, 255, 0.05); }
.acc-tree-row.selectable:hover { background: rgba(99, 102, 241, 0.12); }
.acc-tree-row.active {
  background: rgba(99, 102, 241, 0.2);
  outline: 1px solid rgba(99, 102, 241, 0.35);
}

.acc-tree-chevron {
  width: 14px;
  flex-shrink: 0;
  font-size: 0.65rem;
  color: var(--slate);
  text-align: center;
  line-height: 1;
}

.acc-tree-chevron.placeholder {
  visibility: hidden;
}

.acc-tree-chevron.expanded {
  transform: rotate(90deg);
  display: inline-block;
}

.acc-tree-icon { flex-shrink: 0; font-size: 0.85rem; display: flex; align-items: center; }
.acc-file-icon { flex-shrink: 0; width: 16px; height: 18px; }
.acc-file-icon--typed { width: 18px; height: 22px; }

.acc-tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-tree-badge {
  font-size: 0.62rem;
  color: var(--indigo);
  background: rgba(99, 102, 241, 0.15);
  padding: 2px 5px;
  border-radius: 999px;
  flex-shrink: 0;
}

.acc-tree-loading {
  padding: 4px 6px 4px 28px;
  font-size: 0.7rem;
  color: var(--slate);
}

.acc-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--white);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.78rem;
}
.acc-file-item:hover { background: rgba(255, 255, 255, 0.05); }
.acc-file-item.selectable:hover { background: rgba(99, 102, 241, 0.12); }
.acc-file-item.active { background: rgba(99, 102, 241, 0.2); border: 1px solid rgba(99, 102, 241, 0.35); }

.acc-file-icon { flex-shrink: 0; }
.acc-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acc-file-badge {
  font-size: 0.65rem;
  color: var(--indigo);
  background: rgba(99, 102, 241, 0.15);
  padding: 2px 6px;
  border-radius: 999px;
}

.acc-selected-bar {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: rgba(99, 102, 241, 0.06);
  flex-shrink: 0;
}

.acc-selected-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.acc-selected-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 8px;
  font-size: 0.72rem;
  color: var(--white);
  width: 100%;
}

/* Show a count badge when more than 1 doc selected */
.acc-selected-count {
  font-size: 0.68rem;
  color: var(--slate);
  padding: 2px 0 4px;
  text-align: center;
}

.acc-selected-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-selected-clear {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  flex-shrink: 0;
}
.acc-selected-clear:hover { color: var(--white); }

#btn-acc-connect.acc-connected {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.35);
}

.acc-setup-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.acc-setup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.acc-setup-dialog {
  position: relative;
  max-width: 520px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.acc-setup-dialog h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.acc-setup-dialog p {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.acc-setup-steps {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 0.82rem;
  color: var(--white);
  line-height: 1.6;
}

.acc-setup-callback label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.acc-setup-callback-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}

.acc-setup-callback-row code {
  flex: 1;
  font-size: 0.72rem;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  word-break: break-all;
}

.acc-setup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-attach-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-attach-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}
.chat-attach-btn:disabled { opacity: 0.4; cursor: wait; }

.msg-template-tag {
  font-size: 0.72rem;
  color: var(--indigo);
  margin-bottom: 6px;
  opacity: 0.9;
}

@media (max-width: 900px) {
  .chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    overflow: hidden;
  }

  .chat-sidebar::before {
    display: none;
  }

  .chat-sidebar-head {
    display: flex;
    position: static;
    width: auto;
  }

  .chat-sidebar .chat-sidebar-label,
  .chat-sidebar .mcp-group-label,
  .chat-sidebar .mcp-item-body,
  .chat-sidebar .mcp-item-badge,
  .chat-sidebar .credit-meter,
  .chat-sidebar .credit-topup,
  .chat-sidebar .sidebar-billing-link,
  .chat-sidebar .chat-user-info {
    display: revert;
  }

  .chat-sidebar .mcp-item {
    justify-content: flex-start;
    padding: 10px 12px;
    width: 100%;
    border-radius: 10px;
  }

  .chat-sidebar .mcp-item-icon {
    font-size: 1.1rem;
  }

  .chat-sidebar .chat-sidebar-foot {
    padding: 12px;
    align-items: stretch;
  }

  .chat-sidebar .chat-user {
    justify-content: flex-start;
    width: auto;
    padding: 0;
  }

  .chat-sidebar .sidebar-signout {
    display: block;
  }

  .chat-sidebar.open { transform: translateX(0); }

  .chat-sidebar-backdrop.open { display: block; }

  .chat-header-logo { display: none; }

  .chat-sidebar-close,
  .chat-menu-btn { display: flex; align-items: center; justify-content: center; }

  .chat-header-actions .btn-ghost:first-child { display: none; }

  .chat-header-center { justify-content: flex-start; }

  .model-selector-wrap { display: none; }
}

/* ---------- Admin dashboard ---------- */
.admin-app {
  min-height: 100vh;
  background: var(--bg);
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 12, 15, 0.95);
  backdrop-filter: blur(12px);
}

.admin-header-left,
.admin-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--indigo-dim);
  color: #a5b4fc;
  border: 1px solid var(--border-accent);
}

.admin-period {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.admin-select {
  background: var(--bg-card);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
}

.admin-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.admin-head h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.admin-head p {
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin: 24px 0 32px;
}

.admin-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.admin-kpi--accent {
  border-color: var(--border-accent);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.12), var(--bg-card));
}

.admin-kpi-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 6px 0 2px;
}

.admin-kpi-sub {
  font-size: 0.78rem;
  color: var(--slate);
}

.admin-section {
  margin-bottom: 32px;
}

.admin-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.admin-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.admin-cell-main {
  font-weight: 500;
}

.admin-cell-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.admin-profit {
  color: #86efac;
  font-weight: 600;
}

.admin-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
}

.admin-tag--admin {
  background: var(--indigo-dim);
  color: #c7d2fe;
}

.admin-empty {
  text-align: center;
  color: var(--muted);
  padding: 24px !important;
}

@media (max-width: 900px) {
  .admin-grid-2 { grid-template-columns: 1fr; }
  .admin-header { flex-wrap: wrap; height: auto; padding: 12px 16px; }
}

.admin-section-desc {
  margin: -8px 0 16px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.admin-aps-callout {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--white);
  max-width: 640px;
}
.admin-aps-callout p {
  margin: 6px 0 10px;
  color: var(--muted);
  line-height: 1.45;
}
.admin-aps-callback-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.admin-aps-callback-row code {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  font-size: 0.78rem;
  word-break: break-all;
}

.admin-field-hint {
  font-size: 0.72rem;
  color: var(--slate);
  line-height: 1.4;
}

.admin-integrations-form {
  display: grid;
  gap: 12px;
  max-width: 560px;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.admin-field input {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--white);
  font-family: var(--font);
  font-size: 0.88rem;
}

.admin-integrations-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.admin-integrations-status {
  font-size: 0.78rem;
  color: var(--muted);
}

.admin-integrations-status--ok {
  color: #86efac;
}

.admin-integrations-status--error {
  color: #fca5a5;
  max-width: 420px;
  line-height: 1.4;
}

/* ---------- Citation links [↗ p.N](#MID) ---------- */
a.md-cite {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px 1px 5px;
  border-radius: 10px;
  font-size: 0.78em;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.18);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.35);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  vertical-align: middle;
}
a.md-cite:hover {
  background: rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
}

/* ---------- Document issue markers (PDF / model QA) ---------- */
.doc-marker-bar {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated, #1e1e1e);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 10px;
}

.doc-marker-bar-head {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary, #aaa);
  margin-bottom: 8px;
}

.doc-marker-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.doc-marker-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--marker-color, #6366f1) 40%, transparent);
  background: color-mix(in srgb, var(--marker-color, #6366f1) 12%, var(--bg-card, #222));
  color: var(--text-primary, #eee);
  cursor: pointer;
  text-align: left;
  font: inherit;
  max-width: 220px;
  transition: transform 0.12s, box-shadow 0.12s;
}

.doc-marker-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.doc-marker-kind {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--marker-color, #6366f1);
}

.doc-marker-label {
  font-size: 0.8rem;
  line-height: 1.3;
}

.doc-marker-fix {
  font-size: 0.72rem;
  color: #86efac;
}

/* ── PDF.js viewer stage ───────────────────────────────────────── */
.acc-pdfjs-stage {
  /* Override the centering from .acc-preview-body so the stage fills the full area */
  align-self: stretch;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #1a1a1f;
}

.acc-pdfjs-stage[hidden] { display: none !important; }

.acc-pdfjs-viewport {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 16px 12px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #1a1a1f;
  scroll-behavior: smooth;
}

.acc-pdfjs-page-wrap {
  flex-shrink: 0;
  background: #fff;
}

/* Placeholder shown while a page hasn't been lazy-rendered yet */
.acc-pdfjs-page-placeholder {
  background: #23232a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.acc-pdfjs-render-canvas {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  user-select: none;
}

/* ── Footer bar: page counter + zoom + go-to-page ─────────────── */
.acc-pdfjs-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--bg-elevated, #222);
  border-top: 1px solid var(--border, #2a2a2a);
}

.acc-pdfjs-page-info {
  font-size: 0.76rem;
  color: var(--muted, #94a3b8);
  min-width: 90px;
  text-align: center;
}

.acc-pdfjs-goto {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  color: var(--muted, #94a3b8);
}

.acc-pdfjs-goto input {
  width: 42px;
  padding: 2px 4px;
  background: var(--bg-card, #1a1a21);
  border: 1px solid var(--border, #333);
  border-radius: 4px;
  color: var(--white, #f0f0f0);
  font-size: 0.76rem;
  text-align: center;
}

.acc-pdfjs-zoom {
  display: flex;
  align-items: center;
  gap: 3px;
}

.acc-pdfjs-zoom-btn {
  background: var(--bg-card, #1a1a21);
  border: 1px solid var(--border, #333);
  color: var(--white, #eee);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.acc-pdfjs-zoom-btn:hover { background: var(--bg-elevated, #2a2a35); }

.acc-pdfjs-fit-btn {
  background: var(--bg-card, #1a1a21);
  border: 1px solid var(--border, #333);
  color: var(--white, #eee);
  width: 24px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 2px;
}

.acc-pdfjs-fit-btn:hover { background: var(--bg-elevated, #2a2a35); }

.acc-pdfjs-zoom-value {
  font-size: 0.72rem;
  color: var(--muted, #94a3b8);
  min-width: 36px;
  text-align: center;
}

/* ── legacy stage kept for model/fallback ─────────────────────── */
.acc-preview-pdf-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.acc-preview-pdf-stage[hidden],
.acc-preview-pdf[hidden] {
  display: none !important;
}

.acc-preview-pdf-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border, #2a2a2a);
  background: var(--bg-elevated, #222);
  flex-shrink: 0;
}

.acc-preview-pdf-nav button {
  background: var(--bg-card, #2a2a2a);
  border: 1px solid var(--border, #333);
  color: var(--text-primary, #eee);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.acc-preview-pdf-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

.acc-preview-pdf-page-label {
  font-size: 0.78rem;
  color: var(--text-secondary, #aaa);
  min-width: 140px;
  text-align: center;
}

.acc-preview-pdf-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #111;
}

.acc-preview-pdf-page-inner {
  position: relative;
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  line-height: 0;
}

.acc-preview-pdf-img {
  display: block;
  max-width: 100%;
  height: auto;
  width: auto;
}

.acc-preview-marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.acc-preview-marker {
  position: absolute;
  pointer-events: auto;
  border: 2px solid var(--marker-color, #ef4444);
  background: color-mix(in srgb, var(--marker-color, #ef4444) 22%, transparent);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  animation: marker-pulse 1.6s ease-in-out infinite;
}
/* Draft region box: amber dashed */
.acc-preview-marker.ann-card--draft {
  border-color: #d97706;
  border-style: dashed;
  background: rgba(217, 119, 6, 0.15);
}
/* Accepted region box: solid green */
.acc-preview-marker.ann-card--accepted {
  border-color: #059669;
  border-style: solid;
  background: rgba(5, 150, 105, 0.12);
  animation: none;
}

.acc-preview-marker.active {
  border-width: 3px;
  animation: marker-pulse-active 0.9s ease-in-out infinite;
  z-index: 2;
}
.acc-preview-marker.ann-card--accepted.active { animation: none; }

.acc-preview-marker--page {
  top: 12px;
  right: 12px;
  left: auto;
  width: auto;
  height: auto;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: none;
}

.acc-preview-marker-pin {
  position: absolute;
  top: -10px;
  left: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--marker-color, #ef4444);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.acc-preview-marker-tag {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.acc-preview-pane--marker-focus {
  outline: 2px solid var(--indigo, #6366f1);
  outline-offset: -2px;
}

/* ---------- ACC Issues collapsible panel ---------- */
.acc-preview-main {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.acc-issues-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 32px;
  min-width: 32px;
  border-left: 1px solid var(--border, #2a2a2a);
  background: var(--bg-elevated, #1a1a1a);
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
}

.acc-issues-panel.is-open {
  width: 300px;
  min-width: 260px;
}

.acc-issues-tab {
  flex-shrink: 0;
  width: 32px;
  min-width: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 4px;
  border: none;
  border-right: 1px solid var(--border, #2a2a2a);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted, #888);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.acc-issues-tab:hover {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
}

.acc-issues-tab-icon {
  font-size: 1rem;
  line-height: 1;
}

.acc-issues-tab-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  line-height: 1.2;
}

.acc-issues-panel-inner {
  display: none;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.acc-issues-panel.is-open .acc-issues-panel-inner {
  display: flex;
}

.acc-issues-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #2a2a2a);
  background: var(--bg-surface, #111);
  flex-shrink: 0;
}

.acc-issues-panel-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-issues-panel-collapse {
  background: none;
  border: none;
  color: var(--text-muted, #888);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
  line-height: 1;
  flex-shrink: 0;
}

.acc-issues-panel-collapse:hover { color: var(--text, #fff); }

.acc-issues-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.acc-issues-loading[hidden],
.acc-issues-list-view[hidden],
.acc-issues-detail-view[hidden],
.acc-issues-empty[hidden] {
  display: none !important;
}

.acc-issues-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 16px;
  color: var(--text-muted, #888);
  font-size: 0.82rem;
  text-align: center;
}

.acc-issues-empty {
  padding: 24px 16px;
  color: var(--text-muted, #888);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.5;
}

.acc-issues-list-view {
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.acc-issues-detail-view {
  padding: 0 0 12px;
}

.acc-issues-detail-back {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border, #2a2a2a);
  background: none;
  color: #818cf8;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.acc-issues-detail-back:hover { background: rgba(255, 255, 255, 0.04); }

.acc-issue-detail-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acc-issue-detail-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #888);
}

.acc-issue-detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.acc-issue-detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #888);
}

.acc-issue-detail-value {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text, #fff);
  word-break: break-word;
}

.acc-issue-detail-finding {
  color: var(--text-secondary, #ccc);
}

.acc-issue-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--issue-color, #94a3b8) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--issue-color, #94a3b8) 35%, transparent);
  color: var(--issue-color, #94a3b8);
}

.acc-issue-status-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--issue-color, #94a3b8);
}

.acc-issue-page-link {
  color: #818cf8;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.acc-issue-page-link:hover { text-decoration: underline; }

.acc-issues-group-label {
  padding: 8px 12px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #888);
}

.acc-issue-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border: none;
  border-left: 3px solid var(--issue-color, #94a3b8);
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
  color: var(--text, #fff);
  width: 100%;
}
.acc-issue-row:hover { background: rgba(255,255,255,0.06); }
.acc-issue-row.active { background: rgba(255,255,255,0.10); }

.acc-issue-row-title {
  font-weight: 500;
  font-size: 0.82rem;
  line-height: 1.3;
  word-break: break-word;
}

.acc-issue-row-meta {
  font-size: 0.72rem;
  color: var(--text-muted, #888);
}

/* Issues button in pane header */
.btn-pane-issues {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  color: #818cf8;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-pane-issues:hover:not(:disabled) {
  background: rgba(99,102,241,0.3);
  color: #a5b4fc;
}
.btn-pane-issues.active {
  background: rgba(99,102,241,0.35);
  border-color: rgba(99,102,241,0.55);
  color: #c7d2fe;
}
.btn-pane-issues:disabled {
  opacity: 0.6;
  cursor: default;
}

@keyframes marker-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

@keyframes marker-pulse-active {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--marker-color, #ef4444) 50%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--marker-color, #ef4444) 0%, transparent); }
}

/* ── PDF Annotation toolbar ─────────────────────────────────────────────── */
.acc-ann-toolbar {
  display: flex;
  align-items: center;
  background: #1a1d24;
  border-bottom: 1px solid #2d3148;
  padding: 4px 8px;
  flex-shrink: 0;
  gap: 4px;
  flex-wrap: wrap;
}
.acc-ann-tools {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}
.acc-ann-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #a0aec0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.acc-ann-btn svg {
  width: 16px;
  height: 16px;
}
.acc-ann-btn:hover {
  background: #2d3148;
  color: #e2e8f0;
  border-color: #4a5568;
}
.acc-ann-btn.active {
  background: #3b4a7a;
  color: #90cdf4;
  border-color: #63b3ed;
}
.acc-ann-btn.acc-ann-clear,
.acc-ann-btn.acc-ann-export,
.acc-ann-btn.acc-ann-sync,
.acc-ann-btn.acc-ann-drafts-toggle,
.acc-ann-btn.acc-ann-accept-all,
.acc-ann-btn.acc-ann-reject-all {
  width: auto;
  padding: 0 10px;
  font-size: 11px;
  letter-spacing: 0.02em;
}
/* Draft findings toolbar controls */
.acc-ann-btn.acc-ann-drafts-toggle {
  background: #2d2a1e;
  color: #d69e2e;
  border-color: #744210;
  gap: 5px;
}
.acc-ann-btn.acc-ann-drafts-toggle.acc-ann-drafts-toggle--has-pending {
  background: #744210;
  color: #fefcbf;
  border-color: #d69e2e;
  animation: draft-pulse 2s infinite;
}
@keyframes draft-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214,158,46,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(214,158,46,0); }
}
.acc-ann-drafts-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #d69e2e;
  color: #1a1200;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.acc-ann-btn.acc-ann-accept-all {
  background: #22543d;
  color: #9ae6b4;
  border-color: #276749;
}
.acc-ann-btn.acc-ann-accept-all:hover { background: #276749; color: #fff; }
.acc-ann-btn.acc-ann-reject-all {
  background: #742a2a;
  color: #fed7d7;
  border-color: #c53030;
}
.acc-ann-btn.acc-ann-reject-all:hover { background: #c53030; color: #fff; }
/* Draft card button mini-buttons */
.acc-draft-btn {
  width: 20px; height: 20px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  padding: 0;
}
.acc-draft-btn:hover { opacity: 0.8; }
/* Hide draft layers when user toggles them off */
.acc-drafts-hidden .acc-draft-layer { display: none !important; }
/* Sync to ACC — green */
.acc-ann-btn.acc-ann-sync {
  background: #22543d;
  color: #9ae6b4;
  border-color: #276749;
}
.acc-ann-btn.acc-ann-sync:hover {
  background: #276749;
  color: #fff;
}
/* Download PDF — blue */
.acc-ann-btn.acc-ann-export {
  background: #2c5282;
  color: #bee3f8;
  border-color: #2b6cb0;
}
.acc-ann-btn.acc-ann-export:hover {
  background: #2b6cb0;
  color: #fff;
}
.acc-ann-sep {
  width: 1px;
  height: 20px;
  background: #2d3148;
  margin: 0 4px;
  flex-shrink: 0;
}
.acc-ann-color {
  width: 26px;
  height: 26px;
  border: 1px solid #4a5568;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  padding: 1px;
}
.acc-ann-width {
  height: 26px;
  background: #1a1d24;
  color: #a0aec0;
  border: 1px solid #4a5568;
  border-radius: 5px;
  font-size: 11px;
  padding: 0 4px;
  cursor: pointer;
}

/* Annotation drawing canvas — sits above marker layer, passes events when SELECT */
.acc-ann-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Floating text-input created by the text tool */
.acc-ann-text-input {
  cursor: text;
  border-radius: 3px;
  max-width: 300px;
  word-break: break-word;
}
.acc-ann-text-input:empty::before {
  content: 'Type and press Enter…';
  color: #a0aec0;
  pointer-events: none;
}

/* ── Issue detail popup (shown when clicking an annotation card on the PDF) */
.acc-issue-popup {
  background: #1a1d24;
  border: 1px solid #2d3148;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}
.acc-issue-popup-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--popup-color, #805ad5);
}
.acc-issue-popup-kind {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  flex: 1;
}
.acc-issue-popup-page {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 6px;
  border-radius: 10px;
}
.acc-issue-popup-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.12s;
}
.acc-issue-popup-close:hover { color: #fff; }
.acc-issue-popup-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.acc-issue-popup-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #f7fafc;
  line-height: 1.35;
}
.acc-issue-popup-desc {
  font-size: 11px;
  color: #a0aec0;
  line-height: 1.45;
}
.acc-issue-popup-fix {
  font-size: 11px;
  color: #9ae6b4;
  line-height: 1.45;
  border-left: 2px solid #68d391;
  padding-left: 8px;
}
.acc-issue-popup-fix-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #68d391;
  margin-bottom: 3px;
}
.acc-issue-popup-meta {
  font-size: 10.5px;
  color: #718096;
}
.acc-issue-popup-meta strong { color: #a0aec0; }

/* Action row at the bottom of the popup */
.acc-issue-popup-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
}
.acc-issue-popup-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 10.5px;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.acc-issue-popup-btn:disabled { opacity: 0.6; cursor: default; }
.acc-issue-popup-btn-pdf {
  background: #2d3748;
  color: #e2e8f0;
}
.acc-issue-popup-btn-pdf:hover:not(:disabled) { background: #4a5568; }
.acc-issue-popup-btn-acc {
  background: #553c9a;
  color: #fff;
}
.acc-issue-popup-btn-acc:hover:not(:disabled) { background: #6b46c1; }
.acc-issue-popup-btn-success {
  background: #276749 !important;
  color: #f0fff4 !important;
}

/* Draft / Edit mode buttons */
.acc-issue-popup-btn-edit {
  background: #2d3748;
  color: #e2e8f0;
}
.acc-issue-popup-btn-edit:hover:not(:disabled) { background: #4a5568; }
.acc-issue-popup-btn-accept {
  background: #276749;
  color: #f0fff4;
  font-weight: 700;
}
.acc-issue-popup-btn-accept:hover:not(:disabled) { background: #2f855a; }
.acc-issue-popup-btn-dismiss {
  background: transparent;
  color: #fc8181;
  border: 1px solid #742a2a;
}
.acc-issue-popup-btn-dismiss:hover:not(:disabled) { background: #742a2a; color: #fff; }
.acc-issue-popup-btn-save {
  background: #276749;
  color: #f0fff4;
}
.acc-issue-popup-btn-save:hover:not(:disabled) { background: #2f855a; }
.acc-issue-popup-btn-cancel-edit {
  background: #2d3748;
  color: #a0aec0;
}
.acc-issue-popup-btn-cancel-edit:hover:not(:disabled) { background: #4a5568; }
.acc-issue-popup-btn-back {
  background: #2d3748;
  color: #a0aec0;
  flex: 0 0 auto;
}
.acc-issue-popup-btn-back:hover:not(:disabled) { background: #4a5568; }
.acc-issue-popup-btn-confirm-acc {
  background: #553c9a;
  color: #fff;
  flex: 1;
}
.acc-issue-popup-btn-confirm-acc:hover:not(:disabled) { background: #6b46c1; }

/* Popup status badges in the header */
.acc-issue-popup-status-badge {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
}
.acc-issue-popup-status-draft {
  background: rgba(0,0,0,0.3);
  color: #fef3c7;
}
.acc-issue-popup-status-accepted {
  background: rgba(0,0,0,0.3);
  color: #bbf7d0;
}

/* Edit form fields inside the popup */
.acc-issue-popup-edit-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.acc-issue-popup-edit-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #718096;
}
.acc-issue-popup-input,
.acc-issue-popup-textarea,
.acc-issue-popup-select {
  background: #0d1117;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 11.5px;
  padding: 5px 8px;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit;
}
.acc-issue-popup-input:focus,
.acc-issue-popup-textarea:focus,
.acc-issue-popup-select:focus {
  outline: none;
  border-color: #805ad5;
  box-shadow: 0 0 0 2px rgba(128, 90, 213, 0.25);
}
.acc-issue-popup-select option { background: #1a1d24; }

/* Assign sub-form title */
.acc-issue-popup-assign-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #f7fafc;
  line-height: 1.35;
  padding-bottom: 6px;
  border-bottom: 1px solid #2d3148;
  margin-bottom: 2px;
}

/* ACC issue reference link style */
.acc-issue-popup-acc-ref {
  color: #90cdf4;
  font-weight: 600;
}

/* ── AI Marker annotation styles ─────────────────────────────────────────── */

/* Label chip that sits above a precise-region highlight box */
.acc-preview-marker-label {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 0;
  background: var(--marker-color, #805ad5);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px 3px 3px 0;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Floating annotation card for page-level (no-region) AI markers */
.acc-preview-ann-card {
  position: absolute;
  right: 1%;
  width: 26%;
  background: rgba(255, 255, 255, 0.97);
  border: 2px dashed var(--marker-color, #805ad5);
  border-radius: 6px;
  padding: 7px 10px 8px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 3px 4px 12px rgba(0, 0, 0, 0.28);
  z-index: 6;
  transition: box-shadow 0.15s, transform 0.15s;
}
/* Draft: amber dashed border */
.acc-preview-ann-card.ann-card--draft {
  border-color: #d97706;
  border-style: dashed;
  background: #fffbeb;
}
/* Accepted: solid green border */
.acc-preview-ann-card.ann-card--accepted {
  border-color: #059669;
  border-style: solid;
  background: #f0fff4;
}
.acc-preview-ann-card::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 12px;
  height: 12px;
  background: var(--marker-color, #805ad5);
  border-radius: 4px 0 4px 0;
}
.ann-card--draft::before  { background: #d97706; }
.ann-card--accepted::before { background: #059669; }
.acc-preview-ann-card:hover,
.acc-preview-ann-card.active {
  box-shadow: 2px 4px 16px rgba(0, 0, 0, 0.32);
  transform: translateX(-2px);
}
/* Card header row: kind label + status badge */
.acc-preview-ann-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.acc-preview-ann-card-kind {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--marker-color, #805ad5);
  padding-left: 4px;
}
/* Status badge on the annotation card */
.ann-card-status-badge {
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 8px;
}
.ann-card-status-draft {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #d97706;
}
.ann-card-status-accepted {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #059669;
}
.acc-preview-ann-card-text {
  font-size: 10.5px;
  color: #2d3748;
  line-height: 1.45;
  word-break: break-word;
  font-weight: 500;
  padding-left: 4px;
}

/* Markup button in pane header */
.btn-pane-markup {
  background: rgba(66, 153, 225, 0.12);
  border: 1px solid rgba(66, 153, 225, 0.35);
  color: #63b3ed;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-pane-markup:hover {
  background: rgba(66, 153, 225, 0.25);
  color: #90cdf4;
}
.btn-pane-markup.active {
  background: rgba(66, 153, 225, 0.35);
  border-color: #63b3ed;
  color: #bee3f8;
}

/* Erase cursor ring — positioned by JS on pointermove */
.acc-ann-erase-cursor {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  z-index: 15;
}
