/* ════════════════════════════════════════════════════════════════
   opusfund — port of /Users/nuxos/Downloads/index.html design
   ════════════════════════════════════════════════════════════════ */

:root {
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: Inter, ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Roboto Mono", ui-monospace, monospace;

  --periwinkle: #8b9dff;
  --mint-up: #6ee7b7;
  --coral-down: #fca5a5;
  --amber-hold: #fcd34d;
  --gold-payout: #d9a441;

  --color-primary-500: #8b9dff;
  --color-neutral-300: #888888;
  --color-bg-500: #141414;
  --color-bg-900: #050505;
  --color-foreground-200: #ededed;
  --color-foreground-500: #c4c4c4;
  --color-success-400: #6ee7b7;
  --color-warning-400: #fcd34d;
  --color-danger-300: #fca5a5;

  --color-ivory: #ededed;
  --color-input: #1a1a1a;
  --color-hairline: #2a2a2a;
  --color-vault-3: #1a1a1a;

  --color-background: #0a0a0a;
  --color-surface: #0f0f0f;
  --color-surface-raised: #141414;
  --color-border: #2a2a2a;
  --color-foreground: #ededed;
  --color-text-secondary: #c4c4c4;
  --color-text-muted: #888888;
  --color-primary: #8b9dff;
  --color-sentiment-up: #6ee7b7;
  --color-sentiment-hold: #fcd34d;
  --color-sentiment-down: #fca5a5;

  --text-hero: 3.25rem;
  --text-hero--line-height: 3.5rem;
  --text-hero--letter-spacing: -0.025em;
  --text-body-sm: 0.875rem;
  --text-body-sm--line-height: 1.375rem;
  --text-caption: 0.75rem;
  --text-caption--line-height: 1.125rem;
  --text-micro: 0.6875rem;
  --text-micro--line-height: 1rem;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;

  --shadow-focus: 0 0 0 3px rgb(139 157 255 / 0.28);

  --spacing-2: 0.5rem;
  --spacing-3: 0.75rem;
  --spacing-4: 1rem;
  --spacing-6: 1.5rem;
  --spacing-8: 2rem;
  --spacing-12: 3rem;

  --page-padding-mobile: 1.25rem;
  --page-padding-desktop: 2.5rem;

  --color-success-bg-opacity: rgba(110, 231, 183, 0.1);
  --color-warning-bg-opacity: rgba(252, 211, 77, 0.1);
  --color-danger-bg-opacity: rgba(252, 165, 165, 0.1);
  --color-info-bg-opacity: rgba(139, 157, 255, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-body);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--color-background);
  color: var(--color-foreground);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  color: inherit;
}

input,
select,
textarea {
  font: inherit;
}

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

p {
  font-weight: 300;
}

a,
button,
input,
label {
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
label:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ── brand ────────────────────────────────────────────────────── */
.brand {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.25;
  color: var(--color-foreground);
}

.brand .ac {
  color: var(--color-sentiment-up);
}

/* ── step shell ───────────────────────────────────────────────── */
.step-shell {
  min-height: 100svh;
  display: grid;
  grid-template-rows: 75px 1fr;
  background: var(--color-background);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-6) var(--page-padding-mobile);
}

@media (min-width: 768px) {
  .topbar {
    padding-inline: var(--page-padding-desktop);
  }
}

/* ── progress ─────────────────────────────────────────────────── */
.progress {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 120px;
  height: 2px;
}

.progress-segment {
  height: 2px;
  width: 18px;
  border-radius: var(--radius-full);
  background: var(--color-foreground-500);
  opacity: 0.9;
  transition: width .2s, background-color .2s;
}

.progress-segment.is-active {
  width: 32px;
  background: var(--color-primary);
  opacity: 1;
}

@media (max-width: 720px) {
  .progress {
    width: auto;
  }
}

/* ── step area + card ─────────────────────────────────────────── */
.step-area {
  display: flex;
  justify-content: center;
  padding: 3.5rem var(--page-padding-mobile) 5rem;
}

@media (min-width: 768px) {
  .step-area {
    padding-inline: var(--page-padding-desktop);
  }
}

.step-area.pt-12 {
  padding-top: var(--spacing-12);
}

.card {
  width: min(620px, 100%);
  animation: fade-up .4s cubic-bezier(.4, 0, .2, 1);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .card {
    width: 100%;
  }
}

@media (max-width: 820px) {
  .step-shell {
    grid-template-rows: 70px 1fr;
  }

  .step-area {
    padding: 3rem clamp(1.25rem, 4vw, 2rem) 5rem;
  }

  .step-area.pt-12 {
    padding-top: 3rem;
  }

  .card {
    width: min(100%, 704px);
  }
}

/* ── step kicker + headings ───────────────────────────────────── */
.step-kicker {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.375rem;
}

.step-number {
  color: var(--color-primary);
}

.hero-title {
  max-width: 620px;
  margin: var(--spacing-2) 0 0;
  color: var(--color-foreground);
  font-family: var(--font-display);
  font-size: clamp(2.7rem, 11vw, var(--text-hero));
  font-style: italic;
  font-weight: 500;
  letter-spacing: var(--text-hero--letter-spacing);
  line-height: 0.98;
}

.lead {
  max-width: 620px;
  margin: var(--spacing-2) 0 0;
  color: var(--color-text-secondary);
  font-size: var(--text-body-sm);
  line-height: var(--text-body-sm--line-height);
}

.is-accent {
  color: var(--color-primary);
}

/* ── actions / buttons ────────────────────────────────────────── */
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-4);
  min-height: 48px;
  margin-top: var(--spacing-8);
}

.actions.justify-end {
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  min-width: 91px;
  min-height: 40px;
  border-radius: var(--radius-md);
  padding: 0.6875rem 1.125rem;
  border: 1px solid transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.125rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled,
.btn.disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.btn:disabled:hover,
.btn.disabled:hover {
  transform: none;
}

.btn-primary {
  min-width: 146px;
  background: var(--color-primary);
  color: var(--color-background);
}

.btn-primary:hover {
  background: #9aa9ff;
}

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-foreground);
}

.btn-secondary:hover {
  background: #1a1a1a;
}

.btn.min-w-48 {
  min-width: 12rem;
}

.btn-block {
  width: 100%;
  min-height: 44px;
}

@media (max-width: 720px) {
  .actions {
    align-items: stretch;
  }

  .btn {
    flex: 1 1 auto;
  }
}

/* ── auth screens ─────────────────────────────────────────────── */
.auth-area {
  align-items: flex-start;
  padding-top: 3.5rem;
  padding-bottom: 5rem;
}

.auth-card {
  width: min(458px, 100%);
  overflow: hidden;
}

.auth-title {
  width: 100%;
  margin-top: var(--spacing-2);
  font-size: 3.25rem;
  line-height: 3.5rem;
  letter-spacing: 0;
}

.auth-lead {
  width: 100%;
  max-width: 458px;
}

.auth-form {
  display: grid;
  gap: var(--spacing-8);
  margin-top: var(--spacing-8);
}

.auth-fields {
  display: grid;
  gap: var(--spacing-4);
}

.auth-card .terms {
  align-items: flex-start;
  margin-top: 0;
  padding-top: 0.25rem;
}

.auth-card .terms span {
  min-width: 0;
}

.auth-actions {
  flex-direction: column;
  align-items: stretch;
  gap: var(--spacing-6);
  margin-top: 0;
}

.auth-actions .btn {
  width: 100%;
  min-height: 44px;
}

.auth-passkey {
  padding-top: var(--spacing-2);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--spacing-6);
  width: 100%;
}

.auth-divider span {
  height: 1px;
  flex: 1 1 0;
  background: var(--color-border);
}

.auth-divider em {
  color: var(--color-foreground);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.875rem;
  letter-spacing: 0;
}

.auth-modal-backdrop {
  z-index: 90;
  background: rgb(0 0 0 / 0.25);
  backdrop-filter: blur(1.5px);
}

.auth-dialog {
  position: relative;
  width: min(460px, 100%);
  border: 1px solid #2a2d34;
  border-radius: 12px;
  background: #0e0f11;
  overflow: hidden;
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.38);
}

.auth-dialog-content {
  display: grid;
  justify-items: center;
  gap: var(--spacing-6);
  padding: var(--spacing-6);
  text-align: center;
}

.auth-dialog-close {
  position: absolute;
  top: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid #1f2126;
  border-radius: 6px;
  background: var(--color-surface-raised);
  color: var(--color-foreground);
  font-size: 24px;
  line-height: 1;
  z-index: 1;
}

.auth-dialog-close:hover {
  background: #1a1b1f;
}

.auth-dialog-icon {
  display: inline-flex;
  width: 96px;
  height: 96px;
  color: var(--color-primary);
}

.auth-dialog-icon svg {
  width: 100%;
  height: 100%;
}

.auth-dialog-copy {
  display: grid;
  gap: var(--spacing-2);
  width: 100%;
}

.auth-dialog-title {
  margin: 0;
  color: var(--color-foreground);
  font-family: var(--font-display);
  font-size: 2rem;
  font-style: italic;
  font-weight: 500;
  line-height: 2.375rem;
  letter-spacing: 0;
}

.auth-dialog-description {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--text-body-sm);
  font-weight: 300;
  line-height: var(--text-body-sm--line-height);
}

.auth-dialog-description strong {
  color: var(--color-foreground);
  font-weight: 600;
}

.auth-dialog-button {
  min-height: 40px;
}

@media (max-width: 720px) {
  .auth-area {
    padding-top: 3rem;
  }

  .auth-title {
    font-size: clamp(2.75rem, 12vw, 3.25rem);
    line-height: 1.08;
  }
}

/* ── banner ───────────────────────────────────────────────────── */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-4);
  min-height: 28px;
  margin-top: var(--spacing-8);
  border-radius: var(--radius-sm);
  padding: 0.4375rem 0.625rem;
  background: rgb(110 231 183 / 0.1);
  color: var(--color-sentiment-up);
  font-size: var(--text-micro);
  font-weight: 500;
  line-height: var(--text-micro--line-height);
}

.icon-btn {
  display: inline-grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: currentColor;
  cursor: pointer;
}

/* ── field (bordered box around label + input) ────────────────── */
.field {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--spacing-3) 0.875rem;
  background: var(--color-surface-raised);
}

.field:focus-within {
  border-color: var(--color-primary);
}

.field-label,
.section-label,
.tiny-step {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 0.875rem;
  text-transform: uppercase;
}

.section-label.is-accent {
  color: var(--color-primary);
}

.field-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-foreground);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  line-height: var(--text-caption--line-height);
}

.field-input:focus,
.field-input:focus-visible {
  outline: none;
  box-shadow: none;
}

.field-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.5;
}

.hosted-wallet-fields {
  display: grid;
  gap: var(--spacing-4);
  margin-top: var(--spacing-8);
}

.hosted-wallet-address-value {
  overflow-wrap: anywhere;
}

.hosted-wallet-address-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

.hosted-wallet-address-row .field-input {
  flex: 1;
}

.hosted-wallet-password-hint,
.hosted-wallet-password-error {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  line-height: var(--text-micro--line-height);
}

.hosted-wallet-password-hint {
  color: var(--color-text-muted);
}

.hosted-wallet-password-error {
  color: var(--color-danger-300);
}

.field:has(.field-input[aria-invalid="true"]) {
  border-color: var(--color-danger-300);
}

.hosted-wallet-complete {
  color: var(--color-primary);
  font-weight: 600;
}

.hosted-wallet-verified {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-2);
  margin: 0;
  color: var(--color-success-400);
  font-weight: 600;
}

.hosted-wallet-verified span {
  display: inline-grid;
  width: 1.25rem;
  height: 1.25rem;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--color-success-bg-opacity);
}

/* ── hosted onboarding wizard ────────────────────────────────── */
.hosted-wizard {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  background: #08090a;
}

.hosted-wizard-sidebar {
  padding: 30px 24px;
  border-right: 1px solid #1c1e24;
  background: #0c0d10;
}

.hosted-wizard-brand {
  color: #f7f8f8;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-style: italic;
  font-weight: 600;
}

.hosted-wizard-brand .ac {
  color: #8b9dff;
}

.hosted-wizard-label,
.hosted-provider-label {
  margin: 34px 0 14px;
  color: #5c616c;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hosted-wizard-steps {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hosted-wizard-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #868b95;
  font-size: 0.84375rem;
  font-weight: 500;
}

.hosted-wizard-steps li.is-current {
  color: #f7f8f8;
  background: #1b1d22;
  font-weight: 600;
}

.hosted-wizard-steps li.is-complete {
  color: #9ea3ad;
}

.hosted-wizard-step-number {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid #3a3e47;
  border-radius: 50%;
  color: #868b95;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

.is-current .hosted-wizard-step-number {
  border-color: #8b9dff;
  background: #8b9dff;
  color: #08090a;
}

.is-complete .hosted-wizard-step-number {
  border-color: transparent;
  color: var(--color-success-400);
}

.hosted-wizard-main {
  display: flex;
  min-width: 0;
  min-height: 100svh;
  flex-direction: column;
  padding: 44px 56px 40px;
}

.hosted-wizard-content {
  width: min(600px, 100%);
  flex: 1;
}

.hosted-wizard-crumb {
  margin: 0 0 20px;
  color: #5c616c;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.hosted-wizard-crumb span {
  color: #9ea3ad;
}

.hosted-wizard-title {
  margin: 0 0 10px;
  color: #f7f8f8;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-style: italic;
  font-weight: 600;
  line-height: 1.05;
}

.hosted-wizard-subtitle {
  margin: 0 0 30px;
  color: #9ea3ad;
  font-size: 0.90625rem;
  font-weight: 400;
  line-height: 1.6;
}

.hosted-wizard-box .field {
  margin-bottom: 18px;
}

.hosted-wizard-box .field:last-child {
  margin-bottom: 0;
}

.hosted-wizard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hosted-runtime-wait {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 220px;
  color: #9ea3ad;
  font-size: .90625rem;
}

.hosted-runtime-wait span {
  width: 18px;
  height: 18px;
  border: 2px solid rgb(139 157 255 / .3);
  border-top-color: #8b9dff;
  border-radius: 50%;
  animation: hosted-provider-spin .7s linear infinite;
}

.hosted-wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding-top: 26px;
  border-top: 1px solid #1c1e24;
  width: min(100%, 900px);
}

.agent-chat-setup {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.agent-chat-setup:hover {
  color: var(--color-text);
  border-color: var(--color-primary);
}

.agent-chat-mobile-setup {
  position: fixed;
  z-index: 51;
  top: 8px;
  right: 12px;
  /* AI setup is reachable from the model chip in the composer. */
  display: none;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--app-fg);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.agent-chat-mobile-setup:hover {
  background: var(--panel-head);
}

.agent-provider-dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  width: min(847px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 32px));
  overflow: auto;
  padding: 16px;
  border: 1px solid #30344a;
  border-radius: 16px;
  background: #141414;
  color: var(--color-text);
  box-shadow: 0 24px 90px rgb(0 0 0 / 0.58);
}

.agent-provider-dialog::backdrop {
  background: rgb(0 0 0 / 0.72);
}

.agent-provider-dialog .hosted-provider-picker {
  margin: 0;
}

.agent-provider-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  color: #FFFFFF;
}

.agent-provider-dialog-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.agent-provider-dialog-subtitle {
  margin: 10px 0 0;
  max-width: 52ch;
  color: #C4C4C4;
  font-size: 13px;
  line-height: 19px;
}

.agent-provider-dialog-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid #2a2d36;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.agent-provider-dialog-close:hover {
  border-color: #3a3e47;
  color: var(--color-text);
}

/* The dialog stages one provider at a time: cards on top, the chosen
   provider's action centred in the panel below. */
.agent-provider-dialog .hosted-provider-credential {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 300px;
  margin-top: 16px;
  padding: 28px;
  border-radius: 12px;
  background: #0A0A0A;
  text-align: center;
}

.agent-provider-dialog .hosted-provider-credential>.hosted-provider-label {
  display: none;
}

/* Disconnect is the destructive action in the setup flow, in the onboarding
   wizard and the chat dialog alike. */
[data-agent-provider-target="disconnectOpenai"],
[data-agent-provider-target="disconnectOllama"] {
  color: var(--coral-down);
}

/* Every step past the bare CTA reads left-to-right: the device code, the API
   key form, the model picker, and the disconnect confirmation. */
.agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-device-code:not([hidden])),
.agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-key-field:not([hidden])),
.agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-model-picker:not([hidden])),
.agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-disconnect-confirm:not([hidden])) {
  align-items: stretch;
  text-align: left;
  padding: 48px;
}

.agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-device-code:not([hidden]))>[data-agent-provider-target="openai"] {
  display: none;
}

/* Stretching the panel must not stretch its buttons. OpenAI's single sign-in
   button sits centred; Ollama's follows its left-aligned key form. */
.agent-provider-dialog [data-agent-provider-target="openaiPanel"]>.btn {
  align-self: center;
}

.agent-provider-dialog [data-agent-provider-target="ollamaPanel"]>.btn {
  align-self: flex-start;
}

/* Both credential CTAs are lone children of a 300px-tall panel, so every
   stretching default — flex, grid, and align-self alike — has to be refused or
   the button grows to the full panel height. Alignment stays with the
   panel-scoped rules above, which out-specify this one. */
[data-agent-provider-target="openai"],
[data-agent-provider-target="ollama"] {
  flex: none;
  align-self: center;
  justify-self: center;
  height: 42px;
  min-height: 42px;
  padding-top: 0;
  padding-bottom: 0;
}

/* Inside the dialog the values read as prose, not as codes: Inter for the
   inputs, and the Model/Effort labels keep their sentence case. */
.agent-provider-dialog .field-input {
  font-family: var(--font-body);
}

#ollama-api-key {
  font-size: 14px;
  line-height: 20px;
}

.agent-provider-dialog .hosted-provider-model-fields .field-label {
  text-transform: none;
  font-size: 10px;
  line-height: 14px;
}

.agent-provider-dialog .hosted-provider-credential .field,
.agent-provider-dialog .hosted-provider-model-picker {
  width: 100%;
  text-align: left;
}

.hosted-provider-label {
  margin: 0 0 8px;
}

.hosted-provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.hosted-provider-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 80px;
  padding: 12px;
  border: 1px solid #2A2A2A;
  border-radius: 8px;
  background: transparent;
  color: #C4C4C4;
  font-size: 13px;
  line-height: 19px;
  text-align: left;
}

/* Provider marks ship as 40px PNGs on a white plate, so the tile only has to
   round and frame them. */
.hosted-provider-card-logo {
  width: 40px;
  height: 40px;
  border: 1px solid #2a2d36;
  border-radius: 10px;
  object-fit: contain;
}

.hosted-provider-card-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.hosted-provider-card:hover {
  border-color: #3a3e47;
}

.hosted-provider-card.is-selected {
  border-color: #8b9dff;
  background: rgb(139 157 255 / 0.12);
}

.hosted-provider-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #EDEDED;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.hosted-provider-card-tags {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hosted-provider-tag {
  border: 0;
  border-radius: 999px;
  padding: 1px 7px;
  background: #8B9DFF26;
  color: #8B9DFF;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 14px;
  letter-spacing: 0;
  white-space: pre;
}

/* Once a provider is connected its status pill is the only tag worth reading,
   so the marketing tag steps aside. */
.hosted-provider-card-tags:has(.hosted-provider-card-connection:not([hidden])) .hosted-provider-tag {
  display: none;
}

.hosted-provider-card-connection {
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 4px;
  padding: 3px 8px;
  background: #6EE7B726;
  color: #6EE7B7;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 14px;
  letter-spacing: 0;
}

.hosted-provider-credential {
  margin-top: 22px;
}

/* Onboarding-only provider layout. Scoped to the wizard column (and, for the
   width, to the step that actually renders the picker) so the chat page's
   .agent-provider-dialog keeps its own sizing and spacing. */
.hosted-wizard-content:has(.hosted-provider-picker) {
  width: min(789px, 100%);
}

.hosted-wizard-content [data-agent-provider-target="ollamaPanel"] {
  display: grid;
  gap: 16px;
}

.hosted-wizard-content [data-agent-provider-target="ollamaPanel"]>* {
  margin-top: 0;
}

/* Grid stretches its items; the connect button still sizes to its label. */
.hosted-wizard-content [data-agent-provider-target="ollamaPanel"]>.btn {
  justify-self: start;
  width: fit-content;
}

.hosted-wizard-content .hosted-provider-picker>.hosted-provider-notice {
  margin-top: 16px;
}

.hosted-provider-help,
.hosted-provider-status,
.hosted-provider-device-code {
  margin: 7px 0 0;
  color: #868b95;
  font-size: 0.75rem;
  line-height: 1.5;
}

.hosted-provider-status {
  color: #9ea3ad;
}

/* The one-time code owns the panel: plain copy on top, the code in its own
   surface, then the single primary action. */
.hosted-provider-device-code {
  display: grid;
  gap: 6px;
  margin-top: 0;
  padding: 6px 0 0;
  border: 0;
  background: transparent;
}

.hosted-provider-device-code-title,
.hosted-provider-device-code-instruction {
  margin: 0;
}

.hosted-provider-device-code-title {
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.hosted-provider-device-code-instruction {
  color: #c4c4c4;
  font-size: 14px;
  font-weight: 400;
}

.hosted-provider-device-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0;
  padding: 28px 32px;
  border-radius: 12px;
  background: #131417;
}

.hosted-provider-device-code code {
  color: #f7f8f8;
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 24px;
  line-height: 100%;
  overflow-wrap: anywhere;
}

.hosted-provider-device-code-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
}

.hosted-provider-device-code-action {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8b9dff;
  cursor: pointer;
}

.hosted-provider-device-code-action svg {
  width: 24px;
  height: 24px;
}

.hosted-provider-device-code-action:hover,
.hosted-provider-device-code-action:focus-visible {
  background: rgb(139 157 255 / .12);
}

.hosted-provider-device-code-action.is-copied {
  color: #FFFFFF;
}

.hosted-provider-device-code>.btn {
  justify-self: start;
  margin-top: 4px;
}

.hosted-provider-model-picker {
  position: relative;
  display: grid;
  gap: 24px;
  margin-top: 16px;
  padding: 18px;
  border-radius: 8px;
}

.hosted-provider-model-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 8px;
  background: rgb(12 13 16 / .88);
  color: #c4c4c4;
  font-size: .8125rem;
  font-weight: 600;
}

.hosted-provider-model-loading span {
  width: 16px;
  height: 16px;
  border: 2px solid rgb(139 157 255 / .3);
  border-top-color: #8b9dff;
  border-radius: 50%;
  animation: hosted-provider-spin .7s linear infinite;
}

@keyframes hosted-provider-spin {
  to {
    transform: rotate(1turn);
  }
}

.hosted-provider-model-picker-title,
.hosted-provider-model-picker-help {
  margin: 0;
}

.hosted-provider-model-picker-title {
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.hosted-provider-model-picker-help {
  margin-top: 4px;
  color: #C4C4C4;
  font-size: 14px;
  line-height: 20px;
}

.hosted-provider-model-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.hosted-provider-model-fields .field {
  margin: 0;
  background: #1a1a1a;
  padding: 12px 16px;
  border: unset;
}

.hosted-provider-model-fields .field-input {
  min-height: 20px;
  background: #1a1a1a;
  color: #f7f8f8;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.hosted-provider-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* API key row: label over input, with Paste parked on the right. */
.hosted-provider-key-field {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label paste"
    "input paste";
  align-items: center;
  column-gap: 12px;
  background: #1a1a1a;
  border: unset;
}

.hosted-provider-key-field .field-label {
  grid-area: label;
}

.hosted-provider-key-field .field-input {
  grid-area: input;
}

.hosted-provider-key-paste {
  grid-area: paste;
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: #141414;
  color: var(--color-primary);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  cursor: pointer;
}

.hosted-provider-key-paste:hover {
  background: #2c2c2c;
}

.hosted-provider-disconnect-confirm {
  display: grid;
  gap: 4px;
}

/* The destructive answer gets its own breathing room under the question, and
   both answers carry the same weight, so they share one column width. */
.hosted-provider-disconnect-confirm .hosted-provider-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 174px));
  padding-top: 20px;
}

.btn .btn-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.btn.hosted-provider-danger {
  background: var(--coral-down);
  border-color: var(--coral-down);
  color: var(--color-background);
}

.btn.hosted-provider-danger:hover {
  background: #fdb9b9;
}

.hosted-provider-notice {
  padding: 11px 14px;
  border-radius: 6px;
  background: #FCD34D1A;
  color: #EDEDED;
  font-size: 11px;
  font-weight: 500;
  line-height: 15px;
}

.hosted-provider-notice strong {
  color: var(--color-warning-400);
  font-weight: 500;
}

.hosted-provider-developer-settings {
  display: grid;
  gap: 14px;
  margin-top: 24px;
  border-top: 1px solid #252833;
  padding-top: 20px;
}

.hosted-provider-developer-settings h3 {
  margin: 2px 0 4px;
  color: var(--color-text);
  font-size: 16px;
}

.hosted-provider-developer-settings p:not(.hosted-provider-label) {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.hosted-provider-developer-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid #282b35;
  border-radius: 8px;
  padding: 12px 14px;
  background: #101116;
}

.hosted-provider-developer-setting>div {
  display: grid;
  gap: 3px;
}

.hosted-provider-developer-setting strong {
  color: var(--color-text);
  font-size: 13px;
}

.hosted-provider-developer-setting span {
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 860px) {
  .hosted-wizard {
    grid-template-columns: 1fr;
  }

  .hosted-wizard-sidebar {
    display: none;
  }

  .hosted-wizard-main {
    padding: 32px 20px;
  }
}

/* The one-time code stops sharing its row well before the wizard reflows: past
   this width the code and its actions collide. */
@media (max-width: 781px) {
  .hosted-provider-device-code-row {
    flex-direction: column;
  }
}

@media (max-width: 520px) {

  /* Narrow screens swipe through the providers instead of stacking them: the
     cards keep their width and the row scrolls, snapping onto each card. */
  .hosted-provider-grid {
    grid-auto-flow: column;
    grid-auto-columns: minmax(240px, 82%);
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .hosted-provider-grid::-webkit-scrollbar {
    display: none;
  }

  /* Full-bleed inside the dialog: the dialog hands its horizontal padding to
     each block, and the strip is the one that carries it inside itself. It can
     then run edge to edge with the first card still in line, so the next card
     is cut by the dialog edge instead of by padding. */
  .agent-provider-dialog {
    padding-inline: 0;
  }

  .agent-provider-dialog-header,
  .agent-provider-dialog .hosted-provider-picker> :not(.hosted-provider-grid) {
    padding-inline: 16px;
  }

  .agent-provider-dialog .hosted-provider-grid {
    padding-inline: 16px;
    scroll-padding-inline: 16px;
  }

  .hosted-provider-card {
    scroll-snap-align: start;
    align-items: self-start;
  }

  .hosted-provider-model-fields {
    grid-template-columns: 1fr;
  }

  /* Once the cards swipe, the panel keeps its vertical breathing room but gives
     the horizontal padding back to the content. Every staged variant is listed
     so none of them out-specifies this. */
  .agent-provider-dialog .hosted-provider-credential,
  .agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-device-code:not([hidden])),
  .agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-key-field:not([hidden])),
  .agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-model-picker:not([hidden])),
  .agent-provider-dialog .hosted-provider-credential:has(.hosted-provider-disconnect-confirm:not([hidden])) {
    padding: 48px 16px;
  }

  /* Confirm and Disconnect stop sharing a row — each gets its own. The
     disconnect confirmation keeps Cancel beside its answer. */
  .hosted-provider-model-picker .hosted-provider-actions {
    display: grid;
    /* Own row each, but the buttons keep a fixed width instead of stretching. */
    grid-template-columns: minmax(0, 174px);
    justify-content: center;
  }

  /* One column of controls: the provider CTAs read better centred under them. */
  .hosted-provider-device-code>.btn {
    justify-self: center;
  }

  .hosted-provider-device-code-row {
    padding: 20px 16px;
  }

  .hosted-provider-device-code code {
    font-size: 22px;
    letter-spacing: 8px;
    text-align: center;
    width: 100%;
    /* letter-spacing trails the last glyph; this keeps the row optically centred. */
    text-indent: 8px;
  }

  /* Same treatment for the key form: Paste sits under the field. */
  .hosted-provider-key-field {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "label"
      "input"
      "paste";
    row-gap: 4px;
  }

  .agent-provider-dialog [data-agent-provider-target="ollamaPanel"]>.btn {
    align-self: center;
  }

  .hosted-wizard-title {
    font-size: 2rem;
  }
}

.banner-feedback {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-foreground);
  font-size: var(--text-body-sm);
  line-height: var(--text-body-sm--line-height);
}

.banner-feedback.ok {
  background: var(--color-success-bg-opacity);
  color: var(--color-success-400);
}

.banner-feedback.info {
  background: var(--color-info-bg-opacity);
  color: var(--color-primary);
}

.banner-feedback.error {
  background: var(--color-danger-bg-opacity);
  color: var(--color-danger-300);
}

.banner-feedback.warn {
  background: var(--color-warning-bg-opacity);
  color: var(--color-warning-400);
}

/* ── terms ────────────────────────────────────────────────────── */
.terms {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--spacing-4);
  color: var(--color-text-secondary);
  font-size: var(--text-caption);
  line-height: var(--text-caption--line-height);
  cursor: pointer;
}

.terms a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-surface-raised);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 120ms, border-color 120ms;
}

.checkbox:hover {
  border-color: var(--color-primary);
}

.checkbox:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.checkbox:checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}

.recaptcha-slot {
  width: 256px;
  min-height: 60px;
  margin-top: var(--spacing-4);
}

.recaptcha-slot .grecaptcha-badge {
  position: static !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* ── grids ────────────────────────────────────────────────────── */
.team-grid,
.market-grid,
.size-grid,
.download-grid,
.install-steps {
  display: grid;
  gap: var(--spacing-2);
}

.team-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: var(--spacing-4);
}

.market-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: var(--spacing-3);
}

.size-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: var(--spacing-3);
}

.install-steps {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: var(--spacing-4);
}

@media (max-width: 720px) {

  .team-grid,
  .market-grid,
  .size-grid,
  .download-grid,
  .install-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {

  .market-grid,
  .size-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-3);
  }

  .download-grid,
  .install-steps {
    grid-template-columns: 1fr;
  }
}

/* ── agent card ───────────────────────────────────────────────── */
.agent-card {
  min-height: 238px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.125rem;
  background: var(--color-surface-raised);
}

.agent-top {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: var(--spacing-3);
}

.avatar {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--color-foreground);
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-style: italic;
  line-height: 2rem;
}

.avatar-cooper {
  background: linear-gradient(135deg, #8b1e3f 0%, #d2415c 100%);
}

.avatar-sage {
  background: linear-gradient(135deg, #1e3a8b 0%, #4f6fc8 100%);
}

.agent-name {
  margin: 0;
  color: var(--color-foreground);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.625rem;
  letter-spacing: var(--text-hero--letter-spacing);
}

.agent-role,
.agent-copy,
.file-name {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-micro);
  font-weight: 500;
  line-height: var(--text-micro--line-height);
}

.agent-copy {
  margin-top: var(--spacing-4);
}

.agent-card .field {
  margin-top: var(--spacing-8);
}

/* ── choice cards (markets) ───────────────────────────────────── */
.choice-card {
  min-height: 107px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.875rem var(--spacing-4);
  background: var(--color-background);
  color: var(--color-foreground);
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.choice-card:hover,
.choice-card[aria-pressed="true"],
.size-card:hover,
.size-card[aria-pressed="true"] {
  border-color: var(--color-primary);
}

.choice-card[aria-pressed="true"],
.size-card[aria-pressed="true"] {
  background: rgb(139 157 255 / 0.25);
  color: #fff;
}

.choice-card[aria-pressed="true"] *,
.size-card[aria-pressed="true"] * {
  color: #fff;
}

.choice-code {
  display: block;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  line-height: var(--text-micro--line-height);
}

.choice-title {
  display: block;
  margin-top: 4px;
  color: var(--color-foreground);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  font-weight: 500;
  line-height: 26px;
  letter-spacing: -0.01em;
}

.size-value {
  display: block;
  margin-top: 4px;
  color: var(--color-foreground);
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  line-height: 28px;
  letter-spacing: 0.04em;
}

.choice-desc,
.size-desc {
  display: block;
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: var(--text-micro);
  line-height: var(--text-micro--line-height);
}

/* ── size card ────────────────────────────────────────────────── */
.size-card {
  min-height: 102px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1.625rem var(--spacing-4);
  background: var(--color-background);
  text-align: center;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

@media (max-width: 820px) {
  .choice-card {
    min-height: 132px;
    padding: 1.25rem 1.375rem;
  }

  .size-card {
    min-height: 132px;
    padding: 2rem var(--spacing-4);
  }

  .choice-title {
    margin-top: 0.625rem;
    font-size: 1.75rem;
    line-height: 2rem;
  }

  .choice-desc,
  .size-desc {
    margin-top: 0.625rem;
    font-size: var(--text-caption);
    line-height: var(--text-caption--line-height);
  }

  .size-value {
    font-size: 2.25rem;
    line-height: 2.5rem;
  }
}

/* ── download block ───────────────────────────────────────────── */
.download-block {
  margin-top: var(--spacing-8);
}

.download-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  margin-top: var(--spacing-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.download-col {
  display: grid;
  align-content: start;
  min-height: 290px;
  padding: var(--spacing-4) 1.125rem;
}

.download-col+.download-col {
  border-left: 1px solid var(--color-border);
}

@media (max-width: 720px) {
  .download-col+.download-col {
    border-top: 1px solid var(--color-border);
    border-left: 0;
  }

  .download-col {
    min-height: auto;
  }
}

.download-index {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
}

.download-copy {
  margin-top: var(--spacing-6);
}

.download-title {
  margin: 0;
  color: var(--color-foreground);
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1.625rem;
}

.file-name {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  line-height: var(--text-caption--line-height);
}

.download-col .btn {
  width: 100%;
  margin-top: 1.75rem;
}

.link-list {
  margin-top: var(--spacing-6);
  color: var(--color-text-secondary);
  font-size: var(--text-caption);
  line-height: var(--text-caption--line-height);
}

.link-list a {
  color: var(--color-primary);
  text-decoration: underline;
}

.link-list ul.list-disc {
  margin-top: 0.25rem;
  padding-left: 1.25rem;
  list-style: disc;
}

@media (max-width: 820px) {
  .download-grid {
    grid-template-columns: 1fr;
  }

  .download-col {
    min-height: auto;
    padding: 2rem;
  }

  .download-col+.download-col {
    border-top: 1px solid var(--color-border);
    border-left: 0;
  }

  .download-index {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
  }

  .download-title {
    font-size: 2rem;
    line-height: 2.5rem;
  }

  .file-name {
    font-size: 1rem;
    line-height: 1.5rem;
  }

  .download-col .btn {
    margin-top: 2rem;
  }

  .link-list {
    font-size: 1rem;
    line-height: 1.5rem;
  }
}

.warning {
  margin-top: var(--spacing-6);
  border-radius: var(--radius-sm);
  padding: var(--spacing-3);
  background: rgb(252 211 77 / 0.12);
  color: var(--color-sentiment-hold);
  font-size: var(--text-micro);
  font-weight: 500;
  line-height: var(--text-micro--line-height);
}

/* ── before install card ──────────────────────────────────────── */
.before-card {
  margin-top: var(--spacing-8);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.375rem;
  background: var(--color-surface-raised);
}

.before-title {
  margin: 0;
  color: var(--color-foreground);
  font-size: var(--text-body-sm);
  font-weight: 600;
  line-height: var(--text-body-sm--line-height);
}

.before-copy {
  margin: 0;
  color: var(--color-text-muted);
  margin-top: 4px;
  font-size: var(--text-body-sm);
  line-height: var(--text-body-sm--line-height);
}

.install-step {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: var(--spacing-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--spacing-2);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  letter-spacing: 0.12em;
  line-height: var(--text-micro--line-height);
  list-style: none;
}

.install-step strong {
  display: grid;
  width: 20px;
  height: 18px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-secondary);
  font-size: 0.625rem;
}

.install-steps {
  list-style: none;
  padding: 0;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-8 {
  margin-top: var(--spacing-8);
}

.normal-case {
  text-transform: none;
  letter-spacing: 0;
}

/* ── toast (centralized notifications) ────────────────────────── */
.toast {
  position: fixed;
  top: 22px;
  right: 22px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  color: var(--color-foreground);
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  z-index: 300;
  transform: translateY(-80px);
  opacity: 0;
  transition: all .28s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: none;
  min-width: 220px;
  max-width: 340px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast.ok {
  border-left: 2px solid var(--color-sentiment-up);
}

.toast.info {
  border-left: 2px solid var(--color-primary);
}

.toast.error {
  border-left: 2px solid var(--color-sentiment-down);
}

.toast.warn {
  border-left: 2px solid var(--color-sentiment-hold);
}

.toast.ok .ic {
  color: var(--color-sentiment-up);
}

.toast.info .ic {
  color: var(--color-primary);
}

.toast.error .ic {
  color: var(--color-sentiment-down);
}

.toast.warn .ic {
  color: var(--color-sentiment-hold);
}

.ic {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── turbo progress bar ───────────────────────────────────────── */
.turbo-progress-bar {
  height: 2px;
  background: var(--color-primary);
}

/* ── legacy short tokens (kept so funds/* views still work) ───── */
:root {
  --bg: var(--color-background);
  --bg1: var(--color-surface);
  --bg2: var(--color-surface-raised);
  --bg3: #1a1a1a;
  --bg4: #222;
  --ln: #1f1f1f;
  --ln2: var(--color-border);
  --ln3: #3a3a3a;
  --fg: var(--color-foreground);
  --fg2: var(--color-text-secondary);
  --fg3: #aaaaaa;
  --mu: var(--color-text-muted);
  --mu2: #5a5a5a;
  --mu3: #3e3e3e;
  --pr: var(--color-primary);
  --pr-h: #9aa9ff;
  --pr-d: #6f7ee6;
  --prs: rgba(139, 157, 255, .12);
  --prl: rgba(139, 157, 255, .30);
  --gn: var(--color-sentiment-up);
  --gns: rgba(110, 231, 135, .12);
  --rd: var(--color-sentiment-down);
  --yw: var(--color-sentiment-hold);
  --serif: var(--font-display);
  --sans: var(--font-body);
  --mono: var(--font-mono);
  --r: 8px;
  --rs: 6px;
  --rl: 12px;

  /* cockpit tokens */
  --app-bg: #08090a;
  --nav-bg: #0e0f11;
  --panel-bg: #0e0f11;
  --panel-head: #131417;
  --app-line: #1f2126;
  --app-line-strong: #2a2d34;
  --app-muted: #8a8f99;
  --app-dim: #5c616c;
  --app-fg: #f7f8f8;
  --color-surface-hover: #1a1a1a;
  --motion-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --motion-state: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ════════════════════════════════════════════════════════════════
   cockpit shell (funds#index)
   ════════════════════════════════════════════════════════════════ */

.app-shell {
  min-height: 100vh;
  background: var(--app-bg);
}

.sidebar {
  position: fixed;
  inset: 52px auto 0 0;
  z-index: 40;
  width: min(230px, 82vw);
  padding: 16px 12px;
  overflow-y: auto;
  background: var(--nav-bg);
  border-right: 1px solid var(--app-line);
  transform: translateX(-100%);
  transition: transform var(--motion-state);
}

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

.sidebar .brand,
.mobile-bar .brand {
  display: inline-flex;
  align-items: baseline;
  padding: 8px 12px 20px;
  color: var(--app-fg);
  font-family: var(--font-display);
  font-size: 20px;
  font-style: italic;
  font-weight: 500;
  line-height: 1.2;
}

.mobile-bar .brand {
  padding: 8px 12px;
}

.sidebar .brand {
  display: none;
}

.brand-dot {
  color: #5e6ad2;
}

.nav-group-label {
  padding: 0 12px 4px;
  color: var(--app-dim);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.6px;
  line-height: 13px;
  text-transform: uppercase;
}

.nav-group-label.spaced {
  padding-top: 14px;
}

.nav-link,
.sub-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 30px;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: #b4b8c0;
  font-size: 13px;
  font-weight: 400;
  line-height: 16px;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.nav-link:hover,
.sub-link:hover,
.nav-link[aria-current="page"],
.sub-link[aria-current="page"] {
  background: var(--color-surface-hover);
  color: var(--app-fg);
}

.nav-count-badge {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  border-radius: 999px;
  padding: 0 6px;
  background: rgba(252, 211, 77, .14);
  color: var(--yw);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.nav-icon {
  width: 16px;
  height: 16px;
  color: currentColor;
  opacity: 0.86;
}

.sub-link {
  min-height: 30px;
  padding: 6px 12px 6px 24px;
  color: var(--app-dim);
  font-size: 12px;
  font-weight: 400;
  line-height: 15px;
}

.avatar-mini {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: white;
  font-family: var(--font-display);
  font-size: 10px;
  font-style: italic;
  font-weight: 600;
  line-height: 1;
}

.avatar-pablo {
  background: linear-gradient(135deg, #5b21b6 0%, #a78bfa 70.721%);
}

.mobile-bar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 16px;
  background: rgb(8 9 10 / 0.94);
  border-bottom: 1px solid var(--app-line);
  backdrop-filter: blur(16px);
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  background: var(--nav-bg);
  color: var(--app-fg);
}

.mobile-menu-button {
  position: absolute;
  left: 16px;
}

.mobile-menu-button .close-icon,
.mobile-menu-button[aria-expanded="true"] .menu-icon {
  display: none;
}

.mobile-menu-button[aria-expanded="true"] {
  background: var(--panel-head);
}

.mobile-menu-button[aria-expanded="true"] .close-icon {
  display: block;
}

.main-area {
  min-width: 0;
  padding-top: 52px;
}

.app-shell .topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 28px;
  background: var(--app-bg);
  border-bottom: 1px solid var(--app-line);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--app-muted);
  font-size: 14px;
  line-height: 18px;
  white-space: nowrap;
  font-weight: 300;
}

.breadcrumb-separator {
  color: #3e424b;
}

.breadcrumb-current {
  color: var(--app-fg);
  font-weight: 500;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 28px;
  border: 0;
  border-radius: var(--radius-md);
  padding: 5px 18px;
  background: var(--color-primary);
  color: var(--color-background);
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  transition: filter var(--motion-fast), transform var(--motion-fast);
}

.button:hover {
  filter: brightness(1.06);
}

.button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35) brightness(0.72);
  opacity: 0.62;
}

.button:active {
  transform: translateY(1px);
}

.button-icon {
  width: 14px;
  height: 14px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-background);
  color: var(--color-text-secondary);
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--color-sentiment-up);
}

.live-pill-paper {
  color: #cfd4de;
}

.live-pill-off {
  color: #d7c2c2;
}

.status-dot-paper {
  background: var(--color-warning-400);
}

.status-dot-off {
  background: var(--color-sentiment-down);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100vh - 32px);
  padding: 28px 16px 72px;
  overflow: hidden;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.page-header-with-action {
  align-items: flex-start;
  gap: 14px;
}

.page-title {
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-display);
  font-size: 34px;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 41px;
}

.page-subtitle {
  margin: 0;
  color: var(--app-muted);
  font-size: 14px;
  line-height: 17px;
}

.dashboard-title-block {
  display: grid;
  gap: 5px;
}

.dashboard-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.dashboard-polymarket-link {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .page-header-with-action {
    flex-direction: row;
    justify-content: space-between;
  }
}

.app-shell .card,
.memo,
.data-table,
.position-table {
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  width: auto;
  animation: none;
}

.memo {
  display: flex;
}

.memo::before {
  content: "";
  width: 4px;
  flex: 0 0 4px;
  background: var(--color-primary);
}

.memo-body {
  padding: 16px 20px;
}

.memo-copy {
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-display);
  font-size: 17px;
  font-style: italic;
  font-weight: 500;
  line-height: 1.5;
}

.memo-author {
  margin: 6px 0 0;
  color: var(--app-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.4px;
  line-height: 13px;
  text-transform: uppercase;
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.66px;
  line-height: 13px;
  text-transform: uppercase;
}

.metric-large {
  margin: 4px 0;
  color: var(--color-sentiment-up);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  line-height: 34px;
}

.microcopy {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: flex-end;
}

.tab {
  min-height: 25px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  background: transparent;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 15px;
}

.tab[aria-selected="true"] {
  border-color: var(--app-line-strong);
  background: var(--color-surface-hover);
  color: var(--app-fg);
}

.chart-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
}

.chart-wrap--empty {
  display: grid;
  min-height: 120px;
  place-items: center;
}

turbo-frame#pnl_card {
  display: block;
}

/* Turbo marks the frame [busy] while a range tab is fetching. The only loading
   state is the chart skeleton, brought back over the outgoing canvas — the
   headline and tabs stay untouched. */
turbo-frame#pnl_card[busy] .chart-skeleton--settled {
  opacity: 1;
  visibility: visible;
}

/* Placeholder held over the chart until Chart.js paints, and shown again while
   another range is fetched. chart_skeleton_controller marks it --settled once
   the chart exists; it stays in the DOM so it can be revived. */
.chart-skeleton {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  align-items: end;
  padding: 0 0 28px;
  border-radius: var(--radius-md);
  background: var(--panel-head);
  pointer-events: none;
}

.chart-skeleton--settled {
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--motion-fast), visibility var(--motion-fast);
}

/* Stand-in for the plotted line: a flat rule that sweeps left to right. */
.chart-skeleton__line {
  height: 2px;
  background: linear-gradient(90deg,
      var(--app-line) 0%,
      var(--app-line-strong) 35%,
      var(--app-muted) 50%,
      var(--app-line-strong) 65%,
      var(--app-line) 100%);
  background-size: 220% 100%;
  animation: chart-skeleton-sweep 1.4s ease-in-out infinite;
}

@keyframes chart-skeleton-sweep {
  from {
    background-position: 120% 0;
  }

  to {
    background-position: -120% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chart-skeleton__line {
    background: var(--app-line-strong);
    animation: none;
  }
}

.pnl-chart {
  width: min(930px, 100%);
  min-width: 680px;
  height: 200px;
}

.axis-label,
.tick-label {
  fill: var(--app-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

.grid-line {
  stroke: var(--app-line);
  stroke-width: 1;
}

.area-fill {
  fill: url("#chartGradient");
}

.line-stroke {
  fill: none;
  stroke: var(--color-sentiment-up);
  stroke-width: 2;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stat-card {
  min-height: 95px;
  padding: 14px 16px;
}

.stat-label {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 15px;
}

.stat-value {
  margin: 5px 0;
  color: var(--app-fg);
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  line-height: 29px;
}

.stat-note {
  margin: 0;
  color: var(--app-muted);
  font-size: 11px;
  line-height: 13px;
}

@media (max-width: 719px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-card--total {
    grid-column: 1 / -1;
  }

  .stat-card--total {
    order: 1;
  }

  .stat-card--available {
    order: 2;
  }

  .stat-card--wallet {
    order: 3;
  }

  .stat-card--open-bets {
    order: 4;
  }

  .stat-card--claimable {
    order: 5;
  }

  .stat-card--total {
    min-height: 112px;
    padding: 18px 16px;
  }

  .stat-card--available {
    border-color: var(--app-line-strong);
  }
}

.positive {
  color: var(--color-sentiment-up);
}

.negative {
  color: var(--color-sentiment-down);
}

.app-shell .warning {
  color: var(--color-sentiment-hold);
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  margin-top: 0;
}

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgb(0 0 0 / 0.62);
}

.modal-backdrop.is-open {
  display: grid;
}

.modal {
  width: min(460px, 100%);
  border: 1px solid var(--app-line);
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.42);
  overflow: hidden;
}

.modal-header,
.modal-body,
.modal-actions {
  padding: 18px 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--app-line);
  background: #101113;
}

.modal-title {
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-display);
  font-size: 24px;
  font-style: italic;
  font-weight: 500;
  line-height: 27px;
}

.modal-subtitle {
  margin: 3px 0 0;
  color: var(--app-muted);
  font-size: 13px;
  line-height: 16px;
}

.app-shell .modal .field {
  display: grid;
  gap: 8px;
  margin: 0;
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: auto;
  background: transparent;
}

.app-shell .modal .field label {
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 600;
}

.app-shell .modal .field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  padding: 0 12px;
  background: var(--color-surface-raised);
  color: var(--app-fg);
}

.modal-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.modal-field-label {
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 15px;
}

.modal-input,
.modal-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  padding: 0 12px;
  background: var(--color-surface-raised);
  color: var(--app-fg);
  font-size: 13px;
  line-height: 18px;
}

.modal-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--app-muted) 50%), linear-gradient(135deg, var(--app-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  padding-right: 34px;
}

.modal-input:focus,
.modal-select:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: var(--shadow-focus);
}

.modal-error-message {
  margin: 0 0 14px;
  color: var(--rd);
  font-size: var(--text-body-sm);
  font-weight: 600;
  line-height: var(--text-body-sm--line-height);
}

.add-analyst-header {
  min-height: 76px;
  padding: 18px 22px 14px;
}

.add-analyst-body {
  display: grid;
  gap: 14px;
  padding: 18px 22px;
}

.add-analyst-copy {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.add-analyst-actions {
  padding: 12px 22px;
}

.helper-text {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 18px;
}

.add-funds-modal .modal-header {
  padding: 18px 22px 14px;
}

.add-funds-body {
  display: grid;
  gap: 12px;
  padding: 18px 22px;
}

.deposit-card {
  display: grid;
  justify-items: center;
  gap: 11px;
  min-width: 0;
  min-height: 197px;
  border: 1px solid var(--app-line-strong);
  border-radius: 8px;
  padding: 16px;
  background: #141518;
}

.deposit-qr {
  width: 140px;
  height: 140px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.04);
}

.deposit-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.deposit-address {
  width: 100%;
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 15px;
  overflow-wrap: anywhere;
  text-align: center;
}

.deposit-warning {
  gap: 4px;
  align-items: center;
  min-height: 31px;
  margin: 0;
  border-radius: 6px;
  padding: 7px 16px;
  background: rgb(252 211 77 / 0.13);
  color: #b9b1a0;
  font-size: 12px;
  line-height: 16px;
}

.deposit-warning strong {
  color: var(--color-sentiment-hold);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--app-line);
  background: #101113;
}

.add-wallet-modal .modal-header {
  min-height: 76px;
  padding: 18px 22px 12px;
}

.add-wallet-body {
  display: grid;
  gap: 14px;
  padding: 18px 22px;
}

.add-wallet-modal .modal-field {
  gap: 5px;
}

.add-wallet-modal .modal-field-label {
  color: #b4b8c0;
  font-weight: 500;
}

.add-wallet-modal .modal-input {
  min-height: 35px;
  border-color: var(--app-line-strong);
  border-radius: var(--radius-sm);
  background: #131417;
  font-size: 14px;
}

.add-wallet-address-input {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px 0 12px;
}

.add-wallet-address-field {
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--app-fg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 17px;
}

.add-wallet-address-field:focus,
.add-wallet-address-field:focus-visible {
  outline: none;
  box-shadow: none;
}

.add-wallet-address-input:focus-within {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}

.add-wallet-address-field::placeholder,
.add-wallet-modal .modal-input::placeholder {
  color: #5c616c;
  opacity: 1;
}

.chain-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  min-height: 18px;
  border: 1px solid rgb(94 106 210 / 0.3);
  border-radius: 4px;
  padding: 2px 8px;
  background: rgb(94 106 210 / 0.12);
  color: #5e6ad2;
  font-size: 10px;
  font-weight: 600;
  line-height: 12px;
}

.chain-pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #5e6ad2;
}

.add-wallet-warning {
  min-height: 50px;
  border: 1px solid rgb(252 211 77 / 0.2);
  padding: 10px 14px;
  color: #b9b1a0;
}

.add-wallet-actions {
  padding: 12px 22px;
}

.modal-backdrop:has(.dialog-card-success) {
  place-items: center;
}

.add-wallet-modal:has(.dialog-card-success) {
  width: min(403px, 100%);
  border-color: #2a2d34;
  border-radius: 12px;
  background: #0e0f11;
}

.dialog-card {
  position: relative;
  width: 100%;
  padding: 24px;
}

.dialog-card-success {
  min-height: 238px;
}

.dialog-close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid #1f2126;
  border-radius: 6px;
  background: #141414;
  color: var(--color-ivory);
}

.dialog-close-button:hover {
  background: #1a1b1f;
}

.dialog-card-content {
  display: grid;
  justify-items: center;
  gap: 24px;
}

.dialog-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dialog-icon-success {
  width: 48px;
  height: 48px;
  color: #6ee7b7;
}

.dialog-copy {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
  text-align: center;
}

.dialog-title {
  margin: 0;
  color: #ededed;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
}

.dialog-title-lg {
  font-size: 32px;
  line-height: 38px;
  letter-spacing: -0.8px;
}

.dialog-description {
  margin: 0;
  color: #c4c4c4;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
}

.dialog-actions {
  display: grid;
  width: 100%;
  padding-top: 8px;
}

.dialog-button {
  width: 100%;
  min-height: 40px;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.dialog-button-secondary {
  border: 1px solid #2a2a2a;
  background: #0f0f0f;
  color: #ededed;
}

.dialog-button-secondary:hover {
  background: #141414;
}

.confirm-modal-actions form {
  margin: 0;
}

.add-funds-modal .modal-actions {
  padding: 12px 22px;
}

.button-secondary {
  border: 1px solid var(--app-line);
  background: var(--color-surface-hover);
  color: var(--app-fg);
}

.button-ghost {
  border: 0;
  background: transparent;
  color: var(--app-muted);
}

/* responsive */
@media (min-width: 720px) {
  .content {
    padding: 28px 36px 80px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1040px) {
  .app-shell {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    right: auto;
    bottom: auto;
    left: auto;
    height: 100vh;
    transform: none;
  }

  .mobile-bar {
    display: none;
  }

  .sidebar .brand {
    display: inline-flex;
  }

  .app-shell .topbar {
    display: flex;
  }

  .main-area {
    padding-top: 0;
  }

  .stat-grid {
    grid-template-columns: repeat(var(--stat-cols, 4), minmax(0, 1fr));
  }
}

/* ── position tables ─────────────────────────────────────────── */

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
}

/* ── agent detail ── */
.agent-detail-header {
  display: flex;
  flex-direction: row;
  gap: 18px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--app-line);
  align-items: end;
  justify-content: space-between;
}

.agent-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.avatar-profile {
  display: inline-grid;
  width: 72px;
  height: 72px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-family: var(--font-display);
  font-size: 32px;
  font-style: italic;
  font-weight: 600;
  line-height: 1;
}

.agent-kicker {
  margin: 0 0 4px;
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 300;
  letter-spacing: .66px;
  line-height: 13px;
  text-transform: uppercase;
}

.agent-detail-title {
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-display);
  font-size: 42px;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 48px;
}

.agent-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.agent-edit-button {
  flex: 0 0 auto;
  margin-top: 4px;
}

.agent-rename-form {
  display: grid;
  gap: 10px;
}

.agent-rename-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.agent-rename-input {
  min-width: min(320px, 100%);
}

.agent-rename-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-rename-help,
.agent-rename-error {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
}

.agent-rename-help {
  color: var(--app-muted);
}

.agent-rename-error {
  color: var(--color-sentiment-down);
}

.agent-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
}

.agent-status-text {
  color: var(--color-success-400);
  font-weight: 600;
}

/* instruction box */
.instruction-box {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
}

.instruction-box::before {
  content: "";
  width: 4px;
  flex: 0 0 4px;
  background: var(--instruction-accent, var(--color-primary));
}

.instruction-box.crypto {
  --instruction-accent: #5e6ad2;
}

.instruction-body {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 16px;
}

.instruction-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-small {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  font-weight: 600;
}

.instruction-title {
  margin: 0;
  color: var(--app-fg);
  font-size: 14px;
  font-weight: 700;
  line-height: 18px;
}

.instruction-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.instruction-textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--color-surface-raised);
  color: var(--app-fg);
  line-height: 20px;
}

.instruction-textarea::placeholder {
  color: var(--app-dim);
}

.instruction-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

/* decisions */
.decision-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
}

.decision-row {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--app-line);
}

.decision-row:last-child {
  border-bottom: 0;
}

.decision-row-clickable {
  cursor: pointer;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}

.decision-row-clickable:hover,
.decision-row-clickable:focus-visible {
  background: var(--color-surface-hover);
  outline: none;
}

.decision-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.decision-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: #d9dbde;
  font-size: 13px;
  line-height: 18px;
}

.decision-meta {
  margin: 0;
  color: var(--app-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 13px;
}

.decision-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.decision-research-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--color-primary);
  font: inherit;
  line-height: 18px;
  cursor: pointer;
}

.decision-research-link:hover,
.decision-research-link:focus-visible {
  color: #bec7ff;
  text-decoration: underline;
  outline: none;
}

.ticket-history-modal {
  width: min(460px, 100%);
}

.ticket-history-header {
  min-height: 76px;
  padding: 18px 22px 14px;
}

.ticket-history-header .modal-title {
  max-width: 416px;
  overflow-wrap: anywhere;
}

.ticket-history-body {
  display: grid;
  gap: 18px;
  padding: 18px 22px;
}

.ticket-modal-section {
  display: grid;
  gap: 8px;
}

.ticket-modal-label {
  margin: 0;
  color: var(--app-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .66px;
  line-height: 12px;
  text-transform: uppercase;
}

.ticket-research-box {
  border: 1px solid var(--app-line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: #141518;
}

.ticket-research-box p {
  margin: 0;
  color: #d9dbde;
  font-size: 13px;
  line-height: 20px;
}

.ticket-history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 4px 0 0;
  list-style: none;
}

.ticket-history-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.ticket-history-dot {
  width: 9px;
  height: 9px;
  margin: 4px 0 0 1.5px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(139 157 255 / 0.12);
}

.ticket-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.ticket-history-badge {
  display: inline-flex;
  min-height: 17px;
  align-items: center;
  border: 1px solid var(--app-line-strong);
  border-radius: 4px;
  padding: 2px 8px;
  background: var(--color-surface-hover);
  color: #b4b8c0;
  font-size: 11px;
  line-height: 13px;
}

.ticket-history-copy {
  margin: 3px 0 0;
  color: #d9dbde;
  font-size: 13px;
  line-height: 16px;
}

.ticket-history-actions {
  padding: 12px 22px;
}

/* tickets */
.ticket-table table {
  min-width: 860px;
}

.ticket-cell {
  color: var(--app-fg);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

.ticket-market {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: #d9dbde;
}

.inline-badge {
  display: inline-flex;
  min-height: 16px;
  align-items: center;
  border-radius: 4px;
  padding: 2px 6px;
  background: rgb(252 211 77 / 0.12);
  color: var(--color-sentiment-hold);
  font-size: 10px;
  font-weight: 700;
  line-height: 12px;
  white-space: nowrap;
}

.stage-cell {
  color: var(--app-muted);
  font-size: 11px;
  white-space: nowrap;
}

.stage-live {
  color: var(--color-sentiment-up);
}

.stage-waiting,
.stage-researching {
  color: var(--color-sentiment-hold);
}

/* info banner */
.info-banner {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: rgb(139 157 255 / 0.1);
  color: var(--color-primary);
  font-size: 13px;
  line-height: 16px;
}

.info-banner strong {
  color: #fff;
  font-weight: 700;
}

/* module tabs */
.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.module-tab {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid var(--app-line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  background: var(--panel-bg);
  color: #b4b8c0;
  font-size: 13px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
}

.module-tab[aria-current="page"] {
  border-color: #3a3e47;
  background: var(--color-surface-hover);
  color: var(--app-fg);
}

.module-tab-add {
  border-style: dashed;
}

/* mandate */
.mandate-box {
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
}

.mandate-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--app-line);
  background: var(--panel-head);
}

.mandate-toolbar-label {
  margin: 0;
  color: #b4b8c0;
  font-size: 12px;
  font-weight: 500;
}

.select-pill {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  border: 1px solid var(--app-line-strong);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  background: var(--color-surface-hover);
  color: #e6e7e8;
  font-size: 12px;
  line-height: 15px;
}

.mandate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mandate-body {
  display: grid;
  gap: 18px;
  padding: 8px 16px 22px;
}

.mandate-intro {
  margin: 0;
  color: var(--app-muted);
  font-size: 13px;
  line-height: 18px;
}

.mandate-field {
  display: grid;
  gap: 8px;
}

.mandate-label {
  display: grid;
  gap: 4px;
}

.mandate-label strong {
  color: var(--app-fg);
  font-size: 13.5px;
  line-height: 16px;
}

.mandate-label span,
.mandate-help {
  color: var(--app-dim);
  font-size: 12px;
  line-height: 15px;
}

.mandate-input,
.mandate-textarea {
  width: 100%;
  border: 1px solid var(--app-line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel-head);
  color: var(--app-fg);
  font-size: 13px;
  line-height: 18px;
}

.mandate-textarea {
  min-height: 38px;
  resize: vertical;
}

.mandate-setting {
  display: grid;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--app-line);
}

.mandate-setting:last-child {
  border-bottom: 0;
}

.mandate-setting-title {
  margin: 0;
  color: var(--app-fg);
  font-size: 14px;
  font-weight: 700;
  line-height: 17px;
}

.mandate-setting-control {
  display: grid;
  gap: 8px;
}

.mono-field {
  max-width: 360px;
  background: var(--color-background);
  color: var(--app-fg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
}

/* rules */
.rules-card {
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
}

.rules-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 45px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--app-line);
  background: var(--panel-head);
}

.rules-title {
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-display);
  font-size: 17px;
  font-style: italic;
  font-weight: 500;
  line-height: 21px;
}

.api-badge {
  display: inline-flex;
  min-height: 17px;
  align-items: center;
  border: 1px solid var(--app-line-strong);
  border-radius: 4px;
  padding: 2px 8px;
  background: var(--color-surface-hover);
  color: #b4b8c0;
  font-size: 11px;
  line-height: 13px;
  white-space: nowrap;
}

.rule-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--app-line);
}

.rule-row:last-child {
  border-bottom: 0;
}

.rule-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.rule-name {
  margin: 0;
  color: var(--app-fg);
  font-size: 13px;
  font-weight: 500;
  line-height: 16px;
}

.rule-description {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.rule-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rule-input {
  width: 86px;
  min-height: 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  background: var(--color-background);
  color: var(--app-fg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  text-align: right;
}

.rule-unit {
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.toggle {
  display: inline-flex;
  width: 32px;
  height: 18px;
  align-items: center;
  border: 0;
  border-radius: var(--radius-full);
  padding: 2px;
  background: #30343c;
  transition: background var(--motion-fast);
}

.toggle::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e6e7e8;
  transition: transform var(--motion-fast);
}

.toggle[aria-pressed="true"] {
  background: var(--color-primary);
}

.toggle[aria-pressed="true"]::before {
  transform: translateX(14px);
}

.save-bar {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-end;
  min-height: 68px;
  border-top: 1px solid var(--app-line);
  padding: 14px 18px;
  background: var(--panel-bg);
}

.save-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.save-actions .button {
  min-height: 40px;
  border-radius: 8px;
}

.save-actions .button-ghost {
  min-height: 36px;
  padding-inline: 16px;
  font-weight: 500;
}

.save-actions .button:disabled {
  opacity: 0.5;
}

.save-actions .button-ghost:disabled {
  cursor: default;
  filter: none;
  opacity: 1;
}

/* fund approval review */
.approval-row .rule-control {
  justify-content: flex-start;
}

.approval-page-title {
  max-width: 28ch;
  overflow-wrap: anywhere;
}

.approval-stat-card {
  min-height: 112px;
}

.approval-stat-value {
  font-size: 18px;
  line-height: 24px;
  word-break: break-word;
}

.approval-stat-value-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 19px;
}

.approval-value {
  min-width: 0;
  color: var(--app-fg);
  font-size: 13px;
  line-height: 18px;
  overflow-wrap: anywhere;
  text-align: right;
}

.approval-value-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.approval-status-badge {
  display: inline-flex;
  min-height: 17px;
  align-items: center;
  border: 1px solid var(--app-line-strong);
  border-radius: 4px;
  padding: 2px 8px;
  background: var(--color-surface-hover);
  color: #b4b8c0;
  font-size: 11px;
  line-height: 13px;
  white-space: nowrap;
}

.approval-status-badge-awaiting {
  border-color: rgba(252, 211, 77, .35);
  background: rgba(252, 211, 77, .10);
  color: var(--yw);
}

.approval-status-badge-approved,
.approval-status-badge-executed {
  border-color: rgba(110, 231, 135, .35);
  background: var(--gns);
  color: var(--gn);
}

.approval-status-badge-rejected,
.approval-status-badge-failed {
  border-color: rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .10);
  color: var(--rd);
}

.approval-status-badge-expired {
  color: var(--app-muted);
}

.approval-action-bar {
  gap: 16px;
  justify-content: space-between;
}

.approval-reject-form form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.approval-reject-input {
  width: min(320px, 42vw);
  min-height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: var(--color-background);
  color: var(--app-fg);
  font-size: 12px;
  line-height: 18px;
}

.approval-readonly-copy {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.approval-flash {
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--panel-bg);
  color: var(--app-muted);
  font-size: 13px;
  line-height: 18px;
}

.approval-flash-success {
  border-color: rgba(110, 231, 135, .28);
  color: var(--gn);
}

.approval-flash-alert {
  border-color: rgba(248, 113, 113, .28);
  color: var(--rd);
}

.approval-rationale-row {
  gap: 8px;
  align-items: start;
}

.approval-rationale-copy {
  color: var(--app-fg);
  font-size: 13px;
  line-height: 20px;
  max-width: 72ch;
}

.approval-list-control {
  display: grid;
  justify-items: end;
  min-width: 96px;
}

.approval-list-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.approval-list-title-row .rule-name {
  margin: 0;
  min-width: 0;
}

.approval-list-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.approval-list-amount {
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 15px;
}

.approval-list-time {
  color: var(--app-dim);
}

.approval-list-link {
  min-width: 96px;
  min-height: 34px;
  padding-inline: 14px;
}

.approval-history-row-link {
  color: inherit;
  grid-template-columns: minmax(0, 1fr);
  text-decoration: none;
  transition: background 160ms ease;
}

.approval-history-row-link:hover {
  background: rgba(139, 157, 255, .04);
}

.approval-history-row-link:focus-visible {
  outline: 1px solid rgba(139, 157, 255, .45);
  outline-offset: -1px;
}

@media (max-width: 720px) {

  .approval-action-bar,
  .approval-reject-form form,
  .approval-action-bar .save-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .approval-reject-input {
    width: 100%;
  }

  .approval-list-control {
    align-items: flex-start;
    justify-items: start;
    min-width: 0;
  }

  .approval-list-title-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .approval-list-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

.amount {
  font-family: var(--font-mono);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.pill.warning {
  background: rgb(252 211 77 / 0.12);
  color: var(--color-sentiment-hold);
}

/* responsive */
@media (min-width:720px) {
  .instruction-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .decision-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .rule-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mandate-setting {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
  }

  .mandate-actions {
    margin-left: auto;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
}

.position-table table {
  min-width: 800px;
}

/* Sections rendering the shared position table share one column geometry, so
   the four of them stacked down the page align with each other. Only tables
   carrying the matching <colgroup> opt in — the pending, collected and activity
   tables have their own column sets and size themselves. */
.position-table table.position-columns {
  /* Pinned columns sum to 728px; the floor leaves Market ~170px before the
     surrounding .table-scroll starts scrolling horizontally. */
  min-width: 900px;
  table-layout: fixed;
}

.position-columns .col-outcome {
  width: 76px;
}

.position-columns .col-shares {
  width: 84px;
}

.position-columns .col-price {
  width: 92px;
}

.position-columns .col-price-wide {
  width: 108px;
}

.position-columns .col-value {
  width: 96px;
}

.position-columns .col-payout {
  width: 104px;
}

.position-columns .col-pnl {
  width: 168px;
}

.position-columns .col-start-value {
  width: 110px;
}

/* The resolved-loss table carries five columns rather than eight, so it does
   not need the eight-column floor — Market simply takes the slack. */
.position-table table.lost-columns {
  min-width: 560px;
}

/* Long market titles wrap rather than stretch the pinned columns. */
.position-columns td:first-child {
  overflow-wrap: anywhere;
}

/* P&L carries a figure and a percentage. A fixed column cannot grow for a
   large fund, so let the pair wrap onto a second line instead of spilling
   over the cell — .numeric would otherwise hold it on one line. Matched on a
   class, not a position, so reordering the columns cannot detach it. */
.position-columns .pnl-cell {
  white-space: normal;
}

/* Potential return is the decision-making figure in an open position, so it
   gets a distinct reward accent without changing the column geometry. */
.position-columns .payout-heading,
.position-columns .payout-cell {
  color: var(--gold-payout);
}

.position-columns .payout-cell {
  font-size: 13px;
  font-weight: 700;
}

th {
  background: var(--panel-head);
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 13px;
  text-align: left;
}

td {
  color: #b4b8c0;
  font-size: 12px;
  line-height: 15px;
}

th,
td {
  border-bottom: 1px solid var(--app-line);
  padding: 11px 16px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.position-table thead {
  background: var(--panel-bg);
}

.position-table th {
  box-sizing: border-box;
  height: 28px;
  /* Horizontal padding has to match the data cells' 16px, or every header
     sits offset from the column it labels — left-aligned ones 16px too far
     left, right-aligned numbers 8px too far right. Only the vertical padding
     differs, to keep the header row shorter than a data row. */
  padding: 8px 16px;
  background: var(--panel-bg);
  color: #5c616c;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 12px;
}

.position-table th:first-child {
  padding-left: 14px;
}

.position-table th:last-child {
  padding-right: 14px;
}

.position-table td:first-child {
  padding-left: 14px;
}

.position-table td:last-child {
  padding-right: 14px;
}

.mono {
  font-family: var(--font-mono);
}

.numeric {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 16px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgb(139 157 255 / 0.12);
  color: var(--color-primary);
  font-size: 10px;
  font-weight: 700;
  line-height: 12px;
  white-space: nowrap;
}

.pill-yes {
  background: rgb(110 231 183 / 0.15);
  color: var(--color-sentiment-up);
}

.pill-no {
  background: rgb(252 165 165 / 0.15);
  color: var(--color-sentiment-down);
}

.pill-neutral {
  background: var(--color-surface-hover);
  color: var(--app-muted);
}

.position-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
}

.position-section .position-table {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.position-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  gap: 16px;
  height: 35px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--app-line);
  background: var(--panel-head);
}

.position-bar-title {
  margin: 0;
  color: #b4b8c0;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.66px;
  line-height: 13px;
}

.position-meta {
  margin: 0;
  color: #8a8f99;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 15px;
  white-space: nowrap;
}

.position-meta-live {
  color: #6ee7b7;
}

.market-title {
  display: block;
  color: var(--app-fg);
  line-height: 15px;
}

.market-title-link {
  text-decoration: underline;
  text-decoration-color: rgb(180 184 192 / 0.35);
  text-underline-offset: 3px;
}

.market-title-link:hover {
  color: var(--color-primary);
  text-decoration-color: currentColor;
}

.td-issue-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--app-muted);
  font: inherit;
  text-decoration: underline;
  text-decoration-color: rgb(180 184 192 / 0.35);
  text-underline-offset: 3px;
  cursor: pointer;
}

.td-issue-button:hover {
  color: var(--color-primary);
  text-decoration-color: currentColor;
}

.td-rationale-modal {
  width: min(560px, 100%);
}

.td-rationale-copy {
  margin: 0;
  color: var(--app-fg);
  font-size: 14px;
  line-height: 21px;
  white-space: pre-wrap;
}

.market-id {
  display: block;
  margin-top: 2px;
  color: var(--app-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

.status-text {
  color: var(--app-muted);
  font-size: 11px;
  white-space: nowrap;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title {
  margin: 0;
  color: #e6e7e8;
  font-size: 14px;
  font-weight: 600;
  line-height: 17px;
}

.section-count {
  color: var(--app-muted);
  font-size: 13px;
  line-height: 16px;
  font-weight: 300;
}

/* ── agent grid ──────────────────────────────────────────────── */

.agent-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: 100%;
}

.agent-card {
  display: flex;
  min-height: 136px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 20px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
  text-align: center;
  width: auto;
  animation: none;
}

.agent-card-add {
  border-color: #3a3e47;
  border-style: dashed;
  background: transparent;
}

.avatar-large {
  display: inline-grid;
  width: 60px;
  height: 60px;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-family: var(--font-display);
  font-size: 26px;
  font-style: italic;
  font-weight: 600;
  line-height: 1;
}

.avatar-add {
  background: var(--color-surface-hover);
  color: var(--app-muted);
  font-family: var(--font-body);
  font-size: 24px;
  font-style: normal;
  font-weight: 400;
}

.agent-name {
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-display);
  font-size: 21px;
  font-style: italic;
  font-weight: 500;
  line-height: 25px;
}

.agent-role,
.agent-description {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.agent-description {
  color: #b4b8c0;
}

.agent-action {
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 500;
  line-height: 13px;
}

@media (min-width: 720px) {
  .agent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1040px) {
  .agent-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ── settings & fund-setup pages ─────────────────────────────── */
.settings-card {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  background: var(--panel-bg);
}

.settings-card.danger {
  border-color: #3a2326;
}

.settings-card-title {
  margin: 0;
  color: var(--app-fg);
  font-family: var(--font-display);
  font-size: 21px;
  font-style: italic;
  font-weight: 500;
  line-height: 26px;
}

.settings-card.danger .settings-card-title {
  color: var(--color-sentiment-down);
}

.settings-card-desc {
  margin: 3px 0 16px;
  color: var(--app-muted);
  font-size: 13px;
  line-height: 18px;
}

.settings-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
}

.settings-row:not(:first-child) {
  border-top: 1px solid var(--app-line);
}

.settings-row-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.settings-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.passkey-action-button {
  cursor: pointer;
}

.passkey-action-button svg {
  width: 17px;
  height: 17px;
  pointer-events: none;
}

.passkey-remove-button:hover {
  border-color: var(--rd);
  color: var(--rd);
}

.account-order-mode-actions {
  align-items: center;
}

.account-order-mode-actions .setup-segmented {
  width: min(420px, 100%);
}

.settings-row-title {
  margin: 0;
  color: var(--app-fg);
  font-size: 13px;
  font-weight: 500;
  line-height: 16px;
}

.settings-row-meta {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 15px;
}

.key-pill {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  min-height: 25px;
  align-items: center;
  border: 1px solid var(--app-line-strong);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  background: var(--panel-head);
  color: var(--app-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 15px;
  overflow-wrap: anywhere;
}

.wallet-settings {
  gap: 22px;
}

.wallet-settings-card {
  padding: 20px 22px;
}

.wallet-settings-card .settings-card-title {
  font-size: 22px;
  line-height: 26px;
  letter-spacing: -0.22px;
}

.wallet-settings-card .settings-card-desc {
  margin: 3px 0 16px;
  font-size: 14px;
  line-height: 22px;
}

.wallet-settings-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--app-line);
}

.wallet-settings-row:first-of-type {
  border-top: 1px solid var(--app-line);
}

.wallet-settings-row .settings-row-copy {
  gap: 4px;
}

.wallet-settings-row .settings-row-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
}

.wallet-settings-row .key-pill {
  min-height: 25px;
  padding: 5px 9px;
  background: #131417;
  font-size: 12px;
  line-height: 15px;
}

.wallet-settings-button {
  gap: 8px;
  min-height: 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 4px 12px;
  background: var(--color-surface);
  color: var(--app-fg);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.wallet-settings-button:hover {
  background: var(--color-surface-raised);
}

.wallet-settings-button-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.wallet-settings-button-danger {
  border-color: transparent;
  background: var(--color-sentiment-down);
  color: var(--color-background);
}

.wallet-settings-button-danger:hover {
  background: #ffb5b5;
}

.wallet-settings-add-row {
  display: flex;
  justify-content: flex-end;
  padding: 16px 0 0;
  border-top: 1px solid var(--app-line);
}

.wallet-settings-add-button {
  gap: 8px;
  min-height: 44px;
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 18px;
  background: var(--color-surface);
  color: var(--app-fg);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.wallet-settings-add-button:hover {
  background: var(--color-surface-raised);
}

@media (max-width: 719px) {
  .wallet-settings-row {
    grid-template-columns: 1fr;
  }

  .wallet-settings-row .settings-row-actions {
    justify-content: flex-start;
  }

  .wallet-settings-add-row {
    justify-content: stretch;
  }

  .wallet-settings-add-button {
    width: 100%;
  }
}

.setup-body {
  display: grid;
  gap: 0;
  padding: 8px 16px 0;
}

.setup-intro {
  margin: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--app-line);
  color: var(--app-muted);
  font-size: 13px;
  line-height: 18px;
}

.setup-field {
  display: grid;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--app-line);
}

.setup-field:last-child {
  border-bottom: 0;
}

.setup-label {
  margin: 0;
  color: var(--app-fg);
  font-size: 14px;
  font-weight: 700;
  line-height: 17px;
}

.setup-control {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.setup-control-wide {
  max-width: 420px;
}

.setup-input {
  width: min(360px, 100%);
  min-height: 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--color-background);
  color: var(--app-fg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
}

.setup-segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.setup-segmented-option {
  position: relative;
  min-width: 0;
}

.setup-segmented-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.setup-segmented-label {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: var(--color-background);
  color: var(--app-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  transition: border-color var(--motion-fast), background var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast);
}

.setup-segmented-input:focus-visible+.setup-segmented-label {
  outline: 2px solid rgb(139 157 255 / 0.4);
  outline-offset: 2px;
}

.setup-segmented-input:checked+.setup-segmented-label {
  border-color: transparent;
  background: var(--color-primary);
  color: #0a0a0a;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
}

.analyst-row {
  display: grid;
  gap: 10px;
  width: 100%;
}

.setup-add-agent-button {
  justify-self: start;
  align-self: center;
}

.setup-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--app-line);
  background: var(--panel-bg);
}

.button-danger {
  background: var(--color-sentiment-down);
  color: var(--color-background);
}

/* ──────────────────────────────────────────────────────────────────
   OTP / secure-action modal
   Used by shared/otp/_template_form.html.erb and friends.
   ────────────────────────────────────────────────────────────────── */

.otp-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  min-width: min(420px, 90vw);
}

.otp-shell-heading {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.otp-shell-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-foreground-200);
}

.otp-shell-sub {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--color-foreground-500);
  margin: 0;
  padding: 0 0.5rem;
}

.otp-shell-resend {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-foreground-500);
}

.otp-shell-resend-line {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
}

.otp-resend-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--color-foreground-200);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.otp-resend-button:disabled {
  color: var(--color-neutral-300);
  cursor: not-allowed;
  text-decoration: none;
}

.otp-input-wrapper {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--color-bg-500);
  border-radius: 12px;
  border: 1px solid var(--color-border, #2a2a2a);
}

.otp-input-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.otp-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 40px;
  margin-bottom: 0.75rem;
}

.otp-input-row.with-error .otp-digit {
  border-color: var(--color-sentiment-down);
  color: var(--color-sentiment-down);
}

.otp-digit {
  width: 2.75rem;
  height: 3rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--color-background);
  color: var(--color-foreground-200);
  border: 1px solid var(--color-border, #2a2a2a);
  border-radius: 8px;
  outline: none;
}

.otp-digit:focus {
  border-color: var(--color-primary-500);
  box-shadow: var(--shadow-focus);
}

.otp-paste-link {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
  color: var(--color-primary-500);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.otp-paste-button {
  min-width: 140px;
}

.otp-paste-progress {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
}

.otp-submit-row {
  display: flex;
  justify-content: flex-start;
  margin-top: 1rem;
}

.otp-submit-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.trusted-wallet-otp-modal {
  display: grid;
  gap: 1rem;
}

.trusted-wallet-otp-summary {
  border: 1px solid var(--app-line);
  border-radius: 12px;
  padding: 1rem;
  background: var(--color-bg-500);
}

.trusted-wallet-otp-summary-title,
.trusted-wallet-otp-summary-address {
  margin: 0;
  color: var(--app-fg);
}

.trusted-wallet-otp-summary-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.trusted-wallet-otp-summary-address {
  margin-top: 0.5rem;
  color: var(--app-muted);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.trusted-wallet-otp-resend {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  color: var(--app-muted);
  font-size: 0.85rem;
}

.trusted-wallet-otp-resend-action {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
}

.add-wallet-modal:has(.trusted-wallet-otp-modal) {
  width: min(502px, 100%);
}

.trusted-wallet-otp-header {
  align-items: flex-start;
  gap: 12px;
  min-height: 58px;
  padding: 16px;
  background: var(--panel-bg);
}

.trusted-wallet-otp-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.trusted-wallet-otp-eyebrow {
  margin: 0;
  color: var(--app-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.trusted-wallet-otp-header .modal-title {
  font-size: 22px;
  line-height: 27px;
}

.trusted-wallet-otp-close {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 33px;
  height: 33px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--app-fg);
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
}

.trusted-wallet-otp-close:hover {
  background: var(--color-surface-hover);
}

.trusted-wallet-otp-modal {
  display: block;
  padding: 0;
}

.trusted-wallet-otp-modal turbo-frame,
.trusted-wallet-otp-modal form {
  display: block;
  width: 100%;
}

.trusted-wallet-otp-summary {
  margin: 16px 16px 0;
  border-color: var(--app-line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: #131417;
}

.trusted-wallet-otp-summary-title {
  color: #e6e7e8;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
}

.trusted-wallet-otp-summary-address {
  margin-top: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 17px;
}

.trusted-wallet-otp-code {
  display: flex;
  justify-content: center;
  padding: 26px 16px 37px;
}

.trusted-wallet-otp-code .otp-input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.trusted-wallet-otp-code .otp-input-row {
  order: 1;
  gap: 10px;
  margin-top: 0;
}

.trusted-wallet-otp-code .otp-toolbar {
  order: 2;
  justify-content: center;
  min-height: 28px;
  margin: 16px 0 0;
}

.trusted-wallet-otp-code .otp-digit {
  width: 50px;
  height: 56px;
  border-color: var(--app-line-strong);
  border-radius: var(--radius-md);
  background: #131417;
  color: var(--color-primary);
  font-size: 36px;
  font-weight: 400;
  line-height: 50px;
}

.trusted-wallet-otp-code .otp-paste-button {
  min-width: 0;
  min-height: 28px;
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  padding: 4px 12px;
  background: var(--color-surface);
  color: var(--app-fg);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.trusted-wallet-otp-actions {
  align-items: center;
  justify-content: space-between;
  min-height: 61px;
  padding: 16px 20px 12px 18px;
  background: var(--panel-bg);
}

.trusted-wallet-otp-actions .trusted-wallet-otp-resend {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  color: var(--app-fg);
  font-size: 14px;
  line-height: 22px;
}

.trusted-wallet-otp-actions .trusted-wallet-otp-resend-action {
  gap: 4px;
}

.trusted-wallet-otp-actions .otp-resend-button {
  color: var(--color-primary);
  text-decoration: underline;
}

.trusted-wallet-otp-actions .otp-resend-button:disabled {
  color: var(--color-primary);
  cursor: not-allowed;
  opacity: 0.6;
  text-decoration: underline;
}

.trusted-wallet-otp-submit {
  min-width: 117px;
  min-height: 36px;
  padding: 9px 18px;
  color: #0a0a0a;
}

@media (max-width: 719px) {
  .trusted-wallet-otp-resend {
    flex-direction: column;
    align-items: flex-start;
  }

  .otp-submit-row .otp-submit-button {
    width: 100%;
  }

  .trusted-wallet-otp-code .otp-input-row {
    gap: 6px;
  }

  .trusted-wallet-otp-code .otp-digit {
    width: 42px;
    height: 52px;
    font-size: 32px;
  }

  .trusted-wallet-otp-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .trusted-wallet-otp-submit {
    width: 100%;
  }
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--color-border, #2a2a2a);
  border-top-color: var(--color-primary-500);
  border-radius: 50%;
  animation: otp-spin 0.8s linear infinite;
  display: inline-block;
}

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

@media (min-width:720px) {
  .settings-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .account-order-mode-row {
    grid-template-columns: minmax(0, 1fr) minmax(420px, 1fr);
  }

  .setup-field {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .analyst-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: center;
  }
}

/* ── Pagy pagination nav ─────────────────────────────────────── */
nav.pagy.series-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

nav.pagy.series-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
  cursor: pointer;
}

nav.pagy.series-nav a:not([aria-disabled="true"]):hover {
  background: var(--color-surface-hover);
  color: var(--app-fg);
  border-color: var(--app-line-strong);
}

nav.pagy.series-nav a[aria-current="page"] {
  background: var(--color-primary);
  color: var(--color-background);
  border-color: var(--color-primary);
  font-weight: 700;
  cursor: default;
}

nav.pagy.series-nav a[aria-disabled="true"] {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

nav.pagy.series-nav a[role="separator"] {
  border: 0;
  background: transparent;
  color: var(--app-dim);
  pointer-events: none;
  min-width: 20px;
}

/* ── Markets mandate summary ─────────────────────────────────── */
.mandate-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 0 20px;
}

.mandate-summary-card {
  border: 1px solid var(--app-line);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  min-width: 160px;
}

.mandate-summary-card--wide {
  flex: 1;
  min-width: 240px;
}

.mandate-summary-label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--app-dim);
  text-transform: uppercase;
}

.mandate-summary-value {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--app-fg);
}

.mandate-summary-body {
  margin: 0;
  font-size: 13px;
  color: var(--app-muted);
  line-height: 18px;
}

/* ── Shared empty states ─────────────────────────────────────── */
.empty-note {
  padding: 20px 16px;
  color: var(--app-dim);
  font-size: 13px;
}

.empty-state {
  padding: 48px 0;
  text-align: center;
  color: var(--app-dim);
}

.empty-state-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  color: var(--app-muted);
  margin: 0 0 8px;
}

.empty-state-body {
  font-size: 13px;
  margin: 0;
}

/* ── Dev warning banner ──────────────────────────────────────── */
.dev-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 20px;
  background: rgb(252 211 77 / 0.08);
  border-bottom: 1px solid rgb(252 211 77 / 0.25);
  color: var(--color-sentiment-hold);
  font-size: 13px;
  line-height: 18px;
}

.dev-banner-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.dev-tag {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgb(252 211 77 / 0.15);
  color: var(--color-sentiment-hold);
  line-height: 1.4;
}

/* ── Table utilities ─────────────────────────────────────────── */
.market-id-cell {
  font-size: 11px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-actions-cell {
  display: flex;
  gap: 6px;
}

.td-empty {
  text-align: center;
  color: var(--app-muted);
}

/* ── Text utilities ──────────────────────────────────────────── */
.text-dim {
  opacity: 0.5;
}

.text-negative {
  color: var(--color-sentiment-down);
}

.heading-negative {
  color: var(--color-sentiment-down);
}

/* ── Pagy nav wrapper ────────────────────────────────────────── */
.pagy-nav-wrapper {
  display: flex;
  justify-content: center;
  padding: 14px 16px 16px;
}

/* ── Position meta modifier ──────────────────────────────────── */
.position-meta--negative {
  color: var(--color-sentiment-down);
}

/* ── Agent / article states ──────────────────────────────────── */
.article--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Tag list ────────────────────────────────────────────────── */
.tag-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Form layout ─────────────────────────────────────────────── */
.form-group {
  margin-bottom: 24px;
}

.form-group--lg {
  margin-bottom: 32px;
}

.form-row {
  margin-bottom: 10px;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.field-label-upper {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.66px;
  color: var(--app-muted);
  text-transform: uppercase;
  margin: 0 0 12px;
}

.field-hint {
  font-size: 11px;
  color: var(--app-muted);
  margin-bottom: 6px;
}

.field-hint--inline {
  margin-bottom: 0;
  margin-left: 6px;
}

.sr-hidden {
  display: none;
}

.icon-sm {
  width: 14px;
  height: 14px;
}

/* ── Hosted agent chat ───────────────────────────────────────── */
.agent-runtime-status {
  color: var(--color-text-muted);
  font-size: 12px;
}

.agent-runtime-status--online {
  color: var(--gn);
}

.agent-runtime-status--offline {
  color: var(--rd);
}

.agent-chat-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 982px;
  min-height: 560px;
  max-height: calc(100vh - 210px);
  margin: auto;
  width: 100%;
}

/* Empty conversation: centre the hero above the composer, like the entry screen. */
.agent-chat-panel:not(:has(.agent-chat-messages > *)) {
  justify-content: center;
}

/* Session header: only an open conversation is a named room. */
.agent-chat-session {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 21px 32px;
  border-bottom: 1px solid var(--color-hairline);
  margin: 0 0 0 24px;
}

.main-area:has(.agent-chat-messages > *) .agent-chat-session {
  /* flex: none — the chat surface takes every spare pixel, the band keeps its own. */
  display: flex;
  flex: none;
}

.agent-chat-booting .agent-chat-session {
  visibility: hidden;
}

/* The mark draws its own frame, so it needs no border or padding here. */
.agent-chat-session-mark {
  flex: none;
  width: 24px;
  height: 24px;
}

.agent-chat-session-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 0 auto;
  padding: 5px 12px;
  border: 1px solid var(--color-hairline);
  border-radius: 999px;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 14px;
  letter-spacing: 0px;
  white-space: nowrap;
}

.agent-chat-session-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gn);
}

/* No provider yet, or a runtime we cannot reach: only the dot changes. */
.agent-chat-session-live--offline .agent-chat-session-live-dot {
  background: var(--rd);
}

.agent-chat-session-title {
  margin: 0;
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: 0px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-chat-hero {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 0 clamp(18px, 2.5vw, 36px) 32px;
  text-align: center;
}

.agent-chat-panel:not(:has(.agent-chat-messages > *)) .agent-chat-hero {
  display: flex;
}

/* Nothing said yet: the hero owns the space, the transcript stays out of flow. */
.agent-chat-panel:not(:has(.agent-chat-messages > *)) .agent-chat-messages {
  display: none;
}

/* Once the transcript exists the composer is pinned to the bottom of the panel
   and drops the entry-screen glow for a plain ivory-15% hairline. */
.agent-chat-panel:has(.agent-chat-messages > *) .agent-chat-composer {
  margin-top: auto;
  border-color: rgb(237 237 237 / 0.15);
  background: var(--color-input);
  box-shadow: none;
}

/* On a wide screen an open conversation fills the viewport, so the composer
   ends up at the bottom edge and only the transcript scrolls. */
@media (min-width: 1040px) {

  /* The session band takes its own height off the top, so the surface below it
     is what fills the rest of the viewport. */
  .agent-chat-shell .main-area:has(.agent-chat-messages > *) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  .agent-chat.content:has(.agent-chat-messages > *) {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    padding: 32px 0;
  }

  .agent-chat.content:has(.agent-chat-messages > *) .agent-chat-panel {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
}

.agent-chat-booting .agent-chat-hero,
.agent-chat-booting .agent-chat-suggestions {
  visibility: hidden;
}

.agent-chat-suggestions {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
}

.agent-chat-panel:not(:has(.agent-chat-messages > *)) .agent-chat-suggestions {
  display: flex;
}

.agent-chat-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--color-hairline);
  border-radius: 10px;
  background: var(--color-bg-500);
  color: var(--color-ivory);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  padding: 10px 14px;
  transition: border-color var(--motion-fast), background var(--motion-fast);
  font-weight: 600;
}

.agent-chat-suggestion svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.agent-chat-suggestion:hover,
.agent-chat-suggestion:focus-visible {
  border-color: var(--color-primary);
  background: var(--color-surface-raised);
}

.agent-chat-hero-logo {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.agent-chat-hero-title {
  margin: 0;
  color: var(--color-ivory);
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-style: italic;
  font-weight: 500;
  line-height: 56px;
  letter-spacing: normal;
}

@media (max-width: 700px) {
  .agent-chat-hero-title {
    font-size: 2.25rem;
    line-height: 2.5rem;
  }
}

.agent-chat-messages {
  --agent-chat-message-gap: 4px;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 762px;
  /* Without this the transcript refuses to shrink and slides under the composer. */
  min-height: 0;
  gap: var(--agent-chat-message-gap);
  overflow-x: hidden;
  overflow-y: auto;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding: 0 clamp(18px, 2.5vw, 36px);
  /* The jump-to-latest button is the only scroll affordance we want here. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.agent-chat-messages::-webkit-scrollbar {
  display: none;
}

.agent-chat-panel--offline-empty .agent-chat-messages {
  align-items: center;
  justify-content: center;
}

.agent-chat-panel--offline .agent-chat-composer {
  display: none;
}

.agent-chat-offline-state {
  max-width: 440px;
  text-align: center;
}

.agent-chat-offline-state h2 {
  margin: 0;
  font-size: 20px;
}

.agent-chat-offline-state p {
  margin: 10px 0 20px;
  color: var(--color-text-muted);
}

.agent-chat-offline-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.agent-chat-load-older {
  align-self: center;
  margin: 12px 0 0;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.agent-chat-load-older:hover {
  color: var(--color-text);
}

.agent-chat-jump-latest {
  align-self: center;
  position: absolute;
  bottom: 157px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-hairline);
  border-radius: 10px;
  background: var(--color-vault-3);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  padding: 0;
}

.agent-chat-jump-latest svg {
  width: 24px;
  height: 24px;
}

.agent-chat-activity {
  color: var(--color-text-muted);
  font-size: 12px;
}

.agent-chat-message--queued {
  opacity: 0.72;
}

.agent-chat-message--queued::after {
  display: block;
  margin-top: 4px;
  content: "Queued after current response";
  font-size: 11px;
}

.agent-chat-model {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 5px 4px;
  font-weight: 400;
  line-height: 19px;
}

.agent-chat-model-provider {
  color: var(--color-ivory);
}

.agent-chat-model-name {
  color: var(--color-text-muted);
}

.agent-chat-model-chevron,
.agent-chat-model-icon {
  flex: 0 0 auto;
  align-self: center;
  width: 16px;
  height: 16px;
}

/* No provider yet: the chip becomes the call to action and the bubble above
   explains why the composer will not answer. */
/* The slot deliberately stays unpositioned: the bubble measures itself against
   the whole actions row, so it can never spill past the composer edge. */
.agent-chat-model-slot {
  display: inline-flex;
}

/* New session sits alone on the left of the composer's action row. */
.agent-chat-icon-button.agent-chat-new-session {
  margin-right: auto;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

/* The glyph is drawn inset in its own 32px box, so the icon fills the button. */
.agent-chat-icon-button.agent-chat-new-session .button-icon {
  width: 32px;
  height: 32px;
}

.agent-chat-icon-button.agent-chat-new-session:hover:not(:disabled),
.agent-chat-icon-button.agent-chat-new-session:focus-visible:not(:disabled) {
  background: var(--color-surface-raised);
  color: var(--color-text);
}

.agent-chat-icon-button.agent-chat-new-session:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.agent-chat-model--disconnected,
.agent-chat-model--disconnected .agent-chat-model-name {
  color: var(--amber-hold);
}

/* Anchored to the chip's right edge so the bubble grows inwards and stays
   inside the composer instead of spilling past it. */
/* Right edge stops with the send button; the tail drops onto the middle of the
   "Connect agent" chip. */
.agent-chat-model-tip {
  /* send button (36px) + gap (8px) + half the chip, less half the tail */
  --agent-chat-tip-tail: 96px;
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  z-index: 2;
  margin: 0;
  width: max-content;
  max-width: 204px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #2E3A61;
  color: #8B9DFF;
  font-size: 14px;
  line-height: 140%;
  text-align: center;
}

.agent-chat-model-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  right: var(--agent-chat-tip-tail);
  border: 7px solid transparent;
  border-bottom: 0;
  border-top-color: #2E3A61;
}

/* The glyphs inherit currentColor, so hover has to lift them with the label. */
.agent-chat-model:hover .agent-chat-model-name,
.agent-chat-model:hover .agent-chat-model-icon,
.agent-chat-model:hover .agent-chat-model-chevron {
  color: var(--color-ivory);
}

.agent-chat-message {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.agent-chat-message--user {
  align-self: flex-end;
  max-width: min(620px, 60%);
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--color-vault-3);
  color: var(--color-ivory);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.agent-chat-message--pending {
  opacity: 0.65;
}

.agent-chat-message--failed {
  outline: 1px solid var(--rd);
}

.agent-chat-message--failed::after {
  display: block;
  margin-top: 4px;
  color: var(--rd);
  content: "Not sent — press Send to retry";
  font-size: 11px;
}

.agent-chat-scheduled-run {
  align-self: stretch;
  padding: 13px 15px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--pr);
  border-radius: 10px;
  background: var(--color-background);
}

.agent-chat-scheduled-run-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.agent-chat-scheduled-run-heading strong {
  color: var(--pr);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.agent-chat-scheduled-run-heading span {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-chat-scheduled-run-timing,
.agent-chat-scheduled-run-status,
.agent-chat-scheduled-run details {
  margin: 5px 0 0;
  color: var(--color-text-muted);
  font-size: 12px;
}

.agent-chat-scheduled-run-status {
  flex: 0 0 auto;
  margin-left: auto;
}

.agent-chat-scheduled-run-prompt {
  margin: 8px 0 0;
  color: var(--color-text);
  white-space: pre-wrap;
}

.agent-chat-scheduled-run details p {
  margin: 6px 0 0;
}

.agent-chat-scheduled-run summary {
  cursor: pointer;
}

.agent-chat-scheduled-run-copy {
  border: 0;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.agent-chat-scheduled-run[data-state="completed"] .agent-chat-scheduled-run-status {
  color: var(--gn);
}

.agent-chat-scheduled-run[data-state="failed"] {
  border-left-color: var(--rd);
}

.agent-chat-scheduled-run[data-state="failed"] .agent-chat-scheduled-run-status {
  color: var(--rd);
}

.agent-chat-message--assistant {
  align-self: flex-start;
  width: 100%;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  white-space: normal;
}

.agent-chat-message--cli-result,
.agent-chat-message--debug-event,
.agent-chat-message--tool-routing {
  min-width: 0;
  width: 100%;
}

.agent-chat-message--cli-result summary,
.agent-chat-message--debug-event summary,
.agent-chat-message--tool-routing summary {
  cursor: pointer;
  color: var(--color-text);
  font-weight: 600;
}

.agent-chat-message--cli-result pre,
.agent-chat-message--debug-event pre,
.agent-chat-message--tool-routing pre {
  box-sizing: border-box;
  max-height: 420px;
  max-width: 100%;
  margin: 10px 0 0;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
  white-space: pre;
}

.agent-chat-message--tool-routing pre {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.agent-chat-message--assistant+.agent-chat-message--assistant {
  margin-top: -6px;
}

.agent-chat-message--assistant+.agent-chat-message--user {
  margin-top: 10px;
}

.agent-chat-message--loading {
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--color-background) 25%, var(--color-surface-muted, #eef0f5) 50%, var(--color-background) 75%);
  background-size: 200% 100%;
  animation: agent-chat-history-loading 1.4s ease-in-out infinite;
}

.agent-chat-message--loading-user {
  align-self: flex-end;
  width: min(280px, 45%);
}

.agent-chat-message--loading-assistant {
  width: min(460px, 78%);
}

.agent-chat-working-cue {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.agent-chat-working-spinner {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  /* Eight spokes, so step the rotation to land on each one. */
  animation: agent-chat-working-spin 1.6s steps(8) infinite;
}

.agent-chat-streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  background: var(--color-primary);
  vertical-align: -0.12em;
  animation: agent-chat-cursor 0.8s steps(1) infinite;
}

@keyframes agent-chat-working-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes agent-chat-cursor {

  0%,
  45% {
    opacity: 1;
  }

  46%,
  100% {
    opacity: 0;
  }
}

@keyframes agent-chat-history-loading {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {

  .agent-chat-working-spinner,
  .agent-chat-streaming-cursor,
  .agent-chat-message--loading {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

.agent-chat-message--assistant> :first-child {
  margin-top: 0;
}

.agent-chat-message--assistant> :last-child {
  margin-bottom: 0;
}

.agent-chat-message--assistant h1,
.agent-chat-message--assistant h2,
.agent-chat-message--assistant h3,
.agent-chat-message--assistant h4 {
  margin: 1em 0 0.45em;
  line-height: 26px;
  font-size: 18px;
  font-weight: 600;
}

.agent-chat-message--assistant ul,
.agent-chat-message--assistant ol {
  margin: 0.65em 0;
  padding-left: 1.5em;
}

.agent-chat-message--assistant p,
.agent-chat-message--assistant blockquote,
.agent-chat-message--assistant pre {
  margin: 8px 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
}

.agent-chat-message--assistant blockquote {
  padding-left: 0.9em;
  border-left: 3px solid var(--color-border);
  color: var(--color-text-muted);
}

.agent-chat-message--assistant code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.agent-chat-message--assistant :not(pre)>code {
  padding: 0.1em 0.32em;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-background);
  white-space: break-spaces;
}

.agent-chat-message--assistant a {
  color: var(--color-primary);
  text-underline-offset: 2px;
}

.agent-chat-message--assistant pre {
  box-sizing: border-box;
  max-width: 100%;
  overflow-x: auto;
  padding: 1em;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
  white-space: pre;
}

.agent-chat-message--assistant table {
  width: 100%;
  margin: 0.8em 0;
  border-collapse: collapse;
  font-size: 0.95em;
}

.agent-chat-message--assistant th,
.agent-chat-message--assistant td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.agent-chat-message--assistant th {
  color: var(--color-text-muted);
  font-size: 0.85em;
  font-weight: 600;
}

.agent-chat-answer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

/* Copy / Ask again stay out of the way until the answer is hovered. Pointer
   devices only, so touch keeps them permanently reachable. */
@media (hover: hover) {
  .agent-chat-answer-actions {
    opacity: 0;
    transition: opacity 150ms ease;
  }

  .agent-chat-message--assistant:hover .agent-chat-answer-actions,
  .agent-chat-answer-actions:focus-within {
    opacity: 1;
  }

  /* Same treatment for the whole sent-message row: timestamp and copy come out
     together on hover. */
  .agent-chat-user-actions .agent-chat-icon-action,
  .agent-chat-user-actions .agent-chat-timestamp {
    opacity: 0;
    transition: opacity 150ms ease;
  }

  .agent-chat-message--user:hover+.agent-chat-user-actions .agent-chat-icon-action,
  .agent-chat-message--user:hover+.agent-chat-user-actions .agent-chat-timestamp,
  .agent-chat-user-actions:hover .agent-chat-icon-action,
  .agent-chat-user-actions:hover .agent-chat-timestamp,
  .agent-chat-user-actions .agent-chat-icon-action:focus-visible,
  .agent-chat-user-actions:focus-within .agent-chat-timestamp {
    opacity: 1;
  }
}

/* Sent-message row: timestamp then copy, aligned under the user bubble. The
   negative margin cancels the transcript gap so the row hugs its message. */
.agent-chat-user-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-height: 28px;
}

.agent-chat-user-actions .agent-chat-timestamp {
  margin-right: 6px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0;
}

.agent-chat-message--pending+.agent-chat-user-actions,
.agent-chat-message--queued+.agent-chat-user-actions {
  visibility: hidden;
}

.agent-chat-copy,
.agent-chat-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}

.agent-chat-icon-action svg,
.agent-chat-copy svg {
  width: 28px;
  height: 28px;
}

.agent-chat-icon-action:hover,
.agent-chat-icon-action:focus-visible {
  background: var(--color-surface-raised);
}

.agent-chat-icon-action.is-copied svg {
  opacity: 0.4;
}

.agent-chat-icon-action:disabled {
  cursor: default;
}

.agent-chat-icon-action:disabled:hover {
  background: transparent;
}

.agent-chat-copy:hover,
.agent-chat-copy:focus-visible {
  background: var(--color-background);
  color: var(--color-text);
}


.agent-chat-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgb(139 157 255 / 0.5);
  border-radius: 16px;
  background: var(--color-input);
  box-shadow: 0 6px 75px 0 rgb(139 157 255 / 0.3);
  padding: 12px;
  margin-left: auto;
  margin-right: auto;
  max-width: 752px;
  width: 100%;
}

.agent-chat-composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 160px;
  resize: none;
  overflow-y: auto;
  border: 0;
  background: transparent;
  color: var(--color-ivory);
  padding: 8px;
  font: inherit;
  line-height: 20px;
  font-size: 14px;
  font-weight: 400;
}

.agent-chat-composer textarea:focus {
  outline: none;
}

.agent-chat-composer textarea::placeholder {
  color: var(--color-text-muted);
}

.agent-chat-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
}

.agent-chat-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
}

.agent-chat-icon-button .button-icon {
  width: 18px;
  height: 18px;
}

/* Compound selector: .agent-chat-icon-button sets 36px later in the file. */
.agent-chat-icon-button.agent-chat-send {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 10px;
  background: var(--color-primary);
  cursor: pointer;
}

.agent-chat-send:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.agent-chat-send .button-icon {
  width: 20px;
  height: 20px;
}

/* Stop takes over the send slot from submit until the answer settles, so the
   composer only ever offers the action that applies. Styling stays the
   secondary-button look it always had. */
.agent-chat-abort {
  display: none;
}

.agent-chat--awaiting .agent-chat-abort {
  display: inline-flex;
}

.agent-chat--awaiting .agent-chat-send {
  display: none;
}

@media (max-width: 1039px) {

  html.agent-chat-page,
  body.agent-chat-page {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body.agent-chat-page {
    position: fixed;
    inset: 0;
    width: 100%;
  }

  .agent-chat-shell {
    position: fixed;
    top: var(--agent-chat-viewport-top, 0px);
    right: 0;
    left: 0;
    height: var(--agent-chat-viewport-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }

  .agent-chat-shell .main-area {
    display: flex;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  .agent-chat-shell .mobile-bar,
  .agent-chat-shell .agent-chat-mobile-setup {
    position: absolute;
  }

  .agent-chat.content {
    flex: 1 1 auto;
    min-height: 0;
    max-width: 100%;
    gap: 0;
    padding: 16px;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .agent-chat-panel {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  /* The mobile bar already names the screen; a second header would eat the
     transcript's space. */
  .main-area:has(.agent-chat-messages > *) .agent-chat-session {
    display: none;
  }

  .agent-chat-messages {
    --agent-chat-message-gap: 4px;
    width: 100%;
    min-height: 0;
    padding: 0;
    overscroll-behavior: contain;
  }

  .agent-chat-message--user {
    max-width: 92%;
  }

  .agent-chat-composer {
    gap: 8px;
    width: 100%;
    margin: auto;
    padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  }

  .agent-chat-jump-latest {
    bottom: 157px;
  }

  .agent-chat-message--cli-result pre,
  .agent-chat-message--debug-event pre,
  .agent-chat-message--tool-routing pre {
    max-width: 100%;
    padding: 12px;
    font-size: 12px;
  }

  .agent-chat-message--tool-routing pre {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
  }

  .agent-chat-message--assistant table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
}