/* Floating tool-options bar and the selection properties panel. */

.tool-options {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  z-index: 70;
  max-width: calc(100% - 32px);
  opacity: 0;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.tool-options.visible {
  display: flex;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.opt-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.opt-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.opt-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}

/* Colour swatches */

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  padding: 0;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
}

.swatch:hover { transform: scale(1.14); }

.swatch.is-active {
  border-color: #fff;
  transform: scale(1.12);
}

/* Size steps */

.size-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.size-btn:hover { background: var(--surface-hover); }
.size-btn.is-active { background: var(--accent-soft); }

.size-dot {
  background: var(--text-secondary);
  border-radius: 50%;
  display: block;
}

.size-btn.is-active .size-dot { background: #fff; }

/* Segmented control (shape kind, line kind, alignment, bold/italic) */

.segmented {
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px;
  border-radius: 999px;
}

.seg-btn {
  width: 28px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  position: relative;
}

.seg-btn svg { width: 15px; height: 15px; }

.seg-btn:hover { color: var(--text-primary); background: var(--surface-hover); }

.seg-btn.is-active {
  background: var(--accent);
  color: #fff;
}

/* Native colour input styled as a swatch */

.color-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  background: transparent;
  flex-shrink: 0;
}

.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch {
  border: 2px solid var(--border-strong);
  border-radius: 50%;
}
.color-input::-moz-color-swatch {
  border: 2px solid var(--border-strong);
  border-radius: 50%;
}

/* ---------- Selection properties panel ---------- */

.context-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-strong);
  width: 244px;
  display: none;
  z-index: 75;
  max-height: calc(100% - 120px);
  overflow-y: auto;
}

.context-panel.visible {
  display: block;
  animation: fadeIn 160ms cubic-bezier(0.2, 0, 0.2, 1);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.context-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: var(--font-size-md);
  color: var(--text-primary);
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.icon-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

.context-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  gap: 10px;
}

.context-row.stacked {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.context-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.context-value {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 26px;
  text-align: right;
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

input[type='range'] {
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--surface-raised);
  border-radius: 2px;
  outline: none;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  transition: transform var(--transition-fast);
}

input[type='range']::-webkit-slider-thumb:hover { transform: scale(1.18); }

input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.context-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.btn-context {
  flex: 1;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: filter var(--transition-fast), transform var(--transition-fast);
  font-family: var(--font-family);
}

.btn-context:hover { filter: brightness(1.12); }
.btn-context:active { transform: scale(0.97); }

.btn-context.primary {
  background: var(--accent);
  color: #fff;
}

.btn-context.danger {
  background: rgba(244, 63, 94, 0.16);
  color: #FDA4AF;
}

.btn-context.danger:hover {
  background: var(--danger);
  color: #fff;
}

@media (max-width: 720px) {
  .context-panel { width: 200px; }
  .tool-options { gap: 8px; padding: 6px 10px; }
  .opt-label { display: none; }
}
