.npc-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 100px max-content;
  align-items: end;
  gap: 10px;
}

.npc-settings .field :is(select, input),
.npc-settings button {
  min-height: 44px;
  min-width: 0;
  font-size: 16px;
}

.npc-settings .field :is(select, input) {
  width: 100%;
}

.npc-status,
.npc-meta,
.npc-source {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.npc-detail-modal > .modal-header .npc-meta {
  margin-top: 5px;
}

.npc-status:empty,
.npc-meta:empty,
.npc-workspace .npc-output:empty {
  display: none;
}

.npc-output {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr));
  gap: 12px;
}

.npc-card,
.npc-library-grid .npc-card {
  position: relative;
  display: grid;
  min-width: 0;
  height: auto;
  min-height: 0;
  max-height: none;
  padding: 0;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.npc-card-open {
  display: grid;
  align-content: start;
  gap: 5px;
  width: 100%;
  min-height: 92px;
  padding: 14px 48px 14px 14px;
  border: 0;
  background: transparent;
  text-align: start;
  overflow-wrap: anywhere;
}

.npc-card-open strong {
  font-family: var(--font-heading, inherit);
  font-size: 22px;
  line-height: 1.15;
}

.npc-card-open small {
  color: var(--muted);
  font-size: 13px;
}

.npc-card-open .npc-card-preview {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: normal;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.npc-card .card-remove {
  top: 4px;
  right: 4px;
  width: 44px;
  height: 44px;
}

.npc-detail-modal.tool-modal {
  width: min(820px, 100%);
}

.npc-sheet {
  display: grid;
  gap: 16px;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.npc-sheet h3,
.npc-sheet p {
  margin: 0;
}

.npc-sheet h3 {
  font-size: 19px;
}

.npc-first-line {
  margin: 0;
  padding: 13px 17px;
  border-inline-start: 3px solid var(--accent);
  background: var(--soft);
  font-family: var(--font-heading, inherit);
  font-size: clamp(19px, 3vw, 25px);
  line-height: 1.35;
}

.npc-sheet-section p {
  margin-top: 4px;
}

.npc-portrayal {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr));
  gap: 10px;
}

.npc-portrayal .npc-sheet-section {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.npc-gm-notes {
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.npc-gm-notes > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  gap: 10px;
  cursor: pointer;
}

.npc-gm-notes > summary::-webkit-details-marker {
  display: none;
}

.npc-gm-notes > summary::after {
  color: var(--accent);
  content: "＋";
}

.npc-gm-notes[open] > summary::after {
  content: "−";
}

.npc-gm-notes .npc-sheet-section {
  margin: 2px 0 12px;
}

.npc-gm-notes .npc-sheet-section h3,
.npc-source {
  font-size: 14px;
}

@media (max-width: 740px) {
  .npc-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .npc-generator > .npc-workspace,
  .npc-detail-modal > .npc-detail-body {
    padding: 12px;
  }

  .npc-generator > .modal-actions,
  .npc-detail-modal > .modal-actions {
    padding: 10px 12px;
  }
}

.npc-output, .npc-library-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}
.npc-card .npc-card-open,
.npc-card .npc-card-open:is(:hover, :active, .is-pressing):not(:disabled) {
  align-content: start;
  gap: 0.5rem;
  padding: 1rem 3rem 1rem 1.15rem;
  border-inline-start: 3px solid var(--accent);
  border-radius: inherit;
  background: transparent;
  box-shadow: none;
  filter: none;
  transform: none;
}
.npc-card .npc-card-open strong { font: 700 1.8rem/1.05 var(--font-heading); }
.npc-card .npc-card-open small { font: 400 0.88rem/1.4 var(--font-text); }
.npc-card .npc-card-preview {
  border-top: 1px solid var(--generator-line, var(--border));
  padding-top: 0.55rem;
  font: 400 1rem/1.5 var(--font-text);
}
.npc-detail-modal .npc-sheet {
  gap: 1.25rem;
}
.npc-detail-modal .npc-sheet .npc-opening {
  padding: 0.2rem 0 0.35rem 1rem;
  border: 0;
  border-inline-start: 2px solid var(--accent);
  border-radius: 0;
  background: transparent;
}
.npc-detail-modal .npc-opening h3 {
  font: 400 0.88rem/1.4 var(--font-text);
  color: var(--generator-muted);
}
.npc-detail-modal .npc-sheet .npc-first-line {
  margin-top: 0.4rem;
  color: var(--ink);
  font: 600 clamp(1.35rem, 2.4vw, 1.65rem)/1.2 var(--font-heading);
}
.npc-detail-modal .npc-sheet .npc-sheet-section {
  border: 0;
  background: none;
  padding: 0;
}
.npc-detail-modal .npc-portrayal { gap: 1.25rem; }
.npc-detail-modal .npc-sheet .npc-gm-notes {
  padding: 0.2rem 1rem;
  border: 1px solid var(--generator-line);
  border-radius: var(--radius);
  background: var(--generator-surface);
}
.npc-detail-modal .npc-gm-notes[open] > summary {
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--generator-line);
}
.npc-detail-modal .npc-gm-notes .npc-sheet-section h3 {
  font: 700 1.12rem/1.3 var(--font-heading);
}
.npc-detail-modal .npc-gm-notes .npc-sheet-section + .npc-sheet-section { margin-top: 1rem; }

.npc-detail-modal .npc-sheet .npc-first-line--long {
  font: 400 1.12rem/1.55 var(--font-text);
}

.npc-detail-modal .npc-portrayal {
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--generator-line);
}
