/* Click indicator: halo + "Add material" pill over the selected step (HTML, not part of the exported SVG) */
#material-overlay { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
#material-overlay[hidden] { display: none; }
.mat-halo {
  position: absolute;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  animation: mat-pulse 1.8s ease-in-out infinite;
}
.mat-halo.drop { outline: 2px dashed var(--accent); animation: none; }
.mat-anchor { position: absolute; transform: translate(-50%, -100%); }
.mat-anchor.below { transform: translate(-50%, 0); }
.mat-wrap { position: relative; display: flex; flex-direction: column; align-items: center; pointer-events: auto; }
.mat-wrap.rise { animation: mat-rise 300ms ease-out; }
.mat-pill {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-small);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-float);
}
.mat-pill:hover { background: var(--accent-hover); }
.mat-pill:focus-visible, .mat-menu-item:focus-visible, .mat-btn:focus-visible, .mat-name.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mat-menu {
  position: absolute;
  top: 100%;
  margin-top: 6px;
  min-width: 160px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
}
.mat-anchor:not(.below) .mat-menu { top: auto; bottom: 100%; margin: 0 0 6px; }
.mat-menu[hidden] { display: none; }
.mat-menu-item { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; font-size: var(--fs-small); color: var(--text); cursor: pointer; }
.mat-menu-item:hover { background: var(--surface-2); }
@keyframes mat-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes mat-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .mat-halo { animation: none; }
  .mat-wrap.rise { animation: none; }
}

/* Note dialog + buttons */
.mat-btn { height: 30px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: none; color: var(--text); font-size: var(--fs-small); cursor: pointer; }
.mat-btn:hover { background: var(--surface-2); }
.mat-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.mat-btn.primary:hover { background: var(--accent-hover); }
.mat-btn.small { height: 24px; padding: 0 8px; font-size: var(--fs-small); color: var(--text-muted); }
.mat-dialog { width: min(520px, 92vw); padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-float); }
.mat-dialog::backdrop { background: color-mix(in srgb, var(--text) 35%, transparent); backdrop-filter: blur(2px); }
.mat-dialog h2 { margin: 0 0 10px; font-size: var(--fs-h3); font-weight: 600; }
.mat-note-text { display: block; width: 100%; min-height: 160px; resize: vertical; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--radius-md); background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--fs-small); }
.mat-note-text:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.mat-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* Materials list in the notes panel */
.notes-materials { display: flex; flex-direction: column; gap: 6px; }
.mat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mat-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 8px; background: var(--surface-2); border-radius: var(--radius-sm); }
.mat-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 120px; }
.mat-name { padding: 0; border: 0; background: none; text-align: left; font-size: var(--fs-small); color: var(--text); overflow-wrap: anywhere; }
.mat-name.link { cursor: pointer; }
.mat-name.link:hover { color: var(--accent); }
.mat-meta { font-size: var(--fs-micro); color: var(--text-muted); }
.mat-actions { display: flex; gap: 4px; }
.mat-thumb { width: 36px; height: 36px; flex: 0 0 36px; padding: 0; border: 0; border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; cursor: zoom-in; }
.mat-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mat-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mat-preview { flex: 1 1 100%; margin: 0; max-height: 160px; overflow: auto; padding: 8px; background: var(--surface); border-radius: var(--radius-sm); font-family: var(--mono); font-size: var(--fs-small); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }

/* Material count badge on steps and groups */
.mat-badge { pointer-events: none; }
.mat-chip rect { stroke: var(--surface); stroke-width: 2; }
.mat-chip-note rect { fill: var(--accent); }
.mat-chip-file rect { fill: var(--badge-file); }
.mat-chip-note { color: var(--on-accent); }
.mat-chip-file { color: var(--on-badge-file); }
.mat-chip-icon { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mat-chip text { fill: currentColor; font-size: var(--fs-micro); font-weight: 600; }

/* Image viewer (materials): card with a title row and an X; click outside or Esc closes */
.img-dialog { max-width: min(92vw, 1000px); max-height: 92vh; padding: 0; border: 0; background: transparent; color: var(--text); overflow: visible; }
.img-dialog::backdrop { background: color-mix(in srgb, var(--text) 45%, transparent); backdrop-filter: blur(2px); }
.img-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-float); max-height: 92vh; box-sizing: border-box; }
.img-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.img-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-small); font-weight: 600; }
.img-head .icon-btn { flex: 0 0 auto; }
.img-card img { display: block; max-width: 100%; max-height: calc(92vh - 60px); width: auto; height: auto; margin: 0 auto; object-fit: contain; border-radius: var(--radius-sm); }
.img-card img:focus-visible { outline: 2px solid var(--accent); }

/* Attachment budget under the list, and the rename field */
.mat-usage { margin: 8px 0 0; font-size: var(--fs-small); color: var(--text-muted); }
.mat-usage.low { color: var(--danger); }
.mat-rename-row { display: flex; align-items: baseline; gap: 2px; min-width: 0; }
.mat-rename { flex: 1 1 60px; min-width: 0; padding: 2px 6px; font: inherit; font-size: var(--fs-small); color: var(--text); background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius-sm); }
.mat-ext { font-size: var(--fs-small); color: var(--text-muted); }
