:root {
  --ink: #15202b;
  --ink-soft: #3a4a5a;
  --muted: #6b7c8d;
  --paper: rgba(248, 251, 253, 0.72);
  --line: rgba(21, 32, 43, 0.12);
  --teal: #0b6e6a;
  --teal-deep: #085550;
  --amber: #b45309;
  --ok: #1b7a4a;
  --err: #b42318;
  --shadow: 0 18px 40px rgba(21, 32, 43, 0.08);
  --font-brand: "Bricolage Grotesque", Georgia, serif;
  --font-body: "Figtree", "Segoe UI", sans-serif;
  --radius: 10px;
  --pad: clamp(1.25rem, 3vw, 2.5rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: #d8e2eb;
  line-height: 1.5;
  position: relative;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(11, 110, 106, 0.22), transparent 55%),
    radial-gradient(700px 420px at 92% 0%, rgba(180, 83, 9, 0.12), transparent 50%),
    linear-gradient(165deg, #e7eef4 0%, #cfdce8 45%, #b9ccd9 100%);
  animation: wash 18s ease-in-out infinite alternate;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(21, 32, 43, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 32, 43, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black 0%, transparent 85%);
}

@keyframes wash {
  from { filter: saturate(1); }
  to { filter: saturate(1.08) brightness(1.02); }
}

a {
  color: var(--teal-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--teal);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding: 1.25rem var(--pad) 0.75rem;
  animation: rise 0.55s ease-out both;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--ink);
}

.brand-product {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--teal-deep);
  letter-spacing: 0.02em;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
  font-weight: 600;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
}

.site-nav a.is-active,
.site-nav a:hover {
  color: var(--ink);
}

.site-main {
  padding: 0.75rem var(--pad) 3.5rem;
  max-width: 1120px;
  animation: rise 0.7s ease-out 0.08s both;
}

body.chat-layout .site-main {
  max-width: 760px;
  padding-bottom: 1.5rem;
}

.site-footer {
  display: flex;
  gap: 1rem;
  padding: 1rem var(--pad) 2rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.page-intro h1 {
  font-family: var(--font-brand);
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
  line-height: 1.1;
}

.page-intro p {
  margin: 0;
  color: var(--ink-soft);
  max-width: 40rem;
}

.crumb {
  font-size: 0.9rem;
  margin-bottom: 0.5rem !important;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 1rem;
  align-items: center;
}

.project-list {
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) auto auto minmax(0, 1.2fr);
  gap: 1rem 1.5rem;
  align-items: center;
  padding: 1.15rem 0.25rem;
  border-bottom: 1px solid var(--line);
  transition: background 0.2s ease, transform 0.2s ease;
}

.project-row:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: translateX(2px);
}

.project-link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.project-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.project-slug {
  color: var(--muted);
  font-size: 0.875rem;
}

.lifecycle {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal-deep);
  border: 1px solid rgba(11, 110, 106, 0.35);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.meta {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.url {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.empty {
  margin-top: 2rem;
  color: var(--ink-soft);
}

.panel {
  margin-top: 0;
  padding: 1.5rem 1.6rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: rise 0.65s ease-out both;
}

.workstream {
  margin-top: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.workstream-title {
  font-family: var(--font-brand);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.15rem;
}

.ops-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.35rem;
}

.intro-actions {
  margin-top: 1.15rem !important;
}

.rework-hint {
  margin: 0 0 1rem;
  max-width: 46rem;
}

.panel h3 {
  font-family: var(--font-brand);
  font-size: 1.25rem;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.panel-danger {
  border-color: rgba(180, 35, 24, 0.22);
}

.workstream-danger {
  margin-top: 2.75rem;
}

.panel + .panel {
  animation-delay: 0.12s;
}

.panel h2 {
  font-family: var(--font-brand);
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.panel-lede {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.action-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  align-items: end;
  margin-top: 1rem;
}

.action-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.action-form label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  padding-bottom: 0.45rem;
}

.action-form input[type="text"],
.action-form select,
.action-form textarea {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  min-width: 10rem;
  background: #fff;
}

.action-form label.stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.action-form textarea {
  min-height: 8rem;
  width: min(100%, 28rem);
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}

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

.btn-primary {
  background: var(--teal);
  border-color: var(--teal-deep);
  color: #f4fbfa;
}

.btn-primary:hover {
  background: var(--teal-deep);
  color: #fff;
}

.banner {
  margin-top: 1.25rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  animation: rise 0.4s ease-out both;
}

.banner-error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--err);
}

.banner-ok {
  border-color: rgba(27, 122, 74, 0.35);
}

.json-block {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  overflow: auto;
  max-height: 22rem;
  font-size: 0.8rem;
  line-height: 1.4;
  background: rgba(21, 32, 43, 0.04);
  border-radius: 6px;
}

.ci-state {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
}

.ci-success,
.ci-completed {
  color: var(--ok);
}

.ci-failure,
.ci-error {
  color: var(--err);
}

.ci-pending,
.ci-queued,
.ci-in_progress {
  color: var(--amber);
}

.hint {
  margin: 0.85rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-soft);
}

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

@media (max-width: 720px) {
  .project-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "link life"
      "port url";
  }

  .project-link { grid-area: link; }
  .lifecycle { grid-area: life; justify-self: end; }
  .meta { grid-area: port; }
  .url { grid-area: url; text-align: right; }

  .action-form label:not(.check) {
    flex: 1 1 100%;
  }

  .action-form input[type="text"],
  .action-form select,
  .action-form textarea {
    width: 100%;
  }
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-bubble {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.chat-po { border-left: 3px solid var(--teal); }
.chat-pm { border-left: 3px solid #b45309; }
.chat-system { opacity: 0.85; font-size: 0.9rem; }

.chat-role {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.chat-body {
  white-space: pre-wrap;
  line-height: 1.45;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.llm-chat {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 8rem);
}

.llm-chat-head h1 {
  font-family: var(--font-brand);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  margin: 0 0 0.35rem;
}

.llm-chat-meta {
  color: var(--ink-soft);
  margin: 0;
  font-size: 0.95rem;
}

.llm-chat-thread {
  flex: 1;
  margin-top: 1.25rem;
  padding: 1.1rem 1.15rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 16rem;
  max-height: min(52vh, 32rem);
  overflow-y: auto;
}

.chat-empty {
  margin: 1rem 0;
}

.chat-list {
  gap: 0.9rem;
}

.chat-bubble.chat-pm {
  margin-left: 1.5rem;
  background: rgba(180, 83, 9, 0.08);
}

.chat-bubble.chat-po {
  margin-right: 1.5rem;
}

.llm-chat-composer {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.composer-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}

.composer-row textarea {
  flex: 1;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  min-height: 4.5rem;
  resize: vertical;
  background: #fff;
}

.composer-tools {
  display: flex;
}

.llm-chat-close {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.close-form {
  margin-top: 0;
}

.draft-scope {
  margin: 1.25rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--line);
}

.draft-scope h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.draft-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.draft-table th,
.draft-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

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

  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }
}
