:root {
  --bg: #f5efe4;
  --panel: #fffaf1;
  --panel-strong: #fff;
  --ink: #1f1e1a;
  --muted: #665f53;
  --line: #d7c9b0;
  --accent: #b3471f;
  --accent-soft: #f0caa7;
  --success: #2d6a4f;
  --warning: #9a6700;
  --danger: #a8201a;
  --shadow: 0 20px 60px rgba(79, 52, 23, 0.1);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(179, 71, 31, 0.14), transparent 28%),
    linear-gradient(180deg, #f7f1e8 0%, #f2eadf 100%);
  color: var(--ink);
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 20px;
  margin-bottom: 24px;
}

.hero-copy,
.hero-panel,
.card {
  background: rgba(255, 250, 241, 0.92);
  border: 1px solid rgba(215, 201, 176, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 28px;
}

.hero-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.build-meta {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 4.1rem);
  line-height: 0.95;
  margin-bottom: 12px;
}

.lead {
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.55;
  max-width: 60ch;
}

.chip,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 600;
}

.chip {
  background: #181713;
  color: #f8f1e6;
}

.status {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--ink);
}

.status[data-tone="success"] {
  color: var(--success);
}

.status[data-tone="warning"] {
  color: var(--warning);
}

.status[data-tone="danger"] {
  color: var(--danger);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.context-ribbon {
  position: sticky;
  top: 14px;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px 20px;
  border-radius: 22px;
  background: rgba(24, 23, 19, 0.94);
  color: #f8f1e6;
  border: 1px solid rgba(215, 201, 176, 0.2);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.context-ribbon[hidden] {
  display: none;
}

.ribbon-copy,
.ribbon-actions {
  display: grid;
  gap: 4px;
}

.ribbon-copy span,
.ribbon-next {
  color: rgba(248, 241, 230, 0.78);
  font-size: 0.94rem;
  line-height: 1.35;
}

.ribbon-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ribbon-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.9rem;
  color: #f8f1e6;
}

.ribbon-pill.ready {
  background: rgba(45, 106, 79, 0.22);
  border-color: rgba(45, 106, 79, 0.34);
}

.ribbon-actions {
  justify-items: end;
}

.context-ribbon .secondary {
  min-height: 40px;
  color: #181713;
}

.sse-section-nav {
  position: sticky;
  top: 102px;
  z-index: 24;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 14px;
  border-radius: 20px;
  background: rgba(255, 250, 241, 0.92);
  border: 1px solid rgba(215, 201, 176, 0.9);
  box-shadow: var(--shadow);
}

.sse-section-nav[hidden] {
  display: none;
}

.sse-nav-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
}

.sse-nav-pill.active {
  border-color: rgba(179, 71, 31, 0.35);
  background: #fff1e7;
  color: var(--accent);
}

.sse-nav-pill .count {
  color: var(--muted);
  font-size: 0.88rem;
}

.card {
  padding: 24px;
  scroll-margin-top: 166px;
}

.stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.92rem;
  color: var(--muted);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.check-field input {
  width: auto;
  min-height: auto;
}

input {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 0 14px;
  font: inherit;
}

textarea {
  width: 100%;
  min-height: 140px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px 14px;
  font: inherit;
  resize: vertical;
}

select {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 0 14px;
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  color: #fff7ef;
  background: linear-gradient(135deg, #b3471f 0%, #8f3516 100%);
  cursor: pointer;
}

button:hover {
  filter: brightness(1.03);
}

button.secondary {
  color: var(--ink);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.results {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.results:focus,
.detail-box:focus,
.card:focus {
  outline: 3px solid rgba(179, 71, 31, 0.22);
  outline-offset: 4px;
}

.result-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.result-card.compact {
  align-items: center;
}

.result-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(179, 71, 31, 0.12);
}

.result-main {
  display: grid;
  gap: 4px;
}

.result-main span,
.section-head p,
.detail-box,
.empty,
.meta-row {
  color: var(--muted);
}

.result-actions {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.result-actions button {
  min-height: 38px;
  padding: 0 12px;
}

.detail-box {
  min-height: 128px;
  padding: 16px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}

.compact-stack {
  gap: 10px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.context-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.embedded-results {
  margin-top: 0;
}

.empty {
  padding: 14px 0 4px;
}

.workflow-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.step-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 14px;
  background: #f4ecde;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 0.92rem;
  font-weight: 600;
}

.step-pill.active {
  color: var(--accent);
  border-color: rgba(179, 71, 31, 0.35);
  background: #fff1e7;
}

.step-pill.done {
  color: var(--success);
  border-color: rgba(45, 106, 79, 0.28);
  background: #eef8f2;
}

.form-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.inline-feedback {
  min-height: 44px;
  display: flex;
  align-items: center;
  border-radius: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 600;
}

.inline-feedback[hidden] {
  display: none;
}

.inline-feedback[data-tone="success"] {
  color: var(--success);
  border-color: rgba(45, 106, 79, 0.22);
  background: #eef8f2;
}

.inline-feedback[data-tone="warning"] {
  color: var(--warning);
  border-color: rgba(154, 103, 0, 0.22);
  background: #fff7df;
}

.inline-feedback[data-tone="danger"] {
  color: var(--danger);
  border-color: rgba(168, 32, 26, 0.24);
  background: #fff0ed;
}

.code-box {
  min-height: 180px;
  margin: 16px 0 0;
  padding: 16px;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #201d18;
  color: #f8f1e6;
  font: 0.88rem/1.5 "IBM Plex Mono", "SFMono-Regular", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

button[data-busy="1"] {
  opacity: 0.78;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.section-summary {
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.operator-queue-card {
  margin-bottom: 20px;
}

.operator-results {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.operator-item[data-tone="danger"] {
  border-color: rgba(168, 32, 26, 0.36);
  background: #fff5f2;
}

.operator-item[data-tone="warning"] {
  border-color: rgba(154, 103, 0, 0.28);
  background: #fff8e8;
}

.operator-item[data-tone="success"] {
  border-color: rgba(45, 106, 79, 0.26);
  background: #f3fbf6;
}

.operator-escalate-button {
  border-color: rgba(168, 32, 26, 0.28);
  color: #8a1f17;
  background: #fff7f4;
}

.operator-escalate-button:hover,
.operator-escalate-button:focus {
  border-color: rgba(168, 32, 26, 0.5);
  background: #fff0eb;
}

.operator-task-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 30, 26, 0.42);
}

.operator-task-modal[hidden] {
  display: none;
}

.operator-task-dialog {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-strong);
  box-shadow: 0 24px 80px rgba(31, 30, 26, 0.2);
}

.operator-task-head,
.operator-task-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.operator-task-head h3 {
  margin: 0 0 6px;
}

.operator-task-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.icon-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fffdf8;
}

.operator-task-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 160px;
  gap: 12px;
  margin-top: 16px;
}

.operator-task-grid label {
  display: grid;
  gap: 6px;
}

.operator-task-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.operator-task-wide {
  grid-column: 1 / -1;
}

.operator-task-actions {
  align-items: center;
  margin-top: 14px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.report-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.report-panel h3 {
  margin-bottom: 0;
}

.report-table {
  overflow: auto;
}

.report-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.report-table th,
.report-table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(215, 201, 176, 0.8);
  text-align: left;
}

.report-table th {
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 1180px) {
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .context-ribbon {
    grid-template-columns: 1fr;
    top: 10px;
    gap: 10px;
    padding: 12px 14px;
  }

  .sse-section-nav {
    top: 142px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 10px;
  }

  .card {
    scroll-margin-top: 232px;
  }

  .ribbon-copy,
  .ribbon-actions {
    gap: 2px;
  }

  .ribbon-copy span:last-child,
  .ribbon-next {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .ribbon-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .ribbon-pill {
    white-space: nowrap;
  }

  .ribbon-actions {
    justify-items: stretch;
  }

  .hero,
  .grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .result-card,
  .operator-results,
  .report-grid {
    display: grid;
  }

  .report-grid {
    grid-template-columns: 1fr;
  }

  .operator-results {
    grid-template-columns: 1fr;
  }

  .operator-task-grid {
    grid-template-columns: 1fr;
  }

  .operator-task-head,
  .operator-task-actions {
    display: grid;
  }
}
