/* Copyright (C) 2026 Pierre Arnaud GUYOT (OktoPierre)
   SPDX-License-Identifier: GPL-3.0-or-later */
/* Wavelet Synthesizer — created by Pierre Arnaud GUYOT (OktoPierre). Release beta 0.1.
   Web UI. The device is a fixed 1100×720 panel scaled to fit. */
:root {
  --page: #0b0d10;
  --panel: #171a20;
  --panel-2: #1b1f26;
  --card: #1f242c;
  --card-edge: #2b313b;
  --inset: #101317;
  --text: #d5dce6;
  --dim: #8792a1;
  --faint: #566070;
  --accent-a: #b38cff;   /* FM Wavelet Synthesizer: one accent colour (violet) */
  --accent-b: #ffae42;
  --accent: #b38cff;
  --accent-soft: rgba(47, 212, 198, 0.16);
  --danger: #ff5d5d;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--text); font-family: var(--font); overflow: hidden; }
body { display: flex; flex-direction: column; }
button { font-family: inherit; }

#stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
#device {
  position: absolute; left: 0; top: 0; width: 1100px; height: 790px; transform-origin: 0 0;
  background: linear-gradient(180deg, #1c2027 0%, var(--panel) 9%, #14171c 100%);
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#device.mode-b { --accent: var(--accent-b); --accent-soft: rgba(255, 174, 66, 0.16); }

.section { position: absolute; }
.section.card { background: linear-gradient(180deg, var(--card) 0%, #1a1e25 100%); border: 1px solid var(--card-edge); border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); }
.section .title { position: absolute; left: 12px; top: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; color: var(--dim); white-space: nowrap; }
.section .title b { color: var(--accent); font-weight: 700; }
.section.hidden { display: none; }
.w { position: absolute; }

/* knobs */
.knob { cursor: ns-resize; }
.knob svg { position: absolute; left: 0; top: 0; overflow: visible; }
.knob .label { position: absolute; left: -6px; right: -6px; text-align: center; font-size: 9.5px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--dim); white-space: nowrap; overflow: hidden; }
.knob.active .label, .knob:hover .label { color: var(--text); }
.knob .label.value { color: var(--accent); }
.knob.disabled { opacity: 0.35; }
.knobS .label { display: none; }

/* segmented & stepper */
.seg { display: flex; background: var(--inset); border: 1px solid #262c35; border-radius: 7px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--dim); font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  border-radius: 5px; cursor: pointer; padding: 0; }
.seg button:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.seg button.on { color: #0d1014; background: var(--accent); box-shadow: 0 0 12px var(--accent-soft); }
.seg.engine { padding: 3px; border-radius: 9px; }
.seg.engine button { font-size: 11px; letter-spacing: 0.1em; }
.seg.engine button:nth-child(1).on { background: var(--accent-a); }
.seg.engine button:nth-child(2).on { background: var(--accent-b); }

.step { display: flex; align-items: stretch; background: var(--inset); border: 1px solid #262c35; border-radius: 7px; overflow: hidden; }
.step button { width: 30px; border: 0; background: transparent; color: var(--dim); cursor: pointer; font-size: 12px; }
.step button:hover { color: var(--accent); background: rgba(255,255,255,0.04); }
.step .name { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--text); cursor: pointer; white-space: nowrap; }
.step .name small { color: var(--faint); font-weight: 600; font-size: 9.5px; letter-spacing: 0.12em; }

/* drawbars */
.drawbar { cursor: ns-resize; }
.drawbar .track { position: absolute; left: 7px; right: 7px; top: 0; bottom: 0; background: var(--inset); border-radius: 5px; border: 1px solid #262c35; overflow: hidden; }
.drawbar .fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, var(--accent), rgba(255,174,66,0.35)); opacity: 0.85; }
.drawbar .cap { position: absolute; left: 0; right: 0; height: 10px; border-radius: 3px; background: linear-gradient(180deg, #f1f4f8, #b9c1cc);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.drawbar .num { position: absolute; left: -4px; right: -4px; bottom: -16px; text-align: center; font-size: 9.5px; font-weight: 700; color: var(--dim); }
.drawbar:hover .num, .drawbar.active .num { color: var(--accent); }

/* canvases */
canvas.disp { position: absolute; left: 0; top: 0; border-radius: 6px; }
.screen { background: #0c0f13; border: 1px solid #252b34; border-radius: 7px; box-shadow: inset 0 0 18px rgba(0,0,0,0.6); }

/* header widgets */
.logo { display: flex; align-items: center; gap: 10px; }
.logo .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--inset); border: 1px solid #2a303a; display: flex; align-items: center; justify-content: center; }
.logo .txt { line-height: 1.05; }
.logo .txt b { display: block; font-size: 13.5px; letter-spacing: 0.22em; color: #eef2f7; }
.logo .txt span { font-size: 9px; letter-spacing: 0.32em; color: var(--accent); font-weight: 700; }
.presets { display: flex; background: var(--inset); border: 1px solid #262c35; border-radius: 8px; overflow: visible; position: relative; }
.presets button.arrow { width: 30px; border: 0; background: transparent; color: var(--dim); cursor: pointer; }
.presets button.arrow:hover { color: var(--accent); }
.presets .pname { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: #eef2f7; }
.presets .pname .dirty { color: var(--accent); font-size: 14px; line-height: 1; }
.presets .pname .chev { color: var(--faint); font-size: 10px; }
.pmenu { position: absolute; top: 34px; left: 0; right: 0; background: #1d2129; border: 1px solid #343b47; border-radius: 8px; padding: 6px 0;
  box-shadow: 0 14px 40px rgba(0,0,0,0.6); z-index: 50; max-height: 520px; overflow-y: auto; }
.pmenu .grp { font-size: 9.5px; letter-spacing: 0.16em; color: var(--faint); padding: 8px 14px 4px; font-weight: 700; }
.pmenu .grp.fold { cursor: pointer; display: flex; align-items: baseline; gap: 6px; user-select: none; color: #8b94a3; }
.pmenu .grp.fold:hover, .pmenu .grp.fold.open { color: #b9c0cc; }
.pmenu .grp .tw { width: 10px; display: inline-block; }
.pmenu .grp .cnt { margin-left: auto; font-weight: 400; letter-spacing: 0; }
.pmenu .it { padding: 6px 14px; font-size: 12.5px; cursor: pointer; display: flex; justify-content: space-between; }
.pmenu .it:hover { background: rgba(255,255,255,0.06); }
.pmenu .it.cur { color: var(--accent); }
.pmenu .eng { display: inline-block; width: 24px; font-weight: 800; }
.pmenu .eng .a { color: var(--accent-a); }
.pmenu .eng .b { color: var(--accent-b); }
.pmenu .it .del { color: var(--faint); visibility: hidden; }
.pmenu .it:hover .del { visibility: visible; }
.pmenu .it .del:hover { color: var(--danger); }
.hbtn { border: 1px solid #2c333e; background: var(--inset); color: var(--dim); border-radius: 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  cursor: pointer; line-height: 1.15; }
.hbtn:hover { color: var(--text); border-color: #3a4250; }
.hbtn b { display: block; font-size: 12px; color: var(--accent-a); }
.hbtn.b b { color: var(--accent-b); }
.zoom { display: none; }
/* demo */
.demo-btn { position: absolute; left: 222px; top: 12px; width: 50px; height: 24px; white-space: nowrap; padding: 0; color: var(--accent); border-color: var(--accent);
  font-size: 10px; letter-spacing: 0.1em; z-index: 5; }
.demo-btn:hover { color: #0d1014; background: var(--accent); }
.demo-btn.running { color: #0d1014; background: var(--accent); box-shadow: 0 0 14px var(--accent-soft); }
.demo-arrow { position: absolute; left: 274px; top: 12px; width: 14px; height: 24px; padding: 0; color: var(--accent); border-color: var(--accent);
  font-size: 9px; z-index: 5; }
.demo-arrow:hover { color: #0d1014; background: var(--accent); }
.demo-menu .tag { font-style: normal; font-size: 8.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); margin-left: 6px; }
.demo-menu { position: absolute; left: 222px; top: 40px; width: 360px; right: auto; z-index: 60; }
.demo-menu .it b { font-weight: 600; color: #eef2f7; }
.demo-menu .dur { color: var(--faint); font-variant-numeric: tabular-nums; margin-left: 12px; }
.demo-menu .sep { height: 1px; background: #343b47; margin: 6px 0; }
.demo-win { position: absolute; left: 700px; top: 330px; width: 386px; display: none; z-index: 40; background: rgba(13, 16, 20, 0.95);
  border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 24px var(--accent-soft); }
.dw-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 12px; cursor: move;
  border-bottom: 1px solid #262c35; }
.dw-title { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dw-stop { flex: none; border: 1px solid #343b47; background: #161a20; color: var(--text); border-radius: 5px; font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.08em; padding: 3px 8px; cursor: pointer; }
.dw-stop:hover { border-color: var(--accent); color: var(--accent); }
.dw-body { padding: 8px 12px 9px; }
.dw-sec { font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--dim); text-transform: uppercase; }
.dw-param { font-size: 14px; font-weight: 700; color: #eef2f7; margin-top: 4px; }
.dw-val { font-size: 12px; color: var(--accent); margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dw-text { font-size: 11.5px; line-height: 1.4; color: var(--text); margin-top: 6px; min-height: 48px; }
.dw-prog { height: 3px; background: #262c35; border-radius: 2px; margin-top: 8px; overflow: hidden; }
.dw-prog i { display: block; height: 100%; width: 0; background: var(--accent); }
.dw-foot { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--faint); margin-top: 5px; }
.knob.hot svg { filter: drop-shadow(0 0 6px var(--accent)); }
.knob.hot .label { color: var(--accent); }
.seg.hot, .step.hot { box-shadow: 0 0 0 1px var(--accent), 0 0 14px var(--accent-soft); }
.drawbar.hot .track { border-color: var(--accent); box-shadow: 0 0 10px var(--accent-soft); }
.credit { font-size: 9.5px; line-height: 12px; color: var(--faint); text-align: right; letter-spacing: 0.04em; white-space: nowrap; }

/* status bar */
#statusbar { height: 38px; flex: none; display: flex; align-items: center; gap: 18px; padding: 0 18px; font-size: 12px; color: var(--dim);
  border-top: 1px solid #1d2128; background: #0e1014; }
.st-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.st-item b { color: var(--text); }
.st-keys { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: block; }
#st-midi { flex: none; max-width: 460px; overflow: hidden; text-overflow: ellipsis; display: block; }
.st-sel { flex: none; border: 1px solid #2c333e; background: #161a20; color: var(--text); border-radius: 6px; padding: 4px 6px; font-size: 12px; cursor: pointer; }
.st-sel:hover { border-color: var(--accent-a); }
#st-audio { flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #444b57; display: inline-block; }
.st-item.on .dot { background: #3ddc84; box-shadow: 0 0 8px #3ddc84; }
.st-spacer { flex: 1; }
.st-btn { flex: none; white-space: nowrap; border: 1px solid #2c333e; background: #161a20; color: var(--text); border-radius: 6px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.st-btn:hover { border-color: var(--accent-a); }

/* overlays */
#start-overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(8, 10, 13, 0.55); backdrop-filter: blur(2px); z-index: 80; }
#start-overlay.gone { display: none; }
#start-btn { display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-radius: 40px; border: 1px solid var(--accent-a);
  background: #12161b; color: #eef2f7; font-size: 16px; font-weight: 600; cursor: pointer; box-shadow: 0 0 40px rgba(47,212,198,0.25); }
#start-btn svg { color: var(--accent-a); }
#start-overlay p { color: var(--dim); font-size: 13px; margin: 0; }
#manual-overlay { position: fixed; inset: 0; background: rgba(5, 6, 8, 0.72); z-index: 90; display: flex; align-items: center; justify-content: center; }
#manual-overlay[hidden] { display: none; }
.manual-frame { width: min(1100px, 94vw); height: 90vh; background: #fff; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7); }
.manual-bar { height: 44px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 10px 0 18px; background: #14171c; color: #eef2f7; font-size: 13px; font-weight: 600; }
.manual-bar a { color: var(--accent-a); font-weight: 500; text-decoration: none; }
.manual-bar button { border: 0; background: transparent; color: #c0c8d4; font-size: 18px; cursor: pointer; width: 34px; height: 34px; border-radius: 6px; }
.manual-bar button:hover { background: rgba(255,255,255,0.08); }
#manual-iframe { flex: 1; border: 0; width: 100%; background: #fff; }

.tip { position: fixed; pointer-events: none; z-index: 60; background: #0b0d10; color: var(--text); border: 1px solid #343b47; border-radius: 6px;
  padding: 4px 8px; font-size: 11.5px; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,0.5); }
.tip b { color: var(--accent); font-weight: 600; }

@media (max-width: 760px) {
  .st-keys { display: none; }
  #statusbar { gap: 10px; padding: 0 10px; }
}

/* ---------------------------------------------------------------- FM Wavelet Synthesizer */
#device { --accent-soft: rgba(179, 140, 255, 0.16); }
.section.carrier > .title b { color: var(--accent); }
.demo-win { left: 700px; top: 300px; }
