/* Ink Sandbox — floating glass chrome over a full-bleed ink canvas. */

:root {
  --ground: #0d0a08;
  --ink: #ffffff;

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI Variable Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);

  --r-bar: 16px;
  --r-group: 10px;
  --gap: 16px;
  --bar-h: 64px;
}

body {
  --glass: rgba(38, 38, 42, 0.62);
  --glass-strong: rgba(36, 36, 40, 0.86);
  --glass-edge: rgba(255, 255, 255, 0.1);
  --glass-shine: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 36px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  --text: #f5f5f7;
  --text-2: rgba(235, 235, 245, 0.62);
  --text-3: rgba(235, 235, 245, 0.32);
  --fill: rgba(120, 120, 128, 0.32);
  --fill-2: rgba(118, 118, 128, 0.2);
  --fill-3: rgba(118, 118, 128, 0.12);
  --sep: rgba(255, 255, 255, 0.12);
  --accent: #0a84ff;
  --accent-ink: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.2);
  --on-accent: #fff;
  --danger: #ff453a;
  --knob: #fff;
}

body.on-light {
  --glass: rgba(255, 255, 255, 0.68);
  --glass-strong: rgba(250, 250, 252, 0.9);
  --glass-edge: rgba(0, 0, 0, 0.08);
  --glass-shine: rgba(255, 255, 255, 0.7);
  --shadow: 0 10px 36px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --text-2: rgba(60, 60, 67, 0.64);
  --text-3: rgba(60, 60, 67, 0.32);
  --fill: rgba(120, 120, 128, 0.2);
  --fill-2: rgba(120, 120, 128, 0.12);
  --fill-3: rgba(120, 120, 128, 0.08);
  --sep: rgba(60, 60, 67, 0.16);
  --accent: #007aff;
  --accent-ink: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.14);
  --danger: #ff3b30;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.38;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.4s var(--ease);
}

::selection {
  background: var(--accent-soft);
}

button,
input,
output {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: default;
}

a {
  color: inherit;
  text-decoration: none;
}

a[href]:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ico {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico-sm {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid var(--glass-edge);
  box-shadow: var(--shadow), inset 0 0.5px 0 var(--glass-shine);
}

.sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--sep);
  flex: none;
}

/* ---------- canvas ---------- */

#press {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: none;
}

#press.is-touch {
  cursor: default;
}

/* ---------- intro ---------- */

.hero {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gap) + var(--bar-h) + 92px);
  z-index: 1;
  width: max-content;
  max-width: calc(100vw - 40px);
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.5s var(--ease), transform 0.8s var(--ease);
}

.hero p {
  margin: 0;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(44px, 6.4vw, 88px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.04;
  color: var(--text);
}

.hero-sub {
  margin-top: 10px !important;
  font-family: var(--font-display);
  font-size: clamp(17px, 1.7vw, 24px);
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text-2);
}

body:not(.is-intro) .hero {
  opacity: 0;
  transform: translate(-50%, 16px);
}

.invite {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gap) + var(--bar-h) + 28px);
  z-index: 1;
  margin: 0;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.4s var(--ease);
}

.invite.is-hidden {
  opacity: 0;
}

body.is-empty .invite {
  bottom: 50%;
  font-size: 15px;
  color: var(--text-2);
}

/* ---------- top bar ---------- */

.topbar {
  position: fixed;
  z-index: 3;
  top: var(--gap);
  left: var(--gap);
  right: var(--gap);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.titlebar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding: 12px 16px;
  border-radius: 12px;
  align-items: center;
  transition: opacity 0.4s var(--ease), transform 0.5s var(--ease);
}

body.is-intro .titlebar {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.app-name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.counter {
  margin: 0;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.frozen-tag {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.topbar-end {
  display: flex;
  gap: 10px;
}

.actions {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 4px;
  border-radius: 12px;
}

.icon-btn {
  appearance: none;
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  transition: background-color 0.15s;
}

.icon-btn:hover:not(:disabled) {
  background: var(--fill-3);
}

.icon-btn:active:not(:disabled) {
  background: var(--fill-2);
}

.icon-btn:disabled {
  color: var(--text-3);
}

.icon-btn[aria-pressed='true'] {
  color: var(--accent);
  background: var(--accent-soft);
}

.badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--fill);
  font-size: 10px;
  font-weight: 600;
  line-height: 15px;
  font-variant-numeric: tabular-nums;
}

.badge:empty {
  display: none;
}

.segmented {
  appearance: none;
  display: flex;
  padding: 2px;
  margin-right: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--fill-2);
}

.lang-opt {
  min-width: 30px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  transition: background-color 0.2s, color 0.2s;
}

.lang-opt.is-on {
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

.btn-export {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 12px;
  background: #0071e3;
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: filter 0.15s, transform 0.2s var(--ease);
}

.btn-export .ico {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.btn-export:hover {
  filter: brightness(1.08);
}

.btn-export:active {
  transform: scale(0.97);
}

.export-wrap {
  position: relative;
}

.btn-export[aria-expanded="true"] {
  filter: brightness(1.08);
}

.export-menu {
  position: absolute;
  z-index: 6;
  top: calc(100% + 8px);
  right: 0;
  min-width: 248px;
  padding: 6px;
  pointer-events: auto;
  border-radius: 14px;
  transform-origin: top right;
  animation: menu-in 0.22s var(--ease);
}

.export-menu[hidden] {
  display: none;
}

@keyframes menu-in {
  from { opacity: 0; transform: scale(0.94) translateY(-4px); }
}

.export-item {
  appearance: none;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "fmt key" "sub key";
  align-items: center;
  column-gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.export-item + .export-item {
  margin-top: 2px;
}

.export-item:hover,
.export-item:focus-visible {
  background: #0071e3;
  color: var(--on-accent);
  outline: none;
}

.export-fmt {
  grid-area: fmt;
  font-size: 15px;
  font-weight: 600;
}

.export-sub {
  grid-area: sub;
  font-size: 12px;
  color: var(--text-2);
}

.export-item kbd {
  grid-area: key;
  font: inherit;
  font-size: 12px;
  color: var(--text-3);
}

.export-item:hover :is(.export-sub, kbd),
.export-item:focus-visible :is(.export-sub, kbd) {
  color: inherit;
  opacity: 0.8;
}

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

.toolbar {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: var(--gap);
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--bar-h);
  padding: 0 8px;
  border-radius: var(--r-bar);
  transform: translateX(-50%);
}

.tools {
  display: flex;
  gap: 2px;
}

.tool {
  appearance: none;
  width: 60px;
  height: 52px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  transition: background-color 0.15s, color 0.15s;
}

.tool:hover {
  background: var(--fill-3);
}

.tool:active {
  background: var(--fill-2);
}

.tool-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}

.tool[aria-checked='true'],
.tool[aria-pressed='true'],
.tool[aria-expanded='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.tool[aria-checked='true'] .tool-label,
.tool[aria-pressed='true'] .tool-label,
.tool[aria-expanded='true'] .tool-label {
  color: var(--accent);
}

/* ---------- inspector ---------- */

.panel {
  position: fixed;
  z-index: 4;
  top: calc(var(--gap) + 44px + 10px);
  right: var(--gap);
  width: 300px;
  max-height: calc(100dvh - var(--gap) * 3 - 44px - var(--bar-h) - 10px);
  display: flex;
  flex-direction: column;
  border-radius: var(--r-bar);
  background: var(--glass-strong);
  opacity: 0;
  transform: translateX(12px) scale(0.98);
  transform-origin: top right;
  visibility: hidden;
  transition: opacity 0.2s var(--ease), transform 0.35s var(--ease), visibility 0s 0.35s;
}

body.panel-open .panel {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition: opacity 0.2s var(--ease), transform 0.4s var(--spring), visibility 0s;
}

.grabber {
  display: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 6px 18px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.close-btn {
  appearance: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--fill-2);
  color: var(--text-2);
}

.close-btn .ico {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

.close-btn:hover {
  background: var(--fill);
}

.panel-body {
  padding: 4px 14px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--fill) transparent;
}

.group-wrap {
  margin-top: 14px;
}

.group-wrap:first-child {
  margin-top: 6px;
}

.group-title {
  display: flex;
  justify-content: space-between;
  margin: 0 4px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
}

.hex {
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.group {
  padding: 4px 12px;
  border-radius: var(--r-group);
  background: var(--fill-3);
}

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: 8px 0 4px;
}

.field + .field {
  border-top: 0.5px solid var(--sep);
}

.field label {
  font-weight: 500;
}

.field output {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.field input {
  grid-column: 1 / -1;
}

/* iOS-style slider: thin track filled in the accent up to the knob (--p, set from JS). */
input[type='range'] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--fill) var(--p, 50%));
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.14), 0 6px 13px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s var(--ease);
}

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

input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--fill);
}

input[type='range']::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

input[type='range']::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.14), 0 6px 13px rgba(0, 0, 0, 0.14);
}

input[type='range']:focus-visible {
  outline: none;
}

input[type='range']:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent), 0 6px 13px rgba(0, 0, 0, 0.14);
}

.btn {
  appearance: none;
  width: 100%;
  height: 36px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 8px;
  background: var(--fill-2);
  color: var(--accent);
  font-weight: 500;
  transition: background-color 0.15s;
}

.btn .ico {
  width: 17px;
  height: 17px;
}

.btn:hover {
  background: var(--fill);
}

.group-wrap:last-child .btn {
  margin-top: 0;
}

/* ---------- colour ---------- */

.group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px;
}

.swatches {
  display: flex;
  gap: 8px;
}

.swatch {
  appearance: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--c) 0 52%, var(--g) 55%);
  box-shadow: inset 0 0 0 0.5px rgba(128, 128, 128, 0.5);
  transition: transform 0.2s var(--spring);
}

.swatch-chrome {
  background:
    radial-gradient(circle, transparent 0 52%, var(--g) 55%),
    linear-gradient(#607aa0, #d6c6ba 32%, #fff6e4 50%, #26160e 53%, #a86636 72%, #f8d29c);
}

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

.swatch[aria-checked='true'] {
  box-shadow: inset 0 0 0 0.5px rgba(128, 128, 128, 0.5), 0 0 0 2px var(--glass-strong), 0 0 0 4px var(--accent);
}

.picker {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: conic-gradient(from 90deg, #ff3b30, #ff9500, #ffcc00, #34c759, #00c7be, #007aff, #5856d6, #af52de, #ff2d55, #ff3b30);
  box-shadow: inset 0 0 0 4px var(--glass-strong);
  overflow: hidden;
}

.picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.picker:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}

.keys {
  margin: 14px 4px 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
}

.panel-credit {
  display: none;
  margin: 10px 4px 0;
  font-size: 12px;
  color: var(--text-2);
}

/* ---------- footer, toast ---------- */

.colophon {
  position: fixed;
  z-index: 2;
  left: var(--gap);
  bottom: calc(var(--gap) + (var(--bar-h) - 16px) / 2);
  font-size: 12px;
  color: var(--text-3);
}

.colophon p {
  margin: 0;
}

.colophon a {
  color: var(--text-2);
}

.toast {
  position: fixed;
  z-index: 5;
  left: 50%;
  top: calc(var(--gap) + 4px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translate(-50%, -12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.45s var(--spring);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  position: fixed;
  inset: auto 24px 50% 24px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}

/* ---------- smaller screens ---------- */

@media (max-width: 900px) {
  .titlebar {
    display: none;
  }

  .topbar {
    justify-content: flex-end;
  }
}

@media (max-width: 720px) {
  :root {
    --gap: 12px;
    --bar-h: 56px;
  }

  body {
    font-size: 15px;
  }

  .topbar-end {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .actions,
  .btn-export {
    height: 44px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .btn-export {
    padding: 0 14px 0 12px;
  }

  .export-item kbd {
    display: none;
  }


  .tool {
    width: 48px;
    height: 46px;
  }

  .tool-label {
    display: none;
  }

  .hero {
    bottom: calc(var(--gap) + var(--bar-h) + 76px);
  }

  .invite {
    bottom: calc(var(--gap) + var(--bar-h) + 22px);
  }

  .colophon {
    display: none;
  }

  .panel-credit {
    display: block;
  }

  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 52dvh;
    border-radius: 14px 14px 0 0;
    border-width: 0.5px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    opacity: 1;
    transform: translateY(calc(100% + 20px));
    transition: transform 0.4s var(--ease), visibility 0s 0.4s;
  }

  body.panel-open .panel {
    transform: none;
    transition: transform 0.5s var(--ease), visibility 0s;
  }

  .grabber {
    display: block;
    width: 36px;
    height: 5px;
    margin: 6px auto 0;
    border-radius: 3px;
    background: var(--fill);
  }

  .panel-head {
    padding-top: 8px;
  }

  .panel-head h2 {
    font-size: 17px;
  }

  .group-title {
    font-size: 13px;
  }

  .field {
    padding: 10px 0 6px;
  }

  .btn {
    height: 44px;
  }

  .swatch,
  .picker {
    width: 32px;
    height: 32px;
  }

  .keys {
    display: none;
  }
}

@media (max-width: 380px) {
  .btn-export span {
    display: none;
  }

  .tool {
    width: 44px;
  }

  .icon-btn {
    width: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
