/* Viewer de NPCs — página dedicada. */

:root {
  --nv-bg: #071018;
  --nv-panel: rgba(10, 18, 28, 0.94);
  --nv-panel-border: rgba(148, 163, 184, 0.2);
  --nv-card: #0c1520;
  --nv-text: #e2e8f0;
  --nv-text-dim: #94a3b8;
  --nv-accent: #5eead4;
  --nv-accent-soft: rgba(94, 234, 212, 0.14);
  --nv-warn: #fbbf24;
  --nv-danger: #f87171;
  --nv-ok: #34d399;
  --nv-gym: #fbbf24;
  --nv-role: #60a5fa;
  --nv-civilian: #a3e635;
  --nv-trainer: #fb923c;
  --nv-kanto: #f87171;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(45, 212, 191, 0.12), transparent),
    var(--nv-bg);
  color: var(--nv-text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
}

.nv-app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
  padding: 12px;
}

.nv-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 16px;
  background: var(--nv-panel);
  border: 1px solid var(--nv-panel-border);
  border-radius: 12px;
  position: sticky;
  top: 8px;
  z-index: 5;
  backdrop-filter: blur(8px);
}

.nv-header__meta {
  min-width: 0;
}

.nv-header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nv-header__subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--nv-text-dim);
}

.nv-header__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-left: auto;
}

.nv-status {
  font-size: 12px;
  color: var(--nv-text-dim);
}

.nv-dirty {
  font-size: 11px;
  font-weight: 650;
  color: var(--nv-warn);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.nv-api {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.nv-api.is-online {
  color: var(--nv-ok);
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.28);
}

.nv-api.is-offline {
  color: var(--nv-danger);
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.28);
}

.nv-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.nv-input {
  min-width: 220px;
  background: #0a121c;
  border: 1px solid var(--nv-panel-border);
  border-radius: 8px;
  color: var(--nv-text);
  padding: 7px 10px;
  font: inherit;
}

.nv-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--nv-panel);
  border: 1px solid var(--nv-panel-border);
  border-radius: 12px;
  position: sticky;
  top: 88px;
  z-index: 4;
  backdrop-filter: blur(8px);
}

.nv-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--nv-text-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.nv-tab:hover {
  color: var(--nv-text);
  background: rgba(148, 163, 184, 0.08);
}

.nv-tab:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.55);
  outline-offset: 1px;
}

.nv-tab.is-active {
  color: var(--nv-accent);
  background: var(--nv-accent-soft);
  border-color: rgba(94, 234, 212, 0.35);
}

.nv-tab__count {
  min-width: 1.4em;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  color: inherit;
  background: rgba(148, 163, 184, 0.14);
}

.nv-tab.is-active .nv-tab__count {
  background: rgba(94, 234, 212, 0.2);
}

.nv-tab.is-active[data-pool="gym"] {
  color: var(--nv-gym);
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
}

.nv-tab.is-active[data-pool="role"] {
  color: var(--nv-role);
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.35);
}

.nv-tab.is-active[data-pool="civilian"] {
  color: var(--nv-civilian);
  background: rgba(163, 230, 53, 0.12);
  border-color: rgba(163, 230, 53, 0.35);
}

.nv-tab.is-active[data-pool="hgss"] {
  color: #f472b6;
  background: rgba(244, 114, 182, 0.12);
  border-color: rgba(244, 114, 182, 0.35);
}

.nv-tab.is-active[data-pool="dp"] {
  color: #818cf8;
  background: rgba(129, 140, 248, 0.12);
  border-color: rgba(129, 140, 248, 0.35);
}

.nv-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nv-role {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: min(100%, 280px);
  flex: 1 1 260px;
  padding: 10px 12px;
  background: var(--nv-panel);
  border: 1px solid var(--nv-panel-border);
  border-radius: 12px;
}

.nv-role.is-picking {
  border-color: rgba(94, 234, 212, 0.55);
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.2);
}

.nv-role.is-dirty {
  border-color: rgba(251, 191, 36, 0.55);
}

.nv-role__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--nv-text-dim);
}

.nv-role__name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--nv-text);
}

.nv-role__id {
  font-size: 11px;
  color: var(--nv-text-dim);
  font-family: ui-monospace, Consolas, monospace;
}

.nv-role__hint {
  width: 100%;
  margin: 0;
  font-size: 11px;
  color: var(--nv-accent);
}

.nv-card.is-role-nurse,
.nv-card.is-role-martClerk {
  border-color: rgba(96, 165, 250, 0.45);
}

.nv-card.is-pick-target {
  cursor: pointer;
  outline: 1px dashed rgba(94, 234, 212, 0.45);
}

.nv-card.is-pick-target:hover {
  border-color: rgba(94, 234, 212, 0.65);
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.25);
}

.nv-card__roles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nv-card__role-btn {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--nv-panel-border);
  background: #0a121c;
  color: var(--nv-text-dim);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.nv-card__role-btn.is-active {
  color: var(--nv-role);
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(96, 165, 250, 0.12);
}

.nv-card__role-btn:hover {
  color: var(--nv-text);
  border-color: rgba(148, 163, 184, 0.45);
}

.nv-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--nv-text-dim);
  user-select: none;
}

.nv-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--nv-panel-border);
  background: #0a121c;
  color: var(--nv-text);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.nv-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nv-btn--primary {
  background: var(--nv-accent-soft);
  border-color: rgba(94, 234, 212, 0.45);
  color: var(--nv-accent);
  font-weight: 650;
}

.nv-btn--primary:not(:disabled):hover {
  background: rgba(94, 234, 212, 0.22);
}

.nv-btn--ghost:not(:disabled):hover {
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--nv-danger);
}

.nv-btn--link:hover {
  border-color: var(--nv-accent);
  color: var(--nv-accent);
}

.nv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  align-content: start;
}

.nv-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--nv-card);
  border: 1px solid var(--nv-panel-border);
  border-radius: 12px;
  min-width: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.nv-card.is-dirty {
  border-color: rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.18);
}

.nv-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.nv-card__name {
  flex: 1 1 140px;
  min-width: 0;
  margin: 0;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 650;
  color: var(--nv-text);
  background: rgba(10, 18, 28, 0.65);
  border: 1px solid transparent;
  border-radius: 6px;
  outline: none;
}

.nv-card__name:hover {
  border-color: var(--nv-panel-border);
}

.nv-card__name:focus {
  border-color: rgba(94, 234, 212, 0.55);
  background: #0a121c;
}

.nv-card__name:invalid {
  border-color: rgba(248, 113, 113, 0.65);
}

.nv-card__id {
  font-size: 11px;
  color: var(--nv-text-dim);
  font-family: ui-monospace, Consolas, monospace;
}

.nv-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nv-tag--gym {
  background: rgba(251, 191, 36, 0.16);
  color: var(--nv-gym);
}

.nv-tag--role {
  background: rgba(96, 165, 250, 0.16);
  color: var(--nv-role);
}

.nv-tag--civilian {
  background: rgba(163, 230, 53, 0.14);
  color: var(--nv-civilian);
}

.nv-tag--hgss {
  background: rgba(244, 114, 182, 0.14);
  color: #f472b6;
}

.nv-tag--dp {
  background: rgba(129, 140, 248, 0.14);
  color: #818cf8;
}

.nv-tag--other {
  background: var(--nv-accent-soft);
  color: var(--nv-accent);
}

.nv-tag--kanto {
  background: rgba(248, 113, 113, 0.14);
  color: var(--nv-kanto);
}

.nv-tag--trainers {
  background: rgba(251, 146, 60, 0.16);
  color: var(--nv-trainer);
}

.nv-card.is-ow-trainer {
  border-color: rgba(251, 146, 60, 0.4);
}

.nv-card__trainer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.nv-card__trainer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.nv-card__trainer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--nv-text-dim);
  cursor: pointer;
  user-select: none;
}

.nv-card__trainer-toggle input {
  accent-color: var(--nv-trainer);
}

.nv-card__trainer-toggle.is-on {
  color: var(--nv-trainer);
}

.nv-card__template {
  flex: 1 1 140px;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--nv-panel-border);
  background: #0a121c;
  color: var(--nv-text);
  font: inherit;
  font-size: 12px;
}

.nv-card__template:focus {
  outline: none;
  border-color: rgba(251, 146, 60, 0.55);
}

.nv-card__edit-pool {
  padding: 4px 8px;
  font-size: 11px;
}

.nv-card__party {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 28px;
}

.nv-card__party-size {
  margin: 0;
  font-size: 11px;
  color: var(--nv-text-dim);
}

.nv-card__party-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nv-party-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 2px;
  border-radius: 999px;
  background: rgba(251, 146, 60, 0.08);
  border: 1px solid rgba(251, 146, 60, 0.22);
  font-size: 11px;
  color: var(--nv-text);
}

.nv-party-chip .pokemon-icon {
  --icon-size: 22px;
}

.pokemon-icon {
  --icon-size: 32px;
  width: var(--icon-size);
  height: var(--icon-size);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.pokemon-icon__img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  image-rendering: pixelated;
}

.pokemon-icon.is-missing {
  opacity: 0.35;
}

.nv-party-chip__pct {
  font-variant-numeric: tabular-nums;
  color: var(--nv-trainer);
  font-weight: 650;
}

.nv-party-chip__name {
  color: var(--nv-text-dim);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nv-card__party-empty {
  margin: 0;
  font-size: 11px;
  color: var(--nv-text-dim);
  font-style: italic;
}

.nv-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
  background: rgba(2, 8, 14, 0.55);
  backdrop-filter: blur(4px);
}

.nv-drawer[hidden] {
  display: none;
}

.nv-drawer__panel {
  width: min(420px, 100%);
  height: 100%;
  background: var(--nv-panel);
  border-left: 1px solid var(--nv-panel-border);
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
}

.nv-drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--nv-panel-border);
}

.nv-drawer__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.nv-drawer__sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--nv-text-dim);
}

.nv-drawer__body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.nv-drawer__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nv-drawer__field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--nv-text-dim);
}

.nv-drawer__field input,
.nv-drawer__field select {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--nv-panel-border);
  background: #0a121c;
  color: var(--nv-text);
  font: inherit;
}

.nv-drawer__sizes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.nv-drawer__species {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nv-drawer__species-row {
  display: grid;
  grid-template-columns: 28px 1fr 72px auto;
  gap: 8px;
  align-items: center;
}

.nv-drawer__species-row .pokemon-icon {
  --icon-size: 28px;
}

.nv-drawer__add {
  display: flex;
  gap: 8px;
}

.nv-drawer__add input {
  flex: 1;
}

.nv-drawer__preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.nv-card__meta {
  margin: 0;
  font-size: 11px;
  color: var(--nv-text-dim);
}

.nv-card__views {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nv-view {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.nv-view__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--nv-text-dim);
}

.nv-view canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #121a24 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(-45deg, #121a24 25%, transparent 25%) 0 6px / 12px 12px,
    linear-gradient(45deg, transparent 75%, #121a24 75%) 6px -6px / 12px 12px,
    linear-gradient(-45deg, transparent 75%, #121a24 75%) -6px 0 / 12px 12px,
    #0a1018;
  border: 1px solid rgba(148, 163, 184, 0.12);
  image-rendering: pixelated;
}

@media (max-width: 640px) {
  .nv-card__views {
    grid-template-columns: 1fr;
  }

  .nv-header__status {
    margin-left: 0;
    width: 100%;
  }

  .nv-tabs {
    top: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .nv-tab {
    flex: 0 0 auto;
  }
}
