.floating-window {
  position: fixed;
  top: 96px;
  right: 96px;
  width: 360px;
  max-height: calc(100vh - 180px);
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e8eaed;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 150;
  transition: box-shadow 0.25s ease;
  will-change: transform, box-shadow;
}

.floating-window[aria-hidden="false"] {
  display: flex;
}

.floating-window.is-topmost {
  box-shadow: 0 12px 34px rgba(12, 24, 48, 0.25);
}

.floating-window__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8eaed;
  cursor: grab;
}

body.tablet-mode #referenceHeader,
body.tablet-mode #referenceResizer,
body.tablet-mode #referenceWindow.is-dragging,
body.tablet-mode #referenceWindow.is-resizing {
  touch-action: none;
}

.floating-window__header:active {
  cursor: grabbing;
}

.floating-window__title {
  font-size: 16px;
  font-weight: 500;
}

.floating-window__actions button {
  width: 30px !important;
  height: 30px !important;
  border-radius: 10px;
  border: 1px solid #d5d9e6;
  background: #f5f7fb;
  color: #1f2433;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.floating-window__actions button:hover {
  background: #e6ebf6;
  border-color: #c3c9da;
  color: #0a7aff;
}

.floating-window__body {
  padding: 12px 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.floating-window__resizer {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, transparent 50%, #1a73e8 50%);
  cursor: se-resize;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.floating-window__resizer:hover {
  opacity: 1;
}

.floating-window.is-dragging .floating-window__resizer {
  opacity: 0.3;
}

.floating-window.is-minimized .floating-window__resizer {
  display: none;
}

.floating-window.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.floating-window.is-resizing {
  cursor: se-resize;
  user-select: none;
}

.floating-window.is-minimized {
  width: 120px;
  height: auto;
  min-width: 120px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 10px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.floating-window.is-minimized:hover {
  box-shadow: 0 6px 16px rgba(26, 115, 232, 0.24);
}

.floating-window.is-minimized .floating-window__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-bottom: none;
}

.floating-window.is-minimized .floating-window__title {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 14px;
  color: #3c4043;
  letter-spacing: 2px;
  margin: 0;
}

.floating-window.is-minimized .floating-window__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}


.floating-window.is-minimized .floating-window__actions button:not(#referenceMinimizeBtn) {
  display: none;
}


.floating-window.is-minimized .floating-window__body,
.floating-window.is-minimized .floating-window__resizer {
  display: none;
}

.palette-window {
  right: 32px;
  left: auto;
  top: 120px;
  width: 420px;
  max-height: calc(100vh - 200px);
  min-width: 100px;
  min-height: 300px;
}

.palette-window__body {
  padding: 18px;
  gap: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.palette-window__body .palette-grid {
  flex: 1;
  min-height: 0;
}

/* Tablet mode overrides for floating windows */
.tablet-mode .floating-window.is-tablet-fixed {
  position: fixed !important;
  opacity: 0.95;
  border: 1px solid var(--color-border-dark);
  box-shadow: var(--shadow-l);
  transform: none !important;
}

.tablet-mode .floating-window.is-tablet-fixed .floating-window__header {
  cursor: default;
  pointer-events: none;
}

.tablet-mode .floating-window.is-tablet-fixed .floating-window__resizer {
  pointer-events: none;
  display: none;
}

/* Re-enable pointer events for buttons inside the header */
.tablet-mode .floating-window.is-tablet-fixed .floating-window__header .floating-window__actions button {
  pointer-events: auto;
}

/* Color Palette specific styles */
.tablet-mode #paletteWindow.is-tablet-fixed {
  top: 96px !important;
  right: 16px !important;
  left: auto !important;
  width: 320px !important;
  max-height: 65vh !important;
  height: auto !important;
}
