/* The workflow canvas: its own window chrome, the cards on the grid, the comment pin and
   the tool bar that floats over it. */

.canvas-window {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  overflow: hidden;
}

/* ── window chrome ─────────────────────────────────────────────────── */
.canvas-chrome {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
  padding: 10px var(--s3);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.chrome-left,
.chrome-right {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: 1;
  min-width: 0;
}

.chrome-right {
  justify-content: flex-end;
}

.chrome-title {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
  min-width: 0;
  padding: 4px 10px;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  font-size: var(--t-h3);
  transition: background var(--fast);
}

.chrome-title:hover {
  background: var(--surface-2);
}

.chrome-title .ico {
  color: var(--fg-3);
  flex: none;
}

.zoom {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.zoom-level {
  min-width: 44px;
  padding: 0 4px;
  font-size: var(--t-micro);
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
  border-radius: var(--r-sm);
}

.zoom-level:hover {
  background: var(--surface);
  color: var(--fg);
}

.avatar-stack {
  display: flex;
  flex: none;
  padding-left: 5px;
}

.avatar-stack .avatar {
  margin-left: -5px;
  border: 2px solid var(--surface);
  box-sizing: content-box;
}

/* ── the menu under Options ────────────────────────────────────────── */
.menu-anchor {
  position: relative;
}

.menu-catch {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 21;
  width: 232px;
  padding: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: pop var(--fast) both;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: 7px var(--s2);
  border-radius: var(--r-sm);
  font-size: var(--t-small);
  color: var(--fg-2);
  text-align: left;
}

.menu-item:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.menu-item[data-tone="bad"] {
  color: var(--bad);
}

.menu-item[data-tone="bad"]:hover {
  background: var(--bad-soft);
}

.menu-item .ico {
  flex: none;
  color: var(--fg-3);
}

.menu-item[data-tone="bad"] .ico {
  color: var(--bad);
}

.menu-item .shortcut {
  margin-left: auto;
  font-size: 11px;
  color: var(--fg-3);
}

.menu-sep {
  height: 1px;
  margin: var(--s1) var(--s2);
  background: var(--border);
}

/* ── the grid ──────────────────────────────────────────────────────── */
.canvas-body {
  position: relative;
  min-width: 0;
}

.canvas-stage {
  position: relative;
  min-height: 560px;
  max-height: 72vh;
  overflow: auto;
  background-color: var(--bg-sunk);
  background-image: radial-gradient(var(--border-strong) 1.1px, transparent 1.1px);
  background-size: 22px 22px;
  /* Room under the flow so the last card can scroll clear of the tool bar. */
  padding-bottom: 96px;
}

.canvas-sizer {
  position: relative;
}

:root[data-theme="dark"] .canvas-stage {
  background-color: #0a0a09;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .canvas-stage {
    background-color: #0a0a09;
  }
}

.canvas-world {
  position: relative;
  transform-origin: 0 0;
}

/* ── node cards ────────────────────────────────────────────────────── */
.wf-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  text-align: left;
  cursor: grab;
  transition:
    border-color var(--fast),
    box-shadow var(--fast);
}

.wf-node:hover {
  border-color: var(--fg-3);
}

.wf-node[data-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.wf-node[data-highlight="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wf-who {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--fg-2);
}

.wf-title {
  font-family: var(--font-display);
  font-size: var(--t-h2);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--fg);
}

.wf-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: var(--t-micro);
  font-weight: 600;
}

/* A flat stand-in for whatever the step actually looks at. */
.wf-preview {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.wf-preview i {
  display: block;
  height: 5px;
  border-radius: var(--r-full);
  background: var(--border-strong);
}

.wf-preview i + i {
  margin-top: 7px;
}

.wf-chip {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--t-small);
  font-weight: 500;
}

.wf-people {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s2);
}

.wf-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wf-step {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--t-micro);
  line-height: 1.4;
  text-align: left;
}

.wf-disclose {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--accent);
}

/* ── decision ──────────────────────────────────────────────────────── */
.wf-decision {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  cursor: grab;
  transition:
    border-color var(--fast),
    box-shadow var(--fast);
}

.wf-decision:hover {
  border-color: var(--accent);
}

.wf-decision[data-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.wf-decision-label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding-bottom: 10px;
  font-size: var(--t-micro);
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
}

.edge-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--bg-sunk);
  font-size: var(--t-micro);
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  pointer-events: none;
}

:root[data-theme="dark"] .edge-label {
  background: #0a0a09;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .edge-label {
    background: #0a0a09;
  }
}

/* ── comment pin and thread ────────────────────────────────────────── */
.comment-pin {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: var(--r-full) var(--r-full) var(--r-full) 4px;
  border: 2px solid var(--surface);
  background: var(--t-sand);
  color: var(--t-sand-fg);
  display: grid;
  place-items: center;
  font-size: var(--t-micro);
  font-weight: 700;
  box-shadow: var(--shadow-pop);
  transition: transform var(--fast);
}

.comment-pin:hover {
  transform: scale(1.06);
}

.comment-pop {
  position: absolute;
  z-index: 6;
  width: 320px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  animation: pop var(--fast) both;
}

.comment-head {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.comment-body {
  padding: var(--s3);
}

.comment-text {
  margin-top: 6px;
  font-size: var(--t-small);
  line-height: 1.55;
}

.mention {
  color: var(--accent);
  font-weight: 600;
}

.comment-reply {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3) var(--s3);
}

.comment-reply .field {
  flex: 1;
  min-width: 0;
}

.send-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--accent-fg);
  transition: background var(--fast);
}

.send-btn:hover {
  background: var(--accent-hover);
}

/* ── the floating tool bar ─────────────────────────────────────────── */
.toolbar {
  position: absolute;
  bottom: var(--s4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  overflow-x: auto;
}

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 var(--s3);
}

.tool-group + .tool-group {
  border-left: 1px solid var(--border);
}

.tool-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding-left: 2px;
}

.tool-row {
  display: flex;
  gap: 2px;
}

.tool {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  color: var(--fg-2);
  transition:
    background var(--fast),
    color var(--fast);
}

.tool:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.tool[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ink-fg);
}

.tool[data-tint] {
  color: var(--t-stone-fg);
}

.tool[data-tint="violet"] {
  background: var(--t-violet);
  color: var(--t-violet-fg);
}

.tool[data-tint="sky"] {
  background: var(--t-sky);
  color: var(--t-sky-fg);
}

.tool[data-tint="mint"] {
  background: var(--t-mint);
  color: var(--t-mint-fg);
}

.tool[data-tint="sand"] {
  background: var(--t-sand);
  color: var(--t-sand-fg);
}

.tool[data-tint]:hover {
  filter: brightness(0.96);
}

@media (max-width: 860px) {
  .canvas-stage {
    min-height: 440px;
  }

  .chrome-left .zoom,
  .chrome-right .avatar-stack {
    display: none;
  }
}

/* ── the account popover ───────────────────────────────────────────── */
.account-anchor {
  position: relative;
  display: block;
}

.account-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 21;
  min-width: 248px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  animation: pop var(--fast) both;
  overflow: hidden;
}

.account-menu-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  border-bottom: 1px solid var(--border);
  font-size: var(--t-small);
}

.account-menu-body {
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--s2) var(--s1) var(--s1);
}

.account-menu .menu-item {
  gap: var(--s2);
}
