@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap');

:root {
  --accent-primary: #3b82f6;
  --accent-secondary: #1d4ed8;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --accent-hover-1: #2563eb;
  --accent-hover-2: #1e40af;
  --font-display: 'Instrument Sans';
  --font-body: 'Instrument Sans';

  --note-flat: #60a5fa;
  --note-in: #10b981;
  --note-in-glow: rgba(16, 185, 129, 0.35);
  --note-sharp: #f59e0b;

  --ease-snap: cubic-bezier(0.2, 0, 0, 1);
  --ease-glide: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-dismiss: cubic-bezier(0.4, 0, 1, 1);

  --dur-hover: 130ms;
  --dur-press: 100ms;
  --dur-open: 240ms;
}

/* Color themes (matches QNPLAYER exactly) */
[data-theme="blue"] {
  --accent-primary: #3b82f6;
  --accent-secondary: #1d4ed8;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --accent-hover-1: #2563eb;
  --accent-hover-2: #1e40af;
}

[data-theme="emerald"] {
  --accent-primary: #10b981;
  --accent-secondary: #047857;
  --accent-glow: rgba(16, 185, 129, 0.35);
  --accent-hover-1: #059669;
  --accent-hover-2: #065f46;
}

[data-theme="purple"] {
  --accent-primary: #8b5cf6;
  --accent-secondary: #6d28d9;
  --accent-glow: rgba(139, 92, 246, 0.35);
  --accent-hover-1: #7c3aed;
  --accent-hover-2: #5b21b6;
}

[data-theme="rose"] {
  --accent-primary: #f43f5e;
  --accent-secondary: #be123c;
  --accent-glow: rgba(244, 63, 94, 0.35);
  --accent-hover-1: #e11d48;
  --accent-hover-2: #9f1239;
}

[data-theme="amber"] {
  --accent-primary: #f59e0b;
  --accent-secondary: #b45309;
  --accent-glow: rgba(245, 158, 11, 0.35);
  --accent-hover-1: #d97706;
  --accent-hover-2: #92400e;
}

[data-theme="cyan"] {
  --accent-primary: #06b6d4;
  --accent-secondary: #0e7490;
  --accent-glow: rgba(6, 182, 212, 0.35);
  --accent-hover-1: #0891b2;
  --accent-hover-2: #155e75;
}

[data-theme="indigo"] {
  --accent-primary: #6366f1;
  --accent-secondary: #4338ca;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --accent-hover-1: #4f46e5;
  --accent-hover-2: #3730a3;
}

[data-theme="pink"] {
  --accent-primary: #ec4899;
  --accent-secondary: #be185d;
  --accent-glow: rgba(236, 72, 153, 0.35);
  --accent-hover-1: #db2777;
  --accent-hover-2: #9d174d;
}

[data-theme="lime"] {
  --accent-primary: #84cc16;
  --accent-secondary: #4d7c0f;
  --accent-glow: rgba(132, 204, 22, 0.35);
  --accent-hover-1: #65a30d;
  --accent-hover-2: #3f6212;
}

[data-theme="orange"] {
  --accent-primary: #f97316;
  --accent-secondary: #c2410c;
  --accent-glow: rgba(249, 115, 22, 0.35);
  --accent-hover-1: #ea580c;
  --accent-hover-2: #9a3412;
}

[data-theme="teal"] {
  --accent-primary: #14b8a6;
  --accent-secondary: #0f766e;
  --accent-glow: rgba(20, 184, 166, 0.35);
  --accent-hover-1: #0d9488;
  --accent-hover-2: #115e59;
}

[data-theme="violet"] {
  --accent-primary: #a855f7;
  --accent-secondary: #7e22ce;
  --accent-glow: rgba(168, 85, 247, 0.35);
  --accent-hover-1: #9333ea;
  --accent-hover-2: #6b21a8;
}

[data-theme="red"] {
  --accent-primary: #ef4444;
  --accent-secondary: #b91c1c;
  --accent-glow: rgba(239, 68, 68, 0.35);
  --accent-hover-1: #dc2626;
  --accent-hover-2: #991b1b;
}

[data-theme="sky"] {
  --accent-primary: #0ea5e9;
  --accent-secondary: #0369a1;
  --accent-glow: rgba(14, 165, 233, 0.35);
  --accent-hover-1: #0284c7;
  --accent-hover-2: #075985;
}

* { box-sizing: border-box; }

html {
  touch-action: pan-x pan-y;
  height: 100%;
}

html, body {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: #0d0d0f;
  color: #f0f0f3;
  font-family: var(--font-body, 'Instrument Sans'), -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  padding: 24px 24px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Header (matches QNPLAYER) ---------- */

#appHeader {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  position: relative;
  z-index: 200;
  flex-shrink: 0;
}

@media (min-width: 901px) {
  #appHeader {
    max-width: 900px;
  }
}

#appLogo {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 1px;
  margin: 0;
  color: #f0f0f3;
  text-transform: uppercase;
}

#appLogoAccent {
  color: var(--accent-primary);
}

#appVersion {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: #6b6b7b;
  text-transform: none;
  vertical-align: middle;
}


/* ---------- Layout ---------- */

.app-container {
  width: 100%;
  max-width: 480px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 15px;
  box-sizing: border-box;
}

/* PC width: show Tone (left) and Mic (right) side by side instead of switching screens */
@media (min-width: 901px) {
  .app-container {
    max-width: 900px;
    flex-direction: row;
    align-items: stretch;
  }

  .screen[hidden] {
    display: flex !important;
  }

  #screen-tone {
    order: 1;
  }

  #screen-mic {
    order: 2;
  }

  .screen {
    flex: 1;
    min-width: 0;
  }
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.screen[hidden] {
  display: none;
}

/* Card: QNAUDIO panel language */
.control-card {
  background: #16161b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px 20px;
}

/* ---------- Mic permission ---------- */

.mic-permission {
  text-align: center;
  padding: 18px 22px;
}

.mic-permission-icon {
  font-size: 26px;
  margin-bottom: 6px;
  opacity: 0.9;
}

.mic-permission-text {
  color: #8b8b9e;
  font-size: 13px;
  margin: 0 0 14px;
  line-height: 1.6;
}

.mic-permission-note {
  color: var(--note-sharp);
  font-size: 13px;
  margin-top: 16px;
  min-height: 18px;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  border: none;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 11px 28px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: background var(--dur-hover) var(--ease-snap), transform var(--dur-press) var(--ease-snap), box-shadow var(--dur-hover) var(--ease-snap);
}

.btn-primary:hover {
  background: var(--accent-hover-1);
  box-shadow: 0 6px 18px var(--accent-glow);
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary {
  margin-top: 18px;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #8b8b9e;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 10px 24px;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color var(--dur-hover) var(--ease-snap), color var(--dur-hover) var(--ease-snap), transform var(--dur-press) var(--ease-snap);
}

.btn-secondary:hover {
  border-color: var(--note-sharp);
  color: var(--note-sharp);
}

.btn-secondary:active {
  transform: scale(0.96);
}

/* ---------- Sensitivity slider ---------- */

.sensitivity-control {
  width: 100%;
  max-width: 280px;
  margin-top: 18px;
}

.sensitivity-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #8b8b9e;
  margin-bottom: 8px;
}

.sensitivity-value {
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

.sensitivity-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #1c1c24;
  outline: none;
  cursor: pointer;
  margin: 0;
}

.sensitivity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-snap);
}

.sensitivity-slider::-webkit-slider-thumb:active {
  transform: scale(1.15);
}

.sensitivity-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-snap);
}

.sensitivity-slider::-moz-range-thumb:active {
  transform: scale(1.15);
}

.sensitivity-slider::-moz-range-progress {
  background: var(--accent-primary);
  height: 4px;
  border-radius: 2px;
}

/* ---------- Meter (gauge) ---------- */

.meter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.meter-wrap[hidden] {
  display: none;
}

.gauge {
  position: relative;
  width: 100%;
  max-width: 280px;
}

.gauge-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 10;
  stroke-linecap: round;
}

.gauge-zone-flat {
  fill: none;
  stroke: var(--note-flat);
  stroke-width: 10;
  stroke-linecap: round;
  opacity: 0.5;
}

.gauge-zone-sharp {
  fill: none;
  stroke: var(--note-sharp);
  stroke-width: 10;
  stroke-linecap: round;
  opacity: 0.5;
}

.gauge-zone-in {
  fill: none;
  stroke: var(--note-in);
  stroke-width: 10;
  stroke-linecap: round;
}

.needle {
  transform-origin: 150px 160px;
  transition: transform 0.08s var(--ease-snap);
}

.needle line {
  stroke: #f0f0f3;
  stroke-width: 3;
  stroke-linecap: round;
}

.needle circle {
  fill: #f0f0f3;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 6px;
  margin-top: -4px;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #6b6b7b;
}

.reading {
  text-align: center;
}

.note-display {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  color: #f0f0f3;
  min-height: 58px;
  transition: color var(--dur-hover) var(--ease-snap);
}

.freq-display {
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: #8b8b9e;
  margin-top: 8px;
}

.cents-display {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #6b6b7b;
  margin-top: 4px;
}

.meter-wrap[data-state="flat"] .cents-display { color: var(--note-flat); }
.meter-wrap[data-state="sharp"] .cents-display { color: var(--note-sharp); }
.meter-wrap[data-state="in"] .cents-display,
.meter-wrap[data-state="perfect"] .cents-display { color: var(--note-in); }
.meter-wrap[data-state="flat"] .note-display { color: var(--note-flat); }
.meter-wrap[data-state="sharp"] .note-display { color: var(--note-sharp); }
.meter-wrap[data-state="in"] .note-display { color: var(--note-in); }
.meter-wrap[data-state="perfect"] .note-display {
  color: #ffffff;
  text-shadow: 0 0 16px var(--note-in-glow);
}
.meter-wrap[data-state="flat"] .needle line,
.meter-wrap[data-state="flat"] .needle circle { stroke: var(--note-flat); fill: var(--note-flat); }
.meter-wrap[data-state="sharp"] .needle line,
.meter-wrap[data-state="sharp"] .needle circle { stroke: var(--note-sharp); fill: var(--note-sharp); }
.meter-wrap[data-state="in"] .needle line,
.meter-wrap[data-state="in"] .needle circle,
.meter-wrap[data-state="perfect"] .needle line,
.meter-wrap[data-state="perfect"] .needle circle { stroke: var(--note-in); fill: var(--note-in); }

.meter-wrap[data-state="in"],
.meter-wrap[data-state="perfect"] {
  box-shadow: inset 0 0 0 1px var(--note-in-glow);
}

/* ---------- Tone (oscillator) screen ---------- */

#screen-tone {
  justify-content: flex-start;
}

.preset-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  flex-shrink: 0;
}

.preset-tabs::-webkit-scrollbar { display: none; }

.preset-tab {
  flex: none;
  background: #16161b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #8b8b9e;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 10px 18px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-hover) var(--ease-snap), border-color var(--dur-hover) var(--ease-snap), color var(--dur-hover) var(--ease-snap), transform var(--dur-press) var(--ease-snap);
}

.preset-tab.is-active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.preset-tab:active {
  transform: scale(0.94);
}

/* Tuning switch (Regular/Half Down/Drop tunings): 3x2 grid layout */
.tuning-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  flex-shrink: 0;
}

.tuning-tabs[hidden] {
  display: none;
}

.tuning-tab {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #6b6b7b;
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 8px 6px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: background var(--dur-hover) var(--ease-snap), border-color var(--dur-hover) var(--ease-snap), color var(--dur-hover) var(--ease-snap), transform var(--dur-press) var(--ease-snap);
}

.tuning-tab.is-active {
  background: #1c1c24;
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.tuning-tab:active {
  transform: scale(0.94);
}

/* String list card: padding is 0 so the rows themselves form the border,
   matching the av-toggle-btn "one seamless rounded block" look */
.tone-card {
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  align-items: stretch;
}

.string-list {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Small keyboard-shortcut hint below the string list, PC-only (see media query) */
.kbd-hint {
  display: none;
  flex-shrink: 0;
  text-align: center;
  margin: 0;
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  color: #6b6b7b;
}

.kbd-hint kbd {
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  padding: 2px 7px;
  font-family: monospace;
  font-size: 11px;
  color: var(--accent-primary);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

@media (hover: hover) and (pointer: fine) {
  .kbd-hint {
    display: block;
  }
}

/* Strings are listed top to bottom, string 1 first, just like a TAB chart.
   As with QNAUDIO's av-toggle-btn rows, adjacent buttons share a border
   so they read as a single strip rather than separate cards. */
.string-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  color: #f0f0f3;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background var(--dur-hover) var(--ease-snap), transform var(--dur-press) var(--ease-snap);
}

.string-row:first-child {
  border-top: none;
}

.string-row:first-child {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.string-row:last-child {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.string-row:hover {
  background: #1c1c24;
}

.string-row:active {
  transform: scale(0.99);
}

.string-row.is-playing {
  background: var(--accent-glow);
}

.string-row-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.string-row-order {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #8b8b9e;
}

.string-row.is-playing .string-row-order {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.string-row-note {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

.string-row-label {
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  color: #8b8b9e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.string-row-freq {
  flex-shrink: 0;
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  color: #6b6b7b;
}

/* ---------- Bottom fixed control bar (QNAUDIO av-toggle-btn feel) ---------- */

.bottom-bar {
  width: 100%;
  flex-shrink: 0;
  background: #16161b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 901px) {
  .bottom-bar {
    display: none;
  }
}

.bottom-now {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  animation: toneNowIn var(--dur-open) var(--ease-pop);
}

.bottom-now[hidden] {
  display: none;
}

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

.bottom-now-note {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-primary);
}

.bottom-now-freq {
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #8b8b9e;
}

.bottom-now-stop {
  margin-top: 4px;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f0f0f3;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 12px 40px;
  border-radius: 14px;
  cursor: pointer;
  transition: border-color var(--dur-hover) var(--ease-snap), color var(--dur-hover) var(--ease-snap), background var(--dur-hover) var(--ease-snap), transform var(--dur-press) var(--ease-snap);
}

.bottom-now-stop:hover {
  border-color: var(--note-sharp);
  color: var(--note-sharp);
  background: #201a12;
}

.bottom-now-stop:active {
  transform: scale(0.96);
}

/* Like av-toggle-btn, laid out as one seamless rounded strip */
.bottom-controls {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  overflow: hidden;
}

.bottom-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  background: #1c1c24;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  color: #8b8b9e;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background var(--dur-hover) var(--ease-snap), color var(--dur-hover) var(--ease-snap), transform var(--dur-press) var(--ease-snap);
}

.bottom-btn[hidden] {
  display: none;
}

.bottom-btn:first-child {
  border-left: none;
}

.bottom-btn:hover:not(.is-active) {
  background: #252530;
  color: var(--accent-primary);
}

.bottom-btn:active {
  transform: scale(0.97);
}

.bottom-btn.is-active {
  background: var(--accent-primary);
  color: #fff;
}

.bottom-btn-icon {
  font-size: 15px;
  line-height: 1;
}

.bottom-btn-stop.is-active {
  background: var(--note-sharp);
  color: #1a1206;
}

@media (max-width: 768px) {
  .note-display {
    font-size: 42px;
    min-height: 48px;
  }
  .control-card {
    padding: 16px 16px;
  }
  .mic-permission {
    padding: 16px 16px;
  }
  .string-row {
    padding: 15px 16px;
  }
}

@media (max-height: 700px) {
  .gauge {
    max-width: 210px;
  }
  .note-display {
    font-size: 38px;
    min-height: 44px;
  }
  .meter-wrap {
    gap: 10px;
  }
  .control-card {
    padding: 14px 16px;
  }
  .string-row {
    padding: 12px 16px;
  }
  .bottom-now-note {
    font-size: 38px;
  }
  .bottom-now {
    padding: 10px 12px 6px;
  }
  .bottom-now-stop {
    padding: 9px 30px;
  }
}
