/* style.css — all styling */
:root {
  --bg: #0b0f14;
  --bg2: #111821;
  --panel: rgba(20, 28, 38, 0.72);
  --panel-brd: rgba(127, 200, 255, 0.10);
  --text: #e6f0f5;
  --muted: #8aa0b0;
  --accent: #7fffaa;
  --accent2: #5fd0ff;
  --white-key: #f3f5f8;
  --white-key-down: #bdf0cf;
  --black-key: #1b242e;
  --black-key-down: #2c4a3a;
  color-scheme: dark;
}

html[data-theme="dark"]  { color-scheme: dark; }
html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f6;
  --bg2: #e2e8ee;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-brd: rgba(40, 80, 120, 0.14);
  --text: #0f1c26;
  --muted: #4d6577;
  --accent: #1f9d57;
  --accent2: #1d6fb8;
  --white-key: #ffffff;
  --white-key-down: #c9f0d8;
  --black-key: #2a3641;
  --black-key-down: #1f5a3c;
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #eef2f6;
    --bg2: #e2e8ee;
    --panel: rgba(255, 255, 255, 0.78);
    --panel-brd: rgba(40, 80, 120, 0.14);
    --text: #0f1c26;
    --muted: #4d6577;
    --accent: #1f9d57;
    --accent2: #1d6fb8;
    --white-key: #ffffff;
    --white-key-down: #c9f0d8;
    --black-key: #2a3641;
    --black-key-down: #1f5a3c;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(95, 208, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(127, 255, 170, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px clamp(14px, 3vw, 36px) 20px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #07140d;
  font-size: 20px; font-weight: 800;
  box-shadow: 0 6px 18px rgba(95, 208, 255, 0.25);
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.3px;
  font-weight: 700;
}
.tag {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.meter {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: 12px;
  padding: 6px 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 6px 18px rgba(0,0,0,0.25);
}
#scope { display: block; width: 220px; height: 40px; }

/* ---- Panels ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.04);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
}
.ctrl-group { display: flex; align-items: center; gap: 8px; }
.ctrl-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* segmented control */
.seg {
  display: inline-flex;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-brd);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
html[data-theme="light"] .seg { background: rgba(0,0,0,0.05); }
.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn:active { transform: translateY(1px); }
.seg-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #07140d;
  box-shadow: 0 2px 8px rgba(95, 208, 255, 0.3);
}

/* octave */
.octave { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 9px;
  border: 1px solid var(--panel-brd);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, border-color .15s ease;
}
html[data-theme="light"] .icon-btn { background: rgba(0,0,0,0.04); }
.icon-btn:hover { border-color: var(--accent2); }
.icon-btn:active { transform: translateY(1px) scale(0.97); }
.oct-val {
  min-width: 38px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}

/* volume slider */
.vol-group { flex: 1; min-width: 160px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent2);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent2);
  cursor: pointer;
}

/* ---- Stage / keyboard ---- */
.stage {
  flex: 1;
  min-height: 0;
  padding: 18px;
  display: flex;
  align-items: stretch;
}
.keyboard {
  position: relative;
  flex: 1;
  min-height: 180px;
  user-select: none;
  touch-action: none;
  border-radius: 12px;
}

.white-row {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 4px;
}
.key.white {
  flex: 1;
  background: linear-gradient(180deg, var(--white-key) 0%, #d8dee5 100%);
  border-radius: 0 0 10px 10px;
  box-shadow:
    inset 0 -6px 12px rgba(0,0,0,0.08),
    0 4px 10px rgba(0,0,0,0.3);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 12px;
  color: #33414d;
  cursor: pointer;
  transition: transform .05s ease, background .08s ease, box-shadow .08s ease;
}
.key.white.down {
  background: linear-gradient(180deg, var(--white-key-down) 0%, #9fe6bd 100%);
  transform: translateY(2px);
  box-shadow: inset 0 -3px 8px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.25);
}

.black-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.key.black {
  position: absolute;
  top: 0;
  width: 7.2%;
  height: 62%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #2a3641 0%, var(--black-key) 60%, #0c1218 100%);
  border-radius: 0 0 8px 8px;
  box-shadow:
    inset 0 -4px 8px rgba(0,0,0,0.6),
    0 4px 8px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 8px;
  color: #c8d6df;
  pointer-events: auto;
  cursor: pointer;
  transition: transform .05s ease, background .08s ease;
  z-index: 2;
}
.key.black.down {
  background: linear-gradient(180deg, #34d07a 0%, var(--black-key-down) 80%);
  transform: translateX(-50%) translateY(2px);
  box-shadow: inset 0 -2px 6px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.5);
}

.key .label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.85;
}
.key.black .label { color: #eafaf0; opacity: 0.9; }
.key .note {
  font-size: 10px;
  margin-top: 3px;
  opacity: 0.55;
  font-weight: 600;
}
.key.white .note { color: #5a6975; }

/* ---- Hint footer ---- */
.hint {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 2px 2px;
}
.hint span { display: inline-flex; align-items: center; gap: 6px; }
kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  background: rgba(127, 200, 255, 0.10);
  border: 1px solid var(--panel-brd);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--text);
}

/* ---- Responsive ---- */
@media (max-width: 560px) {
  .meter { display: none; }
  .topbar { justify-content: flex-start; }
  .controls { gap: 12px; padding: 10px 12px; }
  .seg-btn { padding: 6px 9px; font-size: 12px; }
  .key .note { display: none; }
  .key .label { font-size: 11px; }
  #scope { width: 160px; height: 36px; }
}

@media (max-height: 520px) {
  .app { gap: 8px; padding-top: 12px; padding-bottom: 12px; }
  .stage { padding: 10px; }
  .keyboard { min-height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
