:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-alt: #f9fbfb;
  --text: #182026;
  --muted: #65717b;
  --line: #dce3e7;
  --teal: #0b8f83;
  --teal-soft: #e6f6f4;
  --amber: #b7791f;
  --amber-soft: #fff4dd;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --shadow: 0 14px 36px rgba(24, 32, 38, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #102c33;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.runtime-status {
  color: var(--teal);
  font-weight: 800;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.online {
  background: var(--teal);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(300px, 380px);
  gap: 18px;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.composer-panel,
.analysis-panel,
.metadata-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.mode-label {
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

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

label span,
.eyeless-label {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-alt);
  color: var(--text);
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 143, 131, 0.14);
}

textarea {
  resize: vertical;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: #0f766e;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.primary-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.helper-copy {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.helper-copy h3,
.rail-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.helper-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.steps span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a8b3ba;
}

.steps li.active span {
  background: var(--amber);
}

.steps li.complete {
  color: var(--teal);
  border-color: #b8ddd9;
  background: var(--teal-soft);
}

.steps li.complete span {
  background: var(--teal);
}

.error-box {
  margin-bottom: 14px;
  border: 1px solid #f3b5ad;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  padding: 12px;
  font-size: 13px;
  line-height: 1.45;
}

.assessment-card {
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfb 100%);
}

.risk-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

#riskLevel {
  font-size: 38px;
  line-height: 1;
}

#recommendation {
  margin: 0;
  font-size: 20px;
}

.score-badge {
  border-radius: var(--radius);
  padding: 8px 10px;
  font-weight: 800;
  font-size: 13px;
}

.score-badge.low {
  background: var(--teal-soft);
  color: var(--teal);
}

.score-badge.medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.score-badge.high {
  background: var(--danger-soft);
  color: var(--danger);
}

.rationale-list,
.compact-list {
  margin: 0;
  padding-left: 18px;
  color: #334149;
  font-size: 14px;
  line-height: 1.6;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.tab-button.active {
  color: var(--teal);
  border-color: var(--teal);
}

.tab-panel {
  margin-top: 14px;
}

.source-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.source-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.source-item p {
  margin: 0;
  color: #334149;
  font-size: 14px;
  line-height: 1.55;
}

.json-panel {
  overflow: auto;
  max-height: 330px;
  border-radius: var(--radius);
  background: #101820;
  color: #d9f0ee;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
}

.metadata-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.metadata-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-alt);
  padding: 11px 12px;
}

.metadata-item span,
.kv-list dt {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metadata-item strong,
.kv-list dd {
  display: block;
  margin: 5px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.rail-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.kv-list {
  margin: 0;
}

.kv-list dd {
  margin-left: 0;
  overflow-wrap: anywhere;
}

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

  .metadata-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

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

  #riskLevel {
    font-size: 30px;
  }
}
