:root {
  --ink: #1d1c18;
  --muted: #6b6255;
  --paper: #fffdf6;
  --warm: #f4eee0;
  --line: #ded3bd;
  --accent: #0f6b5f;
  --accent-dark: #08483f;
  --accent-soft: #d9eee8;
  --brass: #c88719;
  --reed: #8c3f58;
  --shadow: 0 16px 44px rgb(44 37 25 / 13%);
  font-family:
    Avenir Next,
    Hiragino Sans,
    Yu Gothic,
    Meiryo,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(90deg, rgb(29 28 24 / 4%) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(circle at 18% 5%, rgb(15 107 95 / 12%), transparent 30rem),
    radial-gradient(circle at 80% 18%, rgb(200 135 25 / 13%), transparent 26rem),
    var(--paper);
}

button {
  font: inherit;
}

.app-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 20px 16px calc(122px + env(safe-area-inset-bottom));
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  align-items: stretch;
  min-height: 220px;
  padding: 18px 0 12px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow,
.label,
.section-heading p,
.source-heading p,
.result-meta,
.instrument-list {
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 9em;
  font-size: clamp(2.2rem, 10vw, 4.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.lead {
  max-width: 30rem;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.75;
}

.staff-card {
  position: relative;
  min-height: 200px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 72%), rgb(244 238 224 / 70%)),
    var(--warm);
  box-shadow: var(--shadow);
}

.staff-lines {
  position: absolute;
  inset: 45px 16px auto;
  height: 86px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 15px,
    rgb(29 28 24 / 52%) 15px,
    rgb(29 28 24 / 52%) 17px
  );
}

.staff-card::before {
  position: absolute;
  left: 24px;
  top: 50px;
  color: rgb(29 28 24 / 62%);
  content: "𝄞";
  font-family: Georgia, serif;
  font-size: 5rem;
  line-height: 1;
}

.note-mark {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-weight: 800;
}

.note-text {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.02em;
  line-height: 0.88;
  white-space: nowrap;
}

.note-text .accidental {
  margin-top: 0.02em;
  font-size: 0.68em;
  line-height: 1;
}

.note-mark-main {
  right: 34px;
  top: 74px;
  width: 88px;
  height: 62px;
  transform: rotate(-14deg);
  border: 2px solid var(--ink);
  background: var(--accent);
  color: white;
  font-size: 2rem;
  box-shadow: 8px 8px 0 rgb(29 28 24 / 15%);
}

.note-mark-shadow {
  right: 104px;
  top: 104px;
  width: 48px;
  height: 34px;
  transform: rotate(-14deg);
  border: 2px solid rgb(29 28 24 / 55%);
  background: rgb(200 135 25 / 35%);
}

.source-panel,
.selected-panel {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 253 246 / 86%);
  box-shadow: 0 8px 28px rgb(44 37 25 / 8%);
}

.source-panel {
  flex-direction: column;
  margin: 6px 0 10px;
}

.selected-panel {
  align-items: center;
  margin: 0 0 18px;
}

.source-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.source-heading p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: right;
}

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

.source-key-button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgb(29 28 24 / 18%);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 12px rgb(44 37 25 / 8%);
}

.source-key-button[aria-pressed="true"] {
  border-color: var(--accent-dark);
  background: var(--ink);
  color: white;
}

.selected-panel strong {
  display: block;
  margin-top: 3px;
  font-family: Georgia, serif;
  font-size: 2.8rem;
  line-height: 1;
}

.selected-panel p {
  color: var(--muted);
  line-height: 1.6;
  text-align: right;
}

.label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

h2 {
  font-size: 1.1rem;
}

.section-heading p {
  color: var(--muted);
  font-size: 0.82rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.result-card {
  min-height: 142px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: rgb(255 253 246 / 92%);
  box-shadow: 0 9px 28px rgb(44 37 25 / 8%);
}

.result-card[data-family="brass"] {
  border-left-color: var(--brass);
}

.result-card[data-family="reed"] {
  border-left-color: var(--reed);
}

.result-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.key-name {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.written-note {
  margin: 9px 0 6px;
  font-family: Georgia, serif;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.interval-badge {
  flex: 0 0 auto;
  padding: 5px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.result-meta {
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.45;
}

.instrument-list {
  margin-top: 9px;
  color: var(--ink);
  font-size: 0.83rem;
  line-height: 1.5;
}

.note-pad {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgb(29 28 24 / 16%);
  background: rgb(255 253 246 / 92%);
  backdrop-filter: blur(18px);
  box-shadow: 0 -14px 34px rgb(44 37 25 / 16%);
}

.note-pad-inner {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  width: min(720px, 100%);
  margin: 0 auto;
}

.note-button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgb(29 28 24 / 18%);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 12px rgb(44 37 25 / 8%);
}

.note-button .note-text {
  justify-content: center;
}

.note-button[aria-pressed="true"] {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: white;
  box-shadow: 0 5px 0 var(--accent-dark);
  transform: translateY(-2px);
}

.note-button:focus-visible {
  outline: 3px solid rgb(200 135 25 / 60%);
  outline-offset: 2px;
}

.source-key-button:focus-visible {
  outline: 3px solid rgb(200 135 25 / 60%);
  outline-offset: 2px;
}

@media (max-width: 680px) {
  .app-shell {
    padding-top: 12px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
    padding: 10px 0 8px;
  }

  h1 {
    font-size: 2.05rem;
    line-height: 1;
  }

  .lead {
    margin-top: 8px;
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .staff-card {
    display: none;
  }

  .source-panel,
  .selected-panel {
    align-items: flex-start;
    padding: 12px;
  }

  .source-panel {
    gap: 10px;
    margin-top: 2px;
  }

  .source-heading {
    width: 100%;
  }

  .source-key-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .selected-panel p {
    max-width: 12.5rem;
    font-size: 0.86rem;
  }

  .selected-panel strong {
    font-size: 2.35rem;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-card {
    min-height: 0;
    padding: 13px 14px;
  }

  .written-note {
    font-size: 2.75rem;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .note-pad {
    padding-right: 8px;
    padding-left: 8px;
  }

  .note-pad-inner {
    gap: 6px;
  }

  .note-button {
    min-height: 40px;
    font-size: 1rem;
  }

  .source-key-grid {
    gap: 6px;
  }

  .source-key-button {
    min-height: 40px;
    font-size: 0.92rem;
  }
}
