:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --ink: #101722;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #d9e0e8;
  --line-strong: #bec8d4;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --nav: #0f172a;
  --nav-2: #182338;
  --blue: #175c9e;
  --blue-strong: #0f4376;
  --teal: #0f766e;
  --ok: #177245;
  --warn: #9a6700;
  --error: #b42318;
  --shadow: 0 18px 50px rgba(16, 23, 34, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.product-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 360px;
  gap: 0;
  min-height: 100vh;
  animation: appIn 360ms ease-out both;
}

.rail {
  display: grid;
  align-content: start;
  gap: 24px;
  padding: 22px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), transparent 220px),
    linear-gradient(180deg, var(--nav), var(--nav-2));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  color: var(--nav);
  font-weight: 950;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand div > span {
  color: rgba(255,255,255,.62);
  font-size: 12px;
  margin-top: 2px;
}

.progress-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border-radius: 10px;
  padding: 0 11px;
  color: rgba(255,255,255,.62);
  font-size: 13px;
  font-weight: 820;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.nav-item::before {
  content: attr(data-step);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  font-size: 11px;
  font-weight: 900;
}

.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.1);
  transform: translateX(2px);
}

.nav-item.active::before {
  background: #fff;
  color: var(--nav);
}

.rail-card {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,.07);
}

.rail-kicker,
.section-kicker {
  display: block;
  color: var(--faint);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.rail-card .rail-kicker { color: rgba(255,255,255,.52); }
.rail-card strong { display: block; font-size: 14px; }
.rail-card p { margin: 7px 0 0; color: rgba(255,255,255,.66); font-size: 12px; line-height: 1.45; }

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  padding: 24px;
}

.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 760;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 118px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--blue);
  background: #fff;
  font-size: 13px;
  font-weight: 850;
  box-shadow: 0 8px 22px rgba(16,23,34,.06);
}

.status-pill[data-mode="busy"],
.status-pill[data-mode="warn"] { color: var(--warn); }
.status-pill[data-mode="ok"] { color: var(--ok); }
.status-pill[data-mode="error"] { color: var(--error); }

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

body[data-state="busy"] .status-dot {
  animation: pulse 1200ms ease-out infinite;
}

.compose-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(260px, 520px) 150px;
  gap: 14px;
  align-items: end;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.field > span {
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  font: inherit;
  color: var(--ink);
  background: var(--panel-soft);
  outline: none;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(23, 92, 158, .11);
}

.metric {
  display: grid;
  align-content: center;
  min-height: 45px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 11px;
  background: var(--panel-soft);
}

.metric span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.metric small {
  color: var(--faint);
  font-size: 11px;
  margin-top: 2px;
}

.transcript-field {
  min-height: 0;
  padding: 18px;
}

#transcript {
  height: 100%;
  min-height: 520px;
  resize: none;
  line-height: 1.56;
  font-size: 14px;
}

body[data-state="busy"] #transcript {
  border-color: rgba(23,92,158,.32);
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  min-height: 42px;
  padding: 0 16px;
  font: inherit;
  font-weight: 880;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.btn:disabled { opacity: .62; cursor: wait; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(23,92,158,.14); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.primary {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 10px 20px rgba(23,92,158,.18);
}

.primary:hover { background: var(--blue-strong); }

.secondary {
  color: var(--blue);
  background: #fff;
  border-color: var(--line);
}

.secondary:hover {
  border-color: var(--line-strong);
  background: #f3f7fb;
}

.full { width: 100%; }

.inspector {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 24px 24px 24px 0;
}

.inspector-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 14px 34px rgba(16,23,34,.08);
  animation: cardIn 260ms ease-out both;
}

.result {
  border-radius: 13px;
  border: 1px solid var(--line);
  padding: 13px;
  line-height: 1.45;
  font-size: 14px;
}

.result.empty { color: var(--faint); background: var(--panel-soft); }
.result.ok { border-color: rgba(23,114,69,.25); background: #effaf4; color: var(--ok); }
.result.warn,
.result.info { border-color: rgba(154,103,0,.25); background: #fff8e7; color: var(--warn); }
.result.error { border-color: rgba(180,35,24,.25); background: #fff1f0; color: var(--error); }
.result a { color: inherit; font-weight: 900; }

.hidden { display: none; }

.chat-log {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.chat-msg {
  border-radius: 13px;
  padding: 10px 11px;
  line-height: 1.42;
  font-size: 13px;
  animation: messageIn 180ms ease-out both;
}

.chat-msg.system { background: #eef5fc; color: var(--blue-strong); }
.chat-msg.user { background: #eefaf8; color: var(--teal); }

.compact { margin-bottom: 12px; }
.clarification-input { min-height: 118px; resize: vertical; }

@keyframes appIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(154,103,0,.28); }
  70% { box-shadow: 0 0 0 8px rgba(154,103,0,0); }
  100% { box-shadow: 0 0 0 0 rgba(154,103,0,0); }
}

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

@media (max-width: 1180px) {
  .product-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .inspector {
    grid-column: 2;
    padding: 0 24px 24px;
  }
}

@media (max-width: 860px) {
  .product-shell {
    grid-template-columns: 1fr;
  }
  .rail {
    padding: 16px;
  }
  .progress-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .nav-item {
    justify-content: center;
  }
  .workspace {
    padding: 16px;
  }
  .inspector {
    grid-column: auto;
    padding: 0 16px 16px;
  }
  .input-row {
    grid-template-columns: 1fr;
  }
  #transcript {
    min-height: 380px;
  }
}

@media (max-width: 560px) {
  .workspace-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .toolbar {
    flex-direction: column-reverse;
  }
  .btn {
    width: 100%;
  }
  .progress-nav {
    grid-template-columns: 1fr 1fr;
  }
}
