:root {
  --ink: #1c2430;
  --ink-soft: rgba(28, 36, 48, 0.55);
  --paper: #eef2f6;
  --paper-deep: #d9e2ec;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(28, 36, 48, 0.1);
  --accent: #2a6f97;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(28, 36, 48, 0.14);
  --font-ui: "Sora", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper-deep);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 15% 10%, rgba(42, 111, 151, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 85%, rgba(214, 137, 16, 0.12), transparent 50%),
    linear-gradient(165deg, #f4f7fa 0%, #e4ebf3 48%, #d7e0ea 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

#board {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  background: #f3f6f9;
  -webkit-user-select: none;
  user-select: none;
}

#board.is-panning {
  cursor: grabbing;
}

#board.is-pan-ready {
  cursor: grab;
}

#board.is-image-mode {
  cursor: default;
}

.zoom-group {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.zoom-label {
  appearance: none;
  min-width: 3.1rem;
  height: 2.45rem;
  padding: 0 0.35rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: 500 0.72rem/1 var(--font-ui);
  letter-spacing: 0.02em;
  cursor: pointer;
}

.zoom-label:hover {
  color: var(--ink);
  background: rgba(28, 36, 48, 0.06);
}

.dock-btn.zoom-glyph {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1;
}

.dock {
  position: fixed;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  transition:
    top 280ms cubic-bezier(0.22, 1, 0.36, 1),
    right 280ms cubic-bezier(0.22, 1, 0.36, 1),
    bottom 280ms cubic-bezier(0.22, 1, 0.36, 1),
    left 280ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 280ms ease;
}

.dock-bottom {
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  top: auto;
  right: auto;
  transform: translateX(-50%);
  flex-direction: row;
}

.dock-top {
  left: 50%;
  top: max(1.25rem, env(safe-area-inset-top));
  bottom: auto;
  right: auto;
  transform: translateX(-50%);
  flex-direction: row;
}

.dock-left {
  left: max(1.25rem, env(safe-area-inset-left));
  top: 50%;
  right: auto;
  bottom: auto;
  transform: translateY(-50%);
  flex-direction: column;
  border-radius: 1.35rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  overflow-x: hidden;
}

.dock-right {
  right: max(1.25rem, env(safe-area-inset-right));
  top: 50%;
  left: auto;
  bottom: auto;
  transform: translateY(-50%);
  flex-direction: column;
  border-radius: 1.35rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  overflow-x: hidden;
}

.dock-left .dock-divider,
.dock-right .dock-divider {
  width: 1.4rem;
  height: 1px;
}

.dock-left .dock-cluster,
.dock-right .dock-cluster,
.dock-left .color-group,
.dock-right .color-group,
.dock-left .size-group,
.dock-right .size-group,
.dock-left .zoom-group,
.dock-right .zoom-group {
  flex-direction: column;
}

.dock-left .live,
.dock-right .live {
  padding: 0.35rem 0;
}

.dock.is-dragging {
  z-index: 20;
  cursor: grabbing;
  transition: none;
  box-shadow: 0 22px 55px rgba(28, 36, 48, 0.22);
  touch-action: none;
}

.dock-drag-handle {
  cursor: grab;
  color: var(--ink-soft);
}

.dock-drag-handle:hover {
  color: var(--ink);
}

.dock.is-dragging .dock-drag-handle {
  cursor: grabbing;
}

.dock-cluster {
  display: flex;
  gap: 0.25rem;
}

.dock-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition:
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.dock-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  pointer-events: none;
}

.dock-btn:hover {
  color: var(--ink);
  background: rgba(28, 36, 48, 0.06);
}

.dock-btn:active {
  transform: scale(0.94);
}

.dock-btn.is-active {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 6px 16px rgba(28, 36, 48, 0.22);
}

.dock-clear {
  color: var(--danger);
}

.dock-clear:hover {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.dock-divider {
  width: 1px;
  height: 1.4rem;
  background: rgba(28, 36, 48, 0.12);
  flex-shrink: 0;
}

.color-group {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0 0.15rem;
  transition: opacity 200ms ease;
}

.color-swatch {
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(28, 36, 48, 0.18);
  cursor: pointer;
  transition:
    transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 200ms ease;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.is-active {
  transform: scale(1.18);
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3.5px var(--accent);
}

.color-group.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.size-group {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.size-swatch {
  appearance: none;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.size-swatch:hover {
  background: rgba(28, 36, 48, 0.06);
}

.size-dot {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--ink-soft);
}

.size-swatch.is-active .size-dot {
  background: var(--ink);
}

.size-swatch.is-active {
  background: rgba(28, 36, 48, 0.08);
  box-shadow: inset 0 0 0 1.5px rgba(28, 36, 48, 0.2);
}

.live {
  display: flex;
  align-items: center;
  padding: 0 0.45rem 0 0.15rem;
}

.live-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #b08900;
  box-shadow: 0 0 0 0 rgba(176, 137, 0, 0.45);
  animation: pulse-warn 1.6s ease-out infinite;
}

.live-dot.is-live {
  background: #1e8449;
  animation: pulse-ok 2.2s ease-out infinite;
}

.live-dot.is-down {
  background: #b42318;
  animation: none;
}

@keyframes pulse-ok {
  0% {
    box-shadow: 0 0 0 0 rgba(30, 132, 73, 0.45);
  }
  70% {
    box-shadow: 0 0 0 0.45rem rgba(30, 132, 73, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(30, 132, 73, 0);
  }
}

@keyframes pulse-warn {
  0% {
    box-shadow: 0 0 0 0 rgba(176, 137, 0, 0.4);
  }
  70% {
    box-shadow: 0 0 0 0.4rem rgba(176, 137, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(176, 137, 0, 0);
  }
}

@media (max-width: 640px) {
  .dock-bottom,
  .dock-top {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    transform: none;
    justify-content: center;
    flex-wrap: wrap;
    border-radius: 1.25rem;
    padding: 0.55rem 0.6rem;
    gap: 0.5rem;
  }

  .dock-left,
  .dock-right {
    max-height: calc(100vh - 1.5rem);
    padding: 0.5rem;
    gap: 0.45rem;
  }
}
