/* ═══════════════════════════════════════════════════════════════
   MESA (MAPA VTT) & BIBLIOTECA DE MAPAS E NPCS — Tema Rústico
   ═══════════════════════════════════════════════════════════════ */
.wrap.vtt-active {
  max-width: 1440px;
  grid-template-columns: minmax(0, 1fr);
}

.vtt-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.vtt-main-col {
  display: grid;
  gap: 14px;
  min-width: 0;
}

/* Barra de ferramentas superior da mesa */
.vtt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
}

.vtt-toolbar select {
  width: auto;
  min-width: 190px;
  max-width: 260px;
  background-color: #140c07;
  color: #f0dcb8;
  border: 1px solid rgba(208, 170, 112, 0.45);
  border-radius: 3px;
  padding: 0.32rem 2rem 0.32rem 0.65rem;
}

.vtt-tool-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.vtt-toolbar .bt.on {
  border-color: #c9a24f;
  color: #fff2d6;
  background: var(--leather), linear-gradient(180deg, #7a141d, #46090f);
  box-shadow: inset 0 1px 0 rgba(255, 214, 160, 0.25), 0 0 14px rgba(179, 18, 31, 0.65);
}

.vtt-zoom-badge {
  font: 0.85rem var(--tp);
  color: #f0dcb8;
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(208, 170, 112, 0.35);
  background: rgba(10, 5, 2, 0.7);
  border-radius: 2px;
}

/* Palco / Viewport do Mapa */
.vtt-viewport {
  position: relative;
  width: 100%;
  min-height: 540px;
  max-height: 76vh;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 14px;
  border: 9px solid transparent;
  background:
    linear-gradient(#090503, #090503) padding-box,
    var(--wood) 0 0/400px 160px border-box,
    linear-gradient(135deg, #3d2713, #1d1108 45%, #2f1d0e 70%, #170c05) border-box;
  box-shadow: 0 18px 36px -12px #000, 0 0 0 1px #050201, inset 0 0 40px rgba(0, 0, 0, 0.9);
}

.vtt-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  transform-origin: center center;
  user-select: none;
  touch-action: none;
  box-shadow: 0 12px 32px #000;
}

.vtt-stage img.vtt-bg {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  pointer-events: none;
}

.vtt-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.vtt-tokens {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.vtt-fog {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

.vtt-fog.painting {
  pointer-events: auto;
  cursor: none;
}

.vtt-brush {
  position: absolute;
  z-index: 6;
  display: none;
  transform: translate(-50%, -50%);
  border: 2px dashed #f6e2a8;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.85);
}

.vtt-ruler {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

/* Tokens no Mapa */
.vtt-token {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid var(--ring, #d8b45a);
  background: radial-gradient(circle, #2a180d, #090503);
  display: grid;
  place-items: center;
  color: #f6e2a8;
  font: 700 0.85rem var(--hd);
  box-shadow: 0 4px 10px #000, 0 0 0 1px #000;
  transition: box-shadow 0.2s, transform 0.1s;
}

.vtt-token.movable {
  cursor: grab;
}

.vtt-token.movable:active {
  cursor: grabbing;
  z-index: 20 !important;
}

.vtt-token img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
}

.vtt-token-label {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 1px 7px;
  border-radius: 2px;
  background: rgba(10, 6, 4, 0.9);
  border: 1px solid rgba(208, 170, 112, 0.45);
  color: #f3e2be;
  font: 0.72rem var(--tp);
  pointer-events: none;
}

.vtt-token-hp {
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 0 5px;
  border-radius: 2px;
  background: rgba(110, 10, 18, 0.92);
  border: 1px solid #000;
  color: #fff3dc;
  font: 0.68rem var(--tp);
  pointer-events: none;
}

.vtt-empty-stage {
  text-align: center;
  padding: 48px 20px;
  max-width: 440px;
}

/* Painel Lateral da Mesa */
.vtt-side {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.vtt-roster-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px dashed rgba(208, 170, 112, 0.24);
}

.vtt-mini-av {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  border: 2px solid #8a6a3a;
  background: #140b06;
  overflow: hidden;
  display: grid;
  place-items: center;
  font: 0.85rem var(--hd);
  color: #e3d4b6;
}

.vtt-mini-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vtt-roster-info {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.vtt-roster-info strong {
  display: block;
  font: 0.96rem var(--hd);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vtt-roster-info small {
  font: 0.76rem var(--tp);
  color: var(--mu);
}

/* ═════ ABA MAPAS & NPCS (BIBLIOTECA DO MESTRE) ═════ */
.vtt-lib-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.vtt-form-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px dashed rgba(40, 24, 10, 0.45);
  background: rgba(255, 244, 214, 0.14);
  border-radius: 3px;
}

.vtt-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.vtt-preview-box {
  width: 100%;
  height: 130px;
  border: 2px solid #2a1a0c;
  background: #140b06;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #a89878;
  font: 0.82rem var(--tp);
}

.vtt-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vtt-saved-list {
  display: grid;
  gap: 10px;
}

.vtt-saved-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(40, 24, 10, 0.35);
  background: rgba(255, 244, 214, 0.22);
  border-radius: 3px;
}

.vtt-saved-thumb {
  width: 64px;
  height: 52px;
  flex: none;
  border: 2px solid #2a1a0c;
  background: #140b06;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #e3d4b6;
  font: 1rem var(--hd);
}

.vtt-saved-thumb.round {
  width: 54px;
  height: 54px;
  border-radius: 50%;
}

.vtt-saved-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vtt-saved-meta {
  flex: 1;
  min-width: 0;
}

.vtt-saved-meta strong {
  display: block;
  font: 1.02rem var(--hd);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vtt-saved-meta small {
  display: block;
  font: 0.78rem var(--tp);
  opacity: 0.85;
}

.vtt-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vtt-move-bar {
  height: 12px;
  background: #050302;
  border: 1px solid #000;
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0;
}

.vtt-move-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #46060c, #c4202e);
  transition: width 0.25s;
}

@media (max-width: 960px) {
  .vtt-layout,
  .vtt-lib-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
