﻿* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0a0c10;
  --panel: rgba(20, 26, 34, 0.86);
  --border: rgba(255, 255, 255, 0.07);
  --text: #eef3f9;
  --text-secondary: #a8b4c4;
  --text-faint: #6b7a8d;
  --green-core: #58BD38;
  --green-deep: #3a8a22;
  --green-glow: rgba(88, 189, 56, 0.35);
  --yellow: #fbbf24;
  --red: #f87171;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 46% at 50% -8%, rgba(88, 189, 56, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 100%, #0f141c 0%, #0a0c10 70%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  padding: 24px 18px 48px;
  user-select: none;
  -webkit-user-select: none;
  line-height: 1.5;
}
.app { max-width: 1160px; margin: 0 auto; }

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 24px;
}
.brand h1 {
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #ffffff 0%, #ffffff 120%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand .sub {
  font-size: 14px;
  color: #a8b4c4;
  margin-top: 4px;
  font-weight: 500;
}
.settings {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.setting-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  backdrop-filter: blur(14px);
}
.setting-item input[type="number"] {
  width: 76px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding: 5px 4px;
  text-align: center;
  outline: none;
}
.setting-item input[type="number"]:focus { border-color: var(--green-core); }
.setting-item select {
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 550;
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
}
.setting-item select:focus { border-color: var(--green-core); }

/* ---------- Main ---------- */
.main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Panel ---------- */
.panel {
  background: linear-gradient(180deg, rgba(28, 36, 46, 0.78) 0%, rgba(14, 18, 26, 0.94) 100%);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(22px);
}

/* ---------- Gauge Panel ---------- */
.gauge-panel { padding: 30px 24px 22px; }
.reading { text-align: center; padding-bottom: 2px; }

.note-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  line-height: 1;
  height: 96px;
  padding: 0;
}
.note-name {
  font-size: clamp(72px, 16vw, 96px);
  font-weight: 750;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 0.92;
  transition: color 0.2s;
}
.note-octave {
  font-size: 32px;
  font-weight: 550;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.freq {
  font-size: 17px;
  color: var(--text-secondary);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  background: none;
  border: none;
}
.cents {
  font-size: 38px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  margin-top: 12px;
  min-height: 48px;
  transition: color 0.2s;
}
.cents.state-in { color: var(--green-core); }
.cents.state-warn { color: var(--yellow); }
.cents.state-out { color: var(--red); }
.cents.state-idle { color: transparent; }

.gauge-svg {
  width: 100%;
  max-width: 620px;
  display: block;
  margin: 4px auto 0;
}
.arc-bg { fill: none; stroke: #242c38; stroke-width: 16; stroke-linecap: round; }
.tolerance-arc {
  fill: none;
  stroke: var(--green-core);
  stroke-width: 16;
  stroke-linecap: round;
  opacity: 0.5;
}
.needle-line {
  stroke: #eef3f9;
  transition: stroke 0.25s ease;
}
.needle-line.needle-in { stroke: var(--green-core); }
.needle-line.needle-warn { stroke: var(--yellow); }
.needle-line.needle-out { stroke: var(--red); }

/* ---------- Control Panel ---------- */
.control-panel { padding: 26px; display: flex; flex-direction: column; gap: 18px; }

.start-btn {
  position: relative;
  width: 100%;
  height: 62px;
  border: 1px solid rgba(88, 189, 56, 0.5);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(139, 220, 106, 0.22) 0%, transparent 52%),
    linear-gradient(180deg, #58BD38 0%, #3a8a22 100%);
  color: #fff;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow:
    0 6px 22px var(--green-glow),
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 -2px 6px rgba(0, 0, 0, 0.25) inset;
  overflow: hidden;
  touch-action: manipulation;
}
.start-btn::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 12%;
  width: 76%;
  height: 42%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.02) 100%);
  pointer-events: none;
}
.start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(88, 189, 56, 0.45), 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 -2px 6px rgba(0, 0, 0, 0.25) inset;
}
.start-btn:active { transform: translateY(1px) scale(0.995); }
.start-btn.running {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 52%),
    linear-gradient(180deg, #2a3442 0%, #1a222e 100%);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pulse-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--red);
  display: none;
  flex-shrink: 0;
}
.running .pulse-dot { display: block; animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.55); }
  50% { opacity: 0.45; box-shadow: 0 0 0 7px rgba(248, 113, 113, 0); }
}

/* ---------- Keyboard ---------- */
.keyboard-block {
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 14px 0px 12px 0px;
}
.octave-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}
.octave-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  touch-action: manipulation;
}
.octave-btn:hover { background: rgba(88, 189, 56, 0.12); border-color: rgba(88, 189, 56, 0.35); }
.octave-btn:active { transform: scale(0.93); }
.octave-label { font-size: 16px; color: var(--text-secondary); min-width: 90px; text-align: center; }
.octave-label strong { color: var(--text); font-size: 20px; }

.piano {
  position: relative;
  display: flex;
  height: 156px;
  touch-action: none;
  user-select: none;
}
.white-key {
  flex: 1;
  background: linear-gradient(180deg, #ffffff 0%, #f2f2f2 60%, #e0e0e0 100%);
  border: 1px solid #b8b8b8;
  border-top: none;
  border-radius: 0 0 9px 9px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 11px;
  font-size: 13px;
  font-weight: 650;
  color: #888;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background 0.08s, transform 0.08s;
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.22);
}
.white-key:active, .white-key.active {
  background: linear-gradient(180deg, #eafff0 0%, #c8f5d5 100%);
  transform: translateY(1px);
}
.black-key {
  position: absolute;
  top: 0;
  height: 62%;
  background: linear-gradient(180deg, #3a404c 0%, #1c2028 72%, #101218 100%);
  border-radius: 0 0 7px 7px;
  z-index: 2;
  cursor: pointer;
  transition: background 0.08s, transform 0.08s;
  box-shadow: 0 4px 7px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.black-key:active, .black-key.active {
  background: linear-gradient(180deg, #58BD38 0%, #3a8a22 100%);
  transform: translateY(1px);
}
.piano.hide-labels .key-label { visibility: hidden; }

.hint {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.7;
  padding: 2px 6px 0;
}

/* ---------- Error ---------- */
.error-box {
  display: none;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.32);
  border-radius: 16px;
  padding: 15px 18px;
  font-size: 14px;
  color: #fca5a5;
  line-height: 1.65;
}
.error-box.show { display: block; }


/* ================= 页脚 ================= */
.footer_note {
  width: 100%;
  text-align: center;
  margin: 28px 0 20px;
  position: relative;
  z-index: 1;
}
.footer_note p {
  color: #a8b4c4;
  line-height: 32px;
  font-size: 14px;
  margin: 0;
}
.footer_note p a, .brand .sub a {
  color: #a8b4c4;
  text-decoration: none;
  transition: color 0.2s;
}
.footer_note p:hover a, .brand .sub a:hover {
  color: #58BD38;
}


/* ---------- Desktop ---------- */
@media (min-width: 940px) {
  body { padding: 34px 44px 56px; }
  .header { margin-bottom: 30px; }
  .brand h1 { font-size: 32px; }
  .brand .sub { font-size: 14px; }
  .main {
    display: grid;
    grid-template-columns: 1.06fr 0.94fr;
    gap: 26px;
    align-items: stretch;
  }
  .gauge-panel { padding: 36px 32px 26px; }
  .note-row { height: 108px; }
  .note-name { font-size: 104px; }
  .note-octave { font-size: 36px; }
  .cents { font-size: 42px; }
  .freq { font-size: 18px; }
  .control-panel { display: flex; flex-direction: column; }
  .keyboard-block { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .piano { height: 196px; }
  .white-key { font-size: 14px; }
  .start-btn { height: 66px; font-size: 20px; }
}

/* ========== 手机端：适度收紧，尽量一屏 ========== */
@media (max-width: 480px) {
  body { padding: 10px 10px 22px 10px; }

  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
  }
  .brand h1 { 
	  font-size: 20px; 
	  background: linear-gradient(180deg, #ffffff 0%, #ffffff 120%);
	  -webkit-background-clip: text;
	  -webkit-text-fill-color: transparent;
	  background-clip: text; 
	  display: none;
  }
  .brand .sub {
    display: block;
    font-size: 14px;
    margin-top: 2px;
    color: var(--text-secondary);
    line-height: 1.35;
  }

  .settings {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    gap: 5px;
    width: 100%;
  }
  .setting-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 4px;
    font-size: 11px;
    border-radius: 9px;
    min-width: 0;
    overflow: hidden;
  }
  .setting-item > span {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 11px;
  }
  .setting-item input[type="number"] {
    width: 44px;
    min-width: 0;
    font-size: 11px;
    padding: 2px 1px;
  }
  .setting-item select {
    min-width: 0;
    font-size: 10px;
    padding: 2px 2px;
    flex: 1;
    max-width: 76px;
  }

  .main { gap: 10px; }

  /* 仪表盘：字号与表盘高度适度收紧 */
  .gauge-panel { padding: 14px 12px 10px; border-radius: 10px; }
  .reading { padding-bottom: 0; }
  .note-row { height: 60px; }
  .note-name { font-size: 42px; }
  .note-octave { font-size: 22px; }
  .freq { font-size: 13.5px; margin-top: 4px; }
  .cents { font-size: 28px; min-height: 34px; margin-top: 6px; }

  .gauge-svg {
    max-height: 128px;
    width: auto;
    max-width: 100%;
    margin: 2px auto 0;
  }

  .control-panel { padding: 12px; gap: 10px; border-radius: 20px; }
  .start-btn { height: 50px; font-size: 16px; border-radius: 13px; }

  .keyboard-block { padding: 8px 0px 6px; border-radius: 14px; }
  .octave-control { margin-bottom: 6px; gap: 12px; }
  .octave-btn { width: 30px; height: 30px; font-size: 16px; border-radius: 9px; }
  .octave-label { font-size: 13px; min-width: 66px; }
  .octave-label strong { font-size: 16px; }

  .piano { height: 140px; }
  .white-key { padding-bottom: 7px; font-size: 12px; border-radius: 0 0 6px 6px; }
  .black-key { border-radius: 0 0 4px 4px; }

  .hint { font-size: 11.5px; line-height: 1.45; padding: 2px 2px 0; }

  .error-box { font-size: 12px; padding: 10px 12px; }
  .footer_note { display: none; }
}
