.viewport {
  position: relative;
  width: 100%;
  height: 100%;
  background: #1a1a1f;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Viewport Internal Toolbar */
.viewport-internal-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 8px;
  background: rgba(30, 30, 30, 0.85);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  z-index: 20;
}

.viewport-internal-toolbar-left,
.viewport-internal-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.viewport-snap-control {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #888;
  font-size: 12px;
}

.viewport-snap-dropdown {
  position: relative;
}

.viewport-snap-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: #aaa;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  height: 22px;
}

.viewport-snap-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Zoom display */
.viewport-zoom-display {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  color: #888;
  font-size: 11px;
  font-family: var(--font-family-mono);
}

.viewport-view-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: #aaa;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.viewport-view-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.viewport-more-btn {
  padding: 2px 4px;
}

.viewport-snap-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 80px;
  background: #2d2d2d;
  border: 1px solid #444;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 100;
  overflow: hidden;
}

.viewport-snap-menu-right {
  left: auto;
  right: 0;
  min-width: 140px;
}

.viewport-snap-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: #ccc;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease;
}

.viewport-snap-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.viewport-snap-menu button.active {
  background: rgba(0, 120, 212, 0.3);
  color: #fff;
}

.viewport-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border-default);
  flex-shrink: 0;
  gap: 4px;
  z-index: var(--z-index-above);
  height: 36px;
}

.viewport-toolbar-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

.viewport-toolbar-center {
  display: flex;
  align-items: center;
  gap: 2px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.viewport-toolbar-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.viewport-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.1s ease;
  padding: 0;
}

.viewport-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-primary);
}

.viewport-btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.viewport-btn:active {
  transform: scale(0.96);
}

.viewport-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.viewport-btn:disabled:hover {
  background: transparent;
  color: var(--color-text-secondary);
}

/* Button group styling */
.viewport-btn-group {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  padding: 2px;
  gap: 1px;
}

.viewport-btn-group .viewport-btn {
  border-radius: 2px;
}

/* Playback controls special styling */
.viewport-playback {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 2px 4px;
  gap: 2px;
}

.viewport-playback .viewport-btn {
  width: 28px;
  height: 28px;
}

.viewport-playback .viewport-btn.play-btn {
  color: #4ade80;
}

.viewport-playback .viewport-btn.play-btn:hover {
  background: rgba(74, 222, 128, 0.15);
}

.viewport-playback .viewport-btn.play-btn.active {
  background: #4ade80;
  color: #000;
}

.viewport-playback .viewport-btn.pause-btn.active {
  background: #fbbf24;
  color: #000;
}

.viewport-playback .viewport-btn.stop-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Dropdown */
.viewport-dropdown {
  position: relative;
}

.viewport-dropdown .viewport-btn {
  width: auto;
  padding: 0 8px;
  gap: 4px;
}

.viewport-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 160px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: var(--z-index-dropdown);
  overflow: hidden;
}

.viewport-dropdown-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.viewport-dropdown-menu button:hover {
  background: var(--color-bg-hover);
}

.viewport-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 6px;
}


.viewport-canvas {
  flex: 1;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  background: #1a1a1f;
  user-select: none;
}

.viewport-canvas:active {
  cursor: grabbing;
}

.viewport-stats {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-family-mono);
  font-size: 11px;
  pointer-events: none;
  z-index: var(--z-index-above);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.viewport-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.viewport-stat-label {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.viewport-stat-value {
  color: var(--color-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.viewport:fullscreen {
  background: #000;
}

.viewport:fullscreen .viewport-canvas {
  background: #000;
}

.viewport-canvas:focus {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .viewport-btn {
    transition: none;
  }
}
