/* =============================================================================
 *  Precision Tuner —— 样式
 *  浅色主题 · 白底卡片 · 蓝色主色 · 咨询报告级排版
 * ========================================================================== */

:root {
  --bg:          #FAFAFA;
  --card:        #FFFFFF;
  --ink:         #0F172A;
  --ink-2:       #475569;
  --ink-3:       #94A3B8;
  --line:        #E8EBF0;
  --line-soft:   #F1F3F7;

  --primary:     #2563EB;
  --primary-ink: #1D4ED8;
  --primary-soft:#EFF5FF;

  --green-soft:  #E9F8EF;
  --green-line:  #A7E0BE;
  --blue:        #3B82F6;
  --red:         #DC2626;

  --radius:      18px;
  --radius-sm:   11px;
  --shadow:      0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .055);
  --shadow-sm:   0 1px 2px rgba(15, 23, 42, .05);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 26px 48px;
}

/* ============================ HEADER ==================================== */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 22px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.hero-brand { display: flex; align-items: center; gap: 15px; }

.logo {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(160deg, var(--primary) 0%, #4F87F5 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .28);
  flex: none;
}
.logo svg { width: 26px; height: 26px; }

.hero-text h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.hero-text p {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--ink-2);
  letter-spacing: .01em;
}

.hero-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.tag-live { color: var(--primary-ink); background: var(--primary-soft); border-color: #D6E4FF; }

/* ============================ LAYOUT ==================================== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(340px, 0.94fr);
  gap: 22px;
  align-items: start;
}

.side { display: flex; flex-direction: column; gap: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 22px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.hint {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-3);
}
.hint-center { text-align: center; }

/* ============================ 表盘卡片 ================================== */
.dial-card {
  transition: background-color 95ms ease,
              border-color 95ms ease,
              box-shadow 95ms ease;
}
.dial-card.in-tune {
  background: var(--green-soft);
  border-color: var(--green-line);
  box-shadow: 0 1px 2px rgba(22, 163, 74, .06), 0 14px 38px rgba(22, 163, 74, .16);
}

.status-pill {
  font-size: 12px;
  font-weight: 650;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--line-soft);
  color: var(--ink-2);
  white-space: nowrap;
  transition: color 95ms ease, background-color 95ms ease, border-color 95ms ease;
}
.status-pill[data-state="listen"] { color: var(--primary-ink); background: var(--primary-soft); border-color: #D6E4FF; }
.status-pill[data-state="flat"]   { color: #1D4ED8; background: #EFF5FF; border-color: #CFE0FF; }
.status-pill[data-state="sharp"]  { color: #B91C1C; background: #FEF2F2; border-color: #FBD5D5; }
.status-pill[data-state="tuned"]  { color: #15803D; background: #DCFCE7; border-color: #A7E0BE; }

.gauge-wrap {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  /* 与表盘实际包围盒一致（2.20R × 1.88R ≈ 1.17:1），
     既保证 240° 扇形完整不被裁切，也不留多余空白 */
  aspect-ratio: 2.20 / 1.88;
}
.gauge { display: block; width: 100%; height: 100%; }

.dial-legend {
  display: flex;
  justify-content: space-between;
  max-width: 520px;
  margin: 6px auto 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}
.legend-flat  { color: var(--blue); }
.legend-mid   { color: var(--ink-2); }
.legend-sharp { color: var(--red); }

.dial-hint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.6;
}

/* ============================ 读数 ====================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.stat {
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 10px 11px;
  text-align: center;
  min-width: 0;
}
.stat-label { display: block; font-size: 11px; color: var(--ink-3); font-weight: 600; }
.stat-value {
  display: block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-unit { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }

.meter-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.meter-label { font-size: 11.5px; color: var(--ink-3); font-weight: 600; flex: none; }
.meter {
  position: relative;
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #60A5FA, var(--primary));
  transition: width 70ms linear;
}
.meter-gate {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: var(--ink-3);
  opacity: .55;
  border-radius: 2px;
}

/* ============================ 控件 ====================================== */
.select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink);
  background: #fff
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%2394A3B8' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 34px 10px 13px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.select:hover { border-color: #CBD5E1; }
.select:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .14); }
.select-sm { width: auto; min-width: 168px; padding-top: 7px; padding-bottom: 7px; font-size: 12.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all .13s ease;
}
.chip:hover { border-color: #CBD5E1; background: #FCFCFD; transform: translateY(-1px); }
.chip-idx { font-size: 10.5px; color: var(--ink-3); font-weight: 700; }
.chip-name { font-family: var(--mono); font-size: 14px; color: var(--ink); font-weight: 700; }
.chip-freq { font-size: 10.5px; color: var(--ink-3); font-family: var(--mono); }
.chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.chip.active .chip-name { color: var(--primary-ink); }
.chip.tuned {
  border-color: var(--green-line);
  background: var(--green-soft);
  color: #15803D;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .12);
}
.chip.tuned .chip-name { color: #15803D; }
.chip-empty { cursor: default; background: var(--line-soft); }
.chip-empty:hover { transform: none; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: none; }
.row > label { font-size: 13px; color: var(--ink-2); font-weight: 550; flex: none; }
.row-control { display: flex; align-items: center; gap: 10px; justify-content: flex-end; min-width: 0; }

.out {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 650;
  color: var(--ink);
  min-width: 74px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 168px;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 999px; background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .18);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .18);
}
input[type="range"]:focus-visible { outline: none; }
.vol { max-width: 96px; }

.switch { display: inline-flex; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 42px; height: 24px;
  border-radius: 999px;
  background: #DDE2E9;
  display: block;
  position: relative;
  transition: background-color .16s ease;
}
.switch-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .22);
  transition: transform .16s cubic-bezier(.3, 1.4, .5, 1);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }

/* ============================ 操作区 ==================================== */
.actions { display: flex; flex-direction: column; gap: 11px; padding-top: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .01em;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 13px;
  padding: 14px 20px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .26);
  transition: transform .12s ease, box-shadow .16s ease, background-color .16s ease;
}
.btn:hover:not(:disabled) { background: var(--primary-ink); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: 0 3px 10px rgba(37, 99, 235, .22); }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .3); }

.btn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  flex: none;
  transition: background-color .2s ease, box-shadow .2s ease;
}
.btn.running { background: var(--ink); box-shadow: 0 6px 18px rgba(15, 23, 42, .22); }
.btn.running .btn-dot { background: #4ADE80; box-shadow: 0 0 0 4px rgba(74, 222, 128, .22); }

/* ============================ FOOTER ==================================== */
.foot {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.foot h4 {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.foot ol, .foot ul { margin: 0; padding-left: 18px; }
.foot li { font-size: 12.5px; line-height: 1.85; color: var(--ink-2); }

/* ============================ TOAST ===================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 14px);
  max-width: min(560px, calc(100vw - 40px));
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.5;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #B42318; }

/* ============================ 响应式 ==================================== */
@media (max-width: 940px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .app { padding: 24px 18px 40px; }
  .hero { gap: 14px; }
}

@media (max-width: 520px) {
  .app { padding: 18px 14px 32px; }
  .card { padding: 17px 16px 19px; border-radius: 15px; }
  .hero-text h1 { font-size: 21px; }
  .gauge-wrap { max-width: 100%; }
  .dial-legend { max-width: 100%; }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .stat { padding: 10px 6px 9px; }
  .stat-value { font-size: 16px; }
  .row { flex-direction: column; align-items: flex-start; gap: 7px; }
  .row-control { width: 100%; justify-content: space-between; }
  .out { min-width: 66px; }
  .foot { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
