.bpw-lite-app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #d0d7de;
  border-radius: 12px;
  padding: 12px;
}

.bpw-lite-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.bpw-tool {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.bpw-tool:hover {
  background: #f1f5f9;
}

.bpw-tool.is-active {
  background: #2271b1;
  border-color: #2271b1;
  color: #ffffff;
}

.bpw-tool:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Layout */
.bpw-lite-layout {
  display: flex;
  height: calc(100% - 60px);
  gap: 12px;
}

/* Map */
.bpw-lite-stage {
  flex: 1;
  position: relative;
  background: #0b1020;
  border-radius: 8px;
  overflow: hidden;
}

/* Sidebar */
.bpw-lite-sidebar {
  width: 340px;
  min-width: 300px;
  max-width: 400px;
  background: #111827;
  color: #e5e7eb;
  border-left: 2px solid #1f2937;
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
}

/* Hidden */
.bpw-lite-sidebar[hidden] {
  display: none !important;
}

/* Sheet Styling */
.bpw-lite-sidebar h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.bpw-lite-sidebar label {
  display: block;
  font-size: 12px;
  margin-top: 8px;
  color: #9ca3af;
}

.bpw-lite-sidebar input,
.bpw-lite-sidebar select {
  width: 100%;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #1f2937;
  color: #fff;
}

.bpw-sheet-empty {
  opacity: 0.6;
  text-align: center;
  margin-top: 20px;
}

.bpw-lite-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.bpw-status {
  margin-left: auto;
  font-size: 13px;
  color: #475569;
}

.bpw-zoom {
  font-size: 13px;
  color: #334155;
  min-width: 56px;
  text-align: center;
}

.bpw-lite-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
}

.bpw-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  cursor: crosshair;
}

.bpw-lite-app.is-fullscreen {
  height: 100vh;
  border-radius: 0;
  border: none;
}

.bpw-lite-app.is-fullscreen .bpw-lite-stage {
  flex: 1;
  min-height: 0;
}

.bpw-modal[hidden] {
  display: none !important;
}

.bpw-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.bpw-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
}

.bpw-modal__panel {
  position: relative;
  z-index: 2;
  width: min(720px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 20px auto;
  background: #ffffff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.bpw-modal__panel--wide {
  width: min(960px, calc(100vw - 40px));
}

.bpw-modal__panel--npc,
.bpw-modal__panel--npc-wide {
  width: min(1200px, calc(100vw - 40px));
}

.bpw-modal__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 14px 0;
}

.bpw-modal__fields--stack {
  flex-direction: column;
}

.bpw-modal__fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  flex: 1 1 180px;
}

.bpw-modal__fields input,
.bpw-modal__fields select,
.bpw-modal__fields textarea {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: #ffffff;
}

.bpw-modal__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.bpw-modal__actions--wrap,
.bpw-modal__actions--editor {
  flex-wrap: wrap;
}

.bpw-character-library,
.bpw-npc-library {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.bpw-character-row {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid #dbe3ec;
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
}

.bpw-character-row.is-selected,
.bpw-character-row.is-active {
  border-color: #2271b1;
  box-shadow: inset 0 0 0 1px #2271b1;
  background: #eff6ff;
}

.bpw-character-row__preview {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  font-size: 12px;
  text-align: center;
}

.bpw-character-row__preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bpw-character-row__meta strong {
  display: inline-block;
  margin-bottom: 4px;
}

.bpw-character-row__meta small {
  color: #50575e;
}

.bpw-character-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.bpw-npc-layout,
.bpw-npc-library-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

.bpw-npc-layout__list,
.bpw-npc-layout__editor,
.bpw-npc-library-column,
.bpw-npc-editor-column {
  min-width: 0;
}

.bpw-npc-layout__editor,
.bpw-npc-editor {
  position: sticky;
  top: 0;
  border: 1px solid #dbe3ec;
  border-radius: 14px;
  background: #f8fafc;
  padding: 16px;
}

.bpw-npc-editor-title {
  margin: 0 0 12px;
}

.bpw-npc-editor-hint {
  margin: 12px 0 0;
  color: #50575e;
  font-size: 13px;
}

.bpw-npc-editor__preview {
  margin-top: 16px;
}

.bpw-npc-editor__preview-box {
  width: 160px;
  height: 160px;
  border-radius: 14px;
  overflow: hidden;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  text-align: center;
}

.bpw-npc-editor-preview-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bpw-lite-error {
  padding: 14px 16px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 10px;
}

body.bpw-modal-open,
body.dad-helper-modal-open {
  overflow: hidden;
}

.dad-helper-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.dad-helper-modal__dialog {
  width: min(980px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.dad-helper-modal__header,
.dad-helper-modal__footer {
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.dad-helper-modal__body {
  padding: 0 20px 20px;
}

.dad-helper-modal__close {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.dad-helper-modal__hint {
  color: #475569;
}

.dad-helper-portrait-modal__stage {
  margin-top: 14px;
  border-radius: 14px;
  overflow: hidden;
  background: #111827;
}

.dad-helper-portrait-modal__canvas {
  display: block;
  width: 100%;
  height: auto;
}

.dad-helper-portrait-modal__controls {
  margin-top: 14px;
}

.dad-helper-map-setup__canvas-wrap {
  margin: 14px 0;
  border-radius: 14px;
  overflow: hidden;
  background: #0f172a;
}

.dad-helper-map-setup__canvas {
  display: block;
  width: 100%;
  height: auto;
}

.dad-helper-map-setup__upload,
.dad-helper-map-setup__fields {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 960px) {
  .bpw-npc-layout,
  .bpw-npc-library-layout {
    grid-template-columns: 1fr;
  }

  .bpw-npc-layout__editor,
  .bpw-npc-editor {
    position: static;
  }

  .bpw-character-row {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .bpw-character-row__actions {
    justify-content: flex-start;
  }
}