/* Provn design system.
   Calm and minimal: neutrals plus one accent (periwinkle) and one alert (soft coral).
   Everything shared lives here. See docs/DESIGN.md for the class list. */

/* ---------- Tokens ---------- */
:root {
  /* Neutrals */
  --canvas: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #fafafb;
  --hairline: #e7e9ee;
  --ink: #2b303b;
  --ink-soft: #6a7180;
  --ink-faint: #9aa0ac;           /* placeholders and decoration only, not for essential text */

  /* Accent: calm periwinkle */
  --accent: #5e6ad2;
  --accent-ink: #4f5ac4;          /* accent as text on tinted backgrounds (contrast >= 4.5) */
  --accent-tint: rgba(94, 106, 210, 0.08);
  --accent-tint-2: rgba(94, 106, 210, 0.14);

  /* Alert: soft coral, only for bug found / attack worked / needs attention */
  --alert: #c9635a;
  --alert-ink: #a94a42;           /* alert as text (contrast >= 4.5) */
  --alert-tint: rgba(201, 99, 90, 0.08);
  --alert-tint-2: rgba(201, 99, 90, 0.14);

  /* Type */
  --font: "Urbanist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-12: 0.75rem;
  --fs-13: 0.8125rem;
  --fs-15: 0.9375rem;
  --fs-17: 1.0625rem;
  --fs-22: 1.375rem;
  --fs-28: 1.75rem;

  /* Spacing, 4px grid */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* Radius */
  --r-sm: 10px;
  --r-md: 14px;
  --r-pill: 999px;

  /* Shadow */
  --shadow-1: 0 1px 2px rgba(43, 48, 59, 0.04);
  --shadow-2: 0 1px 2px rgba(43, 48, 59, 0.04), 0 8px 24px -16px rgba(43, 48, 59, 0.12);

  /* Layout */
  --nav-h: 56px;
  --w-chat: 760px;
  --w-page: 760px;
  --sidebar-w: 264px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--fs-15);
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1100px 420px at 12% -140px, rgba(94, 106, 210, 0.16), transparent 70%),
    radial-gradient(900px 380px at 92% 0, rgba(143, 151, 227, 0.14), transparent 70%),
    linear-gradient(180deg, #eef0fb 0%, var(--canvas) 420px, #f2f1fa 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; color: var(--ink); }
h1 { font-size: var(--fs-28); }
h2 { font-size: var(--fs-22); }
h3 { font-size: var(--fs-17); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, pre, kbd { font-family: var(--mono); }
code { font-size: 0.9em; background: var(--surface-soft); border: 1px solid var(--hairline); border-radius: 6px; padding: 1px 6px; }
hr { border: 0; border-top: 1px solid var(--hairline); margin: var(--s-4) 0; }
::selection { background: var(--accent-tint-2); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--s-4); top: -48px; z-index: 100;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-pill);
  padding: var(--s-2) var(--s-4); color: var(--ink);
}
.skip-link:focus { top: var(--s-2); }

/* Utilities */
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: var(--fs-13); }
.xs { font-size: var(--fs-12); }
.strong { font-weight: 600; }
.is-hidden, [hidden] { display: none !important; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-5); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-18 { width: 18px; height: 18px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--nav-h);
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-5);
  background: linear-gradient(90deg, rgba(94, 106, 210, 0.24) 0%, rgba(143, 151, 227, 0.16) 45%, rgba(214, 205, 245, 0.22) 100%),
    var(--surface);
  border-bottom: 1px solid rgba(94, 106, 210, 0.16);
  box-shadow: 0 1px 12px rgba(94, 106, 210, 0.06);
}
.topbar .tab:hover { background: rgba(255, 255, 255, 0.6); }
.topbar .tab[aria-current="page"], .topbar .tab.is-active { background: rgba(255, 255, 255, 0.75); }
.brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-weight: 700; font-size: var(--fs-17); color: var(--ink); letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; display: block; border-radius: 8px; }
.brand-text { letter-spacing: 0.01em; }
.tabs { display: flex; gap: var(--s-1); margin-left: var(--s-4); }
.tab {
  padding: 6px var(--s-4);
  border-radius: var(--r-pill);
  font-size: var(--fs-15); font-weight: 600; color: var(--ink-soft);
  transition: background-color .15s, color .15s;
}
.tab:hover { background: var(--surface-soft); color: var(--ink); text-decoration: none; }
.tab[aria-current="page"], .tab.is-active { background: var(--accent-tint); color: var(--accent-ink); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }

/* ---------- Page container ---------- */
.page {
  width: 100%; max-width: calc(var(--w-page) + 2 * var(--s-5));
  margin: 0 auto; padding: var(--s-6) var(--s-5) var(--s-7);
}
.page-narrow { max-width: calc(var(--w-page) + 2 * var(--s-5)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); }
.page-title { font-size: var(--fs-28); }
.page-sub { margin-top: var(--s-1); color: var(--ink-soft); }
.section { margin-top: var(--s-6); }
.section-title { font-size: var(--fs-17); margin-bottom: var(--s-3); }
.grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-5);
  border: 1px solid transparent; border-radius: var(--r-pill);
  font-size: var(--fs-15); font-weight: 600; line-height: 1; white-space: nowrap;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #5460c4; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--hairline); box-shadow: var(--shadow-1); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-soft); border-color: #dcdfe6; }
.btn-ghost { background: transparent; color: var(--ink-soft); padding: 0 var(--s-3); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-tint); color: var(--accent-ink); }
.btn-sm { min-height: 32px; padding: 0 var(--s-4); font-size: var(--fs-13); }
.btn-lg { min-height: 48px; padding: 0 var(--s-6); font-size: var(--fs-17); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-danger-text { color: var(--alert-ink); }
.btn-ghost.btn-danger-text:hover:not(:disabled) { background: var(--alert-tint); color: var(--alert-ink); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.label { font-size: var(--fs-13); font-weight: 600; color: var(--ink); }
.hint { font-size: var(--fs-13); color: var(--ink-soft); }
.input, .textarea, .select {
  width: 100%; min-height: 40px; padding: 0 var(--s-3);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { padding: var(--s-3); min-height: 96px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none; padding-right: var(--s-6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0ac' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input:hover, .textarea:hover, .select:hover { border-color: #dcdfe6; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint-2); }

/* File attach chip */
.file-chip {
  display: inline-flex; align-items: center; gap: var(--s-2); max-width: 100%;
  min-height: 32px; padding: 0 var(--s-2) 0 var(--s-3);
  background: var(--accent-tint); color: var(--accent-ink);
  border-radius: var(--r-pill); font-size: var(--fs-13); font-weight: 600;
}
.file-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-remove {
  width: 24px; height: 24px; border: 0; border-radius: var(--r-pill);
  display: grid; place-items: center; background: transparent; color: inherit;
}
.file-chip-remove:hover { background: var(--accent-tint-2); }

/* Toggle switch: <label class="switch"><input type="checkbox"><span class="switch-track"></span><span class="switch-text">..</span></label> */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; flex: none; width: 40px; height: 24px; border-radius: var(--r-pill);
  background: var(--hairline); transition: background-color .2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(43, 48, 59, .2); transition: transform .2s var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }

/* Segmented choice (e.g. Student / Professional) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-soft); border: 1px solid var(--hairline); border-radius: var(--r-pill); }
.segmented button, .segmented label {
  min-height: 32px; padding: 0 var(--s-4); border: 0; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; background: transparent; color: var(--ink-soft);
  font-size: var(--fs-13); font-weight: 600; cursor: pointer;
}
.segmented button[aria-pressed="true"], .segmented .is-selected, .segmented input:checked + span {
  background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-1);
}

/* ---------- Badges (states) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px;
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-size: var(--fs-12); font-weight: 600; line-height: 1; white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; stroke-width: 2; }
.badge-new { background: transparent; border-color: var(--hairline); color: var(--ink-soft); }
.badge-safe, .badge-fixed { background: var(--accent-tint); color: var(--accent-ink); }
.badge-attention { background: var(--alert-tint); color: var(--alert-ink); }
.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface-soft); border: 1px solid var(--hairline); font-size: var(--fs-12); font-weight: 600; color: var(--ink-soft); }

/* ---------- Avatars ---------- */
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%; object-fit: cover;
  background: var(--accent-tint); color: var(--accent-ink);
  display: inline-grid; place-items: center; font-size: var(--fs-13); font-weight: 600;
}
.avatar-sm { width: 24px; height: 24px; font-size: var(--fs-12); }
.avatar-md { width: 32px; height: 32px; }
.avatar-lg { width: 48px; height: 48px; font-size: var(--fs-17); }
.avatar-xl { width: 72px; height: 72px; font-size: var(--fs-22); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

/* ---------- Cards, lists, empty state ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: var(--s-5);
}
.card-raised { box-shadow: var(--shadow-2); }
.card-flush { padding: 0; overflow: hidden; }
.card-title { font-size: var(--fs-17); }
.card-sub { margin-top: var(--s-1); color: var(--ink-soft); font-size: var(--fs-13); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }

.list { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  color: inherit; text-decoration: none; background: transparent;
  border: 0; width: 100%; text-align: left;
  transition: background-color .15s;
}
.list-row + .list-row { border-top: 1px solid var(--hairline); }
a.list-row:hover, button.list-row:hover { background: var(--surface-soft); text-decoration: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: var(--fs-13); color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { display: flex; align-items: center; gap: var(--s-3); flex: none; color: var(--ink-soft); }
.icon-tile { width: 32px; height: 32px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-tint); color: var(--accent-ink); }
.icon-tile.is-alert { background: var(--alert-tint); color: var(--alert-ink); }

.empty { text-align: center; padding: var(--s-7) var(--s-5); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.empty .icon-tile { width: 40px; height: 40px; margin-bottom: var(--s-2); }
.empty-title { font-size: var(--fs-17); font-weight: 600; }
.empty-text { color: var(--ink-soft); max-width: 36ch; }
.empty .btn { margin-top: var(--s-3); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: var(--s-5); z-index: 60;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: var(--s-3) var(--s-5);
  background: var(--surface); color: var(--ink); border: 1px solid var(--hairline);
  border-radius: var(--r-pill); box-shadow: var(--shadow-2); font-weight: 600; font-size: var(--fs-13);
  transition: opacity .2s, transform .2s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Skeleton + spinner ---------- */
.skeleton {
  display: block; height: 14px; border-radius: 7px;
  background: linear-gradient(90deg, var(--hairline) 0%, #f0f1f4 50%, var(--hairline) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.skeleton-line-sm { width: 40%; }
.skeleton-line-lg { width: 80%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid var(--accent-tint-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Chat ---------- */
.chat-layout {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: calc(100vh - var(--nav-h)); height: calc(100dvh - var(--nav-h));
}
.chat-sidebar {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4); background: var(--surface); border-right: 1px solid var(--hairline);
  overflow-y: auto;
}
.chat-sidebar-title { padding: 0 var(--s-3); font-size: var(--fs-13); font-weight: 600; color: var(--ink-soft); }
.history { display: flex; flex-direction: column; gap: 2px; }
.history-item {
  display: flex; align-items: center; gap: var(--s-2); width: 100%;
  padding: var(--s-2) var(--s-3); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-soft); text-align: left; text-decoration: none;
  font-size: var(--fs-13); font-weight: 600;
}
.history-item:hover { background: var(--surface-soft); color: var(--ink); text-decoration: none; }
.history-item.is-active, .history-item[aria-current="true"] { background: var(--accent-tint); color: var(--accent-ink); }
.history-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-scroll { flex: 1; overflow-y: auto; padding: var(--s-6) var(--s-5) var(--s-4); scroll-behavior: smooth; }
.thread { max-width: var(--w-chat); margin: 0 auto; display: flex; flex-direction: column; gap: var(--s-5); }

.msg { display: flex; gap: var(--s-3); align-items: flex-start; animation: msg-in .3s var(--ease) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-avatar {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-tint); color: var(--accent-ink);
}
.msg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.msg-body > p, .msg-text { line-height: 1.55; }
.msg-user { justify-content: flex-end; }
.msg-user .msg-bubble {
  max-width: 80%; padding: var(--s-3) var(--s-4);
  background: var(--accent-tint); border: 1px solid var(--accent-tint-2);
  border-radius: var(--r-md); border-bottom-right-radius: 4px;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg-user .file-chip { align-self: flex-end; }

/* Selectable options inside an assistant message (repos, commits) */
.choice-list { display: flex; flex-direction: column; gap: var(--s-2); }
.choice-list.is-scroll { max-height: 336px; overflow-y: auto; padding: 2px; margin: -2px; }
.choice {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: var(--s-3) var(--s-4); text-align: left;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  transition: border-color .15s, background-color .15s;
}
.choice:hover:not(:disabled) { background: var(--surface-soft); border-color: #dcdfe6; }
.choice-main { flex: 1; min-width: 0; }
.choice-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-meta { font-size: var(--fs-13); color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-end { flex: none; display: flex; align-items: center; gap: var(--s-2); color: var(--ink-soft); }
.choice.is-selected, .choice[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent-tint-2); box-shadow: inset 0 0 0 1px var(--accent); }
.choice.is-selected .choice-end, .choice[aria-pressed="true"] .choice-end { color: var(--accent-ink); }
.choice:disabled:not(.is-selected) { opacity: .55; cursor: default; }

.quick-replies { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* Progress lines. Set data-state on .step: waiting | running | done | attack */
.step-list { display: flex; flex-direction: column; gap: var(--s-2); }
.step { display: flex; align-items: center; gap: var(--s-3); color: var(--ink-soft); font-size: var(--fs-15); transition: color .25s; }
.step-icon {
  position: relative; width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--hairline); transition: background-color .25s, border-color .25s;
}
.step[data-state="running"] { color: var(--ink); }
.step[data-state="running"] .step-icon { border-color: var(--accent-tint-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.step[data-state="done"] { color: var(--ink); }
.step[data-state="done"] .step-icon { border-color: transparent; background: var(--accent-tint-2); color: var(--accent-ink); }
.step[data-state="attack"] { color: var(--alert-ink); }
.step[data-state="attack"] .step-icon { border-color: transparent; background: var(--alert-tint-2); color: var(--alert-ink); }
.step[data-state="done"] .step-icon::after, .step[data-state="attack"] .step-icon::after {
  content: ""; position: absolute; inset: 2px; background: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat; mask: var(--glyph) center / contain no-repeat;
}
.step[data-state="done"] .step-icon { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
.step[data-state="attack"] .step-icon { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v8'/%3E%3Cpath d='M12 18.5h.01'/%3E%3C/svg%3E"); }

/* Result: plain sections with hairline dividers */
.result-card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); box-shadow: var(--shadow-2); overflow: hidden; }
.result-section { padding: var(--s-4) var(--s-5); }
.result-section + .result-section { border-top: 1px solid var(--hairline); }
.result-title { margin-bottom: var(--s-1); font-size: var(--fs-13); font-weight: 600; color: var(--ink-soft); }
.result-lede { font-size: var(--fs-17); font-weight: 600; }
.result-status { display: flex; align-items: center; gap: var(--s-3); font-weight: 600; }
.result-status .icon-tile { width: 28px; height: 28px; }
.result-section.is-alert { background: var(--alert-tint); }
.result-section.is-alert .result-title { color: var(--alert-ink); }
.result-section.is-ok { background: var(--accent-tint); }
.result-section.is-ok .result-title { color: var(--accent-ink); }

/* Code diff in a collapsible */
.diff { border: 1px solid var(--hairline); border-radius: var(--r-sm); background: var(--surface-soft); overflow: hidden; }
.diff > summary {
  list-style: none; display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); cursor: pointer; font-size: var(--fs-13); font-weight: 600; color: var(--ink-soft);
}
.diff > summary::-webkit-details-marker { display: none; }
.diff > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.75px solid currentColor; border-bottom: 1.75px solid currentColor; transform: rotate(-45deg); transition: transform .2s; margin: 0 var(--s-1); }
.diff[open] > summary::before { transform: rotate(45deg); }
.diff > summary:hover { color: var(--ink); }
.diff-code {
  margin: 0; padding: var(--s-2) 0; overflow-x: auto; border-top: 1px solid var(--hairline);
  background: var(--surface); font-family: var(--mono); font-size: 12.5px; line-height: 1.6; tab-size: 4;
}
.diff-line { display: block; padding: 0 var(--s-4); white-space: pre; min-width: max-content; }
.diff-line.is-add { background: var(--accent-tint); }
.diff-line.is-del { background: var(--alert-tint); }
.diff-line.is-hunk { color: var(--ink-faint); }

/* Composer: sticky bottom input */
.composer {
  position: sticky; bottom: 0; padding: var(--s-2) var(--s-5) var(--s-4);
  background: linear-gradient(to top, var(--canvas) 70%, rgba(245, 246, 248, 0));
}
.composer-box {
  max-width: var(--w-chat); margin: 0 auto;
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); box-shadow: var(--shadow-2);
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint-2); }
.composer-attachments { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.composer-row { display: flex; align-items: flex-end; gap: var(--s-2); }
.composer-input {
  flex: 1; min-width: 0; min-height: 40px; max-height: 160px; padding: 8px var(--s-1);
  border: 0; outline: none; resize: none; background: transparent; line-height: 1.55;
}
.composer-input::placeholder { color: var(--ink-faint); }
.composer-hint { max-width: var(--w-chat); margin: var(--s-2) auto 0; text-align: center; font-size: var(--fs-12); color: var(--ink-soft); }
.chat-sidebar-toggle { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-sidebar {
    position: fixed; z-index: 30; top: var(--nav-h); bottom: 0; left: 0; width: min(var(--sidebar-w), 86vw);
    transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-2);
  }
  .chat-sidebar.is-open { transform: none; }
  .chat-sidebar-toggle { display: inline-flex; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 var(--s-4); gap: var(--s-2); }
  .brand-text { display: none; }
  .tabs { margin-left: 0; flex: 1; justify-content: center; overflow-x: auto; scrollbar-width: none; }
  .tab { padding: 6px var(--s-3); font-size: var(--fs-13); }
  .topbar-end { margin-left: 0; }
  .topbar-end .avatar { display: none; }
  .page { padding: var(--s-5) var(--s-4) var(--s-6); }
  .thread-scroll { padding: var(--s-5) var(--s-4) var(--s-3); }
  .composer { padding: var(--s-2) var(--s-3) var(--s-3); }
  .list-row { padding: var(--s-3) var(--s-4); }
  .card { padding: var(--s-4); }
  .result-section { padding: var(--s-4); }
  .msg-user .msg-bubble { max-width: 92%; }
  h1, .page-title { font-size: var(--fs-22); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .spinner, .step[data-state="running"] .step-icon { animation: none; border-top-color: var(--accent); }
  .skeleton { animation: none; }
}

/* ---------- Floating assistant (bottom-left) ---------- */
.chat-launcher {
  position: fixed; left: var(--s-5); bottom: var(--s-5); z-index: 60;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 20px -6px rgba(94, 106, 210, 0.6), 0 2px 6px rgba(43, 48, 59, 0.12);
  transition: transform .2s var(--ease), background-color .15s;
}
.chat-launcher:hover { background: #5460c4; transform: translateY(-1px); }
.chat-launcher .icon { width: 24px; height: 24px; stroke-width: 1.9; }
.chat-launcher-close, .chat-launcher.is-open .chat-launcher-open { display: none; }
.chat-launcher.is-open .chat-launcher-close { display: block; }
.chat-panel {
  position: fixed; left: var(--s-5); bottom: calc(var(--s-5) + 56px + var(--s-3)); z-index: 60;
  width: min(420px, calc(100vw - 2 * var(--s-5))); height: min(640px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md);
  box-shadow: 0 24px 60px -20px rgba(43, 48, 59, 0.35), 0 2px 8px rgba(43, 48, 59, 0.08);
  animation: panel-in .22s var(--ease) both;
}
.chat-panel[hidden] { display: none; }
.chat-panel-head {
  display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(90deg, rgba(94, 106, 210, 0.10), rgba(94, 106, 210, 0.02));
}
.chat-panel-mark { width: 20px; height: 20px; display: block; border-radius: 6px; }
.chat-panel-title { font-weight: 700; font-size: var(--fs-15); }
.chat-panel-frame { flex: 1; width: 100%; border: 0; background: var(--canvas); }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 560px) {
  .chat-launcher { left: var(--s-4); bottom: var(--s-4); }
  .chat-panel { left: var(--s-2); right: var(--s-2); width: auto; bottom: calc(var(--s-4) + 56px + var(--s-2)); }
}

/* The chat inside the floating panel: no top bar, full height. */
.is-embed { --nav-h: 0px; background: var(--canvas); }
