/* ==========================================================
   Canonical Tag Renderer UI Style Contract v0.5.0

   RESPONSIBILITY BOUNDARY
   - Value Sort Engine: semantic judgment only.
   - Canonical Renderer: semantic DOM/class/metadata projection only.
   - Canonical UI Style: color, border, hover, focus and nested Value visuals.
   - Host: Model/Preset/Pasted-Preset behavior and persistence.

   Stage 1 (2026-10-25): 75% density for canonical tag text and its
   component geometry. UI Category toggle / Move handles retain click target
   sizes and untouched event ownership. No DOM scaling or data mutation.

   Model and Preset therefore share one visual language while preserving
   independent functions. Host containers may keep fluid spacing and size.
   Hover/focus must never change geometry.
   ========================================================== */
.pse-canonical-tag-entry{
  --pse-tag-value-bg:#ffffff;
  --pse-tag-value-fg:#111827;
  --pse-tag-general-bg:#2563eb;
  --pse-tag-general-fg:#ffffff;
  --pse-tag-border-value:#111827;
  --pse-tag-border-general:#2563eb;
  --pse-tag-hover-value:#f8fafc;
  --pse-tag-hover-general:#2563eb;
  --pse-tag-radius:6px;
  --pse-tag-pad-y:7px;
  --pse-tag-pad-x:9px;

  position:relative !important;
  display:inline-flex !important;
  align-items:center !important;
  align-content:flex-start !important;
  flex-wrap:wrap !important;
  min-width:0 !important;
  max-width:100% !important;
  padding:var(--pse-tag-pad-y) var(--pse-tag-pad-x) !important;
  border-width:1px !important;
  border-style:solid !important;
  border-radius:var(--pse-tag-radius) !important;
  box-sizing:border-box !important;
  font-size:14.25px !important;
  font-weight:600 !important;
  line-height:1.2 !important;
  white-space:normal !important;
  overflow-wrap:anywhere !important;
  word-break:break-word !important;
  vertical-align:middle !important;
  transform:none !important;
  box-shadow:none !important;
  isolation:isolate;
  transition:
    background-color .12s ease,
    color .12s ease,
    border-color .12s ease,
    box-shadow .12s ease,
    opacity .12s ease !important;
}
.pse-canonical-tag-entry,
.pse-canonical-tag-entry::before,
.pse-canonical-tag-entry::after,
.pse-canonical-tag-entry *{
  box-sizing:border-box;
}

/* Legacy generic .tag:hover opacity must not alter Canonical Tags. */
body.tag-adjust-mode .pse-canonical-tag-entry:not(.dragging):hover{
  opacity:1 !important;
}

.pse-canonical-tag-entry[data-pse-tag-type="VALUE"]{
  border-color:var(--pse-tag-border-value) !important;
  background:var(--pse-tag-value-bg) !important;
  color:var(--pse-tag-value-fg) !important;
}
.pse-canonical-tag-entry[data-pse-tag-type="VALUE"]:hover{
  background:var(--pse-tag-hover-value) !important;
  color:var(--pse-tag-value-fg) !important;
  /* Inset feedback cannot protrude beyond the tag or change layout. */
  box-shadow:inset 0 0 0 2px rgba(17,24,39,.08) !important;
}

.pse-canonical-tag-entry[data-pse-tag-type="GENERAL"],
.pse-canonical-tag-entry[data-pse-tag-type="GENERAL_WITH_VALUE"]{
  gap:2.25px !important;
  border-color:var(--pse-tag-border-general) !important;
  background:var(--pse-tag-general-bg) !important;
  color:var(--pse-tag-general-fg) !important;
}
.pse-canonical-tag-entry[data-pse-tag-type="GENERAL"]:hover,
.pse-canonical-tag-entry[data-pse-tag-type="GENERAL_WITH_VALUE"]:hover{
  background:var(--pse-tag-hover-general) !important;
  color:var(--pse-tag-general-fg) !important;
  /* Inset hover prevents the blue edge from appearing to jump outward. */
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.18) !important;
}

.pse-canonical-tag-entry:focus-visible{
  outline:2px solid #0f172a !important;
  outline-offset:2px !important;
}

/* GENERAL_WITH_VALUE: blue carrier, white detected Value group. */
.pse-canonical-tag-entry[data-pse-tag-type="GENERAL_WITH_VALUE"] .pse-value-ui-group{
  display:inline-flex !important;
  align-items:center !important;
  flex:0 1 auto !important;
  min-width:0 !important;
  max-width:100% !important;
  white-space:normal !important;
  overflow-wrap:anywhere !important;
  word-break:break-word !important;
  margin:0 1px !important;
  padding:1.5px 4.5px !important;
  border:1px solid #111827 !important;
  border-radius:4.5px !important;
  background:#ffffff !important;
  color:#111827 !important;
  box-shadow:none !important;
  font-weight:700 !important;
  line-height:1.15 !important;
  vertical-align:middle !important;
  transform:none !important;
  transition:
    background-color .12s ease,
    color .12s ease,
    border-color .12s ease,
    box-shadow .12s ease !important;
}
.pse-canonical-tag-entry[data-pse-tag-type="GENERAL_WITH_VALUE"] .pse-value-ui-group:hover{
  background:#f8fafc !important;
  color:#111827 !important;
  box-shadow:inset 0 0 0 1px rgba(17,24,39,.10) !important;
}
.pse-canonical-tag-entry[data-pse-tag-type="GENERAL_WITH_VALUE"] .pse-value-ui-group:focus-visible{
  outline:2px solid #ffffff !important;
  outline-offset:2px !important;
}

/* Exact whole VALUE: editing metadata remains interactive without a nested box. */
.pse-canonical-tag-entry[data-pse-tag-type="VALUE"] .pse-value-ui-group,
.pse-canonical-tag-entry[data-pse-tag-type="VALUE"].pse-value-scope-whole > .pse-value-ui-group{
  display:inline-flex !important;
  flex:0 1 auto !important;
  min-width:0 !important;
  max-width:100% !important;
  white-space:normal !important;
  overflow-wrap:anywhere !important;
  word-break:break-word !important;
  margin:0 !important;
  padding:0 !important;
  border:0 !important;
  border-radius:0 !important;
  background:transparent !important;
  color:inherit !important;
  box-shadow:none !important;
  font-weight:inherit !important;
  line-height:inherit !important;
  transform:none !important;
}
.pse-canonical-tag-entry .pse-value-general-text{
  flex:0 1 auto !important;
  min-width:0 !important;
  max-width:100% !important;
  color:inherit !important;
  white-space:normal !important;
  overflow-wrap:anywhere !important;
  word-break:break-word !important;
}

/* Reserve the UI Category activation control before its owner engine inserts
   the real button. This prevents a second line-wrap/reflow pass after render. */
.pse-canonical-tag-entry.model-output-tag:not(:has(> .pse-ui-tag-activation-toggle))::before,
.pse-canonical-tag-entry.pse-category-pasted-preset-value:not(:has(> .pse-ui-tag-activation-toggle))::before,
.pse-canonical-tag-entry.pse-category-pasted-preset-directory:not(:has(> .pse-ui-tag-activation-toggle))::before{
  content:"";
  flex:0 0 23px;
  width:23px;
  min-width:23px;
  height:16px;
}

/* Host decorations may react, but they may never resize or move the tag. */
.pse-canonical-tag-entry .pse-ui-tag-activation-toggle,
.pse-canonical-tag-entry .pse-ui-tag-activation-toggle:hover,
.pse-canonical-tag-entry .pse-ui-tag-activation-toggle:active{
  transform:none !important;
  translate:none !important;
  scale:none !important;
}
.pse-canonical-tag-entry .pse-ui-tag-activation-toggle{
  transition:
    background-color .12s ease,
    border-color .12s ease,
    box-shadow .12s ease !important;
}
.pse-canonical-tag-entry .pse-ui-tag-activation-toggle:hover{
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.22) !important;
}
.pse-canonical-tag-entry .pse-ui-tag-activation-toggle:focus-visible{
  outline:2px solid #0f172a !important;
  outline-offset:2px !important;
}

/* Directory origin is metadata-driven and visible only while type=directory. */
.pse-preset-directory-origin-icon{
  display:inline-flex;
  flex:0 0 auto;
  align-items:center;
  justify-content:center;
  margin-right:6px;
  font-size:.9em;
  line-height:1;
  user-select:none;
  pointer-events:none;
}

/* Host layout remains intentionally fluid. */
.pse-preset-reorder-item > .pse-canonical-tag-entry{margin:0 !important}
.pse-category-pasted-preset > .pse-canonical-tag-entry{margin:6px !important}

/* Legacy Directory classes remain behavior hooks only. */
.pse-canonical-tag-entry.pse-preset-directory-chip,
.pse-canonical-tag-entry.pse-category-pasted-preset-directory{
  background:#ffffff !important;
  color:#111827 !important;
  border-color:#111827 !important;
  font-size:14.25px !important;
  font-weight:600 !important;
}

/* Model-only active/inactive behavior remains Host-owned. */
.pse-canonical-tag-entry.model-output-tag.inactive-tag,
.pse-canonical-tag-entry.pse-category-pasted-preset-value.inactive-tag,
.pse-canonical-tag-entry.pse-category-pasted-preset-directory.inactive-tag{
  background:#e2e8f0 !important;
  color:#94a3b8 !important;
  border-color:#cbd5e1 !important;
}
.pse-canonical-tag-entry.model-output-tag.inactive-tag:hover,
.pse-canonical-tag-entry.pse-category-pasted-preset-value.inactive-tag:hover,
.pse-canonical-tag-entry.pse-category-pasted-preset-directory.inactive-tag:hover{
  box-shadow:inset 0 0 0 2px rgba(100,116,139,.14) !important;
}
.pse-canonical-tag-entry.model-output-tag.inactive-tag[data-pse-tag-type="GENERAL_WITH_VALUE"] .pse-value-ui-group,
.pse-canonical-tag-entry.pse-category-pasted-preset-value.inactive-tag[data-pse-tag-type="GENERAL_WITH_VALUE"] .pse-value-ui-group,
.pse-canonical-tag-entry.pse-category-pasted-preset-directory.inactive-tag[data-pse-tag-type="GENERAL_WITH_VALUE"] .pse-value-ui-group{
  background:#94a3b8 !important;
  color:#ffffff !important;
  border-color:#64748b !important;
}
.pse-canonical-tag-entry.model-output-tag.inactive-tag[data-pse-tag-type="VALUE"] .pse-value-ui-group,
.pse-canonical-tag-entry.pse-category-pasted-preset-value.inactive-tag[data-pse-tag-type="VALUE"] .pse-value-ui-group,
.pse-canonical-tag-entry.pse-category-pasted-preset-directory.inactive-tag[data-pse-tag-type="VALUE"] .pse-value-ui-group{
  background:transparent !important;
  color:inherit !important;
  border:0 !important;
}

/* ==========================================================
   CANONICAL REGISTERED VALUE TREE RENDER v0.5.0

   MODEL / PRESET / PASTED_PRESET share one visual contract.
   Preset differs only through its external multi-entry wrapper.

   OUTER CARRIER
   - no registered Value: blue
   - registered Value + meaningful uncovered text: blue
   - all meaningful text covered by one or more Values: white/black
   - exact whole registered Value: white/black

   INNER VALUE TREE
   - every registered contained Value remains a white/black box
   - pure containment remains recursively visible at every depth
   - partial overlap remains one white merged intersection region whose click
     opens the existing candidate chooser
   - Full Coverage never flattens or removes inner Value boxes

   Model inactive presentation remains Host-owned and is excluded here.
   ========================================================== */

/* Full Value coverage changes only the outer carrier. The semantic tag type
   may remain GENERAL_WITH_VALUE because multiple Values were not invented as
   one Registry Value. */
.pse-canonical-tag-entry.pse-full-value-coverage:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
),
.pse-canonical-tag-entry[data-pse-tag-type="GENERAL_WITH_VALUE"][data-pse-value-coverage="FULL"]:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
){
  gap:2.25px !important;
  border-color:#111827 !important;
  background:#ffffff !important;
  color:#111827 !important;
  box-shadow:none !important;
}

.pse-canonical-tag-entry.pse-full-value-coverage:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
):hover,
.pse-canonical-tag-entry[data-pse-tag-type="GENERAL_WITH_VALUE"][data-pse-value-coverage="FULL"]:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
):hover{
  border-color:#111827 !important;
  background:#f8fafc !important;
  color:#111827 !important;
  box-shadow:inset 0 0 0 2px rgba(17,24,39,.08) !important;
}

/* Every visible registered Value node uses the same white/black box in all
   three hosts. This later common rule intentionally overrides the historical
   exact-VALUE flattening rule above after the duplicate whole root has been
   absorbed by the shared projection. */
.pse-canonical-tag-entry:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
) .pse-value-ui-group{
  display:inline-flex !important;
  align-items:center !important;
  align-content:center !important;
  flex:0 1 auto !important;
  flex-wrap:wrap !important;
  gap:1.5px !important;
  min-width:0 !important;
  max-width:100% !important;
  margin:.75px 1.5px !important;
  padding:2.25px 4.5px !important;
  border:1px solid #111827 !important;
  border-radius:4.5px !important;
  background:#ffffff !important;
  color:#111827 !important;
  box-shadow:none !important;
  font-weight:700 !important;
  line-height:1.15 !important;
  white-space:normal !important;
  overflow-wrap:anywhere !important;
  word-break:break-word !important;
  vertical-align:middle !important;
  transform:none !important;
  cursor:pointer !important;
  transition:
    background-color .12s ease,
    color .12s ease,
    border-color .12s ease,
    box-shadow .12s ease !important;
}

/* Recursive containment is real DOM nesting. Parent Value text that is not a
   smaller registered Value remains ordinary black text inside the parent box;
   only source text outside every top-level Value remains on the outer carrier. */
.pse-canonical-tag-entry:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
) .pse-value-ui-group .pse-value-ui-group{
  margin:.75px 1.5px !important;
  padding:2.25px 4.5px !important;
  border:1px solid #111827 !important;
  background:#ffffff !important;
  color:#111827 !important;
}

.pse-canonical-tag-entry:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
) .pse-value-ui-group .pse-value-general-text{
  color:#111827 !important;
}

.pse-canonical-tag-entry:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
) .pse-value-ui-group:hover{
  border-color:#111827 !important;
  background:#f8fafc !important;
  color:#111827 !important;
  box-shadow:inset 0 0 0 1px rgba(17,24,39,.10) !important;
}

.pse-canonical-tag-entry:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
) .pse-value-ui-group:focus-visible{
  outline:2px solid #111827 !important;
  outline-offset:2px !important;
}

/* Intersection is visually one merged Value-covered region. Candidate choice
   remains behavioral metadata and does not create overlapping DOM boxes. */
.pse-canonical-tag-entry:not(.inactive-tag):is(
  [data-pse-render-host="MODEL"],
  [data-pse-render-host="PRESET"],
  [data-pse-render-host="PASTED_PRESET"]
) .pse-value-ui-group[data-pse-value-group-kind="INTERSECTION"]{
  white-space:normal !important;
}
