:root {
  color-scheme: dark;

  --background: #0b0d10;
  --surface: #111419;
  --surface-raised: #171b21;
  --line: rgba(255, 255, 255, 0.1);
  --muted: #8d96a3;
  --text: #f4f6f8;
  --accent: #c4b5fd;
  --accent-soft: rgba(196, 181, 253, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;

  background: var(--background);
  color: var(--text);

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

select {
  font: inherit;
}

.app {
  min-height: 100vh;

  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.app-header {
  border-bottom: 1px solid var(--line);
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 40px;

  padding: 18px 32px 16px;
}

.header-identity,
.header-controls {
  display: flex;
  align-items: center;
}

.header-identity {
  gap: clamp(30px, 4vw, 68px);
}

.header-controls {
  gap: clamp(28px, 4vw, 64px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg, #67e8f9, var(--accent));
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(196, 181, 253, 0.4);
}

.eyebrow,
.summary-label,
.root-control > span,
.family {
  margin: 0 0 6px;

  color: var(--muted);

  font-size: 10px;
  font-weight: 700;

  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;

  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 620;

  letter-spacing: -0.04em;
}

.selected-root {
  min-width: 112px;
}

.selected-root h2 {
  margin-bottom: 0;

  font-size: clamp(18px, 1.7vw, 24px);
  font-weight: 620;

  letter-spacing: -0.03em;
  white-space: nowrap;
}

.root-control {
  width: 170px;
}

.root-control > span {
  display: block;

  margin-bottom: 7px;
}

.root-control select {
  width: 100%;
  height: 42px;

  padding: 0 38px 0 13px;

  appearance: none;

  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%)
      calc(100% - 17px) 18px / 5px 5px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%)
      calc(100% - 12px) 18px / 5px 5px no-repeat,
    var(--surface-raised);
  color: var(--text);

  border: 1px solid var(--line);
  border-radius: 8px;

  outline: none;
}

.root-control select:focus-visible {
  border-color: var(--accent);
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 24px;

  padding: 9px 32px;

  background: rgba(255, 255, 255, 0.012);
  border-top: 1px solid var(--line);
}

.header-meta > p,
.legend {
  margin: 0;

  color: var(--muted);

  font-size: 12px;
}

.legend {
  display: flex;
  justify-content: end;

  gap: 18px;
}

.chord-grid {
  min-height: 0;

  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(150px, 1fr));
}

.chord-card {
  min-width: 0;

  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr auto;

  column-gap: 18px;

  padding: clamp(18px, 1.7vw, 28px);

  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.chord-card:nth-child(4n) {
  border-right: 0;
}

.chord-card:nth-last-child(-n + 4) {
  border-bottom: 0;
}

.family {
  grid-column: 1 / -1;
}

.chord-heading {
  align-self: center;
}

.chord-symbol {
  margin-bottom: 4px;

  color: var(--text);

  font-size: clamp(30px, 3.5vw, 56px);
  font-weight: 560;

  line-height: 0.95;
  letter-spacing: -0.055em;
}

.chord-symbol sup {
  position: relative;
  top: -0.12em;

  color: var(--accent);

  font-size: 0.46em;
}

.chord-name {
  margin-bottom: 0;

  color: var(--muted);

  font-size: 12px;
}

.formula {
  align-self: center;

  color: var(--accent);

  font-size: 12px;
  font-weight: 650;

  letter-spacing: 0.07em;
  text-align: right;
}

.chord-details {
  grid-column: 1 / -1;

  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;

  gap: 12px;

  padding-top: 12px;

  border-top: 1px solid var(--line);
}

.chord-tones {
  overflow: hidden;

  font-size: 13px;
  font-weight: 650;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.character {
  overflow: hidden;

  color: var(--muted);

  font-size: 11px;

  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1050px) {
  .app {
    display: block;
  }

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

  .header-main {
    align-items: end;
  }

  .header-identity {
    align-items: flex-start;
    flex-direction: column;

    gap: 16px;
  }

  .chord-card {
    min-height: 220px;
  }

  .chord-card:nth-child(4n) {
    border-right: 1px solid var(--line);
  }

  .chord-card:nth-child(2n) {
    border-right: 0;
  }

  .chord-card:nth-last-child(-n + 4) {
    border-bottom: 1px solid var(--line);
  }

  .chord-card:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}

@media (max-width: 650px) {
  .header-main {
    align-items: stretch;
    flex-direction: column;

    gap: 20px;

    padding: 17px 18px;
  }

  .header-identity {
    gap: 14px;
  }

  .header-controls {
    align-items: end;
    justify-content: space-between;

    gap: 20px;
  }

  .root-control {
    width: 145px;
  }

  .header-meta {
    align-items: flex-start;
    flex-direction: column;

    gap: 7px;

    padding: 10px 18px;
  }

  .legend {
    justify-content: start;
  }

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

  .chord-card,
  .chord-card:nth-child(2n),
  .chord-card:nth-child(4n),
  .chord-card:nth-last-child(-n + 2) {
    min-height: 210px;

    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chord-card:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 430px) {
  .root-control {
    width: 145px;
  }
}
