:root {
  --bg: #eef4f2;
  --panel: #ffffff;
  --ink: #14201c;
  --muted: #64736e;
  --line: #d8e3df;
  --accent: #0f766e;
  --accent-strong: #0a5e58;
  --danger: #b42318;
  --ok: #15803d;
  --warn: #b45309;
  --shadow: 0 18px 45px rgba(20, 35, 30, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.09), rgba(15, 118, 110, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 9px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button:focus-visible,
a:focus-visible,
.keyboard:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.secondary-button {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.test-app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.test-header,
.section-title,
.button-row,
.song-panel,
.keyboard-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.test-header {
  padding: 10px 0 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand h1,
.brand p,
.section-title h2,
.section-title p,
.song-panel p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(22px, 4vw, 34px);
  line-height: 1.05;
}

.brand p,
.section-title p,
.hint,
.song-panel p,
.keyboard-stats {
  color: var(--muted);
}

.status-pill,
.result-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.is-ok,
.result-chip.is-ok {
  border-color: #b9d9d4;
  background: #e8f5f3;
  color: var(--accent-strong);
}

.status-pill.is-error,
.result-chip.is-error {
  border-color: #f0b4ae;
  background: #fff5f3;
  color: var(--danger);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.quick-grid a,
.quick-grid button {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  padding: 9px 12px;
  font: inherit;
  font-weight: 850;
  text-decoration: none;
}

.test-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.test-card + .test-card {
  margin-top: 12px;
}

.section-title {
  margin-bottom: 12px;
}

.section-title h2 {
  font-size: 21px;
}

.camera-frame {
  display: grid;
  position: relative;
  place-items: center;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17211d;
}

.camera-frame video {
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: cover;
}

.camera-frame p {
  position: absolute;
  max-width: 280px;
  margin: 0;
  color: #dbe2df;
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
}

.button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 10px;
}

.hint {
  margin: 9px 0 0;
  font-size: 13px;
  line-height: 1.35;
}

.hint.is-error {
  color: var(--danger);
  font-weight: 750;
}

.meter {
  height: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f5f7f6;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #22c55e);
  transition: width 0.08s linear;
}

.audio-player {
  width: 100%;
  margin-top: 10px;
}

.tone-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.tone-grid button.is-active {
  border-color: var(--accent);
  background: #e8f5f3;
  color: var(--accent-strong);
}

.song-panel {
  align-items: center;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 10px;
}

.song-panel strong {
  display: block;
  margin-bottom: 2px;
}

.youtube-frame {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  background: #17211d;
}

.youtube-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.keyboard-card {
  margin-bottom: 20px;
}

.keyboard-stats {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 800;
}

.keyboard {
  display: grid;
  gap: 7px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  padding: 10px;
}

.keyboard-row {
  display: grid;
  grid-template-columns: repeat(30, minmax(18px, 1fr));
  gap: 6px;
  min-width: 760px;
}

.key {
  display: grid;
  place-items: center;
  min-height: 42px;
  grid-column: span 2;
  border: 1px solid #cbd8d3;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 4px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.05;
  text-align: center;
  user-select: none;
}

.key.is-pressed {
  border-color: var(--accent);
  background: #e8f5f3;
  color: var(--accent-strong);
  box-shadow: inset 0 -2px 0 rgba(15, 118, 110, 0.2);
}

.key.is-current {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 1px;
}

.key[data-size="3"] {
  grid-column: span 3;
}

.key[data-size="4"] {
  grid-column: span 4;
}

.key[data-size="5"] {
  grid-column: span 5;
}

.key[data-size="6"] {
  grid-column: span 6;
}

.key[data-size="8"] {
  grid-column: span 8;
}

.key[data-size="10"] {
  grid-column: span 10;
}

@media (max-width: 760px) {
  .test-header,
  .section-title,
  .song-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill,
  .result-chip {
    align-self: flex-start;
  }

  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tone-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row button,
  .song-panel button {
    width: 100%;
  }

  .camera-frame,
  .camera-frame video {
    min-height: 220px;
  }
}
