*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #000000;
  --text: rgba(255, 255, 255, 0.92);
  --text-muted: rgba(255, 255, 255, 0.45);
  --accent: #7c6bff;
  --accent-glow: rgba(124, 107, 255, 0.4);
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.1);
  --radius: 14px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  z-index: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(60, 40, 120, 0.12) 0%, var(--bg) 65%);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-content {
  text-align: center;
  padding: 2rem;
  max-width: min(92vw, 560px);
  animation: fadeUp 1s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.logo-ring {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  animation: pulse 3s ease-in-out infinite;
}

.logo-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--accent), transparent);
  opacity: 0.5;
  animation: spin 6s linear infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.logo-text {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-titles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
}

.logo-text,
.logo-subtitle,
.logo-credit {
  display: block;
  width: 100%;
  text-align: center;
}

.logo-subtitle {
  font-size: clamp(0.95rem, 3.2vw, 1.15rem);
  font-weight: 400;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.03em;
  line-height: 1.35;
  white-space: nowrap;
}

.logo-credit {
  font-size: clamp(0.9rem, 2.8vw, 1.05rem);
  font-style: italic;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.02em;
}

.tagline {
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.5;
}

.hint {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.error-box {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: rgba(255, 80, 80, 0.15);
  border: 1px solid rgba(255, 80, 80, 0.3);
  color: #ffb4b4;
  font-size: 0.85rem;
  line-height: 1.4;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 2rem;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(124, 107, 255, 0.25), rgba(124, 107, 255, 0.08));
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  backdrop-filter: blur(12px);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--accent-glow);
  background: linear-gradient(135deg, rgba(124, 107, 255, 0.4), rgba(124, 107, 255, 0.15));
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 0.85rem;
}

.ui-panel {
  z-index: 10;
  pointer-events: auto;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.ui-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.top-bar,
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  z-index: 30;
  pointer-events: none;
}

.top-bar .app-name-block,
.top-bar .controls,
.bottom-bar > * {
  pointer-events: auto;
  touch-action: manipulation;
}

.top-bar {
  top: 0;
  background: linear-gradient(to bottom, rgba(6, 6, 18, 0.85), transparent);
}

.bottom-bar {
  bottom: 0;
  justify-content: center;
  gap: 2rem;
  background: linear-gradient(to top, rgba(6, 6, 18, 0.85), transparent);
}

.status-toast {
  position: fixed;
  top: 4.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: none;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(10, 10, 24, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  backdrop-filter: blur(8px);
}

.status-toast.is-error {
  border-color: rgba(255, 80, 80, 0.45);
  color: #ffb4b4;
}

.click-feedback {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(124, 107, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  transform: translate(-50%, -50%);
  animation: feedbackPop 0.9s ease forwards;
}

@keyframes feedbackPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.9); }
}

.app-name-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: min(46vw, 540px);
}

.app-name {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.app-subtitle {
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: none;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.45;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-ghost {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost.is-active {
  border-color: rgba(124, 107, 255, 0.55);
  background: rgba(124, 107, 255, 0.18);
}

#record-btn.is-recording {
  border-color: rgba(255, 80, 80, 0.7);
  background: rgba(255, 60, 60, 0.15);
  color: #ff8a8a;
}

#record-btn.is-recording #record-icon {
  animation: rec-blink 1s ease-in-out infinite;
}

#record-label {
  margin-left: 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

body.is-fullscreen #top-bar,
body.is-fullscreen #bottom-bar,
body.is-fullscreen #status-toast,
body.is-fullscreen #click-feedback {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#volume {
  width: 80px;
  height: 4px;
  appearance: none;
  background: var(--glass-border);
  border-radius: 2px;
  cursor: pointer;
}

#volume::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.mix-pad {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mix-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 3.4rem;
  height: 2.6rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}

.mix-num {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
}

.mix-label {
  margin-top: 0.15rem;
  font-size: 0.58rem;
  letter-spacing: 0.03em;
  text-transform: lowercase;
  color: var(--text-muted);
  line-height: 1;
}

.mix-btn:hover {
  background: rgba(124, 107, 255, 0.2);
  border-color: rgba(124, 107, 255, 0.45);
}

.mix-btn:active {
  transform: scale(0.94);
}

.mix-btn.is-active {
  background: rgba(124, 107, 255, 0.32);
  border-color: rgba(124, 107, 255, 0.65);
}

.mix-btn.is-active .mix-label {
  color: rgba(255, 255, 255, 0.85);
}

.note-pad {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.note-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}

.note-btn:hover {
  background: rgba(124, 107, 255, 0.25);
  border-color: rgba(124, 107, 255, 0.5);
}

.note-btn:active {
  transform: scale(0.92);
  background: rgba(124, 107, 255, 0.4);
}

.keyboard-hint {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bar-action {
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.bar-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.bar-action:active {
  transform: scale(0.97);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.35rem;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: var(--glass);
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--text);
}

@media (max-width: 600px) {
  .logo-text { font-size: 1.6rem; }
  .logo-subtitle { white-space: normal; font-size: 0.95rem; }
  .logo-credit { font-size: 0.9rem; }
  .app-subtitle { display: none; }
  .bottom-bar { flex-wrap: wrap; gap: 0.75rem; padding-bottom: 1.5rem; }
  .keyboard-hint span { display: none; }
  #volume { width: 60px; }
}
