:root {
  color-scheme: light;
  --canvas: #f6f7fb;
  --canvas-deep: #eef0f8;
  --surface: #ffffff;
  --surface-muted: #f2f3fa;
  --surface-strong: #e6e8f3;
  --ink: #1a1d3a;
  --ink-soft: #3d4166;
  --ink-muted: #6c7192;
  --line: #e1e3ef;
  --line-strong: #c5c9dc;
  --brand: #4f46e5;
  --brand-deep: #3730a3;
  --brand-soft: #e0ddfb;
  --brand-pale: #eeecfd;
  --accent: #dca33a;
  --accent-soft: #f7ebcf;
  --success: #19764f;
  --success-soft: #e0f1e8;
  --danger: #b83a35;
  --danger-soft: #f7e4e1;
  --admin: #a75e12;
  --admin-soft: #f8e6cb;
  --focus: #6366f1;
  --shadow-sm: 0 1px 2px rgba(30, 27, 75, .06);
  --shadow-md: 0 16px 48px rgba(60, 50, 150, .10);
  --shadow-lg: 0 28px 80px rgba(60, 50, 150, .16);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --font-ui: Onest, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "Cascadia Code", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.55 var(--font-ui);
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-deep); }
img, svg { max-width: 100%; }
code, pre { font-family: var(--font-mono); }
code { font-size: .9em; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid #3996dc;
  outline: 3px solid color-mix(in srgb, var(--focus) 68%, transparent);
  outline-offset: 3px;
}
::selection { background: var(--brand-soft); color: var(--brand-deep); }
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Password toggle button */
.password-field .password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field .password-wrapper input {
  flex: 1;
  padding-right: 3rem;
}

.password-field .toggle-password {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem;
  color: var(--text-muted, #6b7280);
  transition: color 0.2s;
  line-height: 1;
}

.password-field .toggle-password:hover {
  color: var(--text-primary, #111827);
}

.password-field .toggle-password:focus-visible {
  outline: 2px solid var(--primary, #4f46e5);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Product shell */
.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 72px;
  padding: 0 clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  background: var(--canvas);
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  backdrop-filter: blur(18px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}
.brand:hover { color: var(--ink); }
.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-block;
  border: 1px solid var(--brand);
  border-radius: 50%;
}
.brand-mark::before,
.brand-mark::after,
.brand-mark i {
  content: "";
  position: absolute;
  display: block;
  border-radius: 50%;
  background: var(--brand);
}
.brand-mark::before { width: 7px; height: 7px; left: 6px; top: 13px; }
.brand-mark::after { width: 7px; height: 7px; right: 6px; top: 7px; }
.brand-mark i:first-child {
  width: 16px; height: 1px; left: 9px; top: 13px;
  border-radius: 0; transform: rotate(-24deg);
}
.brand-mark i:nth-child(2) { width: 7px; height: 7px; right: 6px; bottom: 6px; }
.brand-mark i:nth-child(3) {
  width: 1px; height: 13px; right: 9px; top: 13px;
  border-radius: 0;
}
.brand-copy { display: grid; line-height: 1; }
.brand-copy strong { font-size: 16px; letter-spacing: .02em; }
.brand-copy small {
  margin-top: 5px;
  color: var(--ink-muted);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.header-actions { display: flex; align-items: center; gap: 24px; min-width: 0; }
.primary-nav { display: flex; gap: 6px; }
.primary-nav a {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}
.primary-nav a:hover { color: var(--brand-deep); background: var(--brand-pale); }
.identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-email {
  max-width: 210px;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-form { margin: 0; }
.page-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 80px; }
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin: 18px 0 34px;
}
.page-heading > div { max-width: 760px; }
.page-heading h1 {
  margin: 7px 0 9px;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.03;
  letter-spacing: -.045em;
}
.page-heading p { margin: 0; max-width: 720px; color: var(--ink-soft); font-size: 16px; }
.eyebrow, .section-label {
  color: var(--brand);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.context-role, .server-context, .field-count {
  flex: 0 0 auto;
  padding: 8px 12px;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  font-size: 12px;
}
.context-role strong { color: var(--ink); font-family: var(--font-mono); font-weight: 650; }
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 12px;
}
.breadcrumbs a { color: var(--ink-muted); }

/* Controls */
.btn, button {
  min-height: 44px;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.btn:hover, button:hover { text-decoration: none; }
.btn-primary, button:not([class]) {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  box-shadow: 0 5px 16px rgba(0, 107, 96, .15);
}
.btn-primary:hover, button:not([class]):hover { background: var(--brand-deep); border-color: var(--brand-deep); color: white; }
.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--surface-muted); color: var(--ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-soft); box-shadow: none; }
.btn-quiet:hover { background: var(--surface-muted); color: var(--ink); }
.btn-compact { min-height: 36px; padding: 7px 10px; font-size: 12px; }
.btn-wide { width: 100%; }
button:disabled, .btn[aria-disabled="true"] { opacity: .62; cursor: wait; transform: none; }
.is-loading .btn, .is-loading button { pointer-events: none; }
.loading-spinner {
  width: 15px; height: 15px;
  display: inline-block;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

form.stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.field > label code { color: var(--ink); }
.field .hint { color: var(--ink-muted); font-size: 12px; }
.field-status {
  padding: 2px 7px;
  border-radius: 999px;
  font: 650 9px/1.5 var(--font-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.field-status.required { color: var(--danger); background: var(--danger-soft); }
.field-status.optional { color: var(--ink-muted); background: var(--surface-muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], textarea, select {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(20, 30, 27, .02);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:hover, textarea:hover, select:hover { border-color: #8fa19c; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(8, 127, 221, .18);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}
input::placeholder, textarea::placeholder { color: #89918f; opacity: 1; }
.json-input { tab-size: 2; font-family: var(--font-mono); font-size: 13px; }
.checkbox-row { display: flex; align-items: flex-start; gap: 11px; }
.checkbox-row input {
  width: 20px; height: 20px; margin: 2px 0 0;
  accent-color: var(--brand);
}
.checkbox-row label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; }
.format-hint { padding-left: 11px; border-left: 2px solid var(--brand-soft); }

.alert {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid;
  border-radius: var(--radius-md);
  font-size: 13px;
}
.alert.error { color: #7e2824; background: var(--danger-soft); border-color: #dfaaa5; }
.alert.success { color: #0e5e3d; background: var(--success-soft); border-color: #9bcab2; }

/* Auth */
.auth-page { overflow-x: hidden; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, .82fr) minmax(520px, 1.18fr); }
.auth-panel {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: clamp(32px, 6vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--surface);
}
.auth-brand { position: absolute; top: clamp(28px, 4vw, 54px); left: clamp(32px, 6vw, 88px); }
.auth-heading { max-width: 480px; margin-bottom: 26px; }
.auth-heading h1 {
  margin: 10px 0 12px;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.02;
  letter-spacing: -.05em;
}
.auth-heading p { margin: 0; color: var(--ink-soft); font-size: 15px; }
.auth-form { width: min(100%, 440px); }
.auth-switch { margin: 18px 0 0; color: var(--ink-muted); font-size: 13px; }
.auth-preview {
  position: relative;
  min-height: 100vh;
  padding: clamp(48px, 7vw, 96px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  color: white;
  background:
    radial-gradient(circle at 65% 25%, rgba(216, 164, 58, .16), transparent 29%),
    linear-gradient(145deg, #4f46e5 0%, #3730a3 52%, #1e1b4b 100%);
}
.auth-preview::before {
  content: "";
  position: absolute; inset: 0;
  opacity: .16;
  background-image: linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
}
.auth-preview-copy { position: relative; z-index: 2; max-width: 600px; }
.auth-preview .section-label { color: #c7c8ff; }
.auth-preview h2 { margin: 10px 0 16px; font-size: clamp(36px, 5vw, 68px); line-height: .98; letter-spacing: -.055em; }
.auth-preview p { max-width: 590px; margin: 0; color: #d4d4f5; font-size: 16px; }
.preview-orbit { position: absolute; inset: 12% 8% auto auto; width: min(520px, 76%); aspect-ratio: 1.22; }
.preview-orbit::before, .preview-orbit::after {
  content: ""; position: absolute; border: 1px solid rgba(199, 200, 255, .22); border-radius: 50%;
}
.preview-orbit::before { width: 82%; height: 82%; left: 8%; top: 8%; }
.preview-orbit::after { width: 58%; height: 58%; left: 20%; top: 20%; }
.preview-node {
  position: absolute; z-index: 2;
  min-width: 82px; padding: 9px 12px;
  text-align: center; border: 1px solid rgba(255,255,255,.34);
  border-radius: 999px; color: #e7f6f2;
  background: rgba(0,48,44,.62); backdrop-filter: blur(8px);
  font-size: 11px; letter-spacing: .05em;
}
.node-user { left: 0; top: 45%; }
.node-agent { left: 44%; top: 12%; color: #173d36; background: #e8c475; border-color: #e8c475; font-weight: 800; }
.node-tool { right: 0; bottom: 18%; }
.preview-path { position: absolute; height: 1px; background: rgba(212, 212, 245, .58); transform-origin: left center; }
.path-one { width: 45%; left: 15%; top: 48%; transform: rotate(-30deg); }
.path-two { width: 45%; left: 52%; top: 28%; transform: rotate(43deg); }
.access-diagram {
  position: absolute; top: 19%; left: 14%; right: 14%;
  display: grid; grid-template-columns: 160px 1fr minmax(180px, 250px); align-items: center;
}
.access-role, .access-tools {
  padding: 20px; border: 1px solid rgba(255,255,255,.27); border-radius: 18px; background: rgba(30, 27, 75, .62);
}
.access-role span, .access-tools span { display: block; margin-bottom: 9px; color: #c7c8ff; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.access-role strong { font: 700 22px var(--font-mono); }
.access-tools { display: flex; flex-wrap: wrap; gap: 7px; }
.access-tools span { width: 100%; }
.access-tools b { padding: 6px 9px; border-radius: 999px; background: rgba(230,247,242,.12); font-size: 11px; }
.access-line { height: 1px; background: rgba(255,255,255,.38); }

/* Dashboard */
.dashboard-heading { margin-bottom: 38px; }
.ai-entry {
  position: relative;
  min-height: 285px;
  padding: clamp(28px, 5vw, 54px);
  display: grid;
  grid-template-columns: 100px minmax(300px, 1fr) minmax(240px, .7fr);
  align-items: center;
  gap: clamp(24px, 4vw, 54px);
  overflow: hidden;
  color: white;
  text-decoration: none;
  background: linear-gradient(125deg, #4f46e5, #3730a3 68%, #1e1b4b);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}
.ai-entry::after {
  content: ""; position: absolute; width: 420px; height: 420px; right: -220px; top: -250px;
  border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018);
}
.ai-entry:hover { color: white; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.ai-entry-mark, .empty-agent-mark {
  position: relative; width: 92px; height: 92px; border: 1px solid rgba(225,244,239,.55); border-radius: 50%;
}
.ai-entry-mark span, .ai-entry-mark i, .ai-entry-mark b,
.empty-agent-mark span, .empty-agent-mark i, .empty-agent-mark b {
  position: absolute; width: 13px; height: 13px; border-radius: 50%; background: #efd086;
}
.ai-entry-mark span, .empty-agent-mark span { left: 17px; top: 42px; }
.ai-entry-mark i, .empty-agent-mark i { right: 17px; top: 18px; }
.ai-entry-mark b, .empty-agent-mark b { right: 17px; bottom: 17px; }
.ai-entry-mark::before, .ai-entry-mark::after, .empty-agent-mark::before, .empty-agent-mark::after {
  content: ""; position: absolute; height: 1px; width: 52px; left: 25px; top: 40px; background: rgba(239,208,134,.75); transform: rotate(-28deg);
}
.ai-entry-mark::after, .empty-agent-mark::after { left: 46px; top: 47px; width: 31px; transform: rotate(90deg); }
.ai-entry .section-label { color: #c7c8ff; }
.ai-entry h2 { margin: 8px 0 10px; font-size: clamp(28px, 3.3vw, 45px); line-height: 1.02; letter-spacing: -.04em; }
.ai-entry p { margin: 0; max-width: 610px; color: #d4d4f5; font-size: 15px; }
.text-link { display: inline-flex; gap: 9px; margin-top: 24px; color: white; font-weight: 750; }
.text-link b { color: #efd086; }
.ai-entry-examples { position: relative; z-index: 2; display: grid; gap: 8px; }
.ai-entry-examples span { padding: 11px 13px; color: #d4d4f5; border: 1px solid rgba(30, 27, 75, .3); border-radius: 10px; background: rgba(0,38,35,.3); font-size: 12px; }
.dashboard-section { margin-top: 64px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 20px; }
.section-heading h2 { margin: 5px 0 0; font-size: 26px; line-height: 1.1; letter-spacing: -.025em; }
.section-heading > p { max-width: 500px; margin: 0; color: var(--ink-muted); font-size: 13px; text-align: right; }
.server-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.server-card {
  min-width: 0;
  min-height: 245px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.server-card:hover { color: var(--ink); border-color: #8aa7a0; transform: translateY(-3px); box-shadow: var(--shadow-md); }
.server-card.locked { color: var(--ink-soft); background: var(--surface-muted); border-style: dashed; box-shadow: none; }
.server-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.server-icon {
  width: 44px; height: 44px; display: grid; place-items: center;
  color: var(--brand-deep); background: var(--brand-pale); border: 1px solid #c4ded8; border-radius: 13px;
  font: 700 11px var(--font-mono);
}
.server-icon.knowledge { color: #70500c; background: var(--accent-soft); border-color: #e9cd8f; }
.server-icon.command { color: #7d420b; background: var(--admin-soft); border-color: #dfb87c; }
.availability { color: var(--success); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.server-card h3 { margin: 24px 0 8px; font-size: 19px; letter-spacing: -.02em; }
.server-card p { margin: 0 0 20px; color: var(--ink-muted); font-size: 13px; }
.server-card-action { margin-top: auto; color: var(--brand); font-size: 12px; font-weight: 750; }
.server-card.locked .server-card-action { color: var(--admin); }
.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  color: var(--brand-deep);
  background: var(--brand-soft);
  border: 1px solid #acd3ca;
  border-radius: 999px;
  font: 700 10px var(--font-mono);
  letter-spacing: .04em;
}
.role-badge.admin { color: #7b4109; background: var(--admin-soft); border-color: #deba82; }

/* Tools and forms */
.tools-catalog { margin-top: 44px; }
.catalog-heading h2 small { color: var(--ink-muted); font: 600 12px var(--font-mono); vertical-align: middle; }
.search-field { position: relative; width: min(330px, 100%); }
.search-field input { padding-left: 38px; background: var(--surface); }
.search-field i::before {
  content: ""; position: absolute; left: 14px; top: 14px; width: 11px; height: 11px;
  border: 1.5px solid var(--ink-muted); border-radius: 50%;
}
.search-field i::after {
  content: ""; position: absolute; left: 25px; top: 26px; width: 6px; height: 1.5px;
  background: var(--ink-muted); transform: rotate(45deg);
}
.tool-list { display: grid; gap: 9px; }
.tool-item {
  min-height: 96px;
  padding: 17px 18px;
  display: grid;
  grid-template-columns: 46px 1fr 32px;
  align-items: center;
  gap: 16px;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.tool-item:hover { color: var(--ink); border-color: #8aa7a0; transform: translateX(2px); }
.tool-item-icon { position: relative; width: 42px; height: 42px; border: 1px solid #bfdad4; border-radius: 50%; background: var(--brand-pale); }
.tool-item-icon span, .tool-item-icon i {
  position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--brand);
}
.tool-item-icon span { left: 9px; top: 17px; }
.tool-item-icon i { right: 9px; top: 10px; box-shadow: 0 15px 0 var(--brand); }
.tool-item-icon::before, .tool-item-icon::after {
  content: ""; position: absolute; height: 1px; background: var(--brand); transform-origin: left center;
}
.tool-item-icon::before { width: 18px; left: 14px; top: 20px; transform: rotate(-22deg); }
.tool-item-icon::after { width: 15px; left: 29px; top: 14px; transform: rotate(90deg); }
.tool-item-copy { min-width: 0; }
.tool-item code { color: var(--brand-deep); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.tool-item p { margin: 5px 0 0; color: var(--ink-muted); font-size: 12px; }
.tool-item-arrow { color: var(--brand); font-size: 18px; text-align: center; }
.empty-panel {
  grid-column: 1 / -1;
  padding: 34px;
  text-align: center;
  background: var(--surface-muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}
.empty-panel h3 { margin: 0 0 5px; }
.empty-panel p { margin: 0; color: var(--ink-muted); font-size: 13px; }
.admin-warning {
  margin: 24px 0 32px;
  padding: 16px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 14px;
  color: #71400d;
  background: var(--admin-soft);
  border: 1px solid #deb878;
  border-radius: var(--radius-md);
}
.warning-symbol {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid #bf7a2e; border-radius: 50%; font-weight: 800;
}
.admin-warning strong { display: block; }
.admin-warning p { margin: 2px 0 0; font-size: 12px; }
.tool-heading h1 code { font-size: .82em; color: var(--brand-deep); overflow-wrap: anywhere; }
.form-panel {
  max-width: 900px;
  margin-top: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.form-panel-header { padding: 24px 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.form-panel-header h2 { margin: 5px 0 0; font-size: 22px; }
.dynamic-fields { padding: 28px; display: grid; gap: 25px; }
.dynamic-fields .field + .field { padding-top: 24px; border-top: 1px solid var(--line); }
.form-actions {
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface-muted);
  border-top: 1px solid var(--line);
}
.execution-note { max-width: 560px; display: flex; align-items: flex-start; gap: 10px; color: var(--ink-muted); font-size: 11px; }
.execution-note > span { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.execution-note p { margin: 0; }
.no-parameters { padding: 34px 28px; display: flex; align-items: center; gap: 16px; }
.no-parameters-mark { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; color: var(--success); background: var(--success-soft); border-radius: 50%; }
.no-parameters h3 { margin: 0 0 4px; }
.no-parameters p { margin: 0; color: var(--ink-muted); font-size: 13px; }

/* Result */
.result-page { max-width: 1180px; }
.result-heading { margin: 34px 0 28px; display: flex; align-items: center; gap: 18px; }
.result-heading h1 { margin: 4px 0 0; font-size: clamp(29px, 4vw, 44px); line-height: 1.1; letter-spacing: -.035em; }
.result-heading h1 code { color: var(--brand-deep); font-size: .72em; overflow-wrap: anywhere; }
.result-symbol { width: 52px; height: 52px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; font-size: 22px; font-weight: 800; }
.result-symbol.success { color: var(--success); background: var(--success-soft); border: 1px solid #9bcab2; }
.result-symbol.error { color: var(--danger); background: var(--danger-soft); border: 1px solid #dfaaa5; }
.output-panel { margin-top: 24px; overflow: hidden; background: #12201e; border: 1px solid #30443f; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.output-toolbar, .code-toolbar {
  min-height: 48px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #b9cbc7;
  background: #1a2b28;
  border-bottom: 1px solid #30443f;
  font-size: 11px;
}
.output-toolbar > div { display: flex; align-items: center; gap: 9px; }
.output-status { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.output-status.error { background: #e4675e; }
pre.output, .output-panel .empty-output {
  min-height: 170px;
  max-height: 62vh;
  margin: 0;
  padding: 20px;
  overflow: auto;
  color: #deebe8;
  background: #12201e;
  font-size: 12.5px;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.output-panel .empty-output { color: #91a7a2; }
.copy-button {
  min-height: 30px;
  padding: 5px 9px;
  color: inherit;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 7px;
  box-shadow: none;
  font-size: 10px;
  font-weight: 700;
}
.copy-button:hover { color: white; background: rgba(255,255,255,.08); }
.copy-button.copied { color: #9adcb8; border-color: #51866c; }
.result-retention-note { margin: 12px 3px 0; color: var(--ink-muted); font-size: 11px; }
.result-actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; }

/* Chat */
.chat-main { width: min(1340px, calc(100% - 40px)); padding-top: 24px; }
.chat-layout { margin-top: 17px; display: grid; grid-template-columns: 242px minmax(0, 1fr); gap: 14px; align-items: start; }
.chat-layout.has-active { height: calc(100vh - 145px); min-height: 520px; }
.chat-sidebar {
  height: 100%;
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; color: var(--ink-soft); font-size: 12px; font-weight: 750; }
.sidebar-heading small { min-width: 22px; padding: 2px 5px; text-align: center; color: var(--ink-muted); background: var(--surface-muted); border-radius: 999px; }
.chat-session-list { min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.chat-session-item {
  display: block;
  min-height: 39px;
  padding: 9px 10px;
  overflow: hidden;
  color: var(--ink-muted);
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-session-item:hover { color: var(--ink); background: var(--surface-muted); }
.chat-session-item.active { color: var(--brand-deep); background: var(--brand-pale); border-color: #c5ddd7; font-weight: 700; }
.sidebar-empty { padding: 8px; color: var(--ink-muted); font-size: 11px; }
.chat-pane {
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.conversation-header { min-height: 66px; padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.conversation-header > div { min-width: 0; }
.conversation-kicker { color: var(--brand); font-size: 9px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.conversation-header h1 { margin: 2px 0 0; overflow: hidden; font-size: 15px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.chat-messages {
  flex: 1;
  min-height: 0;
  padding: 26px clamp(18px, 4vw, 52px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overscroll-behavior: contain;
}
.msg { width: min(850px, 100%); display: flex; flex-direction: column; gap: 7px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant, .msg.tool { align-self: flex-start; align-items: flex-start; }
.message-author { padding: 0 3px; color: var(--ink-muted); font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.msg .bubble {
  max-width: min(760px, 88%);
  padding: 12px 15px;
  color: var(--ink);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 5px 16px 16px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.user .bubble { color: white; background: var(--brand); border-color: var(--brand); border-radius: 16px 5px 16px 16px; }
.tool-event { width: min(760px, 94%); border: 1px solid #bedad3; border-radius: var(--radius-md); background: var(--brand-pale); overflow: hidden; }
.tool-event summary {
  min-height: 48px;
  padding: 10px 13px;
  display: grid;
  grid-template-columns: 20px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  list-style: none;
}
.tool-event summary::-webkit-details-marker { display: none; }
.tool-event-node { position: relative; width: 18px; height: 18px; border: 1px solid var(--brand); border-radius: 50%; }
.tool-event-node::before, .tool-event-node::after { content: ""; position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--brand); }
.tool-event-node::before { left: 3px; top: 6px; }
.tool-event-node::after { right: 3px; top: 3px; box-shadow: 0 7px 0 var(--brand); }
.tool-event-label { color: var(--ink-muted); font-size: 10px; }
.tool-event summary code { min-width: 0; overflow: hidden; color: var(--brand-deep); font-size: 11px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.tool-event-toggle { color: var(--brand); font-size: 10px; font-weight: 700; }
.tool-event-toggle::after { content: " ↓"; }
.tool-event[open] .tool-event-toggle::after { content: " ↑"; }
.tool-event-body { border-top: 1px solid #bedad3; }
.tool-event-body pre, .tool-result-card pre {
  max-height: 310px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: #dae9e6;
  background: #132421;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tool-result-card { width: min(760px, 94%); overflow: hidden; border: 1px solid #b9cbc6; border-radius: var(--radius-md); background: var(--surface-muted); }
.tool-result-card > header { min-height: 44px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--ink-soft); background: var(--surface-muted); font-size: 10px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.tool-result-card > header > span { display: flex; align-items: center; gap: 8px; }
.tool-result-card > header i { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: var(--success); }
.tool-result-card .copy-button { color: var(--ink-muted); }
.chat-input { padding: 13px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: flex-end; gap: 10px; background: var(--surface-muted); border-top: 1px solid var(--line); }
.chat-composer { overflow: hidden; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; }
.chat-composer:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(8, 127, 221, .18);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}
.chat-composer textarea { min-height: 55px; max-height: 180px; padding: 12px; border: 0; border-radius: 0; box-shadow: none; resize: vertical; }
.chat-composer textarea:focus { box-shadow: none; }
.composer-meta { padding: 0 12px 9px; display: flex; justify-content: space-between; gap: 18px; color: var(--ink-muted); font-size: 9px; }
.chat-submit { min-width: 116px; height: 55px; }
.chat-submit b { width: 20px; height: 20px; display: grid; place-items: center; color: var(--brand-deep); background: white; border-radius: 50%; }
.chat-pane-empty { min-height: 600px; align-items: center; justify-content: center; padding: 48px; background: radial-gradient(circle at 50% 18%, var(--brand-pale), transparent 34%), var(--surface); }
.chat-empty-state { width: min(790px, 100%); text-align: center; }
.empty-agent-mark { width: 74px; height: 74px; margin: 0 auto 25px; border-color: #78aaa0; }
.empty-agent-mark span, .empty-agent-mark i, .empty-agent-mark b { width: 10px; height: 10px; background: var(--brand); }
.empty-agent-mark span { left: 14px; top: 34px; }.empty-agent-mark i { right: 14px; top: 14px; }.empty-agent-mark b { right: 14px; bottom: 14px; }
.empty-agent-mark::before { left: 20px; top: 33px; width: 43px; background: var(--brand); }
.empty-agent-mark::after { left: 37px; top: 38px; width: 25px; background: var(--brand); }
.chat-empty-state h1 { margin: 9px 0 13px; font-size: clamp(32px, 5vw, 52px); line-height: 1.03; letter-spacing: -.05em; }
.chat-empty-state > p { max-width: 600px; margin: 0 auto 23px; color: var(--ink-soft); }
.prompt-examples { margin-top: 36px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; text-align: left; }
.prompt-examples div { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.prompt-examples span { color: var(--brand); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.prompt-examples p { margin: 7px 0 0; color: var(--ink-soft); font-size: 11px; }
.conversation-empty { margin: auto; text-align: center; }
.conversation-empty h2 { margin: 0 0 5px; }
.conversation-empty p { margin: 0; color: var(--ink-muted); }
.mobile-session-drawer { display: none; }

.chat-messages .bubble p {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.chat-messages .bubble p:first-child {
  margin-top: 0;
}

.chat-messages .bubble p:last-child {
  margin-bottom: 0;
}

/* Error pages */
.error-page { min-height: calc(100vh - 72px); display: grid; place-items: center; }
.error-panel { width: min(670px, 100%); padding: clamp(30px, 6vw, 70px); text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); }
.error-code { margin-bottom: 25px; color: var(--canvas-deep); font-size: clamp(84px, 17vw, 150px); font-weight: 800; line-height: .72; letter-spacing: -.09em; text-shadow: -1px 0 var(--line-strong), 0 1px var(--line-strong), 1px 0 var(--line-strong), 0 -1px var(--line-strong); }
.error-panel h1 { margin: 8px 0 12px; font-size: clamp(28px, 5vw, 45px); line-height: 1.05; letter-spacing: -.045em; }
.error-panel p { max-width: 510px; margin: 0 auto; color: var(--ink-soft); }
.error-actions { margin-top: 28px; }

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

/* Tablet */
@media (max-width: 1024px) {
  .app-header { padding-inline: 24px; }
  .header-actions { gap: 12px; }
  .user-email { display: none; }
  .ai-entry { grid-template-columns: 76px 1fr; }
  .ai-entry-examples { grid-column: 2; grid-template-columns: repeat(3, 1fr); }
  .server-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-shell { grid-template-columns: minmax(390px, .95fr) 1.05fr; }
  .auth-preview { padding: 48px; }
  .auth-preview h2 { font-size: 44px; }
  .chat-layout { grid-template-columns: 220px minmax(0, 1fr); }
}

@media (max-width: 768px) {
  .app-header { min-height: 64px; }
  .primary-nav { display: none; }
  .page-shell { width: min(100% - 32px, 1180px); padding-top: 30px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 16px; }
  .page-heading h1 { font-size: 38px; }
  .context-role, .server-context { align-self: flex-start; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .section-heading > p { text-align: left; }
  .auth-shell { display: block; }
  .auth-panel { min-height: 100vh; padding: 128px 40px 56px; }
  .auth-brand { left: 40px; }
  .auth-preview { display: none; }
  .ai-entry { padding: 32px; grid-template-columns: 62px 1fr; border-radius: 24px; }
  .ai-entry-mark { width: 62px; height: 62px; }
  .ai-entry-mark span { left: 11px; top: 28px; }.ai-entry-mark i { right: 11px; top: 11px; }.ai-entry-mark b { right: 11px; bottom: 11px; }
  .ai-entry-mark::before { left: 17px; top: 28px; width: 36px; }.ai-entry-mark::after { left: 31px; top: 32px; width: 21px; }
  .ai-entry-examples { grid-column: 1 / -1; }
  .server-grid { grid-template-columns: 1fr 1fr; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .chat-main { width: min(100% - 24px, 1340px); }
  .chat-layout, .chat-layout.has-active { height: calc(100vh - 154px); min-height: 540px; grid-template-columns: 1fr; }
  .chat-sidebar { display: none; }
  .mobile-session-drawer {
    display: block;
    margin-top: 13px;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  .mobile-session-drawer summary { min-height: 44px; padding: 9px 13px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 700; list-style: none; }
  .mobile-session-drawer summary::-webkit-details-marker { display: none; }
  .mobile-session-drawer summary span { min-width: 24px; padding: 2px 6px; text-align: center; color: var(--ink-muted); background: var(--surface-muted); border-radius: 999px; font-size: 11px; }
  .mobile-session-content { padding: 0 10px 10px; }
  .mobile-session-content .chat-session-list { max-height: 210px; margin-top: 9px; }
  .chat-layout { margin-top: 10px; }
  .prompt-examples { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .app-header { padding: 0 14px; gap: 10px; }
  .brand-copy small { display: none; }
  .identity { display: none; }
  .header-actions { margin-left: auto; }
  .logout-form .btn { min-height: 38px; }
  .page-shell { width: min(100% - 24px, 1180px); padding-bottom: 48px; }
  .page-heading h1 { font-size: 33px; }
  .page-heading p { font-size: 14px; }
  .auth-panel { padding: 116px 22px 44px; }
  .auth-brand { left: 22px; top: 28px; }
  .auth-heading h1 { font-size: 37px; }
  .ai-entry { min-height: 0; grid-template-columns: 1fr; gap: 20px; padding: 25px; }
  .ai-entry-mark { width: 58px; height: 58px; }
  .ai-entry-copy h2 { font-size: 31px; }
  .ai-entry-examples { display: none; }
  .dashboard-section { margin-top: 44px; }
  .server-grid { grid-template-columns: 1fr; }
  .server-card { min-height: 215px; }
  .catalog-heading .search-field { width: 100%; }
  .tool-item { grid-template-columns: 38px minmax(0, 1fr) 20px; gap: 11px; padding: 14px 12px; }
  .tool-item-icon { width: 36px; height: 36px; }
  .tool-item-icon span { left: 7px; top: 14px; }.tool-item-icon i { right: 7px; top: 8px; }
  .tool-item-icon::before { left: 11px; top: 17px; width: 16px; transform: rotate(-22deg); }.tool-item-icon::after { left: 25px; top: 12px; width: 15px; transform: rotate(90deg); }
  .admin-warning { grid-template-columns: 32px 1fr; }
  .admin-warning .role-badge { grid-column: 2; justify-self: start; }
  .form-panel-header, .dynamic-fields, .form-actions, .no-parameters { padding-left: 17px; padding-right: 17px; }
  .form-panel-header { align-items: flex-start; }
  .field-count { display: none; }
  .result-heading { align-items: flex-start; }
  .result-symbol { width: 42px; height: 42px; }
  .result-actions { flex-direction: column; }
  .result-actions .btn { width: 100%; }
  .chat-main { width: 100%; padding: 16px 10px 0; }
  .chat-main > .breadcrumbs { padding: 0 2px; }
  .chat-layout, .chat-layout.has-active { height: calc(100dvh - 139px); min-height: 500px; }
  .chat-pane { border-radius: 15px 15px 0 0; }
  .chat-messages { padding: 20px 13px; gap: 20px; }
  .msg .bubble, .tool-event, .tool-result-card { max-width: 96%; }
  .tool-event summary { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .tool-event-label { display: none; }
  .conversation-header { min-height: 58px; padding: 9px 13px; }
  .chat-input { padding: 8px; grid-template-columns: minmax(0, 1fr) 48px; gap: 7px; }
  .composer-meta span:first-child { display: none; }
  .chat-submit { min-width: 48px; width: 48px; padding: 0; }
  .chat-submit > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .chat-submit b { color: white; background: transparent; font-size: 18px; }
  .chat-pane-empty { min-height: 560px; padding: 32px 18px; }
  .chat-empty-state h1 { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .app-header, .breadcrumbs, .result-actions, .copy-button { display: none !important; }
  body { background: white; }
  .page-shell { width: 100%; padding: 0; }
  .output-panel { box-shadow: none; }
  pre.output { max-height: none; overflow: visible; }
}

/*  Стили для кнопки удаления чатов */
.chat-session-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.chat-session-row .chat-session-item {
  flex: 1;
  min-width: 0;
}
.delete-session-form {
  margin: 0;
  flex-shrink: 0;
}
.delete-session-btn {
  background: transparent;
  border: none;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1;
}
.delete-session-btn:hover {
  background: rgba(255, 123, 114, 0.15);
  color: #ff7b72;
}

