/* ============================================================
   弦韵调音台 · 全尺寸无边框极简拟物样式
   ============================================================ */

:root {
  --wood-dark: #16110e;
  --text-main: #f7f0e4;
  --text-sub: #bfb3a3;
  --text-dim: #8a7e70;

  --brass: #d9aa52;
  --brass-bright: #f2cc7c;

  --good: #2ecc71;
  --warn: #f5a623;
  --off: #ff5e4d;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse at 25% 0%, rgba(112, 68, 32, 0.26), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(88, 52, 24, 0.2), transparent 50%),
    repeating-linear-gradient(
      90deg,
      rgba(255, 224, 180, 0.012) 0px,
      rgba(255, 224, 180, 0.012) 2px,
      transparent 2px,
      transparent 14px
    ),
    var(--wood-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100%;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------------- 乐器选择页 ---------------- */

#selection-view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.hero {
  text-align: center;
  max-width: 600px;
  margin: 0 auto 24px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 3vw, 2.1rem);
  font-weight: 800;
}

.hero-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-sub);
}

.instrument-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px;
}

.inst-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 12px 16px;
  border-radius: 16px;
  background: rgba(46, 36, 29, 0.55);
  transition: transform 0.18s ease, background 0.18s ease;
}

.inst-card:hover {
  transform: translateY(-3px);
  background: rgba(62, 48, 38, 0.78);
}

.inst-thumb-stage {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #3a2d22, #17120e);
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}

.inst-thumb-stage svg {
  width: 84px;
  height: 84px;
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.45));
}

.inst-card h2 {
  margin: 0 0 5px;
  font-size: 1.08rem;
  font-weight: 750;
}

.inst-card p {
  margin: 0 0 12px;
  font-size: 0.78rem;
  color: var(--text-sub);
  flex: 1;
}

.inst-cta {
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(217, 170, 82, 0.16);
  color: var(--brass-bright);
  font-size: 0.8rem;
  font-weight: 650;
}

/* ---------------- 调音工作台（全尺寸无边框） ---------------- */

#tuner-view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.studio-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  align-items: center;
  min-height: 100dvh;
}

.instrument-stage-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px 16px;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.stage-title-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.stage-title-row h2 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 750;
}

.btn-back-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: 9px;
  background: rgba(255, 236, 204, 0.08);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-back-mini:hover {
  background: rgba(217, 170, 82, 0.22);
}

.stage-legend {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--text-sub);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-gold { background: var(--brass-bright); box-shadow: 0 0 6px var(--brass); }
.dot-red { background: var(--off); box-shadow: 0 0 6px var(--off); }
.dot-green { background: var(--good); box-shadow: 0 0 6px var(--good); }

.instrument-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.inst-svg {
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 76px);
  display: block;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------- 拟物 SVG 交互高亮与动画 ---------------- */

.string-group:hover .string-line {
  stroke: #ffe5a3;
  filter: drop-shadow(0 0 5px rgba(255, 215, 115, 0.7));
}

.string-group.is-selected .string-line {
  stroke: #ffd470 !important;
  filter: drop-shadow(0 0 7px rgba(255, 209, 102, 0.9));
}

.string-group.is-selected .string-pill rect {
  fill: #d9aa52;
  stroke: #fff1cc;
}

.string-group.is-selected .string-pill text {
  fill: #1b130a;
}

.peg-group.is-selected .peg-head {
  stroke: #ffd470;
  stroke-width: 3;
  filter: drop-shadow(0 0 9px rgba(255, 209, 102, 0.85));
}

.fine-tuner.is-selected {
  fill: #ffd470;
  filter: drop-shadow(0 0 7px rgba(255, 209, 102, 0.95));
}

.yq-note-group:hover .yq-dot-bg {
  fill: #47331a;
  stroke: #ffd470;
  stroke-width: 2.2;
}

.yq-note-group.is-selected .yq-dot-bg {
  fill: #d9aa52;
  stroke: #fff4d6;
  stroke-width: 2.4;
  filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.85));
}

.yq-note-group.is-selected .yq-label {
  fill: #1a1209;
}

.yq-note-group.is-selected .yq-course-line {
  stroke: rgba(255, 212, 112, 0.75);
  stroke-width: 2.4;
}

.gz-string-group.is-selected .gz-bridge polygon {
  fill: #d9aa52;
  stroke: #fff2cc;
  stroke-width: 1.8;
  filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.9));
}

.status-good .string-line,
.status-good .yq-course-line {
  stroke: #2ecc71 !important;
  filter: drop-shadow(0 0 9px rgba(46, 204, 113, 0.95)) !important;
}
.status-good .peg-head,
.status-good .yq-dot-bg,
.status-good .gz-bridge polygon {
  stroke: #2ecc71 !important;
  fill: #1e7d46 !important;
  filter: drop-shadow(0 0 10px rgba(46, 204, 113, 0.9)) !important;
}
.status-good .yq-label { fill: #ffffff !important; }

.status-warn .string-line,
.status-warn .yq-course-line {
  stroke: #f5a623 !important;
  filter: drop-shadow(0 0 8px rgba(245, 166, 35, 0.9)) !important;
}
.status-warn .peg-head,
.status-warn .yq-dot-bg,
.status-warn .gz-bridge polygon {
  stroke: #f5a623 !important;
  filter: drop-shadow(0 0 9px rgba(245, 166, 35, 0.85)) !important;
}

.status-off .string-line,
.status-off .yq-course-line {
  stroke: #ff5e4d !important;
  filter: drop-shadow(0 0 8px rgba(255, 94, 77, 0.9)) !important;
}
.status-off .peg-head,
.status-off .yq-dot-bg,
.status-off .gz-bridge polygon {
  stroke: #ff5e4d !important;
  filter: drop-shadow(0 0 9px rgba(255, 94, 77, 0.9)) !important;
}

.is-plucking .string-line {
  animation: string-vibrate 0.42s ease-out;
}

@keyframes string-vibrate {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-2.6px); }
  30%  { transform: translateX(2.4px); }
  45%  { transform: translateX(-1.8px); }
  60%  { transform: translateX(1.3px); }
  75%  { transform: translateX(-0.7px); }
  100% { transform: translateX(0); }
}

.gz-string-group.is-plucking .string-line {
  animation: string-vibrate-y 0.42s ease-out;
}

@keyframes string-vibrate-y {
  0%   { transform: translateY(0); }
  15%  { transform: translateY(-2.4px); }
  30%  { transform: translateY(2.2px); }
  45%  { transform: translateY(-1.5px); }
  60%  { transform: translateY(1px); }
  100% { transform: translateY(0); }
}

.yq-note-group.is-plucking .yq-ripple {
  animation: hammer-ripple 0.65s ease-out;
}

@keyframes hammer-ripple {
  0%   { r: 14; opacity: 0.95; stroke-width: 3; }
  100% { r: 34; opacity: 0; stroke-width: 0.6; }
}

/* ---------------- 调音控制区（无边框） ---------------- */

.control-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 16px 24px 16px 8px;
}

.console-card {
  padding: 0;
}

.meter-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 650;
  margin-bottom: 8px;
}

.scale-flat { color: #ff8c7a; }
.scale-ok { color: var(--good); }
.scale-sharp { color: #ff8c7a; }

.tuner-meter-wrap {
  background: rgba(12, 9, 7, 0.72);
  border-radius: 12px;
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.65);
  padding: 6px 8px;
}

#tuner-meter {
  width: 100%;
  height: auto;
  display: block;
}

.btn-mic-physical {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, #e5b863 0%, #b37f2a 100%);
  color: #1b1207;
  font-size: 0.98rem;
  font-weight: 800;
  box-shadow:
    inset 0 2px 1px rgba(255, 248, 224, 0.5),
    0 6px 18px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s, filter 0.15s;
}

.btn-mic-physical:hover { filter: brightness(1.06); }
.btn-mic-physical:active { transform: translateY(1px); }
.btn-mic-physical:disabled { opacity: 0.7; cursor: wait; }

.btn-mic-physical.active {
  background: linear-gradient(180deg, #e05a4d 0%, #a82e24 100%);
  color: #ffffff;
  box-shadow:
    inset 0 1px 1px rgba(255, 210, 200, 0.35),
    0 6px 18px rgba(200, 50, 40, 0.38);
}

.mic-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4e3b1f;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.btn-mic-physical.active .mic-led {
  background: #72ff9f;
  box-shadow: 0 0 10px #2ecc71;
  animation: led-blink 1.4s ease-in-out infinite;
}

@keyframes led-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.mic-error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 94, 77, 0.16);
  color: #ffc2ba;
  font-size: 0.82rem;
  line-height: 1.65;
}

.mic-hint { margin: 10px 0 0; color: var(--text-muted, #c7bba8); font-size: 0.76rem; line-height: 1.6; }
.mic-error p { margin: 6px 0; }
.mic-error ol { margin: 8px 0 12px; padding-left: 1.5em; }
.mic-error li + li { margin-top: 6px; }
.btn-copy-site { padding: 8px 12px; border-radius: 8px; color: #ffe1aa; background: rgba(229, 184, 99, 0.14); font-size: inherit; }
.site-address { display: block; width: 100%; min-width: 0; margin-top: 8px; padding: 8px; border: 1px solid rgba(255, 194, 186, 0.25); border-radius: 6px; color: inherit; background: rgba(0, 0, 0, 0.15); font-size: 16px; }

/* ---------------- 竖屏 / 窄屏自适应 ---------------- */

@media (max-width: 760px) and (orientation: portrait), (max-width: 560px) {
  .studio-layout {
    display: flex;
    flex-direction: column;
  }

  .instrument-stage-card {
    flex: 1;
    padding: 10px 10px 4px;
  }

  .inst-svg {
    max-height: calc(100dvh - 210px);
  }

  .control-column {
    gap: 10px;
    padding: 10px 14px 14px;
    background: rgba(18, 13, 10, 0.72);
  }

  #tuner-meter {
    max-height: 60px;
  }

  .btn-mic-physical {
    padding: 13px 16px;
  }
}

/* ---------------- 手机横屏紧凑自适应 ---------------- */

@media (max-height: 500px) and (orientation: landscape) {
  .studio-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr);
  }

  .instrument-stage-card {
    padding: 8px 10px;
  }

  .inst-svg {
    max-height: calc(100dvh - 52px);
  }

  .control-column {
    gap: 10px;
    padding: 10px 14px 10px 4px;
  }

  .btn-mic-physical {
    padding: 11px 14px;
    font-size: 0.9rem;
  }
}
