:root {
  /* ── Mochi palette (from DESIGN-v1.md) ─────────── */
  --coral:       #E8635C;   /* Primary brand color */
  --coral-light: #EF8880;   /* Lighter coral — gradients, hover */
  --coral-dark:  #C94A44;   /* Darker coral — button hover, active */
  --coral-soft:  #FDF0EF;   /* Very soft pink — light fills */
  --coral-mid:   #F5C5C3;   /* Mid-tone pink — borders, dividers */
  --green:       #4CAF82;   /* Success */
  --purple:      #9B7FD4;   /* Builder/maker accent */

  /* Text: warm brown family — never pure black */
  --dark:        #2D1810;   /* Primary text */
  --dark-mid:    #5C3828;   /* Secondary text */
  --mid:         #A07060;   /* Muted text */
  --light-text:  #C4957F;   /* Placeholders, footnotes */

  /* Legacy aliases (keep tailwind & components working) */
  --cream:       #FEF5F4;
  --cream-warm:  #FFFFFF;
  --ink:         var(--dark);
  --ink-light:   var(--dark-mid);
  --ink-faint:   var(--mid);
  --coral-deep:  var(--coral);
  --coral-glow:  var(--coral-soft);
  --teal:        var(--green);
  --teal-light:  #E8F8F0;
  --blush:       var(--coral-mid);
  --gold:        #F9D56E;

  /* ── Mapped to existing variable contracts ──── */
  --bg:          var(--cream);
  --bg-sidebar:  #FFFFFF;
  --bg-content:  var(--cream);
  --bg-card:     #FFFFFF;
  --bg-hover:    rgba(232, 99, 92, 0.06);
  --bg-active:   rgba(232, 99, 92, 0.10);
  --border:      var(--coral-mid);
  --border-strong: rgba(232, 99, 92, 0.25);
  --text:        var(--dark);
  --text-muted:  var(--dark-mid);
  --text-dim:    var(--mid);
  --card-label-bright: var(--dark);
  --accent:      var(--coral);
  --accent-bg:   var(--coral-soft);
  --accent-dim:  rgba(232, 99, 92, 0.25);
  --accent-link: var(--coral);
  --orange:      #d98a58;
  --comment:     var(--mid);
  --keyword:     var(--coral);
  --string:      var(--green);
  --number:      #4a90d9;
  --panel-bg-contrast:     rgba(232, 99, 92, 0.02);
  --panel-border-contrast: var(--coral-mid);
  --field-bg-contrast:     #FFFFFF;
  --field-border-contrast: var(--coral-mid);

  /* ── Semantic theme tokens ────────────────────── */
  --text-bright: var(--dark);
  --overlay:     rgba(45, 24, 16, 0.5);

  /* ── Shadow scale (coral-tinted, never gray) ─── */
  --shadow-sm:  0 1px 3px rgba(232, 99, 92, 0.08);
  --shadow-md:  0 4px 12px rgba(232, 99, 92, 0.12);
  --shadow-lg:  0 8px 24px rgba(232, 99, 92, 0.16);
  --shadow-xl:  0 12px 36px rgba(232, 99, 92, 0.20);

  /* ── Transition timing ─────────────────────── */
  --transition-fast:   150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow:   300ms ease;

  /* Status: error */
  --status-error:        #E53E3E;
  --status-error-muted:  #E8635C;
  --status-error-bg:     #FFF5F5;
  --status-error-border: var(--coral-mid);

  /* Status: warning */
  --status-warning:        #D97706;
  --status-warning-muted:  #f59e0b;
  --status-warning-bg:     #FFFBEB;
  --status-warning-border: #fde68a;

  /* Status: success */
  --status-success:        #4CAF82;
  --status-success-muted:  #5cc99a;
  --status-success-bg:     #E8F8F0;
  --status-success-border: #bbf7d0;

  /* Status: info */
  --status-info:        #0891b2;
  --status-info-muted:  var(--green);
  --status-info-bg:     #E8F8F0;
  --status-info-border: #a5f3fc;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito Sans', sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Headings use Nunito (branded) */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Nunito', sans-serif;
}

/* Remove dark grid texture */
body::before {
  display: none;
}

/* ── Card / section label ──────────────────────── */
.card-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.card-label-bright {
  color: var(--card-label-bright);
}

.ac-small-heading {
  font-family: 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--coral);
}

/* ── History list ──────────────────────────────── */
.ac-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ac-history-list.ac-history-list-tight {
  gap: 0;
}

.ac-history-item {
  border: 1.5px solid var(--coral-mid);
  border-radius: 20px;
  background: #FFFFFF;
  box-shadow: 0 4px 16px rgba(232, 99, 92, 0.07);
}

.ac-history-item.ac-history-item-flat {
  border: 0;
  border-bottom: 1px solid var(--coral-mid);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.snippet-collapse-fade {
  background: linear-gradient(to bottom, transparent 0%, rgba(255, 255, 255, 0.9) 70%);
}

.ac-surface-inset {
  border: 1.5px solid var(--coral-mid);
  border-radius: 20px;
  background: #FFFFFF;
  box-shadow: 0 4px 16px rgba(232, 99, 92, 0.07);
}

.ac-history-summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  color: var(--dark);
}

.ac-history-summary::-webkit-details-marker {
  display: none;
}

.ac-history-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ac-history-toggle {
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.ac-history-item[open] > .ac-history-summary .ac-history-toggle {
  transform: rotate(90deg);
  color: var(--dark);
}

.ac-history-body {
  margin: 4px 16px 16px;
  padding-top: 8px;
  border-top: 1px solid var(--coral-mid);
}

.bg-surface {
  background: #FFFFFF !important;
  border-color: var(--coral-mid) !important;
}

.bg-modal {
  background: #FFFFFF !important;
  border-color: var(--coral-mid) !important;
}

.border-border {
  border-color: var(--coral-mid) !important;
}

.ac-tip-link {
  color: var(--coral);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
}

.ac-tip-link:hover {
  color: var(--coral-dark);
}

/* ── Field styles ──────────────────────────────── */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
  background: var(--field-bg-contrast);
  border: 1.5px solid var(--coral-mid);
  border-radius: 12px;
  font-family: 'Nunito Sans', sans-serif;
  color: var(--dark);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
select:focus,
textarea:focus {
  border-color: var(--coral);
  outline: none;
  box-shadow: 0 0 0 3px rgba(232, 99, 92, 0.12);
}

::placeholder { color: var(--light-text) !important; opacity: 1 !important; }
::-webkit-input-placeholder { color: var(--light-text) !important; }
::-moz-placeholder { color: var(--light-text) !important; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(232, 99, 92, 0.15); border-radius: 3px; }

.scrollbar-hidden {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hidden::-webkit-scrollbar {
  display: none;
}

/* ── Scope buttons ─────────────────────────────── */
.scope-btn {
  background: #FFFFFF;
  color: var(--mid);
  border: 1.5px solid var(--coral-mid);
  transition: all 0.2s;
  border-radius: 100px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
}
.scope-btn:hover { border-color: var(--coral-light); color: var(--dark-mid); }
.scope-btn-read.active {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: var(--coral);
}
.scope-btn-write.active {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: var(--coral);
}

/* ── Primary button (coral) ────────────────────── */
.ac-btn-primary,
.ac-btn-cyan {
  border: none;
  background: var(--coral);
  color: #FFFFFF;
  border-radius: 100px;
  box-shadow: 0 4px 16px rgba(232, 99, 92, 0.3);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.ac-btn-primary:hover:not(:disabled),
.ac-btn-cyan:hover:not(:disabled) {
  background: var(--coral-dark);
  box-shadow: 0 8px 28px rgba(232, 99, 92, 0.28);
  transform: translateY(-1px);
}

.ac-btn-primary:active:not(:disabled),
.ac-btn-cyan:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(232, 99, 92, 0.3);
}

.ac-btn-primary:disabled,
.ac-btn-cyan:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ac-btn-cyan-ghost {
  border: 1.5px solid var(--coral-mid);
  color: var(--coral);
  background: var(--coral-soft);
  border-radius: 100px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  transition: all 0.2s ease;
}

.ac-btn-cyan-ghost:hover {
  background: var(--coral);
  color: #FFFFFF;
  border-color: var(--coral);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(232, 99, 92, 0.2);
}

.ac-path-card {
  border: 1.5px solid var(--coral-mid);
  background: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(232, 99, 92, 0.07);
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.25s ease;
}

.ac-path-card:hover {
  border-color: var(--coral);
  box-shadow: 0 8px 32px rgba(232, 99, 92, 0.13);
  transform: translateY(-3px);
}

.ac-path-card:hover .ac-path-icon {
  color: var(--coral);
  border-color: var(--coral);
  background: var(--coral-soft);
}

.ac-path-card:hover .ac-path-title {
  color: var(--dark);
}

.ac-path-card:hover .ac-path-desc {
  color: var(--dark-mid);
}

.ac-path-icon {
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.ac-btn-secondary {
  border: 1.5px solid var(--coral-mid);
  color: var(--dark);
  background: #FFFFFF;
  border-radius: 100px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

.ac-btn-secondary:hover:not(:disabled) {
  border-color: var(--coral-light);
  background: var(--coral-soft);
}

.ac-btn-secondary:active:not(:disabled) {
  transform: translateY(1px);
}

.ac-btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ac-btn-ghost {
  border: none;
  color: var(--mid);
  background: transparent;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  transition: color 0.2s ease;
}

.ac-btn-ghost:hover:not(:disabled) {
  color: var(--dark);
}

.ac-btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ac-btn-danger {
  border: 1.5px solid rgba(229, 62, 62, 0.3);
  background: #FFF5F5;
  color: #E53E3E;
  border-radius: 100px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

.ac-btn-danger:hover:not(:disabled) {
  border-color: rgba(229, 62, 62, 0.5);
  background: #fee2e2;
}

.ac-btn-danger:active:not(:disabled) {
  transform: translateY(1px);
}

.ac-btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ac-btn-green {
  border: none;
  background: var(--green);
  color: #FFFFFF;
  border-radius: 100px;
  box-shadow: 0 4px 16px rgba(76, 175, 130, 0.3);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.ac-btn-green:hover:not(:disabled) {
  background: #3d9c70;
  box-shadow: 0 8px 28px rgba(76, 175, 130, 0.35);
  transform: translateY(-1px);
}

.ac-btn-green:active:not(:disabled) {
  transform: translateY(1px);
}

/* ── Toggle ────────────────────────────────────── */
.ac-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.ac-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ac-toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  border: 1.5px solid var(--coral-mid);
  background: var(--coral-soft);
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.ac-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--mid);
  transition:
    transform 0.2s ease,
    background-color 0.2s ease;
}

.ac-toggle-label {
  font-size: 13px;
  color: var(--dark);
}

.ac-toggle-input:checked + .ac-toggle-track {
  border-color: var(--coral);
  background: var(--coral-soft);
}

.ac-toggle-input:checked + .ac-toggle-track .ac-toggle-thumb {
  transform: translateX(14px);
  background: var(--coral);
}

.ac-toggle-input:focus-visible + .ac-toggle-track {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

/* ── Global focus-visible (see bottom of file for improved version) ── */

.ac-toggle-input:disabled + .ac-toggle-track {
  opacity: 0.55;
}

.ac-toggle-input:disabled + .ac-toggle-track + .ac-toggle-label {
  opacity: 0.6;
}

/* ── Status dots ───────────────────────────────── */
@keyframes acStatusDotPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(76, 175, 130, 0.2);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 4px rgba(76, 175, 130, 0.1);
  }
}

@keyframes acStatusDotPulseInfo {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(76, 175, 130, 0.2);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 4px rgba(76, 175, 130, 0.1);
  }
}

@keyframes acStepPillPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(232, 99, 92, 0.25);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(232, 99, 92, 0.12);
  }
}

.ac-step-pill-pulse {
  animation: acStepPillPulse 2.6s ease-in-out infinite;
}

.ac-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.ac-status-dot--healthy {
  background: var(--green);
  animation: acStatusDotPulse 2.6s ease-in-out infinite;
}

.ac-status-dot--info {
  background: var(--green);
  animation: acStatusDotPulseInfo 2.6s ease-in-out infinite;
}

.ac-status-dot--healthy-offset {
  animation-delay: 0.95s;
}

/* ── Segmented control ─────────────────────────── */
.ac-segmented-control {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--coral-mid);
  border-radius: 100px;
  overflow: hidden;
  background: #FFFFFF;
  height: 32px;
}

.ac-segmented-control-full {
  display: flex;
  width: 100%;
}

.ac-segmented-control-button {
  border: 0;
  background: transparent;
  color: var(--mid);
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  height: 100%;
  line-height: 1;
  padding: 0 16px;
  cursor: pointer;
  border-radius: 100px;
  transition: color 0.2s, background 0.2s;
}

.ac-segmented-control-full .ac-segmented-control-button {
  flex: 1 1 0%;
}

.ac-segmented-control > .inline-flex {
  align-self: stretch;
  display: flex;
}

.ac-segmented-control-full > .inline-flex {
  flex: 1 1 0%;
}

.ac-segmented-control-lg {
  height: 40px;
  border-radius: 100px;
}

.ac-segmented-control-lg .ac-segmented-control-button {
  font-size: 15px;
  padding: 0 20px;
}

.ac-segmented-control-button:hover {
  color: var(--dark);
  background: var(--coral-soft);
}

.ac-segmented-control-button.active {
  color: var(--coral);
  background: var(--coral-soft);
  font-weight: 800;
}

.ac-segmented-control-dark {
  background: var(--coral-soft);
}

/* ── PopActions ────────────────────────────────── */
.ac-pop-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
}

.ac-pop-actions-hidden {
  visibility: hidden;
  pointer-events: none;
}

.ac-pop-actions-in > * {
  animation: acPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ac-pop-actions-in > *:nth-child(2) {
  animation-delay: 0.06s;
}

.ac-pop-actions-in .ac-btn-cyan {
  animation: acPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) 0.06s both;
}

.ac-pop-actions-out > * {
  animation: acPopOut 0.18s ease-in both;
}

.ac-pop-actions-out > *:first-child {
  animation-delay: 0.03s;
}

.ac-pop-actions > button:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

@keyframes acPopIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes acPopOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.85); }
}

/* ── Spinner ───────────────────────────────────── */
@keyframes acSpinnerOrbit {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.ac-spinner {
  animation: acSpinnerOrbit 1s cubic-bezier(0.3, 0.2, 0.7, 0.8) infinite;
  transform-origin: center;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .ac-spinner {
    animation-duration: 1.8s;
    animation-timing-function: linear;
  }
}

/* ── Watchdog terminal ─────────────────────────── */
.watchdog-logs-panel {
  min-height: 160px;
  max-height: 80vh;
  resize: vertical;
}

.watchdog-terminal-host {
  position: relative;
}

.watchdog-terminal-host .xterm {
  height: 100%;
  letter-spacing: 0;
  font-kerning: none;
}

.watchdog-terminal-host .xterm-viewport {
  overflow-y: auto !important;
}

/* ── Modal animation ─────────────────────────── */
@keyframes acModalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes acModalFadeOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
}

@keyframes acModalOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ac-modal-overlay {
  animation: acModalOverlayIn var(--transition-normal) both;
}

.ac-modal-panel {
  animation: acModalFadeIn var(--transition-normal) cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Toast animation ─────────────────────────── */
@keyframes acToastSlideIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes acToastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}

.ac-toast-enter {
  animation: acToastSlideIn var(--transition-normal) cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ac-toast-exit {
  animation: acToastSlideOut var(--transition-fast) ease-in both;
}

.ac-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}

.ac-toast-dismiss {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  margin-left: auto;
  padding: 0;
}

.ac-toast-dismiss:hover {
  opacity: 1;
}

.ac-toast-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

/* ── Button active feedback ──────────────────── */
.ac-btn-secondary:active:not(:disabled),
.ac-btn-ghost:active:not(:disabled),
.ac-btn-cyan-ghost:active:not(:disabled) {
  transform: scale(0.97);
}

/* ── Empty state ─────────────────────────────── */
.ac-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
}

.ac-empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--coral-mid);
  margin-bottom: 4px;
}

.ac-empty-state-title {
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--dark-mid);
  margin: 0;
}

.ac-empty-state-desc {
  font-size: 13px;
  color: var(--mid);
  max-width: 320px;
  line-height: 1.5;
  margin: 0;
}

.ac-empty-state-cta {
  margin-top: 8px;
}

/* ── Sidebar chevron transition ──────────────── */
.sidebar-collapse-chevron {
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-collapse-chevron--open {
  transform: rotate(90deg);
}

/* ── Focus-visible (improved) ────────────────── */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
select:focus-visible {
  outline: 2.5px solid var(--coral);
  outline-offset: 2px;
}

/* ── Global prefers-reduced-motion ───────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
