:root {
  --ink: #2a1a20;
  --ink-soft: #6e545c;
  --bg: #f7f0ea;
  --panel: #fffaf6;
  --panel-2: #ffffff;
  --wine: #7a1f3d;
  --wine-deep: #5a142c;
  --wine-soft: rgba(122, 31, 61, 0.12);
  --line: rgba(122, 31, 61, 0.22);
  --cyan: #7a1f3d;
  --cyan-deep: #5a142c;
  --gold: #c45c2a;
  --ok: #2e7d4f;
  --warn: #e0b000;
  --hot: #e15a38;
  --danger: #7b3fb8;
  --shadow: 0 16px 36px rgba(90, 20, 44, 0.1);
  --radius: 20px;
  --header-h: 4.25rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
  font-size: 18px;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(122, 31, 61, 0.12), transparent 42%),
    radial-gradient(circle at 92% 8%, rgba(196, 92, 42, 0.1), transparent 40%),
    linear-gradient(180deg, #fffaf6 0%, var(--bg) 46%, #efe2d8 100%);
  line-height: 1.65;
}

#main {
  flex: 1 0 auto;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select {
  font-family: inherit;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 200;
  padding: 0.5rem 0.85rem;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
}

.skip-link:focus {
  top: calc(var(--safe-top) + 0.6rem);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--header-h);
  padding: calc(0.55rem + var(--safe-top)) 11.5rem 0.55rem 1rem;
  background: rgba(255, 250, 246, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.brand-text strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 800;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.mute-btn {
  border: 2px solid var(--wine);
  background: #fff;
  color: var(--wine);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 4px 0 var(--wine-deep);
  transform: translateY(-1px);
}

.mute-btn:hover {
  background: var(--wine-soft);
}

.mute-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--wine-deep);
}

.mute-btn[aria-pressed="true"] {
  background: var(--hot);
  border-color: #b33d22;
  color: #fff;
  box-shadow: 0 4px 0 #8a2a16;
}

.layout {
  width: min(1100px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.1rem 0 calc(2rem + var(--safe-bottom));
}

.hero {
  text-align: center;
  margin-bottom: 1rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  font-weight: 900;
  color: var(--wine);
}

.hero .lead {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.tablist-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem 1rem;
  padding: 0.15rem 0.25rem 0.35rem;
}

.tablist {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: min-content;
}

.tab {
  flex: 0 0 auto;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0.55rem 1.05rem;
  border-radius: 14px;
  cursor: pointer;
  min-height: 46px;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(122, 31, 61, 0.12);
  transition: transform 0.15s var(--ease), box-shadow 0.15s, background 0.15s, color 0.15s;
}

.tab:hover {
  transform: translateY(-2px);
  border-color: var(--wine);
  color: var(--wine);
}

.tab[aria-selected="true"] {
  background: linear-gradient(180deg, #9a2a4e, var(--wine-deep));
  color: #fff;
  border-color: var(--wine-deep);
  box-shadow: 0 5px 0 #3d0c1c, 0 10px 18px rgba(90, 20, 44, 0.22);
}

.tab[data-tab="recap"][aria-selected="true"] {
  background: linear-gradient(180deg, #d4783a, #c45c2a);
  border-color: #8a3a16;
  box-shadow: 0 5px 0 #8a3a16, 0 10px 18px rgba(196, 92, 42, 0.22);
}

.panel {
  display: none;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.15rem 1.4rem;
}

.panel.is-active {
  display: block;
}

.panel[hidden] {
  display: none !important;
}

.panel h2 {
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
  color: var(--cyan);
}

.principle {
  margin: 0.65rem auto 1rem;
  max-width: 42rem;
  text-align: center;
  color: var(--ink-soft);
}

.principle strong {
  color: var(--gold);
}

.sim-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
  align-items: stretch;
}

.sim-card,
.observe,
.control-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem;
}

.sim-card h3,
.observe h3,
.control-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  color: var(--gold);
}

.observe {
  margin-top: 1rem;
}

.observe p {
  margin: 0;
  min-height: 3.2em;
}

.wave-wrap {
  position: relative;
  background: #f8efe8;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}

#wave-canvas,
#db-canvas,
#medium-canvas {
  display: block;
  width: 100%;
  height: 180px;
}

.heard-meter {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.7rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.heard-bar {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: #e4ddd2;
  overflow: hidden;
}

.heard-bar > span {
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--cyan-deep), var(--cyan));
  border-radius: inherit;
}

.instrument-scene {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 0.8rem 0.5rem;
  background: #f8efe8;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.scene-caption {
  margin: 0.45rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.drum-wrap {
  text-align: center;
}

.glass-wrap {
  text-align: center;
}

.glass {
  width: 72px;
  height: 92px;
  margin: 0 auto;
  border: 3px solid rgba(122, 31, 61, 0.55);
  border-top: 4px solid rgba(122, 31, 61, 0.78);
  border-radius: 8px 8px 18px 18px;
  background: linear-gradient(180deg, rgba(255, 220, 230, 0.42), rgba(122, 31, 61, 0.16));
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.35);
  transform-origin: center bottom;
}

.glock-wrap {
  text-align: center;
  width: 90%;
}

.glock {
  --bar-tall: 72px;
  height: var(--bar-tall);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 7px;
}

.glock span {
  width: 16px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #f3e2a0, #c48a00);
  box-shadow: 0 2px 0 #8a6200;
}

.glock span:nth-child(1) { height: 58%; }
.glock span:nth-child(2) { height: 70%; }
.glock span:nth-child(3) { height: 82%; }
.glock span:nth-child(4) { height: 92%; }
.glock span:nth-child(5) { height: 100%; }

.guitar {
  width: 80%;
  height: 110px;
  position: relative;
}

.guitar-body {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #8d4a24;
  box-shadow: inset 0 0 0 10px #6b3518;
}

.guitar-neck {
  position: absolute;
  left: 0;
  bottom: 28px;
  height: 14px;
  width: 70%;
  background: #c48a4a;
  border-radius: 4px;
}

.guitar-string {
  position: absolute;
  left: 0;
  right: 18px;
  height: 2px;
  background: #eee;
  bottom: 34px;
  box-shadow: 0 6px 0 #ddd, 0 -6px 0 #ccc;
}

.drum {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff6, #d9c7a2 42%, #8a6a3a);
  border: 8px solid #4a3318;
  box-shadow: inset 0 0 0 6px #c9a56a;
}

.controls {
  display: grid;
  gap: 0.85rem;
}

.slider-row label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.slider-row input[type="range"] {
  --fill: 50%;
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      #9a2a4e 0%,
      var(--wine) var(--fill),
      #ead9d0 var(--fill),
      #ead9d0 100%
    );
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: inset 0 2px 5px rgba(90, 20, 44, 0.18);
  cursor: pointer;
}

.slider-row input[type="range"]:focus-visible {
  box-shadow: inset 0 2px 5px rgba(90, 20, 44, 0.18), 0 0 0 3px rgba(122, 31, 61, 0.28);
}

.slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 18px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      #9a2a4e 0%,
      var(--wine) var(--fill),
      #ead9d0 var(--fill),
      #ead9d0 100%
    );
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -7px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #c44a6a, var(--wine-deep));
  cursor: grab;
  border: 3px solid #fff;
  box-shadow: 0 3px 0 var(--wine-deep), 0 7px 14px rgba(90, 20, 44, 0.3);
}

.slider-row input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.08);
}

.slider-row input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(0.96);
  box-shadow: 0 1px 0 var(--wine-deep), 0 3px 8px rgba(90, 20, 44, 0.28);
}

.slider-row input[type="range"]::-moz-range-track {
  height: 18px;
  border-radius: 999px;
  background: #ead9d0;
  box-shadow: inset 0 2px 5px rgba(90, 20, 44, 0.18);
}

.slider-row input[type="range"]::-moz-range-progress {
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, #9a2a4e, var(--wine));
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #c44a6a, var(--wine-deep));
  cursor: grab;
  border: 3px solid #fff;
  box-shadow: 0 3px 0 var(--wine-deep), 0 7px 14px rgba(90, 20, 44, 0.3);
}

.chip-row,
.preset-row,
.scene-row,
.method-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.preset,
.scene-btn,
.method-btn,
.medium-btn {
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  padding: 0.5rem 0.95rem;
  border-radius: 14px;
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 3px 0 rgba(122, 31, 61, 0.16);
  transform: translateY(-1px);
  transition: transform 0.12s var(--ease), box-shadow 0.12s, background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover,
.preset:hover,
.scene-btn:hover,
.method-btn:hover,
.medium-btn:hover {
  transform: translateY(-3px);
  border-color: var(--wine);
  color: var(--wine);
}

.chip:active,
.preset:active,
.scene-btn:active,
.method-btn:active,
.medium-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 transparent;
}

.chip.is-on,
.scene-btn.is-on,
.method-btn.is-on,
.medium-btn.is-on {
  background: linear-gradient(180deg, #9a2a4e, var(--wine-deep));
  color: #fff;
  border-color: var(--wine-deep);
  box-shadow: 0 4px 0 #3d0c1c, 0 8px 14px rgba(90, 20, 44, 0.22);
}

.chip.is-on:hover,
.scene-btn.is-on:hover,
.method-btn.is-on:hover,
.medium-btn.is-on:hover {
  color: #fff;
}

.chip:focus-visible,
.preset:focus-visible,
.scene-btn:focus-visible,
.method-btn:focus-visible,
.medium-btn:focus-visible,
.listen-btn:focus-visible,
.knock-btn:focus-visible,
.tab:focus-visible,
.mute-btn:focus-visible {
  outline: 3px solid rgba(122, 31, 61, 0.45);
  outline-offset: 2px;
}

.listen-btn,
.knock-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  min-height: 52px;
  font-size: 1.08rem;
  font-weight: 900;
  cursor: pointer;
  color: #fff;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #9a2a4e, var(--wine-deep));
  box-shadow: 0 6px 0 #3d0c1c, 0 12px 20px rgba(90, 20, 44, 0.25);
  transform: translateY(-1px);
  transition: transform 0.12s var(--ease), box-shadow 0.12s, filter 0.12s;
}

.listen-btn:hover,
.knock-btn:hover {
  filter: brightness(1.06);
}

.listen-btn:active,
.knock-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #3d0c1c;
}

.listen-btn.is-on {
  background: linear-gradient(180deg, #d4783a, #c45c2a);
  box-shadow: 0 6px 0 #8a3a16, 0 12px 20px rgba(196, 92, 42, 0.28);
}

.db-readout {
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold);
  margin: 0.2rem 0 0.4rem;
}

.db-band {
  text-align: center;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.thresholds {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.4rem 0 0.8rem;
}

.thresholds span {
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(36, 48, 56, 0.06);
  color: var(--ink-soft);
}

.thresholds span.is-hit-70 { color: #111; background: var(--warn); }
.thresholds span.is-hit-85 { color: #111; background: var(--hot); }
.thresholds span.is-hit-120 { color: #fff; background: #7b3fb8; }

.scene-btn {
  text-align: left;
}

.scene-btn small {
  display: block;
  font-weight: 600;
  opacity: 0.8;
}

.medium-stage {
  position: relative;
}

.medium-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.45rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.knock-btn {
  margin-top: 0.7rem;
}

.why-box {
  margin-top: 0.85rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1px dashed rgba(255, 204, 0, 0.45);
  background: rgba(255, 204, 0, 0.08);
}

.why-box h3 {
  margin: 0 0 0.35rem;
  color: var(--gold);
  font-size: 1rem;
}

.why-box p {
  margin: 0;
  color: var(--ink);
}

.speed-pips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-top: 0.7rem;
  text-align: center;
  font-size: 0.82rem;
}

.speed-pips b {
  display: block;
  color: var(--cyan);
}

.scenario-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0.8rem;
}

.method-btn {
  border-radius: 14px;
}

.method-btn.is-fit {
  box-shadow: 0 0 0 2px var(--gold);
}

.method-btn:not(.is-fit) {
  opacity: 0.72;
}

.recap-list {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: recap;
}

.recap-list li {
  counter-increment: recap;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.95rem 1rem 0.95rem 3.4rem;
  position: relative;
}

.recap-list li::before {
  content: counter(recap);
  position: absolute;
  left: 0.85rem;
  top: 0.95rem;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: linear-gradient(180deg, #9a2a4e, var(--wine-deep));
  color: #fff;
}

.site-footer {
  padding: 1rem 1.2rem calc(1rem + var(--safe-bottom));
  text-align: center;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

.site-footer a {
  color: var(--cyan);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 800px) {
  .sim-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    padding-right: 6.5rem;
  }

  .brand-text strong {
    font-size: 0.86rem;
  }
}

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .panel {
    padding: 1rem 0.8rem 1.15rem;
  }

  #wave-canvas,
  #db-canvas,
  #medium-canvas {
    height: 180px;
  }

  .speed-pips {
    grid-template-columns: 1fr 1fr;
  }
}
