/* assistant01 — design tokens.
   Dark-first: this is an admin panel that gets looked at for long stretches,
   so contrast is tuned for comfort rather than maximum punch. */
:root {
  --bg: #0a0b0f;
  --bg-soft: #0f1117;
  --surface: #14161d;
  --surface-2: #191c25;
  --border: #232733;
  --border-soft: #1c1f28;
  --text: #e7e9ee;
  --muted: #8b93a7;
  --faint: #5b6377;

  --accent: #6366f1;
  --accent-2: #a855f7;
  --accent-soft: rgba(99, 102, 241, 0.14);

  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;

  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.7);
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

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

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- shared bits ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { background: #212633; border-color: #2e3444; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(239, 68, 68, .3); }
.btn-danger:hover { background: rgba(239, 68, 68, .1); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 80px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge-ok { color: var(--ok); border-color: rgba(34, 197, 94, .3); background: rgba(34, 197, 94, .1); }
.badge-warn { color: var(--warn); border-color: rgba(245, 158, 11, .3); background: rgba(245, 158, 11, .1); }
.badge-danger { color: var(--danger); border-color: rgba(239, 68, 68, .3); background: rgba(239, 68, 68, .1); }

.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }

/* ---------- icons ---------- */
.icon { display: block; flex: none; }
.btn .icon { margin-right: -2px; }
.ico { display: inline-flex; align-items: center; justify-content: center; width: 18px; }

/* Destructive actions live apart from the row of routine buttons: a delete
   sitting next to "Copy" gets hit by accident. This one is a small, muted
   corner target that only takes on danger colouring on hover. */
.item-kill {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  /* Dim rather than hidden: fully invisible until hover makes it impossible
     to find, which is the opposite problem to the one being solved. */
  opacity: .3;
  transition: opacity .15s, color .15s, background .15s, border-color .15s;
}
.item:hover .item-kill,
.item-kill:focus-visible { opacity: 1; }
.item-kill:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, .1);
  border-color: rgba(239, 68, 68, .3);
}

/* ---------- landing ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px;
  background: rgba(10, 11, 15, .8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 15px; color: #fff;
}

.hero {
  position: relative;
  padding: 110px 32px 90px;
  text-align: center;
  overflow: hidden;
}
/* Soft radial wash instead of a hard gradient block — keeps the headline
   readable while still giving the page a focal point. */
.hero::before {
  content: '';
  position: absolute; inset: -40% 0 auto;
  height: 600px;
  background: radial-gradient(ellipse 50% 50% at 50% 40%, rgba(99, 102, 241, .18), transparent 70%);
  pointer-events: none;
}
.hero > * { position: relative; }
.hero h1 {
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.08;
  letter-spacing: -.035em;
  font-weight: 800;
  margin-bottom: 20px;
}
.hero h1 .grad {
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p { font-size: clamp(15px, 2vw, 19px); color: var(--muted); max-width: 620px; margin: 0 auto 34px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; margin-bottom: 26px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-size: 13px; color: var(--muted);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.section { max-width: 1120px; margin: 0 auto; padding: 70px 32px; }
.section-head { text-align: center; margin-bottom: 46px; }
.section-head h2 { font-size: clamp(25px, 4vw, 36px); letter-spacing: -.03em; margin-bottom: 12px; font-weight: 700; }
.section-head p { color: var(--muted); }

.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px;
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: #2e3444; transform: translateY(-2px); }
.card-icon {
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--accent-soft); color: #a5b4fc;
  display: grid; place-items: center; margin-bottom: 16px; font-size: 20px;
}
.card h3 { font-size: 17px; margin-bottom: 8px; font-weight: 600; }
.card p { color: var(--muted); font-size: 14px; }

.footer {
  border-top: 1px solid var(--border-soft);
  padding: 30px 32px;
  text-align: center;
  color: var(--faint);
  font-size: 14px;
}

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 23px; margin-bottom: 6px; letter-spacing: -.02em; }
.auth-card > p.muted { margin-bottom: 26px; font-size: 14px; }

.alert {
  padding: 11px 14px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 16px;
  background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .3); color: #fca5a5;
}
.alert-ok { background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .3); color: #86efac; }
.alert-warn { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .3); color: #fcd34d; }
.alert ul { padding-left: 0; }
.alert li { margin: 3px 0; }
.alert[hidden] { display: none; }

/* ---------- dashboard ---------- */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 0 10px 22px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer; font-size: 14.5px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #c7d2fe; border-color: rgba(99,102,241,.25); }
.nav-item .ico { width: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border-soft); padding-top: 14px; }

.main { padding: 30px 34px 60px; max-width: 1240px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 26px; flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; letter-spacing: -.02em; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 3px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
}

/* server / key cards */
.item-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  transition: border-color .18s, transform .18s;
  position: relative;
}
.item:hover { border-color: #333a4d; transform: translateY(-2px); }
/* Right padding keeps the title and badge clear of the corner delete target. */
.item-top { display: flex; align-items: start; justify-content: space-between; gap: 10px; margin-bottom: 14px; padding-right: 34px; }
.item-title { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.item-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid var(--border-soft); }
.item-row:last-of-type { border-bottom: 0; }
.item-row .k { color: var(--faint); }
.item-row .v { text-align: right; word-break: break-all; }
.item-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.empty { text-align: center; padding: 60px 20px; color: var(--faint); }
.empty .big { display: flex; justify-content: center; margin-bottom: 14px; opacity: .35; }

/* modal */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
}
.modal-back[hidden] { display: none; }
.modal {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px;
  box-shadow: var(--shadow);
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 19px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* chat */
/* min-width: 0 on the flexible column stops wide content from expanding the
   grid track and forcing a page-level horizontal scrollbar. */
.chat-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.chat-list { display: flex; flex-direction: column; gap: 8px; }
.chat-entry {
  padding: 11px 13px; border-radius: var(--r-sm); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); font-size: 14px;
}
.chat-entry:hover { border-color: #333a4d; }
.chat-entry.active { background: var(--accent-soft); border-color: rgba(99,102,241,.3); }
.chat-entry small { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }

.chat-box { display: flex; flex-direction: column; height: 66vh; min-width: 0; }
.chat-msgs { flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 14px; padding-right: 6px; min-width: 0; }
/* overflow-wrap: anywhere is the load-bearing rule: a model reply can be a
   megabyte of base64 with no spaces, and break-word alone will not split an
   unbroken token, so it pushed the whole page sideways. */
.msg {
  max-width: 78%;
  padding: 12px 15px;
  border-radius: 14px;
  font-size: 14.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-width: 0;
}
.msg-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 4px 0;
}
.msg-img-link { display: inline-block; margin-top: 6px; font-size: 12px; color: #a5b4fc; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 10px; margin-top: 16px; }
.chat-input textarea { flex: 1; min-height: 46px; max-height: 160px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 11px 20px; border-radius: var(--r-sm); z-index: 200;
  box-shadow: var(--shadow); font-size: 14px;
}
.toast[hidden] { display: none; }

.hint {
  font-size: 13px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 15px; border-radius: var(--r-sm); margin-bottom: 20px;
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--border-soft); padding: 12px;
  }
  .sidebar .logo, .sidebar-foot { display: none; }
  .nav-item { white-space: nowrap; }
  .main { padding: 20px 16px 50px; }
  .chat-layout { grid-template-columns: 1fr; }
  .hero { padding: 70px 20px 60px; }
  .section { padding: 50px 20px; }
  .nav { padding: 14px 18px; }
}
