/* ============================================================
   Sites Agent — admin UI
   Desktop-focused. Dark theme by default; light theme via
   html[data-theme="light"] (stamped by an inline head script
   before first paint, toggled from the header).
   Tokens first; components grouped by view; state selectors
   ([data-state], [data-status], .active/.done/.failed…) are
   driven by app.js — keep their names stable.
   ============================================================ */

:root {
  /* surfaces */
  --bg: #0b0d10;
  --bg-raised: #101318;
  --panel: #14181e;
  --raised: #1a1f27;
  --overlay: #20262f;
  --border: #262c36;
  --border-soft: #1f242d;
  --border-strong: #333b47;

  /* text */
  --text: #e8ecf2;
  --text-dim: #b9c1cc;
  --muted: #848e9c;
  --faint: #5c6674;

  /* accent */
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-strong: #14b8a6;
  --accent-dim: rgba(45, 212, 191, 0.12);
  --accent-glow: rgba(45, 212, 191, 0.35);
  --on-accent: #04211d;

  /* semantic */
  --danger: #f2707a;
  --danger-dim: rgba(242, 112, 122, 0.12);
  --ok: #7fd99a;
  --ok-dim: rgba(127, 217, 154, 0.12);
  --warn: #e6c07b;
  --warn-dim: rgba(230, 192, 123, 0.12);
  --info: #7fb7f2;
  --info-dim: rgba(127, 183, 242, 0.12);

  /* type */
  --sans: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-xs: 0.72rem;
  --fs-sm: 0.8rem;
  --fs-base: 0.875rem;
  --fs-md: 0.95rem;
  --fs-lg: 1.15rem;
  --fs-xl: 1.5rem;

  /* geometry */
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --shell-h: 60px;
  --content-max: 1440px;

  /* effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
  --ring: 0 0 0 3px rgba(45, 212, 191, 0.22);
  --ease: 150ms cubic-bezier(0.4, 0, 0.2, 1);

  /* theme-dependent one-offs */
  --page-glow: rgba(45, 212, 191, 0.05);
  --login-glow: rgba(45, 212, 191, 0.07);
  --shell-bg: rgba(11, 13, 16, 0.85);
  --backdrop: rgba(5, 7, 9, 0.75);
  --selection: rgba(45, 212, 191, 0.28);

  color-scheme: dark;
}

:root[data-theme="light"] {
  /* surfaces */
  --bg: #f2f4f8;
  --bg-raised: #eaedf2;
  --panel: #ffffff;
  --raised: #e3e8ee;
  --overlay: #ffffff;
  --border: #d3dae2;
  --border-soft: #e1e6ec;
  --border-strong: #b7c1cc;

  /* text */
  --text: #1a222c;
  --text-dim: #3c4855;
  --muted: #5d6975;
  --faint: #8b96a3;

  /* accent */
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-strong: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.1);
  --accent-glow: rgba(13, 148, 136, 0.3);
  --on-accent: #ffffff;

  /* semantic */
  --danger: #c13845;
  --danger-dim: rgba(193, 56, 69, 0.1);
  --ok: #1a7f4e;
  --ok-dim: rgba(26, 127, 78, 0.1);
  --warn: #8a6a14;
  --warn-dim: rgba(138, 106, 20, 0.12);
  --info: #1d6fc2;
  --info-dim: rgba(29, 111, 194, 0.1);

  /* effects */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.2);
  --ring: 0 0 0 3px rgba(13, 148, 136, 0.22);

  /* theme-dependent one-offs */
  --page-glow: rgba(13, 148, 136, 0.06);
  --login-glow: rgba(13, 148, 136, 0.08);
  --shell-bg: rgba(245, 247, 250, 0.85);
  --backdrop: rgba(15, 23, 42, 0.4);
  --selection: rgba(13, 148, 136, 0.22);

  color-scheme: light;
}

/* ── Reset / base ── */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 75% -10%, var(--page-glow), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.5;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.015em;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: var(--fs-sm);
}

.tiny {
  font-size: var(--fs-xs);
}

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

.spacer {
  flex: 1;
}

::selection {
  background: var(--selection);
}

/* Scrollbars (WebKit + Firefox) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Header shell ── */

.shell {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--shell-h);
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border-soft);
  background: var(--shell-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.shell-left {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  min-width: 0;
}

.shell-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 0 12px var(--accent-glow);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-mark {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: var(--fs-md);
}

.brand-sub {
  color: var(--faint);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-sm);
  padding: 0.4rem 1.1rem;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--ease), background var(--ease);
}

.nav-tab:hover {
  color: var(--text);
}

.nav-tab.active {
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* status chips */

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-raised);
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  max-width: 15rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.status-chip {
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease);
}

button.status-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-dim);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}

.status-dot.lg {
  width: 10px;
  height: 10px;
}

[data-state="ok"] .status-dot {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(127, 217, 154, 0.5);
}

[data-state="ok"] {
  color: var(--text-dim);
}

[data-state="off"] .status-dot {
  background: var(--warn);
}

[data-state="bad"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(242, 112, 122, 0.5);
}

.env-chip {
  letter-spacing: 0.08em;
  font-weight: 700;
}

.env-chip[data-env="production"] {
  color: var(--danger);
  border-color: rgba(242, 112, 122, 0.35);
  background: var(--danger-dim);
}

.env-chip[data-env="development"] {
  color: var(--info);
  border-color: rgba(127, 183, 242, 0.3);
  background: var(--info-dim);
}

.env-chip[data-env="testing"] {
  color: var(--warn);
  border-color: rgba(230, 192, 123, 0.3);
  background: var(--warn-dim);
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  padding: 0.5rem 1.05rem;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease),
    color var(--ease), transform var(--ease), box-shadow var(--ease);
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(45, 212, 191, 0.25);
}

.btn.primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--raised);
  color: var(--text);
}

.btn.sm {
  padding: 0.34rem 0.75rem;
  font-size: var(--fs-xs);
}

.btn.icon {
  padding: 0.34rem 0.55rem;
  font-size: 0.95rem;
  line-height: 1;
}

.btn.lg {
  padding: 0.65rem 1.5rem;
  font-size: var(--fs-base);
}

.btn.full {
  width: 100%;
}

.link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.link.sm {
  font-size: var(--fs-xs);
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 0.6rem 1.1rem;
  border-radius: var(--r-md);
  background: var(--overlay);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  max-width: min(80vw, 560px);
}

.toast.ok {
  border-color: rgba(127, 217, 154, 0.4);
}

.toast.error {
  border-color: rgba(242, 112, 122, 0.5);
  color: var(--danger);
}

/* ── Layout ── */

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

.view.fade-in {
  animation: fadeIn 200ms ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Messages ── */

.msg {
  font-size: var(--fs-sm);
  padding: 0.55rem 0.85rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
}

.msg.error {
  color: var(--danger);
  background: var(--danger-dim);
  border-color: rgba(242, 112, 122, 0.25);
}

.msg.info {
  color: var(--info);
  background: var(--info-dim);
  border-color: rgba(127, 183, 242, 0.22);
}

.msg.callout {
  margin-top: 1rem;
}

/* ── Forms ── */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: var(--fs-sm);
}

.field > span {
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.field.tight > span {
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--fs-sm);
}

.field.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
}

.field.grow {
  flex: 1;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"],
select,
textarea {
  font: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.7rem;
  transition: border-color var(--ease), box-shadow var(--ease);
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: var(--ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

select {
  cursor: pointer;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.field-grid .field.full {
  grid-column: 1 / -1;
}

.field-grid.two {
  grid-template-columns: 1fr 1fr;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  accent-color: var(--accent);
}

.toggle-row {
  display: flex;
  gap: 1rem;
}

/* ── Wizard (Sites view) ── */

.wizard {
  max-width: 860px;
  margin: 0 auto;
}

.wizard-head {
  text-align: center;
  padding: 1.5rem 0 2rem;
}

.wizard-head h1 {
  font-size: var(--fs-xl);
}

.lede {
  color: var(--muted);
  margin-top: 0.4rem;
}

.stepper {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
}

.stepper-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border-soft);
  background: var(--bg-raised);
  border-radius: 999px;
  padding: 0.4rem 1rem 0.4rem 0.45rem;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}

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

.stepper-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--raised);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  transition: background var(--ease), color var(--ease);
}

.stepper-item.active .stepper-btn {
  border-color: rgba(45, 212, 191, 0.4);
  background: var(--accent-dim);
  color: var(--text);
}

.stepper-item.active .stepper-num {
  background: var(--accent);
  color: var(--on-accent);
}

.stepper-item.done .stepper-btn {
  color: var(--text-dim);
}

.stepper-item.done .stepper-num {
  background: var(--ok-dim);
  color: var(--ok);
}

.stepper-mobile {
  display: none;
  margin-top: 1rem;
  font-size: var(--fs-sm);
}

.focus-panel {
  max-width: 560px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.focus-panel.wide {
  max-width: 860px;
}

.focus-panel h2 {
  font-size: var(--fs-lg);
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

.connect-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 1.1rem 1.25rem;
}

.connect-status {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.connect-card .actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.search-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}

.row-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  text-align: left;
  font: inherit;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}

.project-item:hover {
  border-color: var(--border-strong);
}

.project-item.selected {
  border-color: var(--accent-strong);
  background: var(--accent-dim);
  color: var(--text);
}

.project-item.loading,
.project-item.muted {
  cursor: default;
  color: var(--muted);
}

.project-item .pn {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: var(--fs-sm);
}

.chip-label {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.empty-block {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* import stage rail */

.stage-rail {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.stage {
  position: relative;
  display: flex;
  gap: 0.9rem;
  padding: 0.7rem 0 0.7rem 0.25rem;
}

.stage + .stage::before {
  content: "";
  position: absolute;
  left: calc(0.25rem + 13px);
  top: -0.55rem;
  height: 1.1rem;
  width: 2px;
  background: var(--border);
}

.stage-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--raised);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  flex-shrink: 0;
  transition: background var(--ease), color var(--ease), box-shadow var(--ease);
}

.stage-body strong {
  font-size: var(--fs-sm);
  font-weight: 650;
}

.stage-detail {
  font-size: var(--fs-xs);
  margin-top: 0.1rem;
}

.stage.active .stage-num {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px var(--accent-dim);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(45, 212, 191, 0.06);
  }
}

.stage.done .stage-num {
  background: var(--ok-dim);
  color: var(--ok);
}

.stage.failed .stage-num {
  background: var(--danger-dim);
  color: var(--danger);
}

.stage.failed .stage-detail {
  color: var(--danger);
}

/* ── Jobs view ── */

.empty-hero {
  text-align: center;
  padding: 5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.site-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-sm);
}

.site-select select {
  min-width: 280px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.badge-soft {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  background: var(--raised);
  color: var(--muted);
}

.badge-soft[data-status="ok"] {
  background: var(--ok-dim);
  color: var(--ok);
}

.badge-soft[data-status="stale"] {
  background: var(--warn-dim);
  color: var(--warn);
}

.badge-soft[data-status="raw"] {
  background: var(--danger-dim);
  color: var(--danger);
}

.site-bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* two-column console */

.console {
  display: grid;
  grid-template-columns: minmax(420px, 520px) 1fr;
  gap: 1.1rem;
  align-items: start;
}

.compose {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: sticky;
  top: calc(var(--shell-h) + 1rem);
}

.compose-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compose-head h2 {
  font-size: var(--fs-md);
  letter-spacing: 0.01em;
}

.compose-head-actions {
  display: flex;
  gap: 0.4rem;
}

.compose-field textarea {
  font-size: var(--fs-md);
  padding: 0.85rem 1rem;
  min-height: 160px;
  background: var(--bg-raised);
}

.compose-field textarea.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 20px rgba(45, 212, 191, 0.15);
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.attachment-chips:empty {
  display: none;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.28rem 0.5rem 0.28rem 0.75rem;
  font-size: var(--fs-xs);
  color: var(--text-dim);
}

.compression-tag {
  color: var(--faint);
  font-family: var(--mono);
}

.btn-chip-copy,
.btn-chip-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0 0.2rem;
  border-radius: 4px;
  transition: color var(--ease);
}

.btn-chip-copy:hover {
  color: var(--accent);
}

.btn-chip-remove:hover {
  color: var(--danger);
}

.hints-details,
.history-details,
.raw-plan {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--bg-raised);
}

.hints-details summary,
.history-details summary,
.raw-plan summary {
  cursor: pointer;
  padding: 0.55rem 0.85rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  user-select: none;
  transition: color var(--ease);
}

.hints-details summary:hover,
.history-details summary:hover,
.raw-plan summary:hover {
  color: var(--text);
}

.hints-body {
  padding: 0.35rem 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.compose-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-soft);
}

/* history */

.history-details {
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.history-details > summary {
  padding: 0.8rem 1.1rem;
}

.history-body {
  padding: 0 1.1rem 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.85rem;
}

.history-item-body {
  min-width: 0;
}

.history-query {
  font-size: var(--fs-sm);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-meta {
  font-size: var(--fs-xs);
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-actions {
  flex-shrink: 0;
}

/* run stream */

.stream {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
}

.stream-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border-soft);
}

.stream-head h2 {
  font-size: var(--fs-md);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

#job-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.badge {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.24rem 0.7rem;
  background: var(--raised);
  color: var(--muted);
}

.badge[data-status="queued"],
.badge[data-status="planning"] {
  background: var(--info-dim);
  color: var(--info);
}

.badge[data-status="executing"],
.badge[data-status="running"] {
  background: var(--accent-dim);
  color: var(--accent);
  animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.badge[data-status="completed"] {
  background: var(--ok-dim);
  color: var(--ok);
}

.badge[data-status="failed"] {
  background: var(--danger-dim);
  color: var(--danger);
}

.badge[data-status="aborted"] {
  background: var(--warn-dim);
  color: var(--warn);
}

/* demo links */

.demo-box {
  background: var(--accent-dim);
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: var(--r-md);
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.demo-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}

.demo-row {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  min-width: 0;
}

.demo-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
  width: 72px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.demo-row a {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-warn {
  margin-top: 0.3rem;
}

/* error box */

.error-box {
  background: var(--danger-dim);
  border: 1px solid rgba(242, 112, 122, 0.3);
  border-radius: var(--r-md);
  padding: 0.9rem 1.1rem;
}

.error-box strong {
  color: var(--danger);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.error-box pre {
  margin: 0.45rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  max-height: 200px;
  overflow-y: auto;
}

/* stream blocks */

.block {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.block h3 {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.job-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.job-steps li {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.8rem;
  font-size: var(--fs-sm);
}

.job-steps li.muted {
  background: transparent;
  border-style: dashed;
}

.step-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.step-id {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--accent);
  font-weight: 600;
}

.step-goal {
  font-weight: 600;
}

.step-meta {
  margin-left: auto;
  color: var(--faint);
  font-size: var(--fs-xs);
  font-family: var(--mono);
}

.step-summary {
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  max-height: 180px;
  overflow-y: auto;
  border-top: 1px dashed var(--border-soft);
  padding-top: 0.5rem;
}

.plan-structured {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.plan-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.8rem;
  font-size: var(--fs-sm);
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border-soft);
}

.plan-row:last-child {
  border-bottom: none;
}

.plan-row .k {
  color: var(--muted);
  font-weight: 600;
}

.plan-row .v {
  color: var(--text-dim);
  word-break: break-word;
}

.raw-plan {
  margin-top: 0.3rem;
}

.log {
  margin: 0;
  padding: 0.8rem 1rem;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

pre#summary-view.log {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
}

/* ── Deploy modal ── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--backdrop);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-card {
  width: 100%;
  max-width: 600px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border-soft);
}

.modal-head h2 {
  font-size: var(--fs-md);
}

.btn-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: var(--r-sm);
  transition: color var(--ease), background var(--ease);
}

.btn-close:hover {
  color: var(--text);
  background: var(--raised);
}

.modal-body {
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.status-summary-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 0.85rem 1rem;
}

.status-badge-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.modal-section-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  margin-top: 0.25rem;
}

.modal-section-note {
  margin: 0.2rem 0 0.7rem;
}

.modal-foot {
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  background: var(--bg-raised);
}

/* ── Login ── */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 400px at 50% -5%, var(--login-glow), transparent 60%),
    var(--bg);
}

.login-card {
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 2.25rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  margin-bottom: 0.25rem;
}

/* ── Narrow fallback (not a mobile target; just keep it usable) ── */

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

  .compose {
    position: static;
  }
}

@media (max-width: 760px) {
  .shell {
    flex-wrap: wrap;
    height: auto;
    padding: 0.6rem 1rem;
  }

  .shell-left,
  .shell-right {
    width: 100%;
    justify-content: space-between;
  }

  .stepper {
    display: none;
  }

  .stepper-mobile {
    display: block;
  }

  .site-bar {
    flex-wrap: wrap;
  }

  .site-bar-actions {
    width: 100%;
    margin-left: 0;
  }
}

/* ── Target branch chip ── */

.branch-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-dim);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.branch-chip .branch-icon {
  color: var(--accent);
  font-size: 0.9em;
  line-height: 1;
}

.branch-chip .mono {
  font-weight: 550;
  color: var(--text);
}

/* ── Push modal ── */

.push-modal-card {
  max-width: 34rem;
}

.push-target-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

#push-commit-message {
  resize: vertical;
  min-height: 4.5rem;
}

/* ── Commit history ── */

.commit-item {
  align-items: flex-start;
}

.commit-subject {
  font-size: var(--fs-sm);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.commit-actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.35rem;
}

.commit-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: var(--r-xs, 4px);
  background: var(--overlay);
  color: var(--text-dim);
  font-size: var(--fs-xs);
  vertical-align: baseline;
}

.commit-badge.warn {
  background: var(--warn-dim);
  color: var(--warn);
}

.commits-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

/* ── Push dialog: changed files ── */

.changes-details {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--bg-raised);
  margin-bottom: 0.15rem;
}

.changes-details > summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 550;
  list-style: none;
  user-select: none;
}

.changes-details > summary::-webkit-details-marker {
  display: none;
}

.changes-caret {
  color: var(--muted);
  font-size: 0.75em;
  transition: transform 0.15s ease;
}

.changes-details[open] .changes-caret {
  transform: rotate(90deg);
}

.changes-count {
  margin-left: auto;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--overlay);
  color: var(--text-dim);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.change-list {
  list-style: none;
  margin: 0;
  padding: 0 0.35rem 0.35rem;
  max-height: 12rem;
  overflow-y: auto;
}

.change-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.2rem 0.3rem;
  border-radius: var(--r-xs, 4px);
  font-size: var(--fs-xs);
}

.change-row:hover {
  background: var(--overlay);
}

.change-code {
  flex-shrink: 0;
  width: 1.1rem;
  text-align: center;
  font-family: var(--mono, ui-monospace, monospace);
  font-weight: 700;
  color: var(--muted);
}

.change-code[data-change="modified"] { color: var(--warn); }
.change-code[data-change="added"],
.change-code[data-change="untracked"] { color: var(--ok); }
.change-code[data-change="deleted"] { color: var(--danger); }
.change-code[data-change="renamed"],
.change-code[data-change="copied"] { color: var(--info); }
.change-code[data-change="conflicted"] { color: var(--danger); }

.change-path {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.change-name {
  color: var(--text);
  font-family: var(--mono, ui-monospace, monospace);
}

.change-dir {
  margin-left: 0.4rem;
  color: var(--faint);
  font-size: 0.95em;
}

/* ── Confirm dialog ── */

.confirm-modal-card {
  max-width: 30rem;
}

.confirm-commit {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--bg-raised);
  margin-bottom: 0.75rem;
}

.confirm-commit-subject {
  font-size: var(--fs-sm);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.confirm-detail {
  font-size: var(--fs-sm);
  margin-bottom: 0.4rem;
}

/* Destructive actions must not look like the neutral ones next to them. */
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #2a0d10;
}

.btn.danger:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn.ghost.danger-ghost {
  color: var(--danger);
  border-color: var(--danger-dim);
}

.btn.ghost.danger-ghost:hover:not(:disabled) {
  background: var(--danger-dim);
  border-color: var(--danger);
}

/* ── Discard action ── */

.dirty-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.push-changes-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

.confirm-files {
  max-height: 9rem;
  padding: 0.35rem 0;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--bg-raised);
}

/* human review gate */

.review-box {
  background: var(--warn-dim);
  border: 1px solid rgba(230, 192, 123, 0.32);
  border-radius: var(--r-md);
  padding: 0.9rem 1.1rem;
}

.review-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.review-head strong {
  color: var(--warn);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.review-concerns {
  list-style: none;
  margin: 0.7rem 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.review-concerns li {
  border-left: 2px solid rgba(230, 192, 123, 0.5);
  padding-left: 0.65rem;
}

.review-concerns li[data-severity="advisory"] {
  border-left-color: var(--border);
}

.review-concerns .concern-title {
  display: block;
  font-weight: 600;
  font-size: var(--fs-sm);
}

.review-concerns .concern-detail {
  display: block;
  margin-top: 0.15rem;
  font-size: var(--fs-xs);
  color: var(--text-dim);
}

.review-concerns .concern-code {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  opacity: 0.75;
}

.review-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

/* provider-level outage banner */

.provider-banner {
  background: var(--danger-dim);
  border: 1px solid rgba(242, 112, 122, 0.35);
  border-radius: var(--r-md);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
}

.provider-banner strong {
  display: block;
  color: var(--danger);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.provider-banner p {
  margin: 0.35rem 0 0;
  font-size: var(--fs-sm);
  color: var(--text-dim);
}
