/* ActionSim. Kept out of the template: CSP is style-src 'self'.
   The layout rules are AWSim's (apps/awsim/static/css/awssim.css); ActionSim's own rules follow at the end. */
.sim-wrap { max-width: 1240px; margin: 0 auto; padding: 18px 16px 48px; }
.sim-canvas { overflow: auto; background: var(--bg); padding: 8px; }
.sim-canvas .sim-node, .sim-canvas .sim-box { cursor: pointer; }
.sim-canvas .sim-node { cursor: grab; touch-action: none; }
.sim-list { list-style: none; margin: 0; padding: 0; }
.sim-list li { padding: 5px 4px; border-bottom: 1px dotted var(--border); cursor: pointer; font-size: 13px; }
.sim-list li.selected { background: var(--surface2); }
.sim-actions { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
textarea.sim-input { font-family: ui-monospace, monospace; font-size: 12.5px; }
.msg { color: var(--ok); }
.msg.error { color: var(--ng); }
.sim-props { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.sim-props h3 { font-size: 14px; margin: 0 0 6px; word-break: break-all; }
.sim-props label { font-size: 13px; margin: 8px 0 4px; }
.sim-props input[type="text"], .sim-props select { padding: 6px; font-size: 13px; }
.sim-attrs { font-size: 12px; margin: 4px 0; }
.sim-attrs dt { color: var(--muted); }
.sim-attrs dd { margin: 0 0 4px 10px; word-break: break-all; }
button.danger { border-color: var(--ng); color: var(--ng); }
.sim-templates-wrap { margin: 8px 0 16px; }
.sim-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.sim-template { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.sim-template.selected { outline: 2px solid var(--ok); }
.sim-template h3 { font-size: 14px; margin: 0; }
.sim-template-summary { font-size: 12px; margin: 0; }
.sim-template button { margin-top: auto; padding: 4px 8px; font-size: 12px; }
.sim-storage { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; margin: 8px 0 16px; }
.sim-storage h2 { font-size: 15px; margin: 6px 0 0; }
.sim-storage .sim-actions { margin: 8px 0; }
.sim-storage input[type="text"] { width: 14em; }
.sim-storage select { width: auto; max-width: 22em; }
.sim-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.site-nav { margin-left: auto; font-size: 14px; display: flex; gap: 14px; }
.sim-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.sim-choice { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.sim-choice h2 { font-size: 16px; margin: 6px 0 0; }
.sim-choice p { margin: 0 0 6px; font-size: 13px; }
.sim-choice button, .sim-choice .button { margin-top: auto; align-self: flex-start; }
.sim-decide { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--border); padding: 10px 0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.sim-start { margin: 8px 0 16px; }
.sim-saved-designs { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sim-saved-designs li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.sim-saved-designs .note { font-size: 12px; }
/* Editor (/editor): full-viewport app — header, left palette, canvas, bottom panel. */
.sim-editor-page { height: 100vh; overflow: hidden; }
.sim-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.sim-app-header { flex: none; display: flex; align-items: center; gap: 8px 14px; padding: 6px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.sim-app-header .logo { font-size: 17px; }
.sim-back { font-size: 13px; white-space: nowrap; }
.sim-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.sim-header-actions > button, .sim-menu > summary { padding: 5px 12px; font-size: 13px; }
.sim-menu { position: relative; }
.sim-menu > summary { list-style: none; user-select: none; }
.sim-menu > summary::-webkit-details-marker { display: none; }
.sim-menu[open] > summary { border-color: var(--accent); }
.sim-menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 70px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 14px 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.sim-menu-panel h2 { font-size: 14px; margin: 8px 0 4px; }
.sim-menu-panel .note { font-size: 12px; margin: 4px 0 8px; }
.sim-storage.sim-menu-panel { margin: 0; }
.sim-statusbar { flex: none; min-height: 24px; padding: 2px 14px; font-size: 12.5px; border-bottom: 1px solid var(--border); background: var(--bg); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sim-body { flex: 1; min-height: 0; display: flex; }
/* Palette: floating panel over the canvas's top-left (canvas stays full-size underneath).
   Height leaves room for the bottom-right zoom bar; collapsed it becomes a small expand button. */
.sim-float-panel { position: absolute; top: 12px; left: 12px; z-index: 6; width: min(250px, calc(100% - 24px)); max-height: calc(100% - 76px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.sim-float-panel[hidden], .sim-float-expand[hidden] { display: none; }
.sim-float-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--border); }
.sim-float-head h2 { font-size: 13px; margin: 0; border: 0; padding: 0; }
.sim-float-toggle { padding: 0 8px; font-size: 14px; line-height: 1.6; }
.sim-float-body { flex: 1; min-height: 0; overflow: auto; padding: 6px 12px 12px; overscroll-behavior: contain; }
.sim-float-body h2 { font-size: 13px; margin: 10px 0 6px; }
.sim-float-body > .note { font-size: 11.5px; margin: 0 0 8px; }
.sim-sidebar .sim-list li { font-size: 12px; padding: 3px 2px; word-break: break-all; }
.sim-float-expand { position: absolute; top: 12px; left: 12px; z-index: 6; padding: 4px 10px; font-size: 12.5px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }
.sim-toolbar { flex: none; display: flex; gap: 10px; align-items: center; padding: 4px 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.sim-toolbar button { padding: 3px 10px; font-size: 12.5px; }
.sim-stage { flex: 1; min-height: 0; position: relative; }
.sim-stage .sim-canvas { position: absolute; inset: 0; }
/* Pan: the canvas no longer scrolls; the diagram sits in a translated layer. */
.sim-stage .sim-canvas { overflow: hidden; padding: 0; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
/* Snap grid (20px at 100%) across the whole canvas; actionsim-page.js keeps its
   size / position / strength in step with the zoom and pan of the diagram. */
.sim-stage .sim-canvas { --sim-grid-alpha: 0.14; background-image: linear-gradient(to right, rgba(154, 167, 180, var(--sim-grid-alpha)) 1px, transparent 1px), linear-gradient(to bottom, rgba(154, 167, 180, var(--sim-grid-alpha)) 1px, transparent 1px); background-size: 20px 20px; background-position: 0 0; }
.sim-stage .sim-canvas.panning, .sim-stage .sim-canvas.panning .sim-box { cursor: grabbing; }
.sim-canvas-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.sim-canvas-world svg { display: block; }
.sim-stage .sim-canvas > .note { margin: 12px; }
.sim-zoom { position: absolute; right: 14px; bottom: 14px; z-index: 5; display: flex; gap: 4px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }
.sim-zoom button { padding: 2px 9px; font-size: 13px; }
.sim-zoom-level { min-width: 3.4em; text-align: center; font-size: 12px; color: var(--muted); }
.sim-props-panel { flex: none; max-height: 42%; overflow: auto; border-top: 1px solid var(--border); background: var(--surface); padding: 0 14px 10px; }
.sim-props-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sim-props-head h2 { font-size: 13px; margin: 6px 0; border: 0; padding: 0; }
.sim-props-head button { padding: 0 9px; font-size: 15px; }
.sim-props-panel .sim-props { background: none; border: 0; padding: 0; margin: 0; }
.sim-code-view { padding: 10px 14px; }
.sim-code-view label { margin: 0 0 6px; flex: none; }
.sim-code-view textarea.sim-input { flex: 1; min-height: 0; resize: none; }
.sim-code-view .sim-actions { flex: none; margin: 10px 0 0; }
.sim-code-view .sim-code-note { flex: none; font-size: 12px; margin: 6px 0 0; }
@media (max-width: 720px) {
  .sim-app-header { flex-wrap: wrap; }
  .sim-body { flex-direction: column; }
  .sim-float-panel { top: 8px; left: 8px; width: min(220px, calc(100% - 16px)); max-height: calc(100% - 64px); }
  .sim-float-expand { top: 8px; left: 8px; }
  .sim-header-actions { margin-left: 0; flex-wrap: wrap; }
}
.sim-props-panel .sim-props input[type="text"], .sim-props-panel .sim-props select { max-width: 560px; }
/* About / privacy pages. */
.sim-doc { max-width: 820px; }
.sim-doc h2 { margin-top: 28px; }
.sim-doc p, .sim-doc li { line-height: 1.8; }
/* ---- ActionSim ---------------------------------------------------------------- */
.sim-file-name { font-size: 13px; color: var(--text); max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim-file-name[hidden] { display: none; }
.sim-header-actions > button[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); font-weight: 700; }
.sim-paste { margin: 8px 0 16px; }
.sim-template-shape, .sim-template-duration { font-size: 12px; margin: 0; }
.sim-template-duration { font-weight: 700; }
.sim-template-points { font-size: 12px; margin: 0 0 4px; padding-left: 18px; color: var(--muted); }
/* Nodes on the canvas. */
.sim-canvas .sim-node { cursor: grab; touch-action: none; }
.sim-canvas .sim-node.selected rect:first-of-type { stroke-width: 3; }
/* Stage list in the floating panel. */
.sim-stages { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sim-stage-item { border-left: 3px solid var(--accent); padding: 2px 0 2px 8px; }
.sim-stage-item.unstaged { border-left-color: var(--ng); }
.sim-stage-label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.sim-stage-item.unstaged .sim-stage-label { color: var(--ng); }
.sim-stage-jobs { display: flex; flex-direction: column; gap: 4px; }
.sim-stage-job { text-align: left; padding: 3px 8px; font-size: 12px; word-break: break-all; }
.sim-stage-job.selected { border-color: var(--ok); color: var(--ok); }
.sim-stage-badge { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid #d29922; border-radius: 8px; color: #d29922; font-size: 10.5px; font-weight: 700; }
.sim-stage-badge.reusable { border-color: #bc8cff; color: #bc8cff; }
.sim-problems h3 { font-size: 12px; margin: 10px 0 4px; }
.sim-problems-h.error { color: var(--ng); }
.sim-problems-h.warn { color: #d29922; }
.sim-problem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; line-height: 1.5; }
.sim-problem { border-left: 3px solid #d29922; padding: 2px 6px; }
.sim-problem.error { border-left-color: var(--ng); }
.sim-problem-link { display: block; width: 100%; text-align: left; padding: 0; border: 0; background: none; color: inherit; font-size: inherit; line-height: inherit; }
.sim-problem-link:hover { text-decoration: underline; }
/* Details panel (read-only). */
.sim-props h3 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.sim-kind { font-size: 11px; font-weight: 700; padding: 0 6px; border: 1px solid var(--accent); border-radius: 8px; color: var(--accent); }
.sim-kind.reusable { border-color: #bc8cff; color: #bc8cff; }
.sim-detail-attrs { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; max-width: 900px; }
.sim-detail-attrs dd { margin: 0; }
.sim-detail-section h4 { font-size: 12.5px; margin: 12px 0 4px; color: var(--muted); }
.sim-detail-warn { color: #d29922; font-size: 12px; }
.sim-detail-attrs dd.sim-detail-warn { color: #d29922; }
.sim-pre { margin: 2px 0; padding: 6px 8px; font-size: 11.5px; line-height: 1.5; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; white-space: pre-wrap; word-break: break-all; max-height: 240px; overflow: auto; }
.sim-table { border-collapse: collapse; font-size: 12px; width: 100%; max-width: 1100px; }
.sim-table th, .sim-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.sim-table th { color: var(--muted); font-weight: 700; white-space: nowrap; }
.sim-table code { word-break: break-all; white-space: pre-wrap; }
.sim-steps .sim-step-no { color: var(--muted); width: 2em; }
.sim-step.uses td:nth-child(2) { color: var(--accent); font-weight: 700; }
.sim-step.run td:nth-child(2) { color: var(--ok); font-weight: 700; }
.sim-step-body .note { display: block; font-size: 11px; }
.sim-step-if { white-space: pre-wrap; word-break: break-all; }
.sim-matrix-count { font-size: 12.5px; margin: 2px 0 4px; font-weight: 700; }
.sim-combos { font-size: 11.5px; margin: 0 0 4px; padding-left: 26px; columns: 2 280px; }
.sim-sidebar.sim-float-panel { width: min(290px, calc(100% - 24px)); }
