/* Wagent app — match marketing vibe lightly */
:root {
  --bg: #f4f7f5;
  --bg-alt: #e8efeb;
  --ink: #0b1f1a;
  --ink-muted: #3d534c;
  --line: #c5d4cc;
  --brand: #0f6b4c;
  --brand-deep: #0a4d38;
  --accent: #c4a35a;
  --accent-soft: #f3ead2;
  --panel: #ffffff;
  --shadow: 0 18px 50px rgba(11, 31, 26, 0.12);
  --radius: 16px;
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --max: 760px;
}

*, *::before, *::after { box-sizing: border-box; }
/* Author display rules must not override the HTML hidden attribute */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 10% -10%, #d9ebe2 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, var(--accent-soft) 0%, transparent 50%),
    var(--bg);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-deep); }
a:hover { color: var(--brand); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: 0.75rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

.wrap { width: min(100% - 2rem, var(--max)); margin-inline: auto; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.header-inner {
  display: flex; align-items: center; gap: 0.85rem;
  min-height: 3.75rem;
}
.logo {
  display: inline-flex; align-items: center; gap: 0.55rem;
  text-decoration: none; color: var(--ink); font-weight: 700; letter-spacing: -0.02em;
}
.logo-mark {
  width: 1.35rem; height: 1.35rem; border-radius: 0.4rem;
  background: linear-gradient(145deg, var(--brand), #1a9b6c 55%, var(--accent));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.header-badge {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--brand-deep); background: var(--bg-alt); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.2rem 0.55rem;
}
.header-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.user-email { font-size: 0.875rem; color: var(--ink-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; padding: 0.7rem 1.2rem; font-weight: 600;
  font-size: 0.95rem; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: transform 0.15s ease, background 0.15s ease;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.875rem; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); color: #fff; }
.btn-ghost {
  background: transparent; color: var(--ink); border-color: var(--line);
}
.btn-ghost:hover { background: var(--panel); }

.app-main { padding: 2.5rem 0 4rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.login-card { max-width: 440px; margin-inline: auto; }
.eyebrow {
  margin: 0 0 0.5rem; font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand);
}
h1 {
  margin: 0 0 0.5rem; font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.85rem, 4vw, 2.35rem); letter-spacing: -0.02em;
}
.lede { margin: 0 0 1.5rem; color: var(--ink-muted); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 500; font-size: 0.9rem; }
.field input, .field textarea, .composer textarea {
  font: inherit; padding: 0.75rem 0.9rem; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.field input:focus, .field textarea:focus, .composer textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
  border-color: var(--brand);
}
.status { min-height: 1.25rem; font-size: 0.9rem; color: var(--ink-muted); margin: 1rem 0 0; }
.status.error { color: #8b2e2e; }
.status.ok { color: var(--brand-deep); }
.fine { margin: 1.5rem 0 0; font-size: 0.85rem; color: var(--ink-muted); }
.dogfood {
  margin-top: 1.25rem; padding: 1rem; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  font-size: 0.9rem;
}
.dogfood a { word-break: break-all; font-weight: 600; }

.chat-shell {
  flex-direction: column; gap: 1rem;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-height: min(70vh, 720px); overflow: hidden;
}
.chat-shell:not([hidden]) {
  display: flex;
}
.chat-header {
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.chat-header h1 { font-size: 1.5rem; margin: 0; }
.chat-sub { margin: 0.25rem 0 0; color: var(--ink-muted); font-size: 0.875rem; }

.transcript {
  flex: 1; overflow-y: auto; padding: 1rem 1.5rem;
  display: flex; flex-direction: column; gap: 0.85rem;
  background: linear-gradient(180deg, #fbfcfb, var(--panel));
}
.msg {
  max-width: 85%; padding: 0.75rem 1rem; border-radius: 14px;
  font-size: 0.95rem; white-space: pre-wrap; word-break: break-word;
}
.msg.user {
  align-self: flex-end; background: var(--brand); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start; background: var(--bg-alt); color: var(--ink);
  border: 1px solid var(--line); border-bottom-left-radius: 4px;
}
.msg.system {
  align-self: center; background: transparent; color: var(--ink-muted);
  font-size: 0.85rem; max-width: 100%; text-align: center;
}
.msg .meta { display: block; font-size: 0.7rem; opacity: 0.75; margin-bottom: 0.25rem; }

.composer {
  display: grid; grid-template-columns: 1fr auto; gap: 0.75rem;
  padding: 1rem 1.5rem 1.25rem; border-top: 1px solid var(--line);
  align-items: end;
}
.composer textarea { resize: vertical; min-height: 3rem; max-height: 8rem; }

#chat-status { margin: 0 1.5rem 1rem; }

@media (max-width: 560px) {
  .user-email { display: none; }
  .composer { grid-template-columns: 1fr; }
}

/* —— Workspace: sites + chat —— */
:root {
  --max-workspace: 1100px;
}

.app-main:has(.workspace:not([hidden])) {
  width: min(100% - 2rem, var(--max-workspace));
}

.workspace:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

.sites-panel {
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: min(70vh, 720px);
}
.sites-panel-head .eyebrow { margin-bottom: 0.25rem; }
.sites-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}
.sites-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}
.site-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 280px;
  overflow-y: auto;
}
.site-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.site-item:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  background: #fff;
}
.site-item.active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, #fff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 25%, transparent);
}

.site-item .site-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
}
.site-active-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-deep);
  background: color-mix(in srgb, var(--brand) 14%, #fff);
  border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--line));
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
}
.site-list[hidden] { display: none !important; }
.site-item .site-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.site-item .site-meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.sites-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.create-site {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.optional {
  font-weight: 400;
  color: var(--ink-muted);
  font-size: 0.8rem;
}
#sites-status { margin: 0; min-height: 1rem; font-size: 0.8rem; }

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.active-pill {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--brand-deep);
  background: color-mix(in srgb, var(--brand) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 800px) {
  .workspace:not([hidden]) {
    grid-template-columns: 1fr;
  }
  .sites-panel {
    min-height: unset;
  }
  .site-list {
    max-height: 160px;
  }
}


/* —— Deployments —— */
.deployments-panel {
  margin-top: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.deployments-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.15rem;
}
.deployments-hint {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.deploy-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 220px;
  overflow-y: auto;
}
.deploy-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  font-size: 0.8rem;
}
.deploy-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.deploy-env {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
  color: var(--brand-deep);
}
.deploy-status-pill {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}
.deploy-status-pill.ready { color: var(--brand-deep); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.deploy-status-pill.failed { color: #8b2e2e; }
.deploy-status-pill.building, .deploy-status-pill.pending { color: var(--ink-muted); }
.deploy-status-pill.promoted { color: #6b5a1e; border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.deploy-url {
  display: block;
  word-break: break-all;
  font-size: 0.75rem;
  margin: 0.2rem 0 0.45rem;
}
.deploy-empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
  line-height: 1.45;
}
.live-host {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.live-host a {
  font-weight: 600;
  word-break: break-all;
}
.preview-banner {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.65rem 0 0;
  padding: 0.75rem 0.85rem;
  border-radius: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  background: color-mix(in srgb, var(--brand) 8%, var(--surface, #fff));
  font-size: 0.82rem;
}
.preview-banner[hidden] { display: none !important; }
.preview-banner-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-deep, var(--brand));
}
.preview-banner a {
  font-weight: 650;
  word-break: break-all;
  color: var(--brand-deep, var(--brand));
}
.site-meta a.site-host-link {
  font-weight: 600;
}
#deploy-status { margin: 0; min-height: 1rem; font-size: 0.8rem; }


/* —— Custom domains (ADR 0004) —— */
.domains-panel {
  margin-top: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.domains-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.15rem;
}
.domains-hint {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.add-domain.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.domain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 280px;
  overflow-y: auto;
}
.domain-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.domain-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.domain-host {
  font-weight: 600;
  word-break: break-all;
}
.domain-kind {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.domain-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.domain-status-pill {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}
.domain-status-pill.active { color: var(--brand-deep); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.domain-status-pill.failed { color: #8b2e2e; }
.domain-status-pill.pending, .domain-status-pill.n-a { color: var(--ink-muted); }
.domain-provider {
  font-size: 0.65rem;
  color: var(--ink-muted);
}
.domain-dns {
  font-size: 0.75rem;
  color: var(--ink-muted);
  line-height: 1.35;
}
.domain-dns code {
  font-size: 0.72rem;
  word-break: break-all;
}
.domain-empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}
#domain-status { margin: 0; min-height: 1rem; font-size: 0.8rem; }

/* Billing */
.billing-panel {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.billing-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.billing-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-muted);
  line-height: 1.35;
}
.billing-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.billing-plan-pill {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-muted);
}
.billing-plan-pill.active {
  color: var(--brand-deep);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  background: color-mix(in srgb, var(--brand) 12%, #fff);
}
.billing-plan-pill.past_due,
.billing-plan-pill.unpaid {
  color: #8b2e2e;
}
.billing-meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.billing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
#billing-status { margin: 0; min-height: 1rem; font-size: 0.8rem; }
