/* Compact two-row drawing bar */

.sd-root {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
}

.sd-root.is-active {
  z-index: 18000;
}

.sd-root[hidden] {
  display: none !important;
}

body.screen-draw-active {
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

body.screen-draw-active .header {
  z-index: 18050;
}

.sd-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.sd-root.is-active .sd-canvas-live {
  pointer-events: auto;
  touch-action: none;
  cursor: none;
}

.sd-root.is-active.is-text .sd-canvas-live {
  cursor: text;
}

.sd-cursor {
  position: fixed;
  z-index: 2;
  border: 2px solid #ef4444;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
}

.sd-cursor.is-eraser {
  background: rgba(148, 163, 184, 0.18);
}

.sd-toolbar {
  position: absolute;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: auto;
  display: none;
  flex-direction: column;
  gap: 4px;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: 6px 8px;
  box-sizing: border-box;
  background: linear-gradient(
    180deg,
    var(--color-modal-shell-start) 0%,
    var(--color-modal-shell-end) 100%
  );
  border: 1px solid var(--color-modal-shell-border);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
}

.sd-root.is-active .sd-toolbar {
  display: flex;
}

.sd-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.sd-row-tools {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

.sd-row-opts {
  justify-content: flex-start;
}

.sd-tool-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  flex-shrink: 0;
}

.sd-sep {
  width: 1px;
  align-self: stretch;
  min-height: 22px;
  background: var(--color-border);
  margin: 0 3px;
  flex-shrink: 0;
}

.sd-tool {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--color-tool-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sd-tool:hover:not(:disabled) {
  background: rgba(124, 115, 255, 0.12);
  color: var(--color-primary);
}

.sd-tool.is-active {
  background: rgba(124, 115, 255, 0.18);
  color: var(--color-primary);
  border-color: rgba(124, 115, 255, 0.55);
}

.sd-tool.is-active i {
  color: inherit;
}

.sd-tool:disabled {
  opacity: 0.38;
  cursor: default;
}

.sd-icon-triangle {
  transform: rotate(-90deg);
}

.sd-color-well {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(15, 23, 42, 0.22);
  background: var(--sd-color, #ef4444);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.sd-color-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
}

.sd-thickness {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 120px;
}

.sd-width-input {
  flex: 1 1 90px;
  min-width: 72px;
  max-width: 140px;
  accent-color: var(--color-primary);
}

.sd-width-preview {
  width: var(--sd-preview-size, 8px);
  height: var(--sd-preview-size, 8px);
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.15);
  flex-shrink: 0;
}

.sd-width-preview.is-eraser {
  border: 2px dashed #6b7280;
  background: transparent;
}

.sd-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.sd-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.sd-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.sd-btn-danger {
  background: var(--color-surface);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.35);
}

.sd-btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.1);
}

.sd-btn-exit {
  background: var(--color-primary);
  color: var(--color-on-primary, #fff);
  border-color: var(--color-primary);
}

.sd-btn-exit:hover {
  filter: brightness(1.05);
}

.sd-text-editor {
  position: absolute;
  z-index: 4;
  min-width: 140px;
  min-height: 1.4em;
  margin: 0;
  padding: 2px 4px;
  border: 2px dashed var(--color-primary);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  font-family: Nunito, 'Open Sans', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  resize: both;
  outline: none;
  pointer-events: auto;
}

.screen-draw-btn {
  position: relative;
}

.screen-draw-btn.has-drawing::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-secondary);
  box-shadow: 0 0 0 2px var(--color-header-bg);
}

@media (max-width: 768px) {
  .sd-toolbar {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
  }

  .sd-btn span {
    display: none;
  }

  .sd-btn {
    width: 30px;
    padding: 0;
    justify-content: center;
  }
}
