/* ══════════════════════════════════════════════════════════════════════
   Survey workspace — the playground and the client survey editor.

   One page, three things in priority order: describe the survey (AI),
   check its flow, and read or edit the Syrup behind it. Rendered by
   shared/_survey_workspace inside the playground and survey_editor
   layouts, in the srp.solutions look: dark header, paper body, Inter,
   one amber accent. Only the Syrup source keeps a dark surface.

   Propshaft serves every stylesheet on every page, so everything here is
   prefixed (ws-, dsl-, validation-) and nothing is a bare element rule.
   ══════════════════════════════════════════════════════════════════════ */

.ws-page,
.ws {
  --ws-bg: #f3f1ec;
  --ws-bg-alt: #ebe8e1;
  --ws-surface: #fbfaf7;
  --ws-text: #15191c;
  --ws-muted: #5f676d;
  --ws-border: #e0ddd4;
  --ws-border-strong: #c4bfb2;
  --ws-accent: #8a4b05;
  --ws-amber: #f2a541;
  --ws-accent-dim: rgba(242, 165, 65, 0.16);
  --ws-accent-border: rgba(138, 75, 5, 0.28);
  --ws-ok: #1f6b3a;
  --ws-warn: #8a4b05;
  --ws-err: #8f2b1c;
  --ws-err-bg: #fdf1ef;
  --ws-err-border: #efc6be;
  --ws-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --ws-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* The code editor's theme (survey_editor_controller.js) reads these. */
  --ed-bg: #161a1d; --ed-gutter: #131719; --ed-line: #22282d; --ed-panel: #131719;
  --ed-text: #eceff1; --ed-muted: #a3acb3; --ed-dim: #8b959c;
  --ed-accent: #f2a541; --ed-accent-rgb: 242 165 65;
}

.ws-page {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ws-bg);
  color: var(--ws-text);
  font-family: var(--ws-sans);
  -webkit-font-smoothing: antialiased;
}
.ws-page *, .ws-page *::before, .ws-page *::after { box-sizing: border-box; }
.ws-page [hidden] { display: none !important; }
.ws-page :is(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--ws-amber);
  outline-offset: 2px;
}

/* ── Header (both layouts) ── */
.ws-header {
  min-height: 48px;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 6px 1rem;
  background: #0e1113;
  border-bottom: 1px solid #22282d;
  color: #eceff1;
}
.ws-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 1rem; font-weight: 700; color: #eceff1; text-decoration: none;
}
.ws-brand::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--ws-amber); }
.ws-brand-tag { font-family: var(--ws-mono); font-size: 0.75rem; font-weight: 400; color: #8b959c; }
.ws-header-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.ws-header-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.ws-header-link {
  font-family: var(--ws-sans); font-size: 0.875rem; font-weight: 500;
  color: #a3acb3; text-decoration: none;
  padding: 0.4rem 0.75rem; border-radius: 6px;
  background: none; border: none; cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.ws-header-link:hover { color: #eceff1; background: #1c2125; }
.ws-header-file {
  font-family: var(--ws-mono); font-size: 0.75rem; color: var(--ws-amber);
  background: rgba(242, 165, 65, 0.12); border: 1px solid rgba(242, 165, 65, 0.3);
  border-radius: 4px; padding: 2px 7px;
}
.ws-header-select {
  font-family: var(--ws-sans); font-size: 0.875rem; color: #eceff1;
  background: #1c2125; border: 1px solid #3a4248; border-radius: 6px;
  padding: 0.35rem 0.5rem; max-width: 12rem; cursor: pointer;
}
.ws-header-note { font-size: 0.8125rem; color: #8b959c; }

.ws-main { flex: 1; min-height: 0; display: flex; }
.ws-main > form { flex: 1; min-width: 0; min-height: 0; display: flex; }

/* ── Shell ── */
.ws {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  font-size: 0.9375rem; line-height: 1.5;
}

.ws-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 40px; padding: 0 1rem;
  font-family: var(--ws-sans); font-size: 0.875rem; font-weight: 600;
  color: var(--ws-text); background: #fff;
  border: 1px solid var(--ws-border-strong); border-radius: 6px;
  cursor: pointer; text-decoration: none;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}
.ws-btn:hover { border-color: var(--ws-muted); }
.ws-btn:disabled { opacity: 0.6; cursor: progress; }
.ws-btn-primary { color: #15191c; background: var(--ws-amber); border-color: var(--ws-amber); }
.ws-btn-primary:hover { background: #e8962b; border-color: #e8962b; }
.ws-btn-quiet { min-height: 32px; padding: 0 0.625rem; font-weight: 500; font-size: 0.8125rem; background: transparent; }
.ws-link-btn {
  font: inherit; color: var(--ws-accent); background: none; border: none; padding: 0;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.ws-label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--ws-text); }
.ws-textarea {
  display: block; width: 100%;
  padding: 0.625rem 0.75rem;
  font-family: var(--ws-sans); font-size: 1rem; line-height: 1.5; color: var(--ws-text);
  background: #fff; border: 1px solid var(--ws-border-strong); border-radius: 6px;
  resize: vertical;
}
.ws-textarea:focus { border-color: var(--ws-accent); }
.ws-error { font-size: 0.875rem; color: var(--ws-err); }
.ws-hint { font-size: 0.8125rem; color: var(--ws-muted); }

/* ── Start screen ── */
.ws-start { flex: 1; min-height: 0; overflow: auto; padding: clamp(1.5rem, 6vh, 4.5rem) 1rem 3rem; }
.ws-start-inner { max-width: 44rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }
.ws-eyebrow {
  margin: 0; font-family: var(--ws-mono); font-size: 0.75rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ws-accent);
}
.ws-start-title {
  margin: 0; font-size: clamp(1.75rem, 4.5vw, 2.75rem); font-weight: 700;
  line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance;
}
.ws-lede { margin: 0; max-width: 38rem; font-size: 1.0625rem; color: var(--ws-muted); }
.ws-start-head { display: flex; flex-direction: column; gap: 0.75rem; }
.ws-prompt {
  display: flex; flex-direction: column; gap: 0.75rem;
  padding: 1rem; background: var(--ws-surface);
  border: 1px solid var(--ws-border); border-radius: 10px;
}
.ws-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--ws-muted); }
.ws-chip {
  min-height: 36px; padding: 0 0.875rem;
  font-family: var(--ws-sans); font-size: 0.875rem; color: var(--ws-text);
  background: var(--ws-bg); border: 1px solid var(--ws-border-strong); border-radius: 999px;
  cursor: pointer;
}
.ws-chip:hover { border-color: var(--ws-muted); }
.ws-prompt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.ws-start-alt { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem; font-size: 0.9375rem; color: var(--ws-muted); }
.ws-start-alt .ws-link-btn { padding: 0.5rem 0; }

/* ── Body: rail + canvas ── */
.ws-body { flex: 1; min-height: 0; display: flex; }

.ws-rail {
  flex: 0 0 clamp(18rem, 28vw, 24rem); min-height: 0;
  display: flex; flex-direction: column; gap: 0.875rem;
  padding: 1rem; background: var(--ws-surface);
  border-right: 1px solid var(--ws-border);
}
.ws-rail-title {
  margin: 0; font-family: var(--ws-mono); font-size: 0.75rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ws-muted);
}
.ws-thread { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 0.75rem; }
.ws-thread-empty { margin: 0; color: var(--ws-muted); }
.ws-turn-user {
  align-self: flex-end; max-width: 92%; margin: 0;
  padding: 0.5rem 0.75rem; background: var(--ws-accent-dim);
  border-radius: 10px 10px 2px 10px; overflow-wrap: anywhere;
}
.ws-turn-result {
  margin: 0; padding: 0.625rem 0.75rem;
  border: 1px solid var(--ws-border); border-radius: 8px; background: #fff;
}
.ws-turn-result p { margin: 0; }
.ws-turn-result.is-current { border-color: var(--ws-accent-border); box-shadow: inset 3px 0 0 var(--ws-amber); }
.ws-turn-meta { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.25rem !important; font-size: 0.8125rem; color: var(--ws-muted); }
.ws-turn-result.is-current .ws-turn-meta span { color: var(--ws-accent); font-weight: 600; }
.ws-turn-user.is-pending { opacity: 0.7; }
.ws-turn-result.is-pending { color: var(--ws-muted); }
.ws-turn-result.is-failed { color: var(--ws-err); background: var(--ws-err-bg); border-color: var(--ws-err-border); }
.ws-composer {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.75rem; background: #fff;
  border: 1px solid var(--ws-border-strong); border-radius: 10px;
}
.ws-composer .ws-textarea { resize: none; font-size: 0.9375rem; }
.ws-composer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.ws-notice {
  margin: 0; padding: 0.75rem;
  background: var(--ws-bg); border: 1px solid var(--ws-border); border-radius: 10px;
  color: var(--ws-muted);
}
.ws-notice strong { display: block; color: var(--ws-text); }
.ws-gate {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.625rem;
  padding: 1rem; background: var(--ws-bg);
  border: 1px solid var(--ws-border-strong); border-radius: 10px;
}
.ws-gate p { margin: 0; color: var(--ws-muted); }
.ws-gate .ws-gate-title { font-size: 1.0625rem; font-weight: 700; line-height: 1.25; color: var(--ws-text); }

.ws-canvas { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.ws-tabs {
  flex-shrink: 0; display: flex; align-items: center; gap: 0.25rem;
  padding: 0 1rem; border-bottom: 1px solid var(--ws-border);
}
.ws-tab {
  min-height: 44px; padding: 0 0.875rem;
  font-family: var(--ws-sans); font-size: 0.9375rem; font-weight: 500; color: var(--ws-muted);
  background: none; border: none; border-bottom: 3px solid transparent; cursor: pointer;
}
.ws-tab:hover { color: var(--ws-text); }
.ws-tab[aria-selected="true"] { color: var(--ws-text); border-bottom-color: var(--ws-amber); }
.ws-tab-describe { display: none; }
.ws-status { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; font-size: 0.8125rem; color: var(--ws-muted); }

.ws-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ws-panel-bar {
  flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem;
  padding: 0.375rem 1rem; font-size: 0.8125rem; color: var(--ws-muted);
}
.ws-panel-bar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

/* Flow */
.ws-flow {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 0.5rem 1rem 1.5rem; color: var(--ws-muted);
}
.ws-flow svg { max-width: 100%; height: auto; }
.ws-flow-empty { max-width: 26rem; margin: 3rem auto 0; text-align: center; }
.ws-flow-empty strong { display: block; margin-bottom: 0.25rem; color: var(--ws-text); }

/* Preview */
.ws-preview-frame { flex: 1; min-height: 0; width: 100%; border: 0; border-top: 1px solid var(--ws-border); background: #fff; }

/* Syrup */
.ws-select {
  font-family: var(--ws-sans); font-size: 0.8125rem; color: var(--ws-text);
  background: #fff; border: 1px solid var(--ws-border-strong); border-radius: 6px;
  padding: 0.3rem 0.5rem; cursor: pointer;
}
.ws-syrup-split { flex: 1; min-height: 0; display: flex; }
.ws-editor { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--ed-bg); }
.ws-reference {
  flex: 0 0 22rem; min-height: 0; overflow: auto;
  padding: 1rem; background: var(--ws-surface); border-left: 1px solid var(--ws-border);
  font-size: 0.8125rem; color: var(--ws-muted);
}
.ws-reference h3 {
  margin: 1.25rem 0 0.5rem; font-family: var(--ws-mono); font-size: 0.6875rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ws-muted);
}
.ws-reference p { margin: 0; color: var(--ws-text); }
.ws-reference pre {
  margin: 0; padding: 0.625rem 0.75rem; overflow-x: auto;
  font-family: var(--ws-mono); font-size: 0.75rem; line-height: 1.7;
  color: #d5dade; background: #161a1d; border-radius: 6px;
}
.ws-reference dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.75rem; align-items: baseline; }
.ws-reference dt { font-family: var(--ws-mono); font-size: 0.75rem; color: var(--ws-text); }
.ws-reference dd { margin: 0; }
.ws-reference a { display: inline-block; margin-top: 1.25rem; color: var(--ws-accent); font-weight: 500; }

.ws-issues { flex-shrink: 0; max-height: 40%; overflow: auto; padding: 0.75rem 1rem; background: var(--ws-surface); border-top: 1px solid var(--ws-border); }

/* Playground footer: share link and expiry */
.ws-footer {
  flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 0.75rem;
  padding: 0.375rem 1rem; background: var(--ws-bg-alt); border-top: 1px solid var(--ws-border);
  font-size: 0.8125rem; color: var(--ws-muted);
}
.ws-share-url {
  flex: 1 1 12rem; min-width: 0; max-width: 28rem;
  font-family: var(--ws-mono); font-size: 0.75rem; color: var(--ws-text);
  background: #fff; border: 1px solid var(--ws-border); border-radius: 6px; padding: 0.3rem 0.5rem;
}

/* ── Validation badge and issue list ──
   Written by survey_editor_controller.js; also used by the new-survey form. */
.validation-ok   { color: #1f6b3a; font-weight: 600; }
.validation-warn { color: #8a4b05; font-weight: 600; }
.validation-err  { color: #8f2b1c; font-weight: 600; }
.ide-badge-btn {
  font: inherit; font-weight: 600; background: none; border: none; padding: 0; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 2px;
}
.dsl-errors { width: 100%; }
.dsl-errors-header, .dsl-warnings-header { margin: 0 0 0.5rem; font-size: 0.8125rem; font-weight: 600; }
.dsl-errors-header { color: #8f2b1c; }
.dsl-warnings-header { color: #8a4b05; }
.dsl-issues-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.dsl-issue { padding: 0.4rem 0.625rem; border-radius: 6px; font-size: 0.8125rem; line-height: 1.5; overflow-wrap: anywhere; }
.dsl-issue em { font-style: normal; opacity: 0.8; }
.dsl-issue-error { color: #8f2b1c; background: #fdf1ef; border: 1px solid #efc6be; }
.dsl-issue-warn  { color: #6d3b04; background: rgba(242, 165, 65, 0.16); border: 1px solid rgba(138, 75, 5, 0.28); }
.dsl-dismiss-btn {
  display: block; margin-bottom: 0.5rem; padding: 0;
  font: inherit; font-size: 0.8125rem; color: #5f676d;
  background: none; border: none; cursor: pointer; text-decoration: underline;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes ws-reveal { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
  .ws-flow svg { animation: ws-reveal 0.3s cubic-bezier(0.25, 1, 0.5, 1); }
}

/* ── Phones: one thing at a time, behind four tabs ── */
@media (max-width: 768px) {
  .ws-body { flex-direction: column; }
  .ws-canvas { display: contents; }
  .ws-tabs { order: 0; padding: 0 0.25rem; gap: 0; background: var(--ws-surface); }
  .ws-tab { flex: 1; padding: 0 0.25rem; font-size: 0.875rem; }
  .ws-tab-describe { display: block; }
  .ws-status { display: none; }
  .ws-rail { order: 1; flex: 1; display: none; border-right: 0; }
  .ws-panel { order: 2; }
  .ws-view-describe .ws-rail { display: flex; }
  .ws-view-describe .ws-panel { display: none; }
  .ws-syrup-split { flex-direction: column; }
  .ws-reference { flex: 0 0 45%; border-left: 0; border-top: 1px solid var(--ws-border); }
  .ws-header-right, .ws-header-extra { display: none; }
}
