:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --panel-soft: #eef5f1;
  --ink: #1d2828;
  --muted: #657371;
  --line: #d8e0dc;
  --teal: #0f766e;
  --teal-dark: #0b4f4a;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b42318;
  --green: #166534;
  --shadow: 0 18px 50px rgba(29, 40, 40, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(245, 247, 244, 0) 270px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  min-height: 68px;
  padding: 14px clamp(18px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(15, 118, 110, 0.14);
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.topbar__brand div {
  display: grid;
  gap: 2px;
}

.topbar__brand strong {
  font-size: 16px;
}

.topbar__brand span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal-dark);
  color: #fff;
  font-weight: 800;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px);
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(520px, 1.18fr);
  gap: clamp(18px, 3vw, 30px);
  align-items: start;
}

.intake,
.results {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intake {
  padding: clamp(18px, 3vw, 26px);
  position: sticky;
  top: 18px;
}

.results {
  min-height: calc(100vh - 136px);
  overflow: hidden;
}

.section-heading {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 24px;
  line-height: 1.22;
}

h3 {
  font-size: 17px;
}

h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
}

.intake-form {
  display: grid;
  gap: 16px;
}

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

.field span,
.toggle span {
  color: #344240;
  font-size: 13px;
  font-weight: 700;
}

.field--full {
  min-width: 0;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #c7d2ce;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  resize: vertical;
  min-height: 190px;
  padding: 14px;
  line-height: 1.65;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

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

.quick-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-examples button,
.ghost-button,
.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #30403d;
  min-height: 36px;
}

.quick-examples button {
  padding: 0 12px;
}

.quick-examples button:hover,
.ghost-button:hover,
.tab:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(180, 83, 9, 0.25);
  background: #fff8ed;
  border-radius: 8px;
}

.toggle input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--amber);
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary-button,
.ghost-button {
  height: 46px;
  padding: 0 16px;
}

.primary-button {
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  min-width: 150px;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.primary-button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.ghost-button {
  background: #fff;
  color: var(--muted);
}

.privacy-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.empty-state,
.loading-state,
.error-state {
  padding: clamp(24px, 5vw, 48px);
}

.empty-state {
  display: grid;
  gap: 10px;
  min-height: 340px;
  align-content: center;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(22, 101, 52, 0.06)),
    #fff;
}

.empty-state p:last-child {
  max-width: 580px;
  color: var(--muted);
  line-height: 1.75;
}

.loading-state {
  display: grid;
  gap: 16px;
  color: var(--muted);
}

.loading-bar {
  height: 8px;
  width: 100%;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebe8;
}

.loading-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 38%;
  background: var(--teal);
  animation: loading 1.2s infinite ease-in-out;
}

@keyframes loading {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(270%); }
}

.error-state {
  color: var(--red);
  background: #fff5f4;
  border-bottom: 1px solid rgba(180, 35, 24, 0.18);
}

.result-view {
  display: grid;
}

.risk-banner {
  padding: 14px clamp(18px, 3vw, 26px);
  border-bottom: 1px solid var(--line);
  color: #3d2a15;
  background: #fff8ed;
  line-height: 1.6;
}

.risk-banner.high {
  background: #fff1ef;
  color: #601410;
  border-bottom-color: rgba(180, 35, 24, 0.25);
}

.summary-band {
  padding: clamp(18px, 3vw, 28px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 20px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.summary-band p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.quality-meter {
  width: 108px;
  height: 108px;
  border-radius: 8px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  background: var(--panel-soft);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
}

.quality-meter span {
  display: block;
  color: var(--teal-dark);
  font-size: 28px;
  font-weight: 900;
}

.quality-meter small {
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px clamp(18px, 3vw, 26px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  min-width: 72px;
  padding: 0 14px;
  color: var(--muted);
  font-weight: 800;
}

.tab.is-active {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  color: #fff;
}

.tab-panels {
  padding: clamp(18px, 3vw, 26px);
}

.tab-panel {
  display: grid;
  gap: 16px;
}

.priority-section {
  display: grid;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.priority-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.priority-heading {
  display: grid;
  gap: 4px;
}

.priority-heading--row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.priority-heading--row .ghost-button {
  height: 38px;
  min-width: 96px;
  color: var(--teal-dark);
  font-weight: 800;
}

.priority-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.action-step-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: action-step;
}

.action-step-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.action-step-card.is-primary {
  border-color: rgba(15, 118, 110, 0.38);
  background: linear-gradient(180deg, #f5fbf8, #fff);
}

.action-step-number {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal-dark);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.action-step-card:not(.is-primary) .action-step-number {
  background: #e5efeb;
  color: var(--teal-dark);
}

.action-step-body {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.action-step-body p {
  margin: 0;
  color: #3d4d4a;
  line-height: 1.75;
}

.action-step-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.action-label,
.action-now {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.action-label {
  background: #eef5f1;
  color: var(--teal-dark);
}

.action-now {
  background: #fff8ed;
  color: var(--amber);
}

.case-preview-list {
  display: grid;
  gap: 10px;
}

.case-preview-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.case-preview-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.secondary-grid {
  display: grid;
  gap: 16px;
}

.item-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.item-list li,
.reference,
.case-item,
.brief-box,
.notice-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item-list li {
  padding: 13px 14px;
  line-height: 1.65;
}

.notice-box {
  padding: 14px;
  color: var(--muted);
  line-height: 1.7;
  background: #f9fbfa;
}

.reference,
.case-item {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.reference p,
.case-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 8px;
  background: #eef5f1;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.tag.blue {
  background: #eef4ff;
  color: var(--blue);
}

.tag.amber {
  background: #fff8ed;
  color: var(--amber);
}

.tag.green {
  background: #eef8ee;
  color: var(--green);
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 8px;
  background: #f7f8fb;
  color: #344240;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.source-link:hover {
  color: var(--teal-dark);
}

.case-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.case-actions .ghost-button {
  min-width: 128px;
  height: 40px;
  color: var(--teal-dark);
  font-weight: 800;
}

.case-actions .ghost-button:disabled {
  cursor: default;
  opacity: 0.62;
}

.snippet {
  padding-left: 12px;
  border-left: 3px solid #bfd8d2;
  color: #41514f;
  line-height: 1.75;
}

.brief-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brief-toolbar button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--teal-dark);
  font-weight: 800;
}

.brief-box {
  margin: 0;
  padding: 16px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  color: #263331;
  line-height: 1.75;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

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

  .intake {
    position: static;
  }

  .results {
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .workspace {
    padding: 12px;
  }

  .field-grid,
  .summary-band {
    grid-template-columns: 1fr;
  }

  .quality-meter {
    width: 100%;
    height: auto;
    min-height: 80px;
  }

  .priority-heading--row {
    grid-template-columns: 1fr;
  }

  .action-step-card {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .case-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
