:root {
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-soft: #f9f9ff;
  --text: #121832;
  --muted: #667085;
  --border: #e4e7ef;
  --primary: #6557e8;
  --primary-dark: #5144d3;
  --primary-soft: #efedff;
  --success: #14805e;
  --danger: #c13a4b;
  --shadow: 0 20px 60px rgba(40, 46, 85, .07);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 50% -10%, rgba(101,87,232,.08), transparent 31rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(101,87,232,.22);
  outline-offset: 2px;
}

.site-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 64px);
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.02em;
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-size: 22px;
  transform: rotate(-7deg);
}
.github-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: white;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}
.github-button:hover { border-color: #c8cddd; background: #fafbff; }
.github-button svg { width: 18px; height: 18px; fill: currentColor; }

main { width: min(1460px, calc(100% - 36px)); margin: 0 auto; }
.hero { text-align: center; padding: 46px 20px 28px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: -.045em;
}
.hero-copy {
  max-width: 760px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, .74fr) minmax(560px, 1.26fr);
  gap: 20px;
  align-items: start;
}
.panel {
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.input-panel { padding: 24px; position: sticky; top: 92px; }
.panel-heading { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 22px; }
.panel-heading h2 { margin: 1px 0 5px; font-size: 19px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.step {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; flex: 0 0 auto;
}
.field-label { display: block; font-size: 13px; font-weight: 800; margin: 0 0 8px; }
.note-input-wrap { position: relative; }
.note-input-wrap input {
  width: 100%;
  height: 52px;
  padding: 0 44px 0 15px;
  border: 1px solid #cfd4e1;
  border-radius: 12px;
  background: white;
  color: var(--text);
  font-size: 17px;
  box-shadow: inset 0 1px 0 rgba(16,24,40,.02);
}
.note-input-wrap input:focus { border-color: var(--primary); }
.icon-button {
  position: absolute; right: 7px; top: 7px; width: 38px; height: 38px;
  border: 0; background: transparent; color: #7d8496; border-radius: 9px; font-size: 22px;
}
.icon-button:hover { background: #f0f1f6; }
.field-help { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.error-message { min-height: 18px; margin: 5px 0 0; color: var(--danger); font-size: 12px; font-weight: 700; }

.piano-section { margin-top: 14px; }
.piano-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.text-button { border: 0; background: transparent; color: var(--primary); font-size: 12px; font-weight: 800; padding: 4px; }
.piano {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  height: 138px;
  margin-top: 2px;
  border: 1px solid #d7dbe7;
  border-radius: 13px;
  background: #d7dbe7;
  overflow: hidden;
}
.key { border: 0; }
.white-key {
  position: relative;
  background: linear-gradient(#fff, #f8f9fc);
  border-right: 1px solid #d7dbe7;
  color: #555d73;
}
.white-key:last-of-type { border-right: 0; }
.white-key span { position: absolute; left: 0; right: 0; bottom: 9px; font-size: 12px; font-weight: 700; }
.white-key.active { background: linear-gradient(#efedff, #ded9ff); color: var(--primary-dark); }
.black-key {
  position: absolute;
  z-index: 3;
  top: 0;
  width: 8.6%;
  height: 84px;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(#20243b, #111529);
  color: #fff;
  box-shadow: 0 5px 12px rgba(15,18,35,.25);
}
.black-key span { font-size: 9px; font-weight: 800; position: absolute; bottom: 7px; left: 0; right: 0; }
.black-key.active { background: linear-gradient(#786bf0, #5648d8); }
.key-cs { left: 9.9%; }
.key-ds { left: 24.3%; }
.key-fs { left: 52.8%; }
.key-gs { left: 67.1%; }
.key-as { left: 81.4%; }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.select-field span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 800; }
.select-field small { color: var(--muted); font-weight: 600; }
.select-field select {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid #d7dbe7; border-radius: 11px;
  background: #fff; color: var(--text);
}
.primary-button {
  width: 100%; height: 49px; margin-top: 18px; border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7466f2); color: white; font-weight: 800;
  box-shadow: 0 10px 24px rgba(101,87,232,.23);
}
.primary-button:hover { background: linear-gradient(135deg, var(--primary-dark), #6557e8); }

.result-panel { padding: 25px; }
.result-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.result-kicker { margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }
.result-name-row { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.result-name-row h2 { margin: 0; color: var(--primary); font-size: clamp(38px, 5vw, 52px); line-height: 1; letter-spacing: -.04em; }
.quality-pill { padding: 7px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; font-weight: 800; }
.result-notes { margin: 10px 0 0; color: var(--muted); font-weight: 700; letter-spacing: .03em; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.secondary-button {
  min-height: 38px; padding: 0 13px; border: 1px solid #d9dce8; border-radius: 10px; background: white; color: #343b52; font-size: 12px; font-weight: 800;
}
.secondary-button:hover { background: #f7f7fb; border-color: #c5cad8; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.stat-card { min-height: 87px; padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-soft); }
.stat-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.stat-card strong { display: block; margin-top: 8px; font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }

.analysis-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 14px; margin-top: 14px; }
.analysis-card { padding: 18px; border: 1px solid var(--border); border-radius: 14px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title-row h3 { margin: 0; font-size: 15px; }
.mini-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 900; }
.explanation-list { display: grid; gap: 8px; margin-top: 14px; }
.explanation-row { display: grid; grid-template-columns: 42px 78px 1fr; align-items: center; gap: 8px; min-height: 40px; padding: 7px 9px; border-radius: 9px; background: #f8f8fc; }
.note-chip { width: 32px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--primary); color: white; font-weight: 900; }
.formula-chip { color: var(--primary-dark); font-weight: 900; font-size: 13px; }
.interval-name { color: var(--muted); font-size: 12px; }
.interval-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.interval-pill { padding: 9px 10px; background: #f4f5f9; border-radius: 9px; font-size: 12px; color: #434a60; font-weight: 700; }

.context-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 14px; padding: 17px 18px; border-radius: 14px; background: linear-gradient(135deg, #f1efff, #f8f7ff); border: 1px solid #ded9ff;
}
.context-label { display: block; margin-bottom: 5px; color: var(--primary-dark); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.context-card strong { font-size: 14px; }
.context-result { text-align: right; }
.context-result span { display: block; color: var(--primary-dark); font-size: 23px; font-weight: 900; }
.context-result small { color: var(--muted); }
.alternatives-block { margin-top: 18px; }
.muted { color: var(--muted); font-size: 11px; }
.alternatives { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.alt-card { padding: 11px 9px; border: 1px solid var(--border); border-radius: 11px; background: white; text-align: center; }
.alt-card strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.alt-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.action-status { min-height: 18px; margin: 11px 0 -6px; color: var(--success); font-size: 12px; font-weight: 800; text-align: right; }

.supporting {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  margin: 34px 0 60px;
}
.supporting article { padding: 24px; border-radius: 16px; border: 1px solid var(--border); background: rgba(255,255,255,.7); }
.supporting h2 { margin: 0 0 9px; font-size: 16px; }
.supporting p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
footer { padding: 22px; text-align: center; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; background: white; }

@media (max-width: 1040px) {
  .workspace { grid-template-columns: 1fr; }
  .input-panel { position: static; }
  .supporting { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .site-header { height: 64px; padding: 0 14px; }
  .brand { font-size: 14px; }
  .brand-mark { width: 34px; height: 34px; }
  .github-button { padding: 9px 11px; font-size: 12px; }
  main { width: min(100% - 20px, 1460px); }
  .hero { padding: 32px 10px 22px; }
  .hero h1 { font-size: 38px; }
  .hero-copy { font-size: 15px; }
  .input-panel, .result-panel { padding: 17px; border-radius: 15px; }
  .options-grid, .analysis-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .result-topbar { flex-direction: column; }
  .result-actions { width: 100%; justify-content: flex-start; }
  .alternatives { grid-template-columns: repeat(2, 1fr); }
  .context-card { align-items: flex-start; }
  .piano { height: 126px; }
  .black-key { height: 78px; }
}

@media (max-width: 420px) {
  .brand span:last-child { max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .github-button { width: 42px; height: 40px; padding: 0; justify-content: center; font-size: 0; }
  .github-button svg { width: 20px; height: 20px; }
  .hero h1 { font-size: 34px; }
  .stat-grid { grid-template-columns: 1fr; }
  .explanation-row { grid-template-columns: 38px 62px 1fr; }
  .result-actions .secondary-button { flex: 1; }
}
