/* Infinite Paint */

.ip-body { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.ip-body .topbar { flex: none; padding-top: 10px; padding-bottom: 10px; }

.ip-top { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ip-title { margin: 0; font: 600 1.15rem/1 var(--font-display); color: var(--muted); white-space: nowrap; }
.ip-meter {
  min-width: 5.2em;
  padding: 7px 13px 8px;
  border-radius: 99px;
  background: var(--soft);
  border: 1.5px solid var(--line);
  font: 700 1.05rem/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.ip-meter sup { font-size: .68em; line-height: 0; }

.ip-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-top: 1.5px solid var(--line);
  background: #fffdf8;
}
.ip-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
}
.ip-stage[data-tool=hand] canvas,
.ip-stage.space canvas { cursor: grab; }
.ip-stage.panning canvas { cursor: grabbing; }

.ip-cursor {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .9), inset 0 0 0 1px rgba(255, 255, 255, .7);
  pointer-events: none;
  z-index: 2;
}
.ip-cursor.eraser { border-style: dashed; }

/* ------------------------------------------------------------ hint */

.ip-hint {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100% - 40px));
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
  animation: fade .4s ease;
}
.ip-hint-big { font: 700 clamp(2rem, 7vw, 2.8rem)/1.05 var(--font-display); color: var(--ink); margin-bottom: 8px; }
.ip-hint p { margin: 0 0 16px; }
.ip-hint button { pointer-events: auto; }

/* ------------------------------------------------------------ buttons */

.ip-actions { position: absolute; top: 12px; right: 14px; display: flex; gap: 8px; z-index: 3; }

.ip-btn {
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.ip-btn:hover { background: var(--soft); }
.ip-btn:active { transform: translateY(1px); }
.ip-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ip-btn.active { background: var(--accent); border-color: var(--ink); }
.ip-btn:disabled { opacity: .3; cursor: default; background: transparent; transform: none; }
.ip-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.ip-zoom {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3;
}
.ip-round {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.ip-round:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
.ip-round.held,
.ip-round:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); background: var(--accent); }

/* ------------------------------------------------------------ toolbar */

.ip-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  padding: 7px 8px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--ink);
}
.ip-group { display: flex; align-items: center; gap: 3px; }
.ip-group + .ip-group { padding-left: 8px; border-left: 1.5px solid var(--line); }

.ip-panel { display: flex; align-items: center; gap: 12px; }
.ip-swatches { display: flex; align-items: center; gap: 5px; }
.ip-swatch {
  position: relative;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--c);
  cursor: pointer;
  transition: transform .12s;
}
.ip-swatch:hover { transform: scale(1.12); }
.ip-swatch.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.ip-swatch:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.ip-custom { background: conic-gradient(#e5484d, #ffd23f, #2ec27e, #36c5f0, #2f7cf6, #9b51e0, #ff5d8f, #e5484d); overflow: hidden; }
.ip-custom input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; border: 0; padding: 0; }
.ip-custom:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }

.ip-size { display: flex; align-items: center; gap: 6px; }
.ip-size input { width: 92px; accent-color: var(--ink); margin: 0; }
.ip-size-val { min-width: 1.6em; font: 600 .9rem/1 var(--font-display); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.ip-color-toggle { display: none; }
.ip-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink); background: var(--c, #1d1b16); }

.ip-zp { position: relative; width: auto; gap: 6px; padding: 0 11px 0 8px; font: 600 .92rem/1 var(--font-display); white-space: nowrap; }
.ip-zp[data-mode=in],
.ip-zp[data-mode=out] { background: var(--accent); border-color: var(--ink); }
.ip-zp[data-mode=out] svg { transform: scaleX(-1); }

@media (max-width: 900px) {
  .ip-color-toggle { display: inline-grid; }
  .ip-panel {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 14px);
    width: 236px;
    margin-left: -118px; /* centred without transform, so the pop animation can't shift it */
    flex-direction: column;
    padding: 14px;
    background: #fff;
    border: 2px solid var(--ink);
    border-radius: 18px;
    box-shadow: 0 5px 0 var(--ink);
    display: none;
  }
  .ip-panel.open { display: flex; animation: pop .18s cubic-bezier(.3, 1.5, .5, 1); }
  .ip-swatches { flex-wrap: wrap; justify-content: center; gap: 9px; }
  .ip-swatch { width: 30px; height: 30px; }
  .ip-size { width: 100%; }
  .ip-size input { flex: 1; width: auto; }
}

@media (max-width: 560px) {
  .ip-title { display: none; }
  .ip-meter { font-size: .98rem; }
  .ip-bar { bottom: 12px; gap: 5px; padding: 6px; border-radius: 18px; }
  .ip-group { gap: 2px; }
  .ip-group + .ip-group { padding-left: 5px; }
  .ip-btn { width: 38px; height: 38px; border-radius: 12px; }
  .ip-zp { width: 38px; padding: 0; }
  .ip-zp span { display: none; }
  .ip-zp[data-mode=in]::after,
  .ip-zp[data-mode=out]::after {
    content: attr(data-mode);
    position: absolute;
    right: -6px;
    bottom: -7px;
    font: 700 .62rem/1 var(--font-display);
    text-transform: uppercase;
    background: var(--ink);
    color: #fff;
    padding: 2px 4px;
    border-radius: 6px;
  }
  .ip-zoom { right: 10px; top: 46%; gap: 8px; }
  .ip-round { width: 42px; height: 42px; }
  .ip-actions { top: 10px; right: 10px; gap: 6px; }
  .ip-actions .btn-small { font-size: .82rem; padding: 7px 11px 8px; }
}
