@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&display=swap');

:root {
  --bg: #f3f3f0;
  --panel: #ffffff;
  --text: #222;
  --muted: #666;
  --border: #d8d8d2;
  --accent: #2f6fed;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

main {
  width: 100vw;
  height: 100dvh;
  padding: clamp(6px, 1.2vmin, 14px);
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: clamp(8px, 1.4vmin, 12px);
  padding: clamp(6px, 1.1vmin, 14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.05);
}

.viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(5px, 1vmin, 12px);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.viewer-toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(4px, 0.9vmin, 8px);
  width: 100%;
  min-width: 0;
}

button {
  padding: clamp(6px, 1vmin, 9px) clamp(8px, 1.4vmin, 12px);
  border: 1px solid var(--border);
  border-radius: clamp(7px, 1vmin, 9px);
  background: #fafafa;
  color: var(--text);
  font: inherit;
  font-size: clamp(12px, 1.55vmin, 16px);
  line-height: 1.15;
  white-space: nowrap;
  cursor: pointer;
}

button:hover:not(:disabled) { background: #f1f1f1; }

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#dimensionToggleBtn.is-off {
  color: var(--muted);
  background: #f4f4f2;
}

.canvas-shell {
  position: relative;
  display: block;
  flex: 0 1 auto;
  width: min(100%, calc(100dvh - 96px));
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
  border-radius: clamp(6px, 1.1vmin, 10px);
  outline: 1px solid var(--border);
}

.layer-hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.layer-hotspot {
  position: absolute;
  pointer-events: auto;
  border: 0;
  cursor: pointer;
}

.layer-hotspot:hover {
  background: transparent;
}

.layer-ui {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 1.2vmin, 12px);
  opacity: 0;
  transform: translate(-50%, -50%) scale(1);
  transition: none;
  pointer-events: none;
}

.layer-hotspot:hover .layer-ui {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.layer-chip {
  display: block;
  padding: clamp(5px, 0.9vmin, 8px) clamp(10px, 1.6vmin, 16px);
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.58);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(12px, 1.8vmin, 20px);
  font-weight: 300;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.layer-arrows {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.1vmin, 10px);
  pointer-events: auto;
}

.layer-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(34px, 5.2vmin, 46px);
  height: clamp(34px, 5.2vmin, 46px);
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.layer-arrow svg {
  display: block;
  width: 58%;
  height: 58%;
  margin: 0;
  overflow: visible;
}

.layer-arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

@media (max-width: 700px) {
  .viewer-toolbar { justify-content: stretch; }
  .viewer-toolbar button { flex: 1 1 150px; }
}

@media (max-height: 520px) {
  main { padding: 4px; }
  .panel { padding: 5px; }
  .viewer { gap: 4px; }
  button { padding-block: 5px; }
}
