/* PlayPort Core editors - one frame for all of them (Nov 2026).

   Every Core editor (models, skills, quests, dungeons, kits, cooking, jobs, worldgen,
   enchants, spawners, crates, achievements, drops, commands) is a dialog built the same
   way: a title, a paragraph or two, a list on the left (.npclist), a form on the right
   (.npcpane) made of label.cfgfield rows, and a footer (.modalfoot). They grew one at a
   time and each one sized itself, so they opened at different widths, the Save button
   scrolled out of reach under a long form, and every field carried a paragraph of help
   that turned the form into a wall of text.

   core-frame.js tags those dialogs `.coreed`; this file gives them one shape:

   - a large sheet with the title pinned at the top and Save pinned at the bottom;
   - the list pinned on the left with a search box, the form on the right in a grid;
   - help text under a field shows while you are in that field (or hovering it), not
     all at once;
   - section notes in the form read as section headings.

   Nothing here changes markup or behaviour. The UI editor (`.uis`) keeps its own
   layout and is left alone. */

#modalroot .modal.coreed {
  --ce-pad: 26px;
  --ce-head: 64px;
  position: relative;
  width: min(1240px, 96vw);
  max-width: 96vw;
  height: min(900px, 92vh);
  max-height: 92vh;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 18px;
  scroll-padding-top: calc(var(--ce-head) + 12px);
  scroll-padding-bottom: 90px;
  display: flex;
  flex-direction: column;
}
#modalroot .modal.coreed > * {
  flex: 0 0 auto;
}

/* Everything in the sheet gets the same side margin; the title and footer run edge to edge. */
#modalroot .modal.coreed > :not(h3):not(.modalfoot) {
  margin-left: var(--ce-pad);
  margin-right: var(--ce-pad);
}

/* The title, pinned. */
#modalroot .modal.coreed > h3 {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--ce-head);
  margin: 0 0 14px;
  padding: 16px var(--ce-pad);
  font-size: 21px;
  letter-spacing: -0.02em;
  background: color-mix(in srgb, var(--panel, #160f22) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
#modalroot .modal.coreed > h3 .note,
#modalroot .modal.coreed > h3 small {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

/* The intro paragraph(s) under the title: one calm line of context, not a block. */
#modalroot .modal.coreed > .note,
#modalroot .modal.coreed > .sub {
  max-width: 90ch;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--dim);
}

/* The footer, pinned, with an unsaved-changes marker from core-frame.js. */
#modalroot .modal.coreed > .modalfoot {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  padding: 14px var(--ce-pad);
  background: color-mix(in srgb, var(--panel, #160f22) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
#modalroot .modal.coreed > .modalfoot {
  margin-top: auto;
}
#modalroot .modal.coreed > .modalfoot .btn {
  flex: 0 0 auto;
}
/* Footer order: help and the shortcut on the left, Cancel then Save on the right. */
#modalroot .modal.coreed > .modalfoot > .spacer {
  display: none;
}
#modalroot .modal.coreed > .modalfoot > .coreed-keys {
  margin-right: auto;
}
#modalroot .modal.coreed > .modalfoot > :not(.coreed-dirty):not(.coreed-helpbtn):not(.coreed-keys):not(.btn) {
  order: 1;
}
#modalroot .modal.coreed > .modalfoot > .btn.ghost:not(.coreed-helpbtn) {
  order: 2;
}
#modalroot .modal.coreed > .modalfoot > .btn:not(.ghost) {
  order: 3;
}
.coreed-dirty {
  display: none;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--amber, #f5b84a);
}
.coreed-dirty::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}
.modal.coreed[data-dirty='1'] .coreed-dirty {
  display: inline-flex;
}
.coreed-keys {
  font-size: 11.5px;
  color: var(--dim);
}
.coreed-keys kbd {
  padding: 1px 5px;
  border: 1px solid var(--border2, var(--border));
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 600 10.5px var(--mono, ui-monospace, monospace);
}

/* Tabs some editors put above the list (Skills / Boss bindings, Price table / Units ...). */
#modalroot .modal.coreed :is(.uhtabs, .tabs) {
  margin-bottom: 12px;
}

/* --------------------------------------------------------------- list + form */
#modalroot .modal.coreed .npcwrap {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  min-height: 0;
}

.coreed-side {
  position: sticky;
  top: calc(var(--ce-head) + 14px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(92vh - var(--ce-head) - 120px);
  min-height: 0;
}
.coreed-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.coreed-search svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--dim);
}
.coreed-search input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-height: 36px !important;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.coreed-count {
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
}

#modalroot .modal.coreed .npclist {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  border-radius: 12px;
  padding: 6px;
}
#modalroot .modal.coreed .npcitem {
  margin: 0 0 2px;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  transition: background-color 120ms ease;
}
#modalroot .modal.coreed .npcitem:hover {
  background: color-mix(in srgb, var(--accent2, #a3e635) 7%, transparent);
}
#modalroot .modal.coreed .npcitem.on {
  background: color-mix(in srgb, var(--accent2, #a3e635) 15%, transparent);
  box-shadow: inset 3px 0 0 var(--accent2, #a3e635);
}
#modalroot .modal.coreed .npcitem .npcn {
  font-weight: 650;
  font-size: 13.5px;
}
#modalroot .modal.coreed .npcitem .note {
  margin-top: 2px;
  font-size: 11.5px;
}
#modalroot .modal.coreed .npcitem.coreed-hidden {
  display: none;
}
#modalroot .modal.coreed .npclist > .btn,
#modalroot .modal.coreed .npclist > div:not(.npcitem):has(> .btn) {
  margin: 8px 4px 4px;
}

/* The form: fields in a responsive grid, help on focus. */
#modalroot .modal.coreed .npcpane {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px 20px;
  align-content: start;
  min-width: 0;
  padding: 0 0 8px;
}
#modalroot .modal.coreed .npcpane > :not(.cfgfield) {
  grid-column: 1 / -1;
}
#modalroot .modal.coreed .npcpane > .cfgfield:has(textarea),
#modalroot .modal.coreed .npcpane > .cfgfield:has(.uhtool),
#modalroot .modal.coreed .npcpane > .cfgfield:has(table) {
  grid-column: 1 / -1;
}
#modalroot .modal.coreed .cfgfield {
  text-align: left;
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  min-width: 0;
}
#modalroot .modal.coreed .cfgfield > .cfgname {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
}
#modalroot .modal.coreed .cfgfield > :is(input:not([type='checkbox']):not([type='radio']), select, textarea) {
  width: 100% !important;
  max-width: none !important;
  min-height: 40px;
  border-radius: 9px;
}
#modalroot .modal.coreed .cfgfield > .note {
  -webkit-line-clamp: unset !important;
  max-height: none !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  display: none;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--dim);
}
#modalroot .modal.coreed .cfgfield:focus-within > .note,
#modalroot .modal.coreed .cfgfield:hover > .note,
#modalroot .modal.coreed.coreed-help .cfgfield > .note {
  display: block;
}
/* A checkbox field reads as one line: box, then name. */
#modalroot .modal.coreed .cfgfield:has(> input[type='checkbox']) {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}
#modalroot .modal.coreed .cfgfield > input[type='checkbox'] {
  width: 18px;
  min-height: 18px;
  order: -1;
}

/* A section note inside the form ("Items - one per line", "Rules - who may claim it")
   is a heading for the fields under it. */
#modalroot .modal.coreed .npcpane > .note {
  margin: 10px 0 -4px !important;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
#modalroot .modal.coreed .npcpane > .note:first-child {
  margin-top: 0 !important;
  padding-top: 0;
  border-top: 0;
}
#modalroot .modal.coreed .npcpane > .note b {
  display: block;
  margin-bottom: 2px;
  font-size: 13.5px;
  color: var(--text);
}

/* Boxes and rows inside the form that hold several fields lay them out the same way. */
#modalroot .modal.coreed :is(.cfgbox, .cfgrow, .ckrow):has(> .cfgfield) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 16px;
  align-items: start;
}
#modalroot .modal.coreed :is(.cfgbox, .cfgrow, .ckrow) > :not(.cfgfield) {
  grid-column: 1 / -1;
}
#modalroot .modal.coreed .cfgbox .cfgfield > .cfgname {
  text-align: left;
}

/* The old row-style settings box some editors still use. */
#modalroot .modal.coreed .cfgbox {
  border-radius: 12px;
  padding: 16px 18px;
}

/* Help toggle in the footer. */
.coreed-helpbtn[aria-pressed='true'] {
  border-color: var(--accent2) !important;
  color: var(--accent) !important;
}

/* Narrow windows: one column, nothing pinned beside the form. */
@media (max-width: 900px) {
  #modalroot .modal.coreed {
    --ce-pad: 16px;
    height: 94dvh;
    max-height: 94dvh;
    width: 100%;
  }
  #modalroot .modal.coreed .npcwrap {
    grid-template-columns: minmax(0, 1fr);
  }
  .coreed-side {
    position: static;
    max-height: 40vh;
  }
  #modalroot .modal.coreed .npcpane {
    grid-template-columns: minmax(0, 1fr);
  }
  .coreed-keys {
    display: none;
  }
}
