/* ASCII Studio: design tokens, light + dark.
   Type follows the platform's system font (SF Pro on Apple devices) with size-specific
   tracking; panels are translucent materials; feedback is on press, never on release. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* brand: the logo's sunset, indigo -> magenta -> coral -> amber */
  --brand-1: #6d3ff2;
  --brand-2: #d63ca8;
  --brand-3: #ff6a55;
  --brand-4: #ffb347;
  --brand-grad: linear-gradient(135deg, var(--brand-2), var(--brand-3) 55%, var(--brand-4));

  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);   /* critically damped feel */
  --gutter: max(16px, env(safe-area-inset-left));

  color-scheme: light dark;
}

/* ---------- colours ---------- */
:root {
  --bg: #f4f3f8;
  --bg-glow-1: rgba(214, 60, 168, 0.10);
  --bg-glow-2: rgba(109, 63, 242, 0.10);
  --text: #16151c;
  --text-2: rgba(22, 21, 28, 0.62);
  --text-3: rgba(22, 21, 28, 0.42);
  --material: rgba(255, 255, 255, 0.66);
  --material-solid: #ffffff;
  --card: rgba(255, 255, 255, 0.72);
  --hairline: rgba(22, 21, 28, 0.08);
  --edge-light: rgba(255, 255, 255, 0.9);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --thumb: #ffffff;
  --accent: #e0457b;
  --rec: #ff3b30;
  --shadow: 0 1px 2px rgba(20, 16, 40, 0.06), 0 8px 30px rgba(20, 16, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0a12;
    --bg-glow-1: rgba(214, 60, 168, 0.16);
    --bg-glow-2: rgba(109, 63, 242, 0.20);
    --text: #f4f3f8;
    --text-2: rgba(244, 243, 248, 0.64);
    --text-3: rgba(244, 243, 248, 0.40);
    --material: rgba(30, 28, 42, 0.58);
    --material-solid: #1c1a26;
    --card: rgba(255, 255, 255, 0.05);
    --hairline: rgba(255, 255, 255, 0.08);
    --edge-light: rgba(255, 255, 255, 0.12);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --thumb: #f4f3f8;
    --accent: #ff6a8a;
    --rec: #ff453a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(60vmax 50vmax at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(60vmax 50vmax at -10% 110%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 15px/1.47 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

[hidden] { display: none !important; }

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px 10px;
}
.logo {
  width: 44px; height: 44px;
  border-radius: 11px;
  box-shadow: 0 6px 18px rgba(109, 63, 242, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2);
}
.brand { min-width: 0; flex: 1; }
h1 {
  margin: 0;
  font: 700 26px/1.1 var(--font-display);
  letter-spacing: -0.025em;
}
.brand p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; letter-spacing: -0.005em; }
.privacy {
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  padding: 5px 10px; border-radius: 999px;
  color: var(--text-2); background: var(--fill);
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  padding: 8px 24px 24px;
  height: calc(100dvh - 84px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height: 560px;
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #000;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.stage canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 300ms var(--ease);
}
.stage.empty canvas { opacity: 0; }
.stage.dragging { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); }

.drop {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px;
  text-align: center; cursor: pointer;
  color: #f4f3f8;
  background:
    radial-gradient(50% 60% at 50% 45%, rgba(109, 63, 242, 0.25), transparent 70%),
    #07060c;
  -webkit-tap-highlight-color: transparent;
}
.stage.empty .drop { display: flex; }
.drop-icon img {
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(214, 60, 168, 0.35);
  margin-bottom: 10px;
  transition: transform 160ms var(--ease);
}
.drop:active .drop-icon img { transform: scale(0.96); }
.drop strong { font: 600 20px/1.2 var(--font-display); letter-spacing: -0.02em; }
.drop span { color: rgba(244, 243, 248, 0.6); font-size: 14px; }
.drop .btn { margin-top: 10px; }
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch-only { display: block; }
  .desktop-only { display: none; }
}

.rec-pill {
  position: absolute; top: 14px; left: 14px;
  font: 600 13px/1 var(--mono);
  color: #fff;
  background: rgba(255, 59, 48, 0.85);
  padding: 7px 11px;
  border-radius: 999px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}

/* ---------- control panel: a translucent material ---------- */
.panel {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 14px 14px;
  border-radius: var(--radius-lg);
  background: var(--material);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow), inset 0 1px 0 var(--edge-light);
  scrollbar-width: thin;
}

.group { margin-top: 12px; }
h2 {
  margin: 0 0 6px 6px;
  font: 600 12px/1.3 var(--font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.card {
  display: grid; gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.row { display: flex; gap: 8px; }
.row.buttons > .btn { flex: 1 1 auto; white-space: nowrap; padding-inline: 12px; }

/* ---------- liquid glass controls ----------
   No colour gradients: clear glass that blurs, saturates and (in Chromium) bends whatever
   is behind it, a bright specular edge where light catches the top, a soft sheen, and a
   shadow that lifts it off the surface. Tinted glass marks the main action. */
:root {
  --glass: rgba(255, 255, 255, 0.5);
  --glass-hover: rgba(255, 255, 255, 0.68);
  --glass-edge: rgba(255, 255, 255, 0.95);
  --glass-rim: rgba(0, 0, 0, 0.06);
  --glass-sheen: rgba(255, 255, 255, 0.55);
  --glass-shadow: 0 6px 18px rgba(30, 20, 60, 0.12), 0 1px 2px rgba(30, 20, 60, 0.1);
  --well: rgba(118, 118, 128, 0.14);
  --tint: 88%;          /* light mode needs a deeper tint so white text stays readable */
  --well-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 0 0 0.5px rgba(0, 0, 0, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --glass: rgba(255, 255, 255, 0.09);
    --glass-hover: rgba(255, 255, 255, 0.15);
    --glass-edge: rgba(255, 255, 255, 0.42);
    --glass-rim: rgba(255, 255, 255, 0.1);
    --glass-sheen: rgba(255, 255, 255, 0.16);
    --glass-shadow: 0 8px 22px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
    --well: rgba(0, 0, 0, 0.28);
    --tint: 62%;
    --well-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45), inset 0 -0.5px 0 rgba(255, 255, 255, 0.08);
  }
}

.btn, .seg-thumb {
  position: relative;
  isolation: isolate;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(190%) brightness(1.06);
  backdrop-filter: blur(12px) saturate(190%) brightness(1.06);
  box-shadow:
    inset 0 1px 0.5px var(--glass-edge),          /* light catching the top edge */
    inset 0 -1px 0.5px var(--glass-rim),          /* the lower rim */
    inset 0 0 0 0.5px var(--glass-rim),
    var(--glass-shadow);
}
.liquid .btn, .liquid .seg-thumb {
  -webkit-backdrop-filter: url(#liquid) blur(10px) saturate(190%) brightness(1.06);
  backdrop-filter: url(#liquid) blur(10px) saturate(190%) brightness(1.06);
}
.btn::before, .seg-thumb::before {                /* soft sheen, like a curved surface */
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(130% 100% at 30% 0%, var(--glass-sheen), transparent 60%);
}

.btn {
  appearance: none;
  font: 590 14px/1.2 var(--font);
  letter-spacing: -0.01em;
  color: var(--text);
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  min-height: 40px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 140ms cubic-bezier(0.3, 1.4, 0.5, 1), background-color 150ms ease-out;
}
.btn:hover { background: var(--glass-hover); }
.btn:active { transform: scale(0.96); }         /* a little squish, instantly */
.btn:focus-visible, .seg button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn.wide { width: 100%; }
/* tinted glass for the main action, still see-through */
.btn.primary { color: #fff; font-weight: 650; background: color-mix(in srgb, var(--accent) var(--tint), transparent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) calc(var(--tint) + 10%), transparent); }
.btn.active { color: #fff; background: color-mix(in srgb, var(--accent) 62%, transparent); }
.rec-btn { color: var(--rec); font-weight: 650; }
.rec-btn.recording { color: #fff; background: color-mix(in srgb, var(--rec) 70%, transparent); }

/* ---------- segmented control: a glass pill sliding in a recessed well ---------- */
.seg {
  --n: 3; --i: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  padding: 3px;
  border-radius: 999px;
  background: var(--well);
  box-shadow: var(--well-shadow);
}
.seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--n));
  border-radius: 999px;
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 380ms cubic-bezier(0.3, 1.25, 0.5, 1);   /* settles with a hint of give */
}
.seg button {
  position: relative;
  appearance: none; border: 0; background: none;
  font: 590 13px/1.2 var(--font);
  letter-spacing: -0.005em;
  color: var(--text-2);
  padding: 8px 4px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 200ms, transform 120ms ease-out;
}
.seg button.on { color: var(--text); }
.seg button:active { transform: scale(0.95); }

/* ---------- sliders: a recessed track and a glass capsule ---------- */
.slider { display: block; font-size: 14px; color: var(--text-2); }
.slider output {
  float: right;
  font: 500 13px/1.6 var(--mono);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; margin: 2px 0 0;
  background: transparent;
  touch-action: pan-y;
  --p: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) 0 var(--p), var(--well) var(--p) 100%);
  box-shadow: var(--well-shadow);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--well); box-shadow: var(--well-shadow); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 38px; height: 24px; margin-top: -9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 1),
    inset 0 -1px 1px rgba(0, 0, 0, 0.08),
    inset 0 0 0 0.5px rgba(0, 0, 0, 0.06),
    0 3px 10px rgba(0, 0, 0, 0.22), 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 160ms cubic-bezier(0.3, 1.4, 0.5, 1), background-color 160ms;
}
/* while dragging, the capsule swells and turns to clear glass */
input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.18);
  background: rgba(255, 255, 255, 0.32);
}
input[type="range"]::-moz-range-thumb {
  width: 38px; height: 24px; border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 1px 0.5px #fff, 0 3px 10px rgba(0, 0, 0, 0.22);
}
input[type="range"]:active::-moz-range-thumb { background: rgba(255, 255, 255, 0.32); }

/* ---------- switches: a glass capsule on a track ---------- */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; color: var(--text);
  padding: 2px 0;
}
.switch {
  -webkit-appearance: none; appearance: none;
  position: relative;
  width: 62px; height: 28px; margin: 0;
  border-radius: 999px;
  background: var(--well);
  box-shadow: var(--well-shadow);
  cursor: pointer;
  transition: background-color 220ms ease-out;
}
.switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 36px; height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 0.5px #fff, inset 0 -1px 1px rgba(0, 0, 0, 0.08), 0 3px 8px rgba(0, 0, 0, 0.22);
  transition: transform 300ms cubic-bezier(0.3, 1.3, 0.5, 1), background-color 160ms, width 160ms;
}
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(22px); }
.switch:active::after { background: rgba(255, 255, 255, 0.4); }

/* ---------- fields ---------- */
.field { display: grid; gap: 6px; font-size: 14px; color: var(--text-2); }
select, input[type="number"] {
  width: 100%;
  font: 400 15px/1.3 var(--font);
  color: var(--text);
  background: var(--fill);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 40px;
}
.note { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--text-3); letter-spacing: 0; }
.note.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- status toast ---------- */
.status {
  position: fixed;
  left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: min(92vw, 520px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 14px; font-weight: 500; text-align: center;
  color: var(--text);
  background: var(--material);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow), inset 0 1px 0 var(--edge-light);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease), transform 320ms var(--ease);
  z-index: 10;
}
.status.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- phones and narrow windows ---------- */
@media (max-width: 820px) {
  .topbar {
    position: sticky; top: 0; z-index: 5;
    padding: 10px var(--gutter);
    background: var(--material);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
  }
  .logo { width: 34px; height: 34px; border-radius: 8px; }
  h1 { font-size: 20px; letter-spacing: -0.02em; }
  .brand p { display: none; }
  .layout {
    display: block;
    height: auto; min-height: 0;
    padding: 8px var(--gutter) calc(80px + env(safe-area-inset-bottom));
  }
  .stage {
    position: sticky; top: 64px; z-index: 4;
    height: min(46vh, 120vw);
    border-radius: 18px;
  }
  .panel {
    margin-top: 14px;
    overflow: visible;
    padding: 0;
    background: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
    box-shadow: none;
  }
  .card { background: var(--material-solid); box-shadow: var(--shadow); }
  .btn, select, input[type="number"] { min-height: 44px; }   /* comfortable touch targets */
}

/* ---------- accessibility preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; }
  .btn:active, .seg button:active { transform: none; }
  input[type="range"]:active::-webkit-slider-thumb { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .panel, .topbar, .status, .rec-pill, .btn, .seg-thumb, .liquid .btn, .liquid .seg-thumb {
    background: var(--material-solid); -webkit-backdrop-filter: none; backdrop-filter: none;
  }
}
@media (prefers-contrast: more) {
  .card, .btn, .seg, select, input[type="number"] { box-shadow: inset 0 0 0 1px var(--text-3); }
  .note, h2 { color: var(--text-2); }
}
