:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e6e6e1;
  --text: #141414;
  --muted: #6f6f6a;
  --accent: #111;
  --soft: #f1f1ed;
  --lime: #c8f542;
  --danger: #b42318;
  --ok: #067647;
  --warn: #854d0e;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.05);
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}
.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.gate-card.wide { max-width: 860px; }
.gate-card h1 {
  font-size: 1.5rem;
  margin: 16px 0 14px;
  letter-spacing: -0.03em;
}

.logo-row { display: flex; align-items: center; gap: 10px; }
.logo-row img { border-radius: 9px; display: block; }
.logo-row strong { display: block; font-size: 15px; }
.logo-row span { display: block; font-size: 12px; color: var(--muted); }
.logo-row.compact strong { font-size: 15px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: #bdbdb7;
  box-shadow: 0 0 0 4px rgba(0,0,0,.05);
}
textarea { resize: vertical; min-height: 72px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  min-height: 48px;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.big {
  min-height: 54px;
  padding: 14px 22px;
  font-size: 16px;
  border-radius: 14px;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: #000; }
.btn.ghost { background: transparent; }
.err { color: var(--danger); font-size: 13px; margin: 0; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.two-col h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 0 0 10px;
}
@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
}

.project-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; }
.project-item {
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  min-height: 64px;
}
.project-item:hover { background: #fafafa; border-color: #ccc; }
.project-item strong { display: block; font-size: 15px; }
.project-item span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.app { min-height: 100vh; }
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.project-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  min-height: 40px;
}
.project-pill span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.project-pill strong { font-size: 14px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status { font-size: 12px; color: var(--muted); }

.wizard {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
}
@media (max-width: 900px) {
  .wizard { grid-template-columns: 1fr; }
}

.steps {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  min-height: 42px;
}
.step span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.step.active { color: var(--text); border-color: #111; }
.step.active span { background: var(--lime); }
.step.done span { background: #111; color: #fff; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow);
}
.panel h1 {
  margin: 0 0 14px;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}
#goalInput {
  width: 100%;
  min-height: 150px;
  font-size: 16px;
  margin-bottom: 14px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  min-height: 40px;
}
.chip:hover { color: var(--text); background: var(--soft); }

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.nav-row .btn { min-width: 140px; }

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: #fafaf8;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card ul { margin: 0; padding-left: 18px; }
.card li { margin: 6px 0; font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }
.preview .mock {
  background: #fff;
  border: 1px dashed #d2d2cc;
  border-radius: 12px;
  padding: 18px;
  font-size: 15px;
  white-space: pre-wrap;
  line-height: 1.5;
}
.kv { display: grid; gap: 10px; }
.kv div { display: flex; gap: 12px; font-size: 15px; align-items: flex-start; }
.kv span { color: var(--muted); min-width: 100px; flex-shrink: 0; }

.result-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
}
.result-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--soft);
  display: grid;
  place-items: center;
  font-size: 26px;
  flex-shrink: 0;
}
.result-hero strong { display: block; font-size: 18px; letter-spacing: -0.02em; }
.result-hero .muted { margin: 4px 0 0; }
.result-hero.ok .result-icon { background: #e8f6ee; }
.result-hero.run .result-icon { background: #fff6d6; }
.result-hero.err .result-icon { background: #fde8e6; }

.files {
  display: grid;
  gap: 8px;
}
.file-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  min-height: 52px;
}
.file-link:hover { background: var(--soft); }
.file-link span { font-size: 18px; }

.side h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 0 0 10px;
}
.history { display: flex; flex-direction: column; gap: 8px; }
.hist-item {
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  min-height: 56px;
}
.hist-item:hover { background: #fafafa; }
.hist-item strong { display: block; font-size: 13px; }
.hist-item span { font-size: 11px; color: var(--muted); }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #111;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 50;
  max-width: min(92vw, 440px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

.loader {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--soft);
  margin: 0 4px 4px 0;
}
.badge.ok { background: #e8f6ee; color: var(--ok); }
.badge.run { background: #fff6d6; color: var(--warn); }
.badge.err { background: #fde8e6; color: var(--danger); }


/* ========== Motion ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.panel {
  opacity: 1;
  transform: translateY(0);
  transition: opacity .28s ease, transform .28s ease;
}
.panel.is-leaving {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}
.panel.is-entering {
  opacity: 0;
  transform: translateY(12px);
}
.panel.is-entering.is-in {
  opacity: 1;
  transform: translateY(0);
}

.step {
  transition: border-color .2s ease, color .2s ease, background .2s ease, transform .15s ease;
}
.step:active { transform: scale(0.97); }
.step span { transition: background .2s ease, color .2s ease; }

.btn {
  transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.primary:hover { box-shadow: 0 6px 18px rgba(0,0,0,.18); }

.chip, .project-item, .hist-item, .file-link {
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.chip:active, .project-item:active, .hist-item:active { transform: scale(0.98); }

.toast {
  transition: opacity .25s ease, transform .25s ease;
}

.result-hero {
  transition: background .25s ease, border-color .25s ease;
}
.result-icon {
  transition: transform .35s ease, background .25s ease;
}
.result-hero.ok .result-icon { animation: pop .45s ease; }
@keyframes pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.gate-card {
  animation: gateIn .35s ease;
}
@keyframes gateIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ========== Desktop polish ========== */
@media (min-width: 901px) {
  .wizard {
    max-width: 1120px;
    padding: 28px 28px 72px;
    gap: 24px;
  }
  .panel {
    min-height: 420px;
    display: flex;
    flex-direction: column;
  }
  .nav-row { margin-top: auto; padding-top: 18px; }
  .side {
    position: sticky;
    top: 72px;
    align-self: start;
  }
  .steps {
    justify-content: flex-start;
  }
}

/* ========== Mobile ========== */
@media (max-width: 900px) {
  .top {
    padding: 10px 12px;
    gap: 8px;
  }
  .project-pill span { display: none; }
  .project-pill { max-width: 46vw; }
  .project-pill strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 42vw;
  }
  .top .btn.ghost { padding: 8px 12px; min-height: 40px; font-size: 13px; }

  .wizard {
    display: block;
    padding: 14px 12px 110px; /* room for sticky bottom nav */
  }
  .steps {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .steps::-webkit-scrollbar { display: none; }
  .step {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 12px;
    min-height: 38px;
  }
  .step span { width: 20px; height: 20px; font-size: 11px; }

  .panel {
    padding: 18px 16px 20px;
    border-radius: 16px;
    min-height: auto;
  }
  .panel h1 { font-size: 1.35rem; margin-bottom: 12px; }
  #goalInput { min-height: 130px; font-size: 16px; } /* avoid iOS zoom */

  .nav-row {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    margin: 0;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    gap: 10px;
  }
  .nav-row .btn {
    flex: 1;
    min-width: 0;
    min-height: 52px;
    font-size: 15px;
  }

  .side {
    margin-top: 16px;
    padding-bottom: 8px;
  }
  .side h2 { margin-top: 8px; }

  .gate { padding: 20px 12px; align-items: flex-start; }
  .gate-card { padding: 22px 18px; border-radius: 16px; }
  .gate-card.wide { max-width: 100%; }
  .two-col { gap: 22px; }
  .btn.big { min-height: 52px; width: 100%; }
  .stack .btn.big { width: 100%; }
}

@media (max-width: 420px) {
  .step { padding: 8px 10px; }
  /* show only number on very small if needed — keep short labels */
}


/* ========== Theme toggle ========== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.theme-toggle:hover { background: var(--soft); }
.theme-toggle:active { transform: scale(0.98); }
.theme-toggle.compact {
  padding: 8px 10px;
  min-width: 40px;
  justify-content: center;
}
.theme-ico { font-size: 14px; line-height: 1; }
html[data-theme="light"] .theme-ico-sun { display: none; }
html[data-theme="dark"] .theme-ico-moon { display: none; }
.gate-theme-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.gate-theme-row h1 { margin: 16px 0 14px; }

/* ========== Soft dark mode ========== */
html[data-theme="dark"] {
  --bg: #12141a;
  --surface: #1a1d26;
  --border: #2a2f3a;
  --text: #e8eaef;
  --muted: #9aa3b2;
  --accent: #e8eaef;
  --soft: #222733;
  --lime: #c8f542;
  --danger: #f2a4a0;
  --ok: #6fcf97;
  --warn: #e6c07b;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.28);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: #151821;
  border-color: var(--border);
  color: var(--text);
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
  border-color: #4a5568;
  box-shadow: 0 0 0 4px rgba(200, 245, 66, 0.12);
}
html[data-theme="dark"] .btn {
  background: #222733;
  border-color: var(--border);
  color: var(--text);
}
html[data-theme="dark"] .btn:hover { background: #2a3140; }
html[data-theme="dark"] .btn.primary {
  background: var(--lime);
  color: #0a0b0f;
  border-color: var(--lime);
}
html[data-theme="dark"] .btn.primary:hover {
  background: #d4ff5c;
  box-shadow: 0 6px 18px rgba(200, 245, 66, 0.2);
}
html[data-theme="dark"] .btn.ghost {
  background: transparent;
  color: var(--muted);
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .preview .mock {
  background: #151821;
  border-color: var(--border);
}
html[data-theme="dark"] .project-item,
html[data-theme="dark"] .hist-item,
html[data-theme="dark"] .chip,
html[data-theme="dark"] .step,
html[data-theme="dark"] .project-pill,
html[data-theme="dark"] .file-link {
  background: #151821;
}
html[data-theme="dark"] .project-item:hover,
html[data-theme="dark"] .hist-item:hover,
html[data-theme="dark"] .chip:hover,
html[data-theme="dark"] .file-link:hover {
  background: var(--soft);
}
html[data-theme="dark"] .step.active {
  border-color: var(--lime);
  background: #1f2430;
}
html[data-theme="dark"] .step.active span { background: var(--lime); color: #0a0b0f; }
html[data-theme="dark"] .step.done span { background: #3a4254; color: #fff; }
html[data-theme="dark"] .result-hero { background: #151821; }
html[data-theme="dark"] .result-hero.ok .result-icon { background: #1a2e24; }
html[data-theme="dark"] .result-hero.run .result-icon { background: #2e2a1a; }
html[data-theme="dark"] .result-hero.err .result-icon { background: #2e1c1c; }
html[data-theme="dark"] .toast { background: #e8eaef; color: #12141a; }
html[data-theme="dark"] .toast.error { background: #f2a4a0; color: #2a1010; }
html[data-theme="dark"] .badge { background: var(--soft); color: var(--text); }
html[data-theme="dark"] .badge.ok { background: #1a2e24; color: var(--ok); }
html[data-theme="dark"] .badge.run { background: #2e2a1a; color: var(--warn); }
html[data-theme="dark"] .badge.err { background: #2e1c1c; color: var(--danger); }

@media (max-width: 900px) {
  html[data-theme="dark"] .nav-row {
    background: rgba(18, 20, 26, 0.92);
    border-top-color: var(--border);
  }
}

/* ——— Auth switch / hints ——— */
.auth-switch { margin-top: 16px; text-align: center; }
.linkish {
  background: none; border: none; color: var(--text); font: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0;
}
.hint { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.45; }
.hint.ok-text, .ok-text { color: var(--ok); }
.err { color: var(--danger); font-size: 13px; margin: 0; }
.user-chip {
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; background: var(--soft);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.section-title { margin: 0; font-size: 14px; letter-spacing: -0.02em; }
.soft-hr { border: none; border-top: 1px solid var(--border); margin: 4px 0 8px; }
.two-col.tight { gap: 10px; }
.two-col.tight label { margin: 0; }

/* ——— Modal (profile) ——— */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 10020;
  background: rgba(10, 12, 16, 0.45);
  display: none; align-items: center; justify-content: center;
  padding: 20px 12px;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open, .modal-backdrop:not([hidden]) {
  display: flex;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: min(520px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 8px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-head strong { display: block; font-size: 15px; }
.modal-head .muted { font-size: 12px; color: var(--muted); }
.modal-body { padding: 14px 18px 18px; }
.icon-btn {
  border: none; background: var(--soft); color: var(--text);
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.icon-btn:hover { filter: brightness(0.96); }

/* ——— Admin Grok FAB + panel ——— */
.admin-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10050;
  min-width: 56px;
  height: 56px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid rgba(200, 245, 66, 0.55);
  background: linear-gradient(145deg, #243018, #10140c);
  color: #c8f542;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px rgba(200,245,66,.15);
}
.admin-fab:hover { filter: brightness(1.12); }
.admin-fab.is-admin {
  border-color: #c8f542;
  box-shadow: 0 0 0 2px rgba(200,245,66,.25), 0 10px 30px rgba(0,0,0,.4);
}
.admin-fab[hidden] { display: none !important; }

.admin-grok-panel {
  position: fixed;
  right: 20px;
  bottom: 84px;
  width: min(720px, calc(100vw - 32px));
  height: min(82vh, 820px);
  z-index: 10040;
  display: none;
  flex-direction: column;
  background: linear-gradient(180deg, #10131a 0%, #0b0d12 100%);
  color: #e8eaef;
  border: 1px solid rgba(200, 245, 66, 0.35);
  border-radius: 20px;
  box-shadow: 0 28px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(200,245,66,.12);
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .15s ease, transform .15s ease;
}
.admin-grok-panel[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}
#adminGrokPanel.open,
.admin-grok-panel.open {
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  transform: translateY(0);
}
.admin-grok-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(90deg, rgba(200,245,66,.1), transparent 55%);
}
.admin-grok-head strong { display: block; font-size: 16px; color: #fff; letter-spacing: -0.02em; }
.admin-grok-head .muted { color: rgba(255,255,255,.55); font-size: 12px; }
.admin-grok-actions { display: flex; gap: 6px; align-items: center; }
.admin-grok-actions .btn.ghost {
  background: transparent; color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.15);
  padding: 7px 12px; font-size: 12px;
}
.admin-grok-actions .icon-btn {
  background: rgba(255,255,255,.08); color: #fff;
}
.admin-grok-archives {
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.28);
  max-height: 42%;
  overflow: auto;
  padding: 10px 12px 12px;
}
.admin-grok-archives[hidden] { display: none !important; }
.admin-grok-archives-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.admin-grok-archives-head strong {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
}
.admin-grok-archives-head .linkish {
  color: #c8f542;
  font-size: 12px;
  text-decoration: none;
}
.admin-grok-archives-list { display: flex; flex-direction: column; gap: 6px; }
.g-arch-item {
  text-align: left;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: #e8eaef;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.g-arch-item:hover {
  border-color: rgba(200,245,66,.35);
  background: rgba(200,245,66,.08);
}
.g-arch-item strong {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}
.g-arch-item span {
  font-size: 11px;
  color: rgba(255,255,255,.45);
}

.admin-grok-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.admin-msg {
  max-width: 94%;
  padding: 0;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
  overflow: hidden;
}
.admin-msg.user {
  align-self: flex-end;
  max-width: 78%;
  background: linear-gradient(145deg, rgba(200, 245, 66, 0.18), rgba(200, 245, 66, 0.08));
  border: 1px solid rgba(200, 245, 66, 0.3);
  color: #f3f7e8;
  padding: 12px 14px 14px;
}
.admin-msg.assistant {
  align-self: flex-start;
  max-width: 96%;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 12px 16px 16px;
}
.admin-msg.system {
  align-self: center;
  max-width: 100%;
  background: transparent;
  color: rgba(255,255,255,.55);
  font-size: 12.5px;
  text-align: center;
  border: none;
  padding: 4px 8px;
}
.admin-msg.error {
  align-self: center;
  background: rgba(180, 35, 24, 0.2);
  border: 1px solid rgba(180, 35, 24, 0.45);
  color: #ffb4ae;
  padding: 12px 14px;
}

.g-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.g-meta-user { justify-content: flex-end; margin-bottom: 6px; }
.g-avatar {
  width: 26px; height: 26px; border-radius: 9px;
  display: inline-grid; place-items: center;
  background: linear-gradient(145deg, #c8f542, #8bbf1a);
  color: #10140c; font-size: 13px; font-weight: 800;
  box-shadow: 0 0 0 2px rgba(200,245,66,.2);
}
.g-name {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: rgba(255,255,255,.45);
}
.admin-msg.user .g-name { color: rgba(200,245,66,.7); }
.g-body { color: rgba(236, 240, 248, 0.96); }
.g-body-plain { white-space: pre-wrap; }
.g-body-system { white-space: pre-wrap; opacity: 0.9; }

.g-body .g-p { margin: 0 0 0.7em; }
.g-body .g-p:last-child { margin-bottom: 0; }
.g-body .g-h {
  margin: 0.85em 0 0.4em;
  font-size: 1.05em;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.3;
}
.g-body h2.g-h { font-size: 1.15em; color: #c8f542; }
.g-body h3.g-h { font-size: 1.05em; }
.g-body .g-h:first-child { margin-top: 0; }
.g-body .g-list {
  margin: 0.35em 0 0.75em;
  padding-left: 1.15em;
}
.g-body .g-list li {
  margin: 0.28em 0;
  padding-left: 0.15em;
}
.g-body .g-list li::marker { color: #c8f542; }
.g-body strong { color: #fff; font-weight: 700; }
.g-body em { color: rgba(255,255,255,.88); }
.g-body .g-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: rgba(200,245,66,.12);
  color: #d8f07a;
  padding: 0.1em 0.4em;
  border-radius: 6px;
}
.g-body .g-code {
  margin: 0.55em 0 0.8em;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.08);
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  color: #d7e0f0;
}
.g-body .g-quote {
  margin: 0.5em 0 0.75em;
  padding: 8px 12px;
  border-left: 3px solid #c8f542;
  background: rgba(200,245,66,.06);
  color: rgba(255,255,255,.82);
  border-radius: 0 10px 10px 0;
}
.g-body .g-hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,.12);
  margin: 0.9em 0;
}

.admin-grok-form {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.28);
}
.admin-grok-form textarea {
  flex: 1;
  min-height: 56px;
  max-height: 160px;
  resize: vertical;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.45;
}
.admin-grok-form textarea:focus {
  border-color: rgba(200,245,66,.5);
  box-shadow: 0 0 0 3px rgba(200,245,66,.12);
}
.admin-grok-form .btn.primary {
  align-self: flex-end;
  background: #c8f542;
  color: #10140c;
  border: none;
  font-weight: 700;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
}
.admin-grok-note {
  margin: 0;
  padding: 6px 16px 12px;
  font-size: 11px;
  color: rgba(255,255,255,.42);
}

body.role-member #adminFab,
body.role-member #newProjectSection { display: none !important; }

@media (max-width: 900px) {
  .admin-grok-panel {
    width: min(640px, calc(100vw - 24px));
    height: min(78vh, 740px);
  }
}
@media (max-width: 640px) {
  .admin-grok-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 72px;
    height: min(78vh, 680px);
    border-radius: 16px;
  }
  .admin-msg.user { max-width: 90%; }
  .user-chip { display: none; }
  .top-right .btn.ghost { padding: 8px 10px; }
}
