:root {
  color-scheme: light;
  --ink: #182132;
  --muted: #66758c;
  --line: #d9e2ec;
  --surface: #ffffff;
  --soft: #eef4f8;
  --nav: #101827;
  --accent: #0e7490;
  --accent-strong: #155e75;
  --ok: #16a34a;
  --warn: #b45309;
  --bad: #b91c1c;
  --shadow: 0 18px 60px rgba(24, 33, 50, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: var(--nav);
  color: #f8fafc;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #22d3ee;
  color: #083344;
  font-weight: 900;
}

.brand h1 {
  font-size: 19px;
}

.brand p,
.sidebar-copy,
.runtime-card small,
.metric span,
.metric small,
.eyebrow,
.workflow-card small {
  color: #94a3b8;
}

.steps {
  display: grid;
  gap: 8px;
}

.step {
  width: 100%;
  text-align: left;
  min-height: 42px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #dbeafe;
  cursor: pointer;
  font-weight: 800;
}

.step.is-active {
  background: #e0f2fe;
  color: #0f172a;
}

.runtime-card {
  margin-top: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--warn);
}

.dot.ok {
  background: var(--ok);
}

.dot.bad {
  background: var(--bad);
}

.workspace {
  min-width: 0;
  padding: 28px 32px 48px;
  display: grid;
  gap: 20px;
  align-content: start;
  max-height: 100vh;
  overflow: auto;
}

.topbar,
.hero-grid,
.panel {
  max-width: 1180px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar h2 {
  font-size: 34px;
}

.topbar-copy {
  margin-top: 4px;
  max-width: 680px;
  color: var(--muted);
}

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

.topbar a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 900;
}

.hero-grid,
.workflow-grid,
.token-grid,
.validation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel,
.surface,
.workflow-card,
.score-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric,
.workflow-card,
.score-panel {
  padding: 18px;
  border-radius: 8px;
}

.metric strong,
.score-panel strong {
  display: block;
  margin: 6px 0;
  font-size: 28px;
}

.panel {
  display: none;
  gap: 16px;
  border-radius: 8px;
  padding: 22px;
}

.panel.is-visible {
  display: grid;
}

.panel-copy {
  display: grid;
  gap: 6px;
}

.panel-copy p,
.contract-list dd,
.issue-list,
.component-card small,
.ready-item span {
  color: var(--muted);
}

.workflow-card {
  box-shadow: none;
}

.workflow-card span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #cffafe;
  color: var(--accent-strong);
  font-weight: 900;
  margin-bottom: 10px;
}

.split,
.component-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 14px;
  align-items: start;
}

.surface {
  border-radius: 8px;
  padding: 18px;
  box-shadow: none;
}

.surface h4 {
  margin-bottom: 12px;
}

.inspector-panel {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 56px);
  overflow: auto;
}

.component-preview {
  min-height: 150px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #f8fafc;
}

.figma-thumb {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  object-fit: contain;
}

.live-node,
.empty-card {
  width: 100%;
  min-height: 110px;
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.live-node strong {
  color: var(--ink);
}

.live-node span {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.preview-button {
  border-radius: 8px;
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.preview-card {
  width: min(340px, 100%);
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.preview-avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: #cffafe;
}

.preview-toggle {
  width: min(360px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.switch {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent);
  position: relative;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
}

.preview-empty {
  text-align: center;
  display: grid;
  gap: 10px;
}

.contract-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.contract-list div {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.contract-list dt {
  font-weight: 900;
}

.contract-list dd {
  margin: 0;
}

.component-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 4px;
}

.component-card {
  display: grid;
  gap: 6px;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 14px;
}

.source-pill {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e0f2fe;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.component-card.is-selected {
  border-color: var(--accent);
  background: #ecfeff;
}

.token-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.token-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.45fr) minmax(180px, 0.55fr) auto;
  gap: 12px;
  align-items: end;
}

.connect-grid {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.45fr) auto;
}

.live-grid {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 0.72fr) minmax(160px, 0.45fr) auto;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.secondary {
  background: #dbeafe;
  color: #1d4ed8;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.notice {
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f0f9ff;
  color: #075985;
}

.notice.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--bad);
}

.notice.subtle {
  border-color: var(--line);
  background: #ffffff;
  color: var(--muted);
}

.comparison-grid {
  align-items: stretch;
}

.sim-canvas {
  --sim-color: var(--figma-color, var(--figma-text, var(--figma-ink, #182132)));
  --sim-surface: var(--figma-surface, var(--figma-background, #ffffff));
  --sim-accent: var(--figma-primary, var(--figma-color-primary, var(--accent)));
  --sim-space: var(--figma-spacing, var(--figma-space, 16px));
  width: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, #f8fafc 0, #f8fafc 10px, #eef4f8 10px, #eef4f8 20px);
}

.sim-component {
  max-width: 100%;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-left: 5px solid var(--sim-accent);
  border-radius: 8px;
  background: var(--sim-surface);
  color: var(--sim-color);
  box-shadow: 0 16px 34px rgba(24, 33, 50, 0.16);
}

.sim-kicker {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  background: #cffafe;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.output {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  border-radius: 8px;
  background: #101827;
  color: #dbeafe;
  padding: 16px;
  white-space: pre-wrap;
}

.code-output {
  min-height: 320px;
}

.compact-output {
  max-height: 280px;
}

.score-panel {
  grid-column: span 1;
  box-shadow: none;
  display: grid;
  gap: 12px;
}

.validation-grid {
  grid-template-columns: minmax(220px, 0.32fr) minmax(0, 1fr);
}

.score-track {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.score-track div {
  height: 100%;
  width: 0;
  background: var(--bad);
}

.score-breakdown {
  display: grid;
  gap: 8px;
  margin: 0;
}

.score-breakdown div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.score-breakdown dt {
  color: var(--muted);
  font-weight: 800;
}

.score-breakdown dd {
  margin: 0;
  font-weight: 900;
}

.issue-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.issue-list strong {
  color: var(--ink);
}

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

.rubric-grid div,
.instruction-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.rubric-grid strong,
.rubric-grid span {
  display: block;
}

.rubric-grid span,
.instruction-list {
  color: var(--muted);
}

.instruction-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.instruction-list strong {
  color: var(--ink);
}

.readiness {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.ready-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.ready-item strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  padding: 12px 14px;
  background: #101827;
  color: #f8fafc;
  font-weight: 900;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--bad);
}

@media (max-width: 980px) {
  .shell,
  .hero-grid,
  .workflow-grid,
  .split,
  .component-layout,
  .token-grid,
  .form-grid,
  .connect-grid,
  .live-grid,
  .validation-grid,
  .rubric-grid,
  .readiness {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    min-height: auto;
  }

  .workspace {
    max-height: none;
    overflow: visible;
  }

  .component-list {
    max-height: 420px;
  }

  .inspector-panel {
    position: relative;
    max-height: none;
    overflow: visible;
  }

  .topbar,
  .top-actions {
    align-items: flex-start;
    flex-direction: column;
  }
}
