.page {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg, #12141a);
  color: var(--text, #e8eaef);
}

.sidebar {
  border-right: 1px solid var(--stroke, #2a2f3a);
  padding: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.sideTitle {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
  flex-shrink: 0;
  min-width: 0;
}

.hint {
  font-size: 12px;
  opacity: 0.65;
  line-height: 1.35;
  flex-shrink: 0;
}

.accordionScroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
}

.accordion {
  border: 1px solid var(--stroke, #2a2f3a);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.accordionHead {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
}

.palette {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.gridPanel {
  display: grid;
  gap: 10px;
  padding: 10px 12px 12px;
}

.checkRow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.field {
  display: grid;
  gap: 6px;
}

.fieldDisabled {
  opacity: 0.45;
  pointer-events: none;
}

.fieldLabel {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
}

.fieldValue {
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.range {
  width: 100%;
  accent-color: #f5c542;
}

.colorInput {
  width: 100%;
  height: 34px;
  padding: 0;
  border: 1px solid var(--stroke, #2a2f3a);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}

.colorInput:disabled {
  cursor: default;
}

.colorInput::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: inherit;
}

.colorInput::-webkit-color-swatch {
  border: none;
  border-radius: inherit;
}

.colorInput::-moz-color-swatch {
  border: none;
  border-radius: inherit;
}

.paletteItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--stroke, #2a2f3a);
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  cursor: grab;
  user-select: none;
}

.paletteItem:active {
  cursor: grabbing;
}

.paletteLabel {
  font-size: 13px;
  font-weight: 600;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #0a0b0e;
}

.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.mapImg {
  display: block;
  max-width: none;
  user-select: none;
  pointer-events: none;
}

.trap {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  cursor: move;
  touch-action: none;
}

.trapSelected {
  border-color: #f5c542;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 0 3px rgba(245, 197, 66, 0.35);
}

.trapLabel {
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  font-size: 11px;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.7);
  padding: 2px 6px;
  border-radius: 4px;
}

.handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: #f5c542;
  border: 1px solid #000;
  cursor: nwse-resize;
  touch-action: none;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0.7;
}

.tokensPanel {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
}

.tokensToolbar {
  display: grid;
}

.tokensToolbar button {
  width: 100%;
  box-sizing: border-box;
}

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

.tokenTile {
  display: grid;
  gap: 4px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--stroke, #2a2f3a);
  background: rgba(0, 0, 0, 0.22);
  cursor: grab;
  user-select: none;
}

.tokenTile:active {
  cursor: grabbing;
}

.npcTile {
  display: grid;
  justify-content: center;
  overflow: hidden;
  padding: 7px 4px;
  border: 1px solid var(--stroke, #2a2f3a);
  border-radius: 8px;
  background: rgb(0 0 0 / 22%);
  cursor: grab;
}

.sceneNpcToken {
  position: absolute;
  z-index: 2;
  overflow: visible;
  transform: translate(-50%, -50%);
  cursor: move;
  touch-action: none;
}

.sceneNpcToken > * {
  pointer-events: none;
}

.sceneNpcToken .handle {
  pointer-events: auto;
}

.tokenThumb {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}

.tokenThumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tokenTileMeta {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.tokenTileName {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tokenTileMore {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}

.tokenTileMore:hover,
.tokenTileMore[aria-expanded='true'] {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.tokenCtxMenu {
  position: fixed;
  z-index: 80;
  min-width: 160px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--stroke, #333);
  background: #1a1d24;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 2px;
}

.tokenCtxItem,
.tokenCtxItemDanger {
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #e8eaef;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
}

.tokenCtxItem:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tokenCtxItemDanger {
  color: #f87171;
}

.tokenCtxItemDanger:hover {
  background: rgba(248, 113, 113, 0.12);
}

.clearSceneBtn {
  width: 100%;
  box-sizing: border-box;
  flex: 0 0 auto;
}

.clearSceneBtn > * {
  width: 100%;
  max-width: 100%;
  display: flex;
  box-sizing: border-box;
}

.clearSceneBtn button {
  width: 100%;
  box-sizing: border-box;
  flex: 1;
}

.sceneToken {
  position: absolute;
  z-index: 1;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.25);
  overflow: visible;
  cursor: move;
  touch-action: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.sceneTokenSelected {
  border-color: #f5c542;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 0 3px rgba(245, 197, 66, 0.35);
}

.sceneTokenImg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  pointer-events: none;
  display: block;
}

.rotateHandle {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #000;
  background: #f5c542;
  color: #111;
  font-size: 12px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  padding: 0;
}

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

.toolbar button {
  font-size: 12px;
}

.ctxMenuBackdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: default;
}

.ctxMenu {
  position: fixed;
  z-index: 41;
  min-width: 200px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--stroke, #2a2f3a);
  background: var(--color-surface-menu, #1a1e28);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 2px;
}

.ctxItem,
.ctxItemDanger {
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text1, #e8eaef);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
}

.ctxItemDanger {
  color: var(--color-danger, #e57373);
}

.ctxItem:hover,
.ctxItemDanger:hover {
  background: rgba(255, 255, 255, 0.06);
}
