/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Fourier Draw. The shared look lives in /core/static/core.css. */

#view-draw.active { display: grid; grid-template-columns: 1fr 300px; gap: 14px; overflow: hidden; }

/* input */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  border: 2px dashed var(--line); border-radius: 12px; padding: 16px 10px; cursor: pointer;
  transition: .15s; color: var(--muted);
}
.drop:hover, .drop.over { border-color: var(--yellow); color: var(--text); background: rgba(255, 201, 60, .05); }
.drop input { display: none; }
.drop-icon { font-size: 26px; }
.drop b { color: var(--text); }
.drop small { color: var(--dim); font-size: 11px; }

.samples { margin-top: 12px; }
.sample-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.sample-tabs button {
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  font-size: 11px; color: var(--muted); cursor: pointer;
}
.sample-tabs button:hover { color: var(--text); border-color: var(--muted); }
.sample-tabs button.on { background: var(--yellow); border-color: var(--yellow); color: var(--bg); font-weight: 600; }
.samples h4 { margin: 10px 0 6px; font: 600 10px/1 var(--mono); letter-spacing: .15em; color: var(--muted); text-transform: uppercase; }
.sample-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sample {
  aspect-ratio: 1; border-radius: 9px; border: 1px solid var(--line); background: #e9edf5;
  padding: 5px; cursor: pointer; transition: .15s; position: relative;
}
.sample img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sample:hover { transform: translateY(-2px) scale(1.05); border-color: var(--yellow); }
.sample.on { outline: 3px solid var(--yellow); outline-offset: 1px; }

/* preprocessing */
.previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.previews figure { margin: 0; }
.previews img {
  width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 8px;
  background: #1a2238; border: 1px solid var(--line); display: block;
}
.previews img:not([src]) { visibility: hidden; }
.previews figcaption { font-size: 10px; color: var(--dim); text-align: center; margin-top: 2px; }
.status { font-size: 12px; color: var(--muted); margin: 8px 0 4px; min-height: 18px; }
.status.err { color: var(--pink); }
.hud-top {
  position: absolute; top: 14px; left: 0; right: 0; text-align: center; pointer-events: none;
  font: 600 12px var(--mono); color: var(--yellow); letter-spacing: .05em;
}
.hud-caption {
  position: absolute; bottom: 120px; left: 0; right: 0; text-align: center; pointer-events: none;
  font-size: 22px; font-weight: 800; opacity: 0; transition: opacity .4s; text-shadow: 0 2px 12px #000;
}
.hud-caption.on { opacity: 1; }
.hud-caption em { font-style: normal; color: var(--yellow); }
.hud-bottom { position: absolute; bottom: 58px; left: 0; right: 0; text-align: center; pointer-events: none; }
.hud-n { font-size: 40px; font-weight: 800; letter-spacing: -.02em; text-shadow: 0 2px 16px #000; }
.hud-n #hudN { color: var(--yellow); display: inline-block; }
.hud-n #hudN.pop { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(1.7); } 100% { transform: scale(1); } }
.hud-err { font: 13px var(--mono); color: var(--muted); }
/* live panel */
.live {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; overflow-y: auto; scrollbar-width: thin;
}
.live h3 { font-size: 13px; margin-top: 4px; }
.live h3 + .sub { margin-top: 2px; }
canvas.spec { width: 100%; height: 130px; display: block; }
canvas.clocks { width: 100%; display: block; cursor: pointer; }
.energy { margin: 0 0 16px; }
.energy-label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.energy-label b { color: var(--green); font-family: var(--mono); }
.bar { height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; margin-top: 4px; }
.bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--green)); transition: width .3s; }
canvas.spec-big { width: 100%; height: 220px; display: block; }
canvas.xy { width: 100%; height: 320px; display: block; }
canvas.errchart { width: 100%; height: 340px; display: block; cursor: crosshair; }
canvas.heat { width: 100%; height: 340px; display: block; }
.heat-scale { display: flex; align-items: center; gap: 8px; font: 11px var(--mono); color: var(--muted); }
.heat-scale .grad { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #3ddc97, #ffc93c, #ff5c8a); }

.partials { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.partial {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; cursor: pointer;
  transition: .15s;
}
.partial:hover { border-color: var(--yellow); transform: translateY(-2px); }
.partial.cur { border-color: var(--yellow); box-shadow: 0 0 0 1px var(--yellow); }
.partial canvas { width: 100%; aspect-ratio: 1; display: block; }
.partial div { font: 11px var(--mono); color: var(--muted); text-align: center; }
.partial div b { color: var(--yellow); }
.partial { position: relative; }
.partial-stl {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; padding: 0; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(17, 24, 41, .85); cursor: pointer; font-size: 14px;
  opacity: .45; transition: opacity .15s, border-color .15s;
}
.partial:hover .partial-stl { opacity: 1; }
.partial-stl:hover { border-color: var(--yellow); }

.milestones { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.ms { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.ms .lab { font-size: 12px; color: var(--muted); }
.ms .val { font-size: 26px; font-weight: 800; color: var(--yellow); }
.ms .val small { font-size: 12px; color: var(--muted); font-weight: 400; }
.ms .alt { font-size: 11px; color: var(--blue); }
.ms.reached { border-color: rgba(61, 220, 151, .5); }
/* math */
.math-layout { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
.math-side { position: sticky; top: 0; }
canvas.mini {
  width: 100%; aspect-ratio: 1; display: block; border-radius: var(--radius); border: 1px solid var(--line);
  background: radial-gradient(circle at 50% 45%, #0f1628 0%, #070a12 75%);
}
.mini-cap { text-align: center; color: var(--muted); font: 12px var(--mono); margin-top: 6px; }
.formula { font-size: 22px; text-align: center; padding: 14px 0; overflow-x: auto; }
.formula math { color: var(--text); }
.math-opts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.math-opts select { padding: 3px 6px; }
.terms { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 2px; font-size: 18px; margin: 8px 0; line-height: 2; }
.terms .lhs { margin-right: 6px; font-size: 20px; }
.term {
  padding: 0 6px; border-radius: 8px; transition: background .1s; cursor: default;
  border: 1px solid transparent;
}
.term:hover, .term.hl { background: rgba(255, 92, 138, .15); border-color: rgba(255, 92, 138, .5); }
.term.muted { opacity: .35; text-decoration: line-through; }
.plus { color: var(--dim); }
.ellipsis { color: var(--muted); font-size: 14px; }
.table-wrap { max-height: 380px; overflow: auto; scrollbar-width: thin; }
table.coef { border-collapse: collapse; width: 100%; font: 12px var(--mono); }
table.coef th { position: sticky; top: 0; background: var(--panel2); color: var(--muted); font-weight: 600; text-align: right; padding: 6px 10px; }
table.coef td { text-align: right; padding: 4px 10px; border-bottom: 1px solid var(--line); }
table.coef tr:hover td, table.coef tr.hl td { background: rgba(255, 92, 138, .15); }
table.coef tr.hl td:first-child { box-shadow: inset 3px 0 0 var(--pink); }
table.coef td.barcell { width: 30%; }
table.coef .mbar { height: 6px; border-radius: 3px; background: var(--yellow); }
table.coef tr.muted td { opacity: .4; }
#cvHand {
  display: block; width: min(720px, 88vw); aspect-ratio: 3 / 2; border-radius: 12px;
  background: #0a0f1c; border: 1px solid var(--line); cursor: crosshair; touch-action: none;
}
/* big popup above a preprocessing slider while dragging */
.slider-pop {
  position: fixed; z-index: 30; pointer-events: none; min-width: 180px;
  transform: translate(-50%, calc(-100% - 14px)) scale(.92); opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  background: var(--panel2); border: 1px solid var(--yellow); border-radius: 14px; padding: 10px 16px 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55), 0 0 24px var(--yellow-glow); text-align: center;
}
.slider-pop.on { opacity: 1; transform: translate(-50%, calc(-100% - 14px)) scale(1); }
.slider-pop::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px; transform: translateX(-50%) rotate(45deg);
  background: var(--panel2); border-right: 1px solid var(--yellow); border-bottom: 1px solid var(--yellow);
}
.sp-label { font-size: 12px; color: var(--muted); }
.sp-value { font-size: 34px; font-weight: 800; color: var(--yellow); font-family: var(--mono); line-height: 1.1; }
.sp-preview { display: none; width: 150px; margin: 8px auto 0; border-radius: 8px; background: #1a2238; }
.slider-pop.has-preview .sp-preview { display: block; }

/* ------------------------------------------------------------ Listen tab */
.listen-controls { display: grid; grid-template-columns: auto 1fr minmax(240px, 320px) auto; gap: 18px; align-items: center; }
.play-btn { font-size: 16px; padding: 0 22px; height: 52px; border-radius: 14px; min-width: 190px; }
.play-btn.playing { background: var(--pink); border-color: var(--pink); color: #fff; box-shadow: 0 0 24px rgba(255, 92, 138, .45); }
.listen-mode .seg { margin: 0; }
.listen-mode .sub { margin: 8px 2px 0; min-height: 32px; }
.listen-sliders .field:first-child { margin-top: 0; }
.listen-sliders .chips { margin-top: 8px; }
.listen-warn { color: var(--muted); font-size: 12px; margin: -6px 2px 12px; }
.listen-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; margin-bottom: 14px; }
.listen-grid .panel { margin: 0; }
canvas.scope {
  width: 100%; aspect-ratio: 1; max-height: 520px; display: block; border-radius: 12px;
  background: #050910; box-shadow: inset 0 0 40px rgba(61, 220, 151, .08); border: 1px solid #12301f;
}
.scope-cap { font: 12px var(--mono); color: var(--green); text-align: center; margin-top: 6px; min-height: 16px; }
canvas.waterfall { width: 100%; height: 420px; display: block; border-radius: 12px; background: #070a12; }
canvas.wave { width: 100%; height: 200px; display: block; }
.audible { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.audible b { color: var(--green); }
.overtones { display: flex; flex-direction: column; gap: 3px; font: 12px var(--mono); }
.ot { display: grid; grid-template-columns: 44px 74px 44px 1fr 52px; gap: 8px; align-items: center; padding: 2px 6px; border-radius: 6px; }
.ot-n { color: var(--yellow); font-weight: 700; }
.ot-f { color: var(--text); text-align: right; }
.ot-note { color: var(--green); }
.ot-bar { height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.ot-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--pink)); }
.ot-db { color: var(--dim); text-align: right; }
.ot.out { opacity: .45; }
.ot.now { background: rgba(255, 92, 138, .15); }
.lesson-wide p { color: #c3cbe0; max-width: 900px; }
.tab[data-tab="listen"].playing::after { content: " ●"; color: var(--pink); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }
@media (max-width: 1200px) {
  .listen-controls { grid-template-columns: 1fr; }
  .listen-grid { grid-template-columns: 1fr; }
  canvas.scope { max-width: 520px; margin: 0 auto; }
}

.hint kbd { font-size: 9px; padding: 0 4px; color: var(--muted); }
.spiro-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.spiro-side { margin: 0; }
.spiro-presets { margin: 10px 0 6px; }
.spiro-presets button { flex: none; padding: 4px 9px; }
.spiro-circle { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 10px; background: var(--bg2); }
.spiro-circle h4 { margin: 0; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.spiro-circle h4 i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.spiro-circle .field { margin-top: 6px; }
.spiro-circle.off { opacity: .35; pointer-events: none; }
.spiro-third { margin: 12px 0 4px; }
.spiro-stage { padding: 0; overflow: hidden; margin-bottom: 14px; }
.spiro-stage canvas { width: 100%; height: 520px; display: block; background: radial-gradient(circle at 50% 45%, #0f1628 0%, #070a12 75%); }
.spiro-facts .panel { margin: 0; text-align: center; }
.spiro-facts + .panel { margin-top: 14px; }
@media (max-width: 1200px) { .spiro-layout { grid-template-columns: 1fr; } }
#spUse { white-space: normal; line-height: 1.3; padding: 10px 14px; }
.zip-score { font: 800 22px var(--mono); }
.zip-score.good { color: var(--yellow); }
.zip-score.bad { color: var(--pink); }

@media (max-width: 1200px) {
  #view-draw.active { grid-template-columns: 1fr; grid-template-rows: minmax(420px, 1fr) auto; overflow-y: auto; }
  .live { overflow: visible; }
  .math-layout { grid-template-columns: 1fr; }
  .math-side { position: static; max-width: 360px; margin: 0 auto; }
}
@media (max-width: 860px) {
  #view-draw.active { grid-template-rows: 70vh auto; }
  .hud-n { font-size: 30px; }
}
