/* =============================================================
   Modern Web Part Canvas — scoped to body[data-modern-ui="true"]
   Ported from _project/design/from_ClaudeDesigner/styles.css
   ============================================================= */

/* Canvas grid */
body[data-modern-ui="true"] .wp-canvas {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  padding: 20px 32px 80px;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
body[data-modern-ui="true"] .wp-canvas.fill {
  max-width: none;
  padding: 20px 40px 80px;
}
body[data-modern-ui="true"] .wp-cell {
  min-width: 0;
}

/* Frame */
body[data-modern-ui="true"] .wp-frame {
  position: relative;
  border-radius: var(--radius-md);
  background: transparent;
  transition: background 80ms ease;
}
body[data-modern-ui="true"] .wp-canvas.editing .wp-frame {
  cursor: default;
  padding: 2px;
  margin: 2px;
  border: 1px dashed transparent;
}
body[data-modern-ui="true"] .wp-canvas.editing .wp-frame:hover {
  border-color: var(--border-strong);
  background: oklch(0.99 0.01 260);
}
body[data-modern-ui="true"] .wp-canvas.editing .wp-frame.selected {
  border: 1px solid var(--accent);
  background: var(--bg-panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Tag (hover label) */
body[data-modern-ui="true"] .wp-tag {
  position: absolute;
  top: -11px;
  left: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 2px 3px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--fg-muted);
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
  white-space: nowrap;
}
body[data-modern-ui="true"] .wp-canvas.editing .wp-frame:hover .wp-tag,
body[data-modern-ui="true"] .wp-canvas.editing .wp-frame.selected .wp-tag {
  opacity: 1;
}
body[data-modern-ui="true"] .wp-tag-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  flex-shrink: 0;
}
body[data-modern-ui="true"] .wp-tag-source {
  color: var(--fg-subtle);
  font-weight: 400;
  font-size: 10px;
}

/* Toolbar (top-right of selected frame) */
body[data-modern-ui="true"] .wp-toolbar {
  position: absolute;
  top: -14px;
  right: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 2px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 6px oklch(0 0 0 / 0.08);
}
body[data-modern-ui="true"] .wp-toolbar button {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  color: var(--fg-muted);
}
body[data-modern-ui="true"] .wp-toolbar button:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
body[data-modern-ui="true"] .wp-toolbar button.danger:hover {
  background: oklch(0.95 0.05 25);
  color: oklch(0.5 0.18 25);
}
body[data-modern-ui="true"] .wp-toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
}

/* Body (content area) */
body[data-modern-ui="true"] .wp-body {
  padding: 16px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-height: 40px;
}
body[data-modern-ui="true"] .wp-body.dense {
  padding: 12px 14px;
}

/* Text/heading/divider/image parts are less "card-y" */
body[data-modern-ui="true"] .wp-frame[data-wp-type="text"] > .wp-body,
body[data-modern-ui="true"] .wp-frame[data-wp-type="heading"] > .wp-body,
body[data-modern-ui="true"] .wp-frame[data-wp-type="divider"] > .wp-body,
body[data-modern-ui="true"] .wp-frame[data-wp-type="image"] > .wp-body {
  border: none;
  background: transparent;
  padding: 6px 4px;
}
body[data-modern-ui="true"] .wp-frame[data-wp-type="divider"] > .wp-body {
  padding: 16px 4px;
}

/* Resize handles */
body[data-modern-ui="true"] .wp-handle {
  position: absolute;
  background: var(--accent);
  border: 2px solid var(--bg-panel);
  border-radius: 3px;
  width: 10px;
  height: 10px;
  z-index: 5;
}
body[data-modern-ui="true"] .wp-handle.n {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}
body[data-modern-ui="true"] .wp-handle.s {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}
body[data-modern-ui="true"] .wp-handle.e {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}
body[data-modern-ui="true"] .wp-handle.w {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

/* Add strips between parts */
body[data-modern-ui="true"] .wp-add-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 14px;
  opacity: 0;
  transition: opacity 120ms ease, height 120ms ease;
  cursor: pointer;
  margin: -6px 0;
  grid-column: span 12;
}
body[data-modern-ui="true"] .wp-canvas.editing:hover .wp-add-strip {
  opacity: 0.55;
}
body[data-modern-ui="true"] .wp-add-strip:hover {
  opacity: 1 !important;
  height: 28px;
}
body[data-modern-ui="true"] .wp-add-line {
  flex: 1;
  height: 1px;
  background: var(--accent);
}
body[data-modern-ui="true"] .wp-add-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  color: var(--accent-fg);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
body[data-modern-ui="true"] .wp-add-btn:hover {
  background: var(--accent-soft);
}

/* Empty canvas placeholder */
body[data-modern-ui="true"] .wp-empty {
  grid-column: span 12;
  padding: 48px 24px;
  text-align: center;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--fg-muted);
  background: var(--bg-sunken);
}

/* Gallery modal */
body[data-modern-ui="true"] .wp-gallery-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: oklch(0 0 0 / 0.25);
  backdrop-filter: blur(2px);
}
body[data-modern-ui="true"] .wp-gallery {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 640px;
  max-width: 92vw;
  max-height: 80vh;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px oklch(0 0 0 / 0.25);
  z-index: 91;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body[data-modern-ui="true"] .wp-gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
body[data-modern-ui="true"] .wp-gallery-head .iconbtn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--fg-muted);
  display: grid;
  place-items: center;
}
body[data-modern-ui="true"] .wp-gallery-head .iconbtn:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
body[data-modern-ui="true"] .wp-gallery-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
body[data-modern-ui="true"] .wp-gallery-search input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 13px;
  color: var(--fg);
}
body[data-modern-ui="true"] .wp-gallery-cats {
  display: flex;
  gap: 2px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}
body[data-modern-ui="true"] .wp-cat {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--fg-muted);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
body[data-modern-ui="true"] .wp-cat:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
body[data-modern-ui="true"] .wp-cat.active {
  background: var(--accent-soft);
  color: var(--accent-fg);
  font-weight: 500;
}
body[data-modern-ui="true"] .wp-gallery-grid {
  flex: 1;
  overflow: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
body[data-modern-ui="true"] .wp-gallery-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}
body[data-modern-ui="true"] .wp-gallery-card:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
body[data-modern-ui="true"] .wp-gallery-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: white;
  flex-shrink: 0;
}
body[data-modern-ui="true"] .wp-gallery-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--fg-muted);
}

/* Page chrome when in web-part canvas mode */
body[data-modern-ui="true"] .page.has-canvas {
  padding-bottom: 0;
}
body[data-modern-ui="true"] .page.has-canvas .page-body {
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Page head when editing */
body[data-modern-ui="true"] .page-head.editing {
  background: linear-gradient(to bottom, oklch(0.99 0.01 90), var(--bg-panel));
  border-bottom: 1px solid oklch(0.9 0.04 90);
}
body[data-modern-ui="true"] .page-head.editing::before {
  content: "";
  display: block;
  height: 3px;
  background: oklch(0.7 0.14 90);
}

/* Inline table in web parts */
body[data-modern-ui="true"] .dt.compact td {
  padding: 5px 10px;
  font-size: 12.5px;
}
body[data-modern-ui="true"] .dt.compact tr {
  border-bottom: 1px solid var(--border-subtle);
}
body[data-modern-ui="true"] .dt.compact tbody tr:hover {
  background: var(--bg-hover);
}

/* Dirty badge */
body[data-modern-ui="true"] .dirty-badge {
  font-size: 11.5px;
  color: oklch(0.55 0.14 50);
  font-weight: 500;
}

/* KPI sparkline */
body[data-modern-ui="true"] .wp-sparkline {
  margin-top: 10px;
  height: 28px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
}
body[data-modern-ui="true"] .wp-sparkline-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 1px;
}

/* Drag-over indicator */
body[data-modern-ui="true"] .wp-cell.drag-over > .wp-frame {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Col tooltip during resize */
body[data-modern-ui="true"] .wp-col-tooltip {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg-panel);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

/* namecell in doc-list table */
body[data-modern-ui="true"] .namecell {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* cell-user in doc-list table */
body[data-modern-ui="true"] .cell-user {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

/* doc-list row hover */
body[data-modern-ui="true"] .doc-list tbody tr:hover {
  background: var(--bg-hover);
  cursor: pointer;
}

/* Avatar (initials circle) */
body[data-modern-ui="true"] .wp-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* Quick links grid */
body[data-modern-ui="true"] .wp-quicklinks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
body[data-modern-ui="true"] .wp-quicklink-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg);
  background: var(--bg-panel);
  text-decoration: none;
}
body[data-modern-ui="true"] .wp-quicklink-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
body[data-modern-ui="true"] .wp-quicklink-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: white;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* People grid */
body[data-modern-ui="true"] .wp-people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
body[data-modern-ui="true"] .wp-person-item {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* Clickable announcement rows (BUG-0085) */
body[data-modern-ui="true"] .wp-announce-link {
  display: block;
  padding: 10px 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
body[data-modern-ui="true"] .wp-announce-link:hover {
  background: var(--bg-subtle, oklch(0.97 0.005 260));
  margin: 0 -6px;
  padding: 10px 6px;
  border-radius: 4px;
}

/* Clickable event rows (BUG-0086) */
body[data-modern-ui="true"] .wp-event-link {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
body[data-modern-ui="true"] .wp-event-link:hover {
  background: var(--bg-subtle, oklch(0.97 0.005 260));
  margin: 0 -6px;
  padding: 8px 6px;
  border-radius: 4px;
}

/* Clickable team member cards (BUG-0087) */
body[data-modern-ui="true"] .wp-person-link {
  display: flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px;
  margin: -4px;
}
body[data-modern-ui="true"] .wp-person-link:hover {
  background: var(--bg-hover);
}

/* Events list */
body[data-modern-ui="true"] .wp-event-date {
  width: 42px;
  flex-shrink: 0;
  text-align: center;
  padding: 4px 0;
  border-radius: 6px;
  background: oklch(0.96 0.02 330);
}
body[data-modern-ui="true"] .wp-event-month {
  font-size: 9.5px;
  font-weight: 600;
  color: oklch(0.5 0.14 330);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
body[data-modern-ui="true"] .wp-event-day {
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
}

/* Property pane (BUG-0120) */
body[data-modern-ui="true"] .wp-property-pane {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  height: 100vh;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(0,0,0,.12);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body[data-modern-ui="true"] .wp-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
body[data-modern-ui="true"] .wp-pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
body[data-modern-ui="true"] .wp-pane-row {
  margin-bottom: 16px;
}
body[data-modern-ui="true"] .wp-pane-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 4px;
}
body[data-modern-ui="true"] .wp-pane-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
}
body[data-modern-ui="true"] .wp-pane-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
body[data-modern-ui="true"] .wp-pane-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* BUG-0568: Minimize web part � toggle class hides the web part body */
.ms-webpart-chrome-minimized { display: none !important; }

/* BUG-1362/1363: Web Part modal overlays — position:fixed, backdrop, scroll-lock */
.spm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    overflow-y: auto;
}
.spm-modal-overlay.is-open { display: flex; }
body.spm-modal-open { overflow: hidden; }

/* ── Web-Part Gallery card grid (PLAN-1352 Phase 2) ── */

body[data-modern-ui="true"] .webpart-category {
  margin-bottom: 24px;
}
body[data-modern-ui="true"] .webpart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
body[data-modern-ui="true"] .webpart-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
body[data-modern-ui="true"] .webpart-card:hover {
  border-color: var(--accent-border);
  box-shadow: 0 2px 8px oklch(0.2 0.02 240 / 0.08);
  transform: translateY(-1px);
}
body[data-modern-ui="true"] .webpart-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  margin-bottom: 8px;
  color: var(--accent-fg);
}
body[data-modern-ui="true"] .webpart-card-body {
  flex: 1;
  margin-bottom: 12px;
}
body[data-modern-ui="true"] .webpart-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: var(--font-size);
  font-weight: 600;
  color: var(--fg);
}
body[data-modern-ui="true"] .webpart-source-badge {
  font-size: var(--font-size-xs);
}
body[data-modern-ui="true"] .webpart-card-desc {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--fg-muted);
  line-height: 1.5;
}
body[data-modern-ui="true"] .webpart-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
body[data-modern-ui="true"] .webpart-card-actions > .btn-save,
body[data-modern-ui="true"] .webpart-card-actions > .btn-cancel {
  justify-content: center;
}
body[data-modern-ui="true"] .webpart-card-footer {
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--font-size-xs);
  color: #666666; /* WCAG 2.1 AA PLAN-1644: was var(--fg-faint) oklch — axe cannot parse oklch; #666 gives 5.74:1 on white */
}
body[data-modern-ui="true"] .webpart-card-footer code {
  font-family: var(--font-mono, ui-monospace, monospace);
  background: #f0f1f3; /* WCAG 2.1 AA PLAN-1644: was var(--bg-hover) oklch — axe cannot parse oklch; explicit hex */
  color: #444444; /* WCAG 2.1 AA PLAN-1644: was var(--fg-muted) oklch — explicit hex gives 8.54:1 on #f0f1f3 */
  padding: 1px 4px;
  border-radius: var(--radius-sm);
}

/* =============================================================
   PLAN-1737: Web-Part EDIT-MODE chrome — full frame + command bar
   ------------------------------------------------------------
   The home page renders web parts via WebPartZone/Default.cshtml, which
   emits the CLASSIC per-part chrome: .ms-webpart-zone (only a faint
   `1px dashed #ccc` outline in edit mode) + .spm-webpart-editbar (a bare
   flex row of Bootstrap .btn-outline-* buttons with NO bar surface →
   floating ghost controls). Two ik browser-capture bundles (93id "move
   this to the menu bar" + 2ert "each Web Part needs a full frame … buttons
   should be in a menu bar like we have it in other situations") asked for:
     (1) a real frame per part, and
     (2) a command/menu bar matching the .mlv-commandbar convention.

   This is a CSS-ONLY face-lift scoped to body[data-modern-ui="true"].sp-editmode.
   Behavior is byte-identical (every onclick / data-* / aria / the <tr><td>
   structure that delete depends on is untouched — caller analysis in
   _project/areas/webpart-editmode/analysis.md).

   Specificity (PLAN-1730 lesson): the editbar buttons HAVE .btn, so the
   tokens.css:154 `button:not(.btn)` reset does NOT apply; the only competitor
   is Bootstrap `.btn-outline-*` (0,1,0). The selectors below are body+
   `.sp-editmode`-scoped (≥0,3,1) and win cleanly — no !important needed.
   Modern UI tokens are light-only (no dark block in tokens.css), so matching
   tokens gives the correct parity without a separate dark rule.
   ============================================================= */

/* (1) Frame — replace the faint dashed outline with a real framed card. */
body[data-modern-ui="true"].sp-editmode .ms-webpart-zone {
  outline: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  padding: 0 14px 14px;          /* no top padding: the command bar full-bleeds the top edge */
  margin-bottom: 14px;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}
body[data-modern-ui="true"].sp-editmode .ms-webpart-zone:hover,
body[data-modern-ui="true"].sp-editmode .ms-webpart-zone:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* (2) Command/menu bar — convert .spm-webpart-editbar into a real bar surface
   attached to the top of the framed part, matching the .mlv-commandbar convention. */
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 40px;
  margin: 0 -14px 14px;          /* full-bleed to the frame's left/right + space below */
  padding: 6px 12px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

/* Command items — give the Bootstrap buttons a resting affordance (border,
   padding, hover) so they read as a cohesive command bar, not loose links. */
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  box-shadow: none;
  transition: background 80ms ease, border-color 80ms ease, color 80ms ease;
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--fg);
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* One filled accent primary (the principal action = Edit, always first). */
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .btn:first-child {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-on);
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .btn:first-child:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-on);
}

/* Keep the color intent: Connections=info accent, Delete=danger. */
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .btn-outline-info {
  color: var(--accent-fg);
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .btn-outline-danger {
  color: var(--danger);
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .btn-outline-danger:hover {
  background: oklch(0.95 0.05 25);
  border-color: var(--danger);
  color: var(--danger);
}

/* Web part ZONE title row (ik 4yfl + 1f5i: "make (1) a menu bar like (2)"): a per-zone
   command bar styled to MATCH the per-part .spm-webpart-editbar (2) — same band surface,
   same button affordance, one accent primary — so the two bars read as one convention. */
body[data-modern-ui="true"].sp-editmode .spm-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  margin-bottom: 12px;
  padding: 6px 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
body[data-modern-ui="true"].sp-editmode .spm-zone-header .spm-zone-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
body[data-modern-ui="true"].sp-editmode .spm-zone-header .spm-zone-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
/* Buttons mirror the editbar command buttons exactly (resting border + panel bg). */
body[data-modern-ui="true"].sp-editmode .spm-zone-header .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  box-shadow: none;
}
/* The principal zone action is accent-filled, exactly like the editbar's first-child. */
body[data-modern-ui="true"].sp-editmode .spm-zone-header .spm-add-webpart-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-on);
}
body[data-modern-ui="true"].sp-editmode .spm-zone-header .spm-add-webpart-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-on);
}

/* Web-part drag-and-drop (edit mode): grab handle in the command bar + drag feedback. */
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .wp-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  color: var(--fg-muted);
  cursor: grab;
  border-radius: var(--radius-sm, 4px);
  user-select: none;
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .wp-drag-handle:hover {
  background: var(--bg-sunken);
  color: var(--fg-default);
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .wp-drag-handle:active { cursor: grabbing; }
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .wp-drag-handle .bi { font-size: 18px; }
body[data-modern-ui="true"].sp-editmode .wp-drag-ghost {
  opacity: 0.5;
  outline: 2px dashed var(--border-strong);
}
body[data-modern-ui="true"].sp-editmode .wp-drag-chosen { background: var(--bg-sunken); }

/* ik 1f5i: per-part "type: title" identifier in the edit command bar (e.g. "List View: Documents").
   Sits left after the drag handle; margin-right:auto pushes the action buttons to the right. */
body[data-modern-ui="true"].sp-editmode .spm-webpart-editbar .spm-webpart-typetitle {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-right: auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.2;
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-typetitle .spm-wp-type {
  color: var(--fg-muted);
  font-weight: 600;
  flex: 0 0 auto;
}
body[data-modern-ui="true"].sp-editmode .spm-webpart-typetitle .spm-wp-name {
  color: var(--fg);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ──────────────────────────────────────────────────────────────────────────
   Wiki page EDIT-MODE web-part chrome (ik manual bug, 2026-06-08).
   The Wiki page (Wiki.cshtml) renders stored web parts via its own
   RenderStoredWebPartsAsync, NOT the WebPartZone component, so it needs its
   own light edit chrome: a labelled section + per-part header (type:title)
   with a Remove button. Tokens only, light/dark adaptive.
   ────────────────────────────────────────────────────────────────────────── */
.ms-wp-zone-edit {
  margin-top: var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  background: var(--bg-sunken);
}
.ms-wp-zone-edit .ms-wp-zone-editlabel {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--fg-subtle);
  margin-bottom: var(--space-sm);
}
.ms-wp-zone-webpart-edit {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card, var(--bg));
  margin-bottom: var(--space-sm);
  overflow: hidden;
}
.ms-wp-zone-webpart-edit:last-child { margin-bottom: 0; }
.ms-wp-zone-webpart-edit .ms-wp-editbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border-subtle);
}
.ms-wp-zone-webpart-edit .ms-wp-editbar-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-wp-zone-webpart-edit .ms-wp-remove-btn {
  flex: 0 0 auto;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  color: var(--accent-fg, #fff);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}
.ms-wp-zone-webpart-edit .ms-wp-remove-btn:hover { filter: brightness(.92); }
.ms-wp-zone-webpart-edit .ms-wp-remove-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.ms-wp-zone-webpart-edit .ms-wp-editbody { padding: var(--space-sm); }
.ms-wp-zone-webpart-edit .ms-wp-unavailable { color: var(--fg-muted); }
