@font-face{
  font-family:"Spline Sans Mono";
  src:url("../fonts/SplineSansMono.ttf") format("truetype-variations"),
      url("../fonts/SplineSansMono.ttf") format("truetype");
  font-weight:300 700;
  font-display:swap;
}

:root{
  --glass-bg: rgba(28,28,32,0.55);
  --glass-border: rgba(255,255,255,0.14);
  --text: #f3f1ee;
  --accent: #f3f1ee;
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}

html,body{
  margin:0;padding:0;width:100%;height:100%;overflow:hidden;
  background:#0c0c0e;
  font-family:"Spline Sans Mono", Menlo, monospace;
  color:var(--text);
  touch-action:none;
  position:fixed;
  -webkit-user-select:none;user-select:none;
}

#stage{
  position:fixed;inset:0;
  width:100%;height:100%;
  display:block;
  touch-action:none;
  background:#f6f1ea;
}

/* ---- glass chrome ---- */
.ui-top{
  position:fixed;
  top:env(safe-area-inset-top, 14px);
  left:0;right:0;
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  z-index:30;
}
.ui-top .spacer{flex:1}

.glass-btn{
  width:40px;height:40px;
  border-radius:50%;
  border:1px solid var(--glass-border);
  background:var(--glass-bg);
  text-decoration:none;
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  color:var(--text);
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 4px 14px rgba(0,0,0,0.25);
  transition:transform .15s ease, background .2s ease;
  padding:0;
}
.glass-btn svg{width:19px;height:19px}
.glass-btn:active{transform:scale(0.88);background:rgba(28,28,32,0.8);}

.rec-btn .rec-dot{
  width:14px;height:14px;border-radius:50%;
  background:#f3f1ee;
  box-shadow:0 0 0 0 rgba(243,241,238,0.6);
}
.rec-btn.recording .rec-dot{
  border-radius:4px;
  animation:pulse 1.1s infinite;
}
@keyframes pulse{
  0%{box-shadow:0 0 0 0 rgba(243,241,238,0.55)}
  70%{box-shadow:0 0 0 9px rgba(243,241,238,0)}
  100%{box-shadow:0 0 0 0 rgba(243,241,238,0)}
}

/* ---- settings panel ---- */
.panel{
  position:fixed;
  top:calc(env(safe-area-inset-top, 14px) + 58px);
  right:12px;
  width:min(78vw, 300px);
  background:var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border:1px solid var(--glass-border);
  border-radius:18px;
  padding:14px 16px;
  z-index:31;
  box-shadow:0 10px 30px rgba(0,0,0,0.35);
}
.panel-row{
  display:flex;align-items:center;gap:10px;
  padding:8px 0;
}
.panel-label{font-size:13px;opacity:.85;width:84px;flex:none;}
.panel input[type=range]{flex:1;accent-color:var(--accent);}
.panel-value{font-size:12px;width:34px;text-align:right;opacity:.75;font-variant-numeric:tabular-nums;}

.brush-toggle{display:flex;gap:6px;flex:1;}
.brush-opt{
  flex:1;
  padding:7px 0;
  font-size:12px;
  color:var(--text);
  background:rgba(255,255,255,0.06);
  border:1px solid var(--glass-border);
  border-radius:10px;
}
.brush-opt.active{background:var(--accent);border-color:var(--accent);color:#111;}

.dir-toggle{display:flex;gap:6px;flex:1;}
.dir-opt{
  flex:1;
  padding:6px 0;
  font-size:15px;
  font-family:inherit;
  line-height:1;
  color:var(--text);
  background:rgba(255,255,255,0.06);
  border:1px solid var(--glass-border);
  border-radius:10px;
}
.dir-opt.active{background:var(--accent);border-color:var(--accent);color:#111;}

.panel-divider{
  height:1px;
  background:var(--glass-border);
  margin:6px 0 8px;
}
.panel-actions{
  display:flex;
  gap:8px;
}
.panel-action{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:5px;
  padding:10px 6px;
  font-family:inherit;
  font-size:11px;
  color:var(--text);
  background:rgba(255,255,255,0.06);
  border:1px solid var(--glass-border);
  border-radius:12px;
}
.panel-action svg{width:18px;height:18px}
.panel-action:active{background:rgba(255,255,255,0.12);}

/* ---- bottom bar (solo velocità + play) ---- */
.ui-bottom{
  position:fixed;
  left:0;right:0;
  bottom:calc(env(safe-area-inset-bottom, 10px) + 14px);
  z-index:30;
  display:flex;
  justify-content:center;
  padding:0 10px;
}

/* ---- isola colori: striscia verticale a sinistra, centrata ---- */
.palette{
  position:fixed;
  left:calc(env(safe-area-inset-left, 0px) + 10px);
  top:50%;
  transform:translateY(-50%);
  display:flex;
  flex-direction:column;
  gap:9px;
  padding:12px 8px;
  border-radius:22px;
  background:var(--glass-bg);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border:1px solid var(--glass-border);
  overflow-y:auto;
  max-height:70vh;
  z-index:29;
  box-shadow:0 6px 20px rgba(0,0,0,0.3);
}
.swatch{
  width:26px;height:26px;border-radius:50%;
  flex:none;
  border:2px solid rgba(255,255,255,0.25);
  transition:transform .15s ease;
}
.swatch.active{
  transform:scale(1.22);
  border-color:#fff;
  box-shadow:0 0 0 2px rgba(0,0,0,0.25);
}

.transport{
  display:flex;align-items:center;gap:14px;
  width:100%;
  max-width:360px;
}
.speed-wrap{
  flex:1;
  background:var(--glass-bg);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border:1px solid var(--glass-border);
  border-radius:20px;
  padding:8px 14px;
}
.speed-wrap input{width:100%;accent-color:var(--accent);}

.play-btn{
  width:58px;height:58px;border-radius:50%;
  background:var(--accent);
  color:#111;
  border:none;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 8px 22px rgba(0,0,0,0.35);
  flex:none;
  transition:transform .15s ease;
}
.play-btn svg{width:24px;height:24px;margin-left:1px}
.play-btn:active{transform:scale(0.92)}
.play-btn.playing{background:#2b2b2f;color:#f3f1ee;box-shadow:0 8px 22px rgba(0,0,0,0.4);}

.rec-timer{
  position:fixed;
  top:calc(env(safe-area-inset-top, 14px) + 60px);
  left:50%;transform:translateX(-50%);
  background:rgba(20,20,22,0.9);
  color:#f3f1ee;font-size:12px;font-weight:600;letter-spacing:.3px;
  padding:5px 12px;border-radius:12px;
  z-index:31;
}

.toast{
  position:fixed;
  bottom:120px;left:50%;transform:translateX(-50%);
  background:rgba(28,28,32,0.85);
  color:#fff;font-size:13px;
  padding:10px 16px;border-radius:14px;
  z-index:40;
  max-width:80vw;text-align:center;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
