/* SkillSafe App Renderer v1 — spec-app styles (self-contained; app origins
 * do not load the main-site design system). */
:root {
  color-scheme: light dark;
  --sr-fg: #1c1e21;
  --sr-muted: #6b7280;
  --sr-bg: #ffffff;
  --sr-card: #f6f7f9;
  --sr-border: #d5d9e0;
  --sr-accent: #2563eb;
  --sr-accent-fg: #ffffff;
  --sr-error: #b91c1c;
  --sr-ok: #15803d;
  --sr-code-bg: #eef0f3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sr-fg: #e7e9ee;
    --sr-muted: #9aa1ad;
    --sr-bg: #101216;
    --sr-card: #191c22;
    --sr-border: #30343d;
    --sr-accent: #3b82f6;
    --sr-accent-fg: #ffffff;
    --sr-error: #f87171;
    --sr-ok: #4ade80;
    --sr-code-bg: #1e222a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 40px 16px 64px;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--sr-fg);
  background: var(--sr-bg);
}
#root { max-width: 680px; margin: 0 auto; }

.sr-header { margin-bottom: 24px; }
.sr-title { margin: 0 0 4px; font-size: 26px; line-height: 1.25; }
.sr-tagline { margin: 0; color: var(--sr-muted); }
.sr-credits { float: right; color: var(--sr-muted); font-size: 13px; padding-top: 6px; }

.sr-card {
  padding: 16px;
  border: 1px solid var(--sr-border);
  border-radius: 10px;
  background: var(--sr-card);
  margin-bottom: 16px;
}

.sr-form { margin: 0; }
.sr-widget { margin-bottom: 16px; }
.sr-label { display: block; margin-bottom: 5px; font-weight: 600; }
.sr-check-label { display: flex; align-items: center; gap: 4px; font-weight: 600; cursor: pointer; }

input[type="text"], input[type="number"], input[type="date"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 9px 10px;
  font: inherit;
  color: inherit;
  background: var(--sr-card);
  border: 1px solid var(--sr-border);
  border-radius: 8px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--sr-accent); outline-offset: 1px; }
.sr-invalid { border-color: var(--sr-error); }

.sr-slider-row { display: flex; align-items: center; gap: 12px; }
.sr-slider-row input[type="range"] { flex: 1; accent-color: var(--sr-accent); }
.sr-slider-value { min-width: 2.5em; text-align: right; font-variant-numeric: tabular-nums; color: var(--sr-muted); }

.sr-btn {
  padding: 9px 20px;
  font: inherit;
  font-weight: 600;
  color: var(--sr-accent-fg);
  background: var(--sr-accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.sr-btn:disabled { opacity: 0.6; cursor: default; }
.sr-run { margin-top: 6px; }

.sr-status { margin-top: 16px; color: var(--sr-muted); white-space: pre-wrap; }
.sr-status.sr-error { color: var(--sr-error); }

.sr-estimate { margin: 8px 0 0; color: var(--sr-muted); font-size: 0.82rem; }

.sr-output {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--sr-border);
  border-radius: 10px;
  overflow-x: auto;
}
.sr-output > :first-child { margin-top: 0; }
.sr-output > :last-child { margin-bottom: 0; }
.sr-text, .sr-code {
  margin: 10px 0;
  padding: 0;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.sr-code { padding: 10px 12px; background: var(--sr-code-bg); border-radius: 8px; }
.sr-inline-code {
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--sr-code-bg);
  padding: 1px 5px;
  border-radius: 5px;
}
.sr-h { margin: 18px 0 6px; line-height: 1.3; }
.sr-p { margin: 8px 0; }
.sr-list { margin: 8px 0; padding-left: 24px; }
.sr-link { color: var(--sr-accent); }

.sr-footer { max-width: 680px; margin: 40px auto 0; font-size: 13px; }
.sr-footer a { color: var(--sr-muted); }

/* Workflow apps (kind: "workflow") — trigger cards, node timeline, item table. */
select[multiple] { min-height: 96px; }
input[type="file"] { font: inherit; color: var(--sr-muted); }
.sr-hint { margin: 6px 0 0; color: var(--sr-muted); font-size: 0.82rem; }
.sr-hint.sr-error { color: var(--sr-error); }
.sr-muted { color: var(--sr-muted); }
.sr-form-title { margin: 0 0 6px; font-size: 20px; }
.sr-btn-secondary { background: transparent; color: var(--sr-fg); border: 1px solid var(--sr-border); }
.sr-cancel { margin-top: 10px; }
.sr-run-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.sr-details { margin-top: 12px; }
.sr-details summary { cursor: pointer; font-weight: 600; }
.sr-json {
  margin-top: 8px;
  min-height: 140px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.sr-method { font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--sr-accent); }
.sr-webhooks li { margin: 4px 0; word-break: break-all; }
.sr-timeline {
  list-style: none;
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--sr-border);
  border-radius: 10px;
  font-size: 13px;
}
.sr-tl-item { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; padding: 3px 0; }
.sr-tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sr-muted); flex: none; align-self: center; }
.sr-tl-ok .sr-tl-dot { background: var(--sr-ok); }
.sr-tl-error .sr-tl-dot { background: var(--sr-error); }
.sr-tl-waiting .sr-tl-dot, .sr-tl-running .sr-tl-dot { background: var(--sr-accent); }
.sr-tl-skipped .sr-tl-dot, .sr-tl-not_run .sr-tl-dot, .sr-tl-pending .sr-tl-dot { background: var(--sr-border); }
.sr-tl-pending .sr-tl-status { opacity: 0.7; }
.sr-tl-type { color: var(--sr-muted); font-size: 12px; }
.sr-tl-head { margin: 16px 0 4px; font-size: 14px; }
.sr-tl-name { font-weight: 600; }
.sr-tl-status { color: var(--sr-muted); }
.sr-tl-ms { margin-left: auto; color: var(--sr-muted); font-variant-numeric: tabular-nums; }
.sr-tl-err { flex-basis: 100%; padding-left: 17px; color: var(--sr-error); font-size: 12px; }
.sr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sr-table th, .sr-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--sr-border);
  vertical-align: top;
  word-break: break-word;
}
.sr-table th { color: var(--sr-muted); font-weight: 600; }
.sr-chat-log { display: flex; flex-direction: column; gap: 8px; min-height: 60px; margin-bottom: 10px; }
.sr-chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 10px; background: var(--sr-code-bg); }
.sr-chat-composer { display: flex; align-items: flex-end; gap: 8px; }
.sr-chat-input { flex: 1; min-height: 48px; }

.sr-hidden { display: none; }

/* Workflow canvas — n8n's canvas language (square nodes, name beneath, dot
 * grid, handles, status icons, run animation), drawn with our own assets. */
:root {
  --wfn-canvas: #f6f6f8; --wfn-dot: #cfd0d8;
  --wfn-node-bg: #ffffff; --wfn-node-border: #7d7d87; --wfn-node-hover: #4d4d59;
  --wfn-text: #555555; --wfn-text-light: #8a8c99;
  --wfn-edge: #7d7d87;
  --wfn-primary: #ff6d5a; --wfn-primary-soft: rgba(255, 109, 90, 0.35);
  --wfn-success: #26b56d; --wfn-danger: #e64a3e; --wfn-warning: #f7a500; --wfn-secondary: #7e5bef;
  --wfn-select: rgba(0, 0, 0, 0.09);
  --wfn-control-bg: #ffffff; --wfn-control-border: #d9dbe3;
  --wfn-glyph-filter: none;
  --wfn-sticky-1: #fff5b3; --wfn-sticky-1b: #e8d47a;
  --wfn-sticky-2: #ffe4cc; --wfn-sticky-2b: #f2be93;
  --wfn-sticky-3: #ffd9d9; --wfn-sticky-3b: #f0a3a3;
  --wfn-sticky-4: #dcf6e3; --wfn-sticky-4b: #9fd8ae;
  --wfn-sticky-5: #dbe8ff; --wfn-sticky-5b: #a9c2f0;
  --wfn-sticky-6: #ebe0ff; --wfn-sticky-6b: #c7aef2;
  --wfn-sticky-7: #f4f4f6; --wfn-sticky-7b: #d5d5dd;
}
@media (prefers-color-scheme: dark) {
  :root {
    --wfn-canvas: #26272f; --wfn-dot: #3f414d;
    --wfn-node-bg: #33343e; --wfn-node-border: #8a8c9a; --wfn-node-hover: #c4c6d2;
    --wfn-text: #d3d5df; --wfn-text-light: #9a9cab;
    --wfn-edge: #8a8c9a;
    --wfn-select: rgba(255, 255, 255, 0.14);
    --wfn-control-bg: #33343e; --wfn-control-border: #4a4c5a;
    --wfn-glyph-filter: brightness(1.5) drop-shadow(0 0 1px rgba(255, 255, 255, 0.45));
    --wfn-sticky-1: #4a3f14; --wfn-sticky-1b: #6b5a1c;
    --wfn-sticky-2: #4a3418; --wfn-sticky-2b: #6b4a22;
    --wfn-sticky-3: #4a2323; --wfn-sticky-3b: #6b3232;
    --wfn-sticky-4: #1f3d25; --wfn-sticky-4b: #2e5a37;
    --wfn-sticky-5: #1d3247; --wfn-sticky-5b: #2b4a68;
    --wfn-sticky-6: #2e2645; --wfn-sticky-6b: #453a66;
    --wfn-sticky-7: #2a2e37; --wfn-sticky-7b: #3f444f;
  }
}
.sr-wfc {
  position: relative;
  width: min(1080px, calc(100vw - 32px));
  left: 50%;
  transform: translateX(-50%);
  margin: 0 0 20px;
  border: 1px solid var(--sr-border);
  border-radius: 12px;
  background: var(--wfn-canvas);
  overflow: hidden;
}
.sr-wfc-canvas {
  position: relative;
  height: 440px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background-color: var(--wfn-canvas);
  background-image: radial-gradient(circle, var(--wfn-dot) 1px, transparent 1.6px);
  background-size: 20px 20px;
}
.sr-wfc-canvas.sr-wfc-panning { cursor: grabbing; }
.sr-wfc-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.sr-wfc-edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.sr-wfc-edge-line { fill: none; stroke: var(--wfn-edge); stroke-width: 2; vector-effect: non-scaling-stroke; transition: stroke 0.2s; }
.sr-wfc-edge-ok .sr-wfc-edge-line { stroke: var(--wfn-success); }
.sr-wfc-edge-running .sr-wfc-edge-line { stroke: var(--wfn-primary); stroke-dasharray: 8 6; animation: sr-wfc-dash 0.6s linear infinite; }
@keyframes sr-wfc-dash { to { stroke-dashoffset: -28; } }
.sr-wfc-edge-ai .sr-wfc-edge-line { stroke-dasharray: 6 5; }
.sr-wfc-edge-label { font: 600 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--wfn-text); paint-order: stroke; stroke: var(--wfn-canvas); stroke-width: 5px; stroke-linejoin: round; }
.sr-wfc-node { position: absolute; left: 0; top: 0; }
.sr-wfc-card {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  background: var(--wfn-node-bg);
  border: 2px solid var(--wfn-node-border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sr-wfc-trigger .sr-wfc-card { border-radius: 36px 8px 8px 36px; }
.sr-wfc-node:hover .sr-wfc-card { border-color: var(--wfn-node-hover); }
.sr-wfc-selected .sr-wfc-card { box-shadow: 0 0 0 4px var(--wfn-select); }
.sr-wfc-glyph { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; filter: var(--wfn-glyph-filter); }
.sr-wfc-disabled .sr-wfc-card { border-color: var(--wfn-control-border); }
.sr-wfc-disabled .sr-wfc-glyph { filter: grayscale(1) opacity(0.45); }
.sr-wfc-strike { position: absolute; left: -2px; right: -2px; top: 50%; height: 2px; margin-top: -1px; background: var(--wfn-node-border); }
.sr-wfc-label {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 190px;
  margin-top: 8px;
  transform: translateX(-50%);
  text-align: center;
  font: 500 14px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--wfn-text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  pointer-events: none;
}
.sr-wfc-deact { color: var(--wfn-text-light); }
.sr-wfc-status { position: absolute; top: 6px; right: 6px; display: flex; align-items: center; gap: 3px; font: 600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.sr-wfc-status-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sr-wfc-ok .sr-wfc-status { color: var(--wfn-success); }
.sr-wfc-error .sr-wfc-status { color: var(--wfn-danger); }
.sr-wfc-error .sr-wfc-card { border-color: var(--wfn-danger); }
.sr-wfc-waiting .sr-wfc-status { color: var(--wfn-warning); }
.sr-wfc-running .sr-wfc-card { border-color: var(--wfn-primary); animation: sr-wfc-pulse 1.4s ease-out infinite; }
@keyframes sr-wfc-pulse {
  0% { box-shadow: 0 0 0 0 var(--wfn-primary-soft); }
  70% { box-shadow: 0 0 0 10px rgba(255, 109, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 109, 90, 0); }
}
.sr-wfc-spinner { width: 16px; height: 16px; box-sizing: border-box; border: 2px solid var(--wfn-primary-soft); border-top-color: var(--wfn-primary); border-radius: 50%; animation: sr-wfc-spin 0.8s linear infinite; }
@keyframes sr-wfc-spin { to { transform: rotate(360deg); } }
.sr-wfc-in { position: absolute; left: -4px; width: 8px; height: 20px; margin-top: -10px; border-radius: 1px; background: var(--wfn-node-border); }
.sr-wfc-out { position: absolute; right: -7px; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--wfn-node-border); }
.sr-wfc-outlabel { position: absolute; left: 18px; top: -16px; font: 500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--wfn-text); white-space: nowrap; }
.sr-wfc-sticky {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  padding: 14px 16px;
  border-radius: 4px;
  border: 1px solid var(--wfn-sticky-1b);
  background: var(--wfn-sticky-1);
  color: var(--wfn-text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
.sr-wfc-c2 { background: var(--wfn-sticky-2); border-color: var(--wfn-sticky-2b); }
.sr-wfc-c3 { background: var(--wfn-sticky-3); border-color: var(--wfn-sticky-3b); }
.sr-wfc-c4 { background: var(--wfn-sticky-4); border-color: var(--wfn-sticky-4b); }
.sr-wfc-c5 { background: var(--wfn-sticky-5); border-color: var(--wfn-sticky-5b); }
.sr-wfc-c6 { background: var(--wfn-sticky-6); border-color: var(--wfn-sticky-6b); }
.sr-wfc-c7 { background: var(--wfn-sticky-7); border-color: var(--wfn-sticky-7b); }
.sr-wfc-sticky-h1 { font-size: 20px; font-weight: 700; line-height: 1.25; margin-bottom: 6px; }
.sr-wfc-sticky-h2 { font-size: 16px; font-weight: 700; line-height: 1.3; margin-bottom: 4px; }
.sr-wfc-sticky-h3 { font-size: 14px; font-weight: 600; }
.sr-wfc-sticky-gap { height: 8px; }
.sr-wfc-sticky-li { position: relative; padding-left: 14px; }
.sr-wfc-sticky-li::before { content: "\2022"; position: absolute; left: 2px; }
.sr-wfc-sticky a { color: var(--wfn-primary); }
.sr-wfc-sticky code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(0, 0, 0, 0.07); padding: 0 4px; border-radius: 3px; }
.sr-wfc-controls { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px; }
.sr-wfc-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  border: 1px solid var(--wfn-control-border);
  border-radius: 4px;
  background: var(--wfn-control-bg);
  color: var(--wfn-text);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.sr-wfc-btn:hover { border-color: var(--wfn-primary); color: var(--wfn-primary); }
.sr-wfc-btn-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-wfc-pop {
  position: absolute; z-index: 3; width: 250px;
  padding: 10px 12px; border: 1px solid var(--wfn-control-border); border-radius: 6px;
  background: var(--wfn-control-bg); color: var(--wfn-text); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); font-size: 12px;
}
.sr-wfc-pop-name { font-weight: 600; font-size: 13px; }
.sr-wfc-pop-type { font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--wfn-text-light); margin: 2px 0 6px; }
.sr-wfc-pop-row { color: var(--wfn-text); }
.sr-wfc-pop-err { margin-top: 4px; color: var(--wfn-danger); }
.sr-tl-details { margin: 14px 0 0; }
.sr-tl-details .sr-timeline { margin-top: 8px; }
@media (max-width: 720px) {
  .sr-wfc-canvas { height: 320px; }
  .sr-wfc { width: calc(100vw - 32px); }
}
