/* ============================================================================
 * 37degrees · Plasmid Map Renderer — embed styles
 *
 * All rules are scoped to `.pmr-root` so they will not collide with the host
 * page. Dark theme by default; `.pmr-theme-light` overrides the surfaces.
 *
 * Brand tokens (from src/styles/global.css):
 *   navy-900  #082540  (background)
 *   navy-950  #04141f  (deeper background)
 *   navy-700  #133b56  (borders)
 *   pink-400  #ff7bac  (accent)
 *   pink-600  #ec1f6a  (accent press)
 *   text      #dde4ed  (light text)
 *   muted     #8ba5bd  (muted text)
 * ========================================================================== */

.pmr-root {
  --pmr-bg:       #082540;
  --pmr-bg-2:     #04141f;
  --pmr-surface:  rgba(255, 255, 255, 0.04);
  --pmr-surface-2:rgba(255, 255, 255, 0.06);
  --pmr-border:   #133b56;
  --pmr-border-2: #21506e;
  --pmr-text:     #dde4ed;
  --pmr-muted:    #8ba5bd;
  --pmr-accent:   #ff7bac;
  --pmr-accent-2: #ec1f6a;
  --pmr-error-bg: rgba(236, 31, 106, 0.10);
  --pmr-error-fg: #ffb7d0;

  font-family: "Nunito Sans Variable", "Nunito Sans", system-ui, -apple-system,
    sans-serif;
  color: var(--pmr-text);
  background: radial-gradient(70% 55% at 12% 8%, rgba(255,123,172,0.13) 0%, rgba(255,123,172,0) 60%), radial-gradient(60% 55% at 88% 95%, rgba(52,211,153,0.08) 0%, rgba(52,211,153,0) 65%), linear-gradient(180deg, var(--pmr-bg) 0%, var(--pmr-bg-2) 100%);
  border: 1px solid var(--pmr-border);
  border-radius: 16px;
  padding: 20px;
  box-sizing: border-box;
  width: 100%;
}

.pmr-root *,
.pmr-root *::before,
.pmr-root *::after {
  box-sizing: border-box;
}

/* Light theme override */
.pmr-root.pmr-theme-light {
  --pmr-bg:       #ffffff;
  --pmr-bg-2:     #f5f7fa;
  --pmr-surface:  #ffffff;
  --pmr-surface-2:#f1f4f8;
  --pmr-border:   #d6dde6;
  --pmr-border-2: #b5c5d6;
  --pmr-text:     #0a2e48;
  --pmr-muted:    #5d83a1;
  --pmr-accent:   #ec1f6a;
  --pmr-accent-2: #c41152;
  --pmr-error-bg: #fff1f6;
  --pmr-error-fg: #c41152;
}

/* ---------- layout ------------------------------------------------------ */
.pmr-shell {
  display: grid;
  gap: 18px;
}

.pmr-controls {
  display: grid;
  gap: 14px;
}

/* ---------- mode tabs --------------------------------------------------- */
.pmr-mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--pmr-surface);
  border: 1px solid var(--pmr-border);
  border-radius: 999px;
  width: max-content;
}

.pmr-tab {
  font: inherit;
  color: var(--pmr-muted);
  background: transparent;
  border: 0;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.4px;
  transition: background 0.15s ease, color 0.15s ease;
}

.pmr-tab:hover {
  color: var(--pmr-text);
}

.pmr-tab.is-active {
  background: var(--pmr-accent);
  color: #ffffff;
}

/* ---------- file drop zone --------------------------------------------- */
.pmr-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 20px;
  border: 1.5px dashed var(--pmr-border-2);
  border-radius: 12px;
  background: var(--pmr-surface);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pmr-drop:hover,
.pmr-drop:focus-visible,
.pmr-drop.is-dragover {
  border-color: var(--pmr-accent);
  background: var(--pmr-surface-2);
  outline: none;
}

.pmr-drop-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--pmr-text);
}

.pmr-drop-hint {
  font-size: 12px;
  color: var(--pmr-muted);
  letter-spacing: 0.3px;
}

.pmr-file-name {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--pmr-accent);
  background: rgba(255, 123, 172, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
}

.pmr-theme-light .pmr-file-name {
  background: rgba(236, 31, 106, 0.08);
}

/* ---------- paste textarea --------------------------------------------- */
.pmr-textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--pmr-border);
  border-radius: 10px;
  background: var(--pmr-surface);
  color: var(--pmr-text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.pmr-textarea:focus-visible {
  outline: 2px solid var(--pmr-accent);
  outline-offset: 2px;
  border-color: var(--pmr-accent);
}

/* ---------- row: topology + actions ------------------------------------ */
.pmr-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.pmr-topology {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  margin: 0;
  padding: 0;
}

.pmr-legend {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--pmr-muted);
  padding: 0;
}

.pmr-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--pmr-text);
  cursor: pointer;
}

.pmr-radio input {
  accent-color: var(--pmr-accent);
  margin: 0;
}

.pmr-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ---------- buttons ----------------------------------------------------- */
.pmr-btn {
  font: inherit;
  border: 0;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  transition: background 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
}

.pmr-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.pmr-btn-primary {
  background: var(--pmr-accent);
  color: #ffffff;
}

.pmr-btn-primary:hover:not(:disabled) {
  background: var(--pmr-accent-2);
}

.pmr-btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.pmr-btn-ghost {
  background: transparent;
  color: var(--pmr-text);
  border: 1px solid var(--pmr-border-2);
}

.pmr-btn-ghost:hover:not(:disabled) {
  border-color: var(--pmr-accent);
  color: var(--pmr-accent);
}

.pmr-btn-download {
  background: var(--pmr-accent);
  color: #ffffff;
}

.pmr-btn-download:hover:not(:disabled) {
  background: var(--pmr-accent-2);
}

/* ---------- error ------------------------------------------------------- */
.pmr-error {
  background: var(--pmr-error-bg);
  color: var(--pmr-error-fg);
  border: 1px solid var(--pmr-accent);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ---------- display area ----------------------------------------------- */
.pmr-display {
  display: grid;
  gap: 10px;
}

.pmr-display-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pmr-meta {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--pmr-muted);
  text-transform: uppercase;
}

.pmr-stage {
  min-height: 500px;
  max-height: 80vh;
  overflow: auto;
  padding: 16px;
  background: var(--pmr-surface);
  border: 1px solid var(--pmr-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* When showing a linear plot, the SVG is short + wide. Drop the 500px min so
   the stage shrinks to the SVG height instead of leaving big empty bands.
   The widget toggles this class via data-topology on the stage. */
.pmr-stage[data-topology="linear"] {
  min-height: 0;
  align-items: flex-start;
}
/* No constraints — let the SVG render at its native pt size; stage scrolls. */
.pmr-stage[data-topology="linear"] .pmr-svg-wrap {
  align-items: flex-start;
  justify-content: flex-start;
  width: auto;
}

.pmr-theme-light .pmr-stage {
  background: #ffffff;
}

.pmr-placeholder {
  color: var(--pmr-muted);
  font-size: 14px;
  font-weight: 600;
}

.pmr-svg-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pmr-svg-wrap svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* dark theme — give the white matplotlib SVG canvas a light pad so labels
   stay readable when dropped onto the dark stage */
.pmr-root:not(.pmr-theme-light) .pmr-svg-wrap {
  background: #ffffff;
  border-radius: 8px;
  padding: 12px;
}

/* ---------- spinner ---------------------------------------------------- */
.pmr-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--pmr-muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.pmr-spinner-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--pmr-border);
  border-top-color: var(--pmr-accent);
  animation: pmr-spin 0.9s linear infinite;
}

@keyframes pmr-spin {
  to { transform: rotate(360deg); }
}

/* ---------- footer ----------------------------------------------------- */
.pmr-footer {
  font-size: 12px;
  color: var(--pmr-muted);
  border-top: 1px solid var(--pmr-border);
  padding-top: 12px;
}

.pmr-footer a {
  color: var(--pmr-accent);
  text-decoration: none;
  font-weight: 700;
}

.pmr-footer a:hover {
  text-decoration: underline;
}

/* ---------- responsive ------------------------------------------------- */
@media (max-width: 600px) {
  .pmr-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .pmr-actions {
    width: 100%;
    justify-content: space-between;
  }
  .pmr-stage {
    min-height: 380px;
  }
}

/* SEO backlink: brand attribution to 37degrees */
.pmr-footer-brand { color: #ff7bac !important; font-weight: 700; }
.pmr-footer-brand:hover { color: #ec1f6a !important; text-decoration: underline; }

/* ---------- zoom controls ---------------------------------------------- */
.pmr-zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(255, 123, 172, 0.08);
  border: 1px solid rgba(255, 123, 172, 0.18);
}
.pmr-icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  background: transparent;
  color: var(--pmr-pink, #ff7bac);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.pmr-icon-btn:hover {
  background: rgba(255, 123, 172, 0.16);
  border-color: rgba(255, 123, 172, 0.3);
}
.pmr-zoom-pct {
  min-width: 44px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--pmr-muted, #8ba5bd);
  font-variant-numeric: tabular-nums;
}
.pmr-stage {
  cursor: grab;
}
.pmr-stage:has(.pmr-placeholder),
.pmr-stage:has(.pmr-spinner) {
  cursor: default;
}
.pmr-stage:fullscreen,
.pmr-stage:-webkit-full-screen {
  background: var(--pmr-surface, #04141f);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pmr-svg-wrap {
  will-change: transform;
}
.pmr-hint {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--pmr-muted, #8ba5bd);
  text-align: center;
  margin-top: 2px;
  opacity: 0.75;
}

/* ---------- advanced panel --------------------------------------------- */
.pmr-advanced-toggle.is-active {
  border-color: var(--pmr-accent);
  color: var(--pmr-accent);
}

.pmr-advanced {
  background: var(--pmr-surface);
  border: 1px solid var(--pmr-border);
  border-radius: 12px;
  padding: 14px;
}

.pmr-adv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.pmr-adv-block {
  border: 1px solid var(--pmr-border);
  border-radius: 10px;
  margin: 0;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--pmr-surface-2);
}

.pmr-adv-block .pmr-legend {
  padding: 0 6px;
  margin-bottom: 2px;
}

.pmr-adv-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.pmr-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--pmr-muted);
  flex: 1 1 100px;
  min-width: 100px;
}

.pmr-field input[type="number"],
.pmr-field select {
  font: inherit;
  font-weight: 600;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 6px 8px;
  color: var(--pmr-text);
  background: var(--pmr-surface);
  border: 1px solid var(--pmr-border-2);
  border-radius: 6px;
}

.pmr-field input[type="number"]:focus-visible,
.pmr-field select:focus-visible {
  outline: 2px solid var(--pmr-accent);
  outline-offset: 1px;
  border-color: var(--pmr-accent);
}

.pmr-field input[type="range"] {
  accent-color: var(--pmr-accent);
  width: 100%;
}

.pmr-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--pmr-text);
  cursor: pointer;
}
.pmr-check input { accent-color: var(--pmr-accent); margin: 0; }
.pmr-check input:disabled + span { color: var(--pmr-muted); opacity: 0.6; }

.pmr-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px 10px;
}

.pmr-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px 10px;
}

.pmr-color-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--pmr-text);
}

.pmr-color-row input[type="color"] {
  width: 28px;
  height: 22px;
  border: 1px solid var(--pmr-border-2);
  border-radius: 4px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.pmr-hint-inline {
  margin: 0;
  font-size: 11px;
  color: var(--pmr-muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ---------- annotation builder ---------------------------------------- */
.pmr-anno-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  grid-template-areas:
    "label label label label"
    "start end   color add";
  gap: 8px;
  align-items: center;
}
.pmr-anno-form .pmr-anno-label  { grid-area: label; }
.pmr-anno-form .pmr-anno-start  { grid-area: start; }
.pmr-anno-form .pmr-anno-end    { grid-area: end; }
.pmr-anno-form .pmr-anno-color  { grid-area: color; }
.pmr-anno-form .pmr-anno-add    { grid-area: add; }

.pmr-anno-form input[type="text"],
.pmr-anno-form input[type="number"] {
  font: inherit;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 6px 8px;
  color: var(--pmr-text);
  background: var(--pmr-surface);
  border: 1px solid var(--pmr-border-2);
  border-radius: 6px;
  min-width: 0;
}

.pmr-anno-form input[type="color"] {
  width: 30px;
  height: 28px;
  border: 1px solid var(--pmr-border-2);
  border-radius: 4px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.pmr-anno-form .pmr-btn {
  padding: 6px 12px;
  font-size: 12px;
}

.pmr-anno-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pmr-anno-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid;
  border-radius: 999px;
  background: var(--pmr-surface);
  font-size: 11px;
  font-weight: 700;
  color: var(--pmr-text);
}

.pmr-anno-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.pmr-anno-remove {
  background: transparent;
  border: 0;
  color: var(--pmr-muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.pmr-anno-remove:hover { color: var(--pmr-accent); }

/* ---------- label-drag affordances ------------------------------------ */
.pmr-svg-wrap svg text {
  cursor: grab;
}
.pmr-svg-wrap svg text:active {
  cursor: grabbing;
}

/* Mobile collapse: keep advanced panel single-column */
@media (max-width: 600px) {
  .pmr-adv-grid { grid-template-columns: 1fr; }
  .pmr-anno-form {
    grid-template-columns: 1fr 1fr;
  }
  .pmr-anno-form input[type="text"] { grid-column: 1 / -1; }
  .pmr-anno-form .pmr-btn { grid-column: 1 / -1; }
}

/* ===================================================================
   In-page dialog overlay (replaces browser Fullscreen API)
   =================================================================== */
.pmr-root.pmr-is-expanded {
  position: fixed;
  inset: 0;
  z-index: 99990;
  margin: 0;
  padding: 24px;
  overflow: auto;
  background: var(--pmr-bg, #04141f);
  box-shadow: 0 30px 60px -10px rgba(0, 0, 0, 0.5);
}
.pmr-root.pmr-is-expanded .pmr-stage {
  max-height: calc(100vh - 280px);
}
body.pmr-body-locked {
  overflow: hidden;
}
.pmr-dialog-close {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 99991;
  width: 40px;
  height: 40px;
  font-size: 26px;
  line-height: 1;
  font-family: inherit;
  font-weight: 800;
  background: rgba(255, 123, 172, 0.15);
  color: #ff7bac;
  border: 1px solid rgba(255, 123, 172, 0.45);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, transform 0.12s ease;
}
.pmr-dialog-close:hover {
  background: rgba(255, 123, 172, 0.28);
  transform: scale(1.05);
}

/* Floating fullscreen icon button — top-right of widget */
.pmr-root { position: relative; }
.pmr-expand-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 50;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 123, 172, 0.10);
  color: #ec1f6a;
  border: 1px solid rgba(255, 123, 172, 0.30);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
  padding: 0;
  font-family: inherit;
}
.pmr-expand-icon:hover {
  background: rgba(255, 123, 172, 0.22);
  border-color: rgba(255, 123, 172, 0.55);
  transform: scale(1.05);
}
.pmr-root.pmr-is-expanded .pmr-expand-icon {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 99991;
}


/* ===================================================================
   Expanded state: fit the widget to the viewport with a single scrollbar.
   - <html> + <body> both locked.
   - Root takes the full viewport, no scroll.
   - Inner shell/content area gets the single scrollbar (only if needed).
   - Inner stage/viewer no longer scrolls — use zoom/pan to navigate.
   =================================================================== */
html.pmr-html-locked, body.pmr-body-locked {
  overflow: hidden !important;
  height: 100vh !important;
}
.pmr-root.pmr-is-expanded {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 56px 28px 28px 28px;
}
.pmr-root.pmr-is-expanded > * {
  flex-shrink: 0;
}

.pmr-root.pmr-is-expanded .pmr-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.pmr-root.pmr-is-expanded .pmr-display {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pmr-root.pmr-is-expanded .pmr-stage {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

/* ===================================================================
   Fullscreen overlay: white background + 37degrees logo top-left
   (mirrors structure / codon widgets for consistency)
   =================================================================== */
.pmr-root.pmr-is-expanded {
  background: #ffffff !important;
  /* No padding — the brand band + footer hug the screen edges; the rail
     and canvas paint their own backgrounds (grey, white). */
  padding: 0;
}
.pmr-root.pmr-is-expanded .pmr-controls,
.pmr-root.pmr-is-expanded .pmr-display,
.pmr-root.pmr-is-expanded .pmr-footer,
.pmr-root.pmr-is-expanded .pmr-fold {
  color: #082540;
}
.pmr-root.pmr-is-expanded .pmr-stage {
  background: #ffffff;
  border-color: #e4ecf2;
}
.pmr-root.pmr-is-expanded .pmr-svg-wrap {
  background: #ffffff;
}
.pmr-root.pmr-is-expanded .pmr-meta,
.pmr-root.pmr-is-expanded .pmr-hint,
.pmr-root.pmr-is-expanded .pmr-drop-hint {
  color: #5d83a1;
}
.pmr-root.pmr-is-expanded .pmr-drop {
  background: #f7f9fc;
  border-color: #cdd6e2;
  color: #082540;
}
.pmr-root.pmr-is-expanded .pmr-legend,
.pmr-root.pmr-is-expanded .pmr-tab {
  color: #082540;
}
.pmr-root.pmr-is-expanded .pmr-btn-ghost,
.pmr-root.pmr-is-expanded .pmr-btn-ghost:hover {
  color: #ec1f6a;
  background: rgba(236, 31, 106, 0.06);
  border-color: rgba(236, 31, 106, 0.25);
}
.pmr-root.pmr-is-expanded .pmr-dialog-close {
  color: #ec1f6a;
  background: rgba(236, 31, 106, 0.10);
  border-color: rgba(236, 31, 106, 0.35);
}
.pmr-root.pmr-is-expanded .pmr-expand-icon {
  color: #ec1f6a;
  background: rgba(236, 31, 106, 0.10);
  border-color: rgba(236, 31, 106, 0.30);
}

/* Brand bar — navy band along the top-left of the fullscreen layout.
   Hidden in embedded mode; rendered in-grid (grid-area: brand) for the
   fullscreen overlay. */
.pmr-brand-logo { display: none; }
.pmr-root.pmr-is-expanded .pmr-brand-logo {
  position: static;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #082540;
  color: #ffffff;
  text-decoration: none;
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.3px;
  padding: 14px 20px;
  border-radius: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.12s ease;
}
.pmr-root.pmr-is-expanded .pmr-brand-logo:hover {
  background: #04141f;
}
.pmr-root.pmr-is-expanded .pmr-brand-logo svg {
  height: 28px;
  width: 28px;
  display: block;
  flex-shrink: 0;
}
.pmr-brand-wordmark { display: inline-block; color: #ffffff; }
.pmr-brand-sep {
  color: #ff7bac;
  margin: 0 2px;
  font-weight: 800;
}
.pmr-tool-name {
  color: #ff7bac;
  font-weight: 800;
  letter-spacing: 0.4px;
}
@media (max-width: 720px) {
  .pmr-brand-sep,
  .pmr-tool-name { display: none; }
}

/* ===================================================================
   Foldable section pattern (matches sx-fold / co-section styling)
   =================================================================== */
.pmr-fold {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pmr-fold-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--pmr-muted, #8ba5bd);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.pmr-fold-toggle:hover {
  color: #ec1f6a;
}
.pmr-fold-toggle:hover .pmr-fold-caret {
  color: #ec1f6a;
}
.pmr-fold-caret {
  display: inline-block;
  font-size: 14px;
  line-height: 1;
  transition: transform 0.18s ease;
}
.pmr-fold-toggle.pmr-open .pmr-fold-caret {
  transform: rotate(90deg);
  color: #ff7bac;
}
.pmr-fold-body.pmr-fold-collapsed {
  display: none;
}
.pmr-fold-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===================================================================
   Fullscreen 2-panel layout: centered header + (controls rail | canvas)
   =================================================================== */

/* Header is embedded-hidden; shown only when fullscreen overlay is on */
.pmr-header { display: none; }
.pmr-eyebrow,
.pmr-title,
.pmr-subtitle { display: none; }
.pmr-root.pmr-is-expanded .pmr-header { display: block; }
.pmr-root.pmr-is-expanded .pmr-eyebrow,
.pmr-root.pmr-is-expanded .pmr-title,
.pmr-root.pmr-is-expanded .pmr-subtitle { display: block; }

/* Compact one-line heading: eyebrow only, no title / subtitle. Saves the
   ~80px vertical band that was eating into the canvas area. */
.pmr-root.pmr-is-expanded .pmr-header {
  text-align: center;
  margin: 0;
  padding: 0 60px;
}
.pmr-root.pmr-is-expanded .pmr-eyebrow {
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 800;
  color: #ec1f6a;
  text-transform: uppercase;
  margin: 0;
}
.pmr-root.pmr-is-expanded .pmr-title,
.pmr-root.pmr-is-expanded .pmr-subtitle {
  display: none;
}

/* Branded 2-panel layout: navy brand top-left + grey rail + white canvas
   spanning full vertical right + navy footer bar across the bottom. */
.pmr-root.pmr-is-expanded .pmr-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "brand   canvas"
    "rail    canvas"
    "footer  footer";
  gap: 0;
  overflow: hidden;
  height: 100vh;
}
.pmr-root.pmr-is-expanded .pmr-header { display: none; }
.pmr-root.pmr-is-expanded .pmr-brand-logo { grid-area: brand; }
.pmr-root.pmr-is-expanded .pmr-controls {
  grid-area: rail;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 18px 20px;
  border-right: 1px solid #dde4ed;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  align-content: start;
  align-items: start;
  background: #f1f4f8;
}
.pmr-root.pmr-is-expanded .pmr-display {
  grid-area: canvas;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 6px;
  height: 100%;
  padding: 14px 18px;
  background: #ffffff;
}
.pmr-root.pmr-is-expanded .pmr-footer {
  grid-area: footer;
  background: #082540;
  color: #ffffff;
  padding: 12px 24px;
  justify-content: center;
  border-top: 0;
  margin: 0;
}
.pmr-root.pmr-is-expanded .pmr-footer,
.pmr-root.pmr-is-expanded .pmr-footer span {
  color: #ffffff;
}
.pmr-root.pmr-is-expanded .pmr-footer a {
  color: #ff7bac;
  text-decoration: none;
}
.pmr-root.pmr-is-expanded .pmr-footer a:hover {
  color: #ffffff;
  text-decoration: underline;
}
.pmr-root.pmr-is-expanded .pmr-footer-sep {
  color: #ff7bac;
  opacity: 0.6;
}

/* Close (fullscreen) icon — when relocated into the rail via JS, render it
   as a full-width pill at the top of the controls with explicit text so
   it's unambiguous (no guessing what the icon means). */
.pmr-root.pmr-is-expanded .pmr-controls .pmr-expand-icon {
  position: static;
  width: 100%;
  height: 38px;
  align-self: stretch;
  margin-bottom: 4px;
  background: rgba(236, 31, 106, 0.10);
  border-color: rgba(236, 31, 106, 0.28);
  color: #ec1f6a;
  gap: 8px;
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.4px;
}
.pmr-root.pmr-is-expanded .pmr-controls .pmr-expand-icon:hover {
  background: rgba(236, 31, 106, 0.22);
  transform: none;
}
.pmr-expand-icon-label {
  display: inline-block;
}

/* Download SVG, when relocated into the rail, becomes a full-width button
   at the bottom of the controls. */
.pmr-root.pmr-is-expanded .pmr-controls .pmr-btn-download {
  width: 100%;
  margin-top: 8px;
}

/* Stage fills the canvas cell — no 100vh cap in 2-panel layout */
.pmr-root.pmr-is-expanded .pmr-stage {
  max-height: none;
  min-height: 0;
  height: 100%;
}

/* For circular plots, let the SVG scale up to fill the stage height.
   SVG preserveAspectRatio keeps the map proportional and centered, so
   we get a big map instead of one centered in a sea of whitespace.
   Linear plots keep their native scrolling behavior. */
.pmr-root.pmr-is-expanded .pmr-stage:not([data-topology="linear"]) {
  overflow: hidden;
  padding: 8px;
}
.pmr-root.pmr-is-expanded .pmr-stage:not([data-topology="linear"]) .pmr-svg-wrap {
  width: 100%;
  height: 100%;
}
.pmr-root.pmr-is-expanded .pmr-stage:not([data-topology="linear"]) .pmr-svg-wrap svg {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}

/* Inside the narrow rail, force the topology+actions row to wrap vertically
   so the Render button isn't cramped next to the radios. Override the
   embedded-mode space-between so they pack tightly under each other. */
.pmr-root.pmr-is-expanded .pmr-controls .pmr-row {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
}
.pmr-root.pmr-is-expanded .pmr-controls .pmr-topology {
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.pmr-root.pmr-is-expanded .pmr-controls .pmr-actions {
  flex-direction: column;
  align-items: stretch;
}
.pmr-root.pmr-is-expanded .pmr-controls .pmr-actions .pmr-btn {
  width: 100%;
}
.pmr-root.pmr-is-expanded .pmr-controls .pmr-adv-grid {
  grid-template-columns: 1fr;
}

/* Narrow viewport fallback — stack rail above canvas */
@media (max-width: 960px) {
  .pmr-root.pmr-is-expanded .pmr-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "header"
      "controls"
      "display"
      "footer";
  }
  .pmr-root.pmr-is-expanded .pmr-controls {
    border-right: none;
    border-bottom: 1px solid #e4ecf2;
    padding-right: 0;
    padding-bottom: 12px;
    max-height: 40vh;
  }
  .pmr-root.pmr-is-expanded .pmr-header {
    padding: 0 0 4px;
  }
}
