:root {
  color-scheme: dark;
  --bg: #090a08;
  --panel: #141611;
  --panel-2: #1c1f17;
  --line: #eefc35;
  --line-soft: rgba(238, 252, 53, 0.3);
  --text: #f7f8dc;
  --muted: #adb095;
  --faint: #62664f;
  --cyan: #67e8f9;
  --pink: #fb7185;
  --green: #86efac;
  --violet: #c4b5fd;
  --orange: #fbbf24;
  --border: rgba(247, 248, 220, 0.16);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 56px 56px;
  color: var(--text);
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.workspace,
.inspector {
  min-width: 0;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-kicker,
label span {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel h2 {
  margin: 3px 0 0;
  line-height: 1;
}

label {
  display: grid;
  gap: 6px;
}

select {
  min-width: 134px;
  height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0f100d;
  color: var(--text);
  outline: none;
}

select:focus-visible {
  border-color: var(--line);
  box-shadow: 0 0 0 3px rgba(238, 252, 53, 0.16);
}

.chart-frame {
  flex: 1;
  min-height: calc(100vh - 36px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, rgba(238, 252, 53, 0.07), transparent 24%), #050604;
  overflow: hidden;
  box-shadow: var(--shadow);
}

#chart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 36px);
  top: 5px;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-button {
  height: 42px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(238, 252, 53, 0.12);
  color: var(--line);
  font-weight: 850;
}

.settings-button:hover,
.settings-button:focus-visible {
  border-color: var(--line);
  background: rgba(238, 252, 53, 0.18);
  outline: none;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(20, 22, 17, 0.92);
  box-shadow: var(--shadow);
  padding: 16px;
}

.selected-panel {
  display: grid;
  gap: 12px;
  border-color: var(--line-soft);
}

.panel h2 {
  font-size: 1.38rem;
  color: var(--text);
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.compact-control {
  width: 142px;
}

.compact-control select {
  width: 100%;
  min-width: 0;
}

.detail-list {
  display: grid;
  gap: 12px;
  margin: 4px 0 0;
}

.detail-list div {
  display: grid;
  gap: 3px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.35;
}

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

.chip,
.move-row {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
}

.chip {
  min-height: 64px;
  padding: 10px;
}

.chip strong,
.move-row strong {
  display: block;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.15;
}

.chip span,
.move-row span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.25;
}

.move-list {
  display: grid;
  gap: 8px;
}

.move-row {
  padding: 10px 12px;
}

.voicing-panel {
  display: grid;
  gap: 12px;
}

.preview-count,
.preview-roman,
.note-row {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.3;
}

.preview-count {
  align-self: start;
  padding-top: 3px;
}

.preview-step-controls {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: center;
}

.preview-nav {
  width: 34px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 900;
}

.preview-nav:hover,
.preview-nav:focus-visible {
  border-color: var(--line);
  color: var(--line);
  outline: none;
}

.step-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.inversion-strip {
  padding-top: 2px;
}

.step-dot {
  flex: 0 0 auto;
  max-width: 118px;
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  overflow: hidden;
  padding: 0 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-dot.is-active {
  border-color: var(--line);
  color: var(--line);
}

.inversion-dot {
  min-width: 56px;
  max-width: none;
}

.keyboard {
  --white-count: 21;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--white-count), minmax(0, 1fr));
  height: 124px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #070806;
  cursor: pointer;
  overflow: hidden;
}

.piano-key {
  user-select: none;
}

.piano-key.white {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: center;
  min-width: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.38);
  background: #f4f0dc;
  color: #222419;
  font-size: 0.62rem;
  font-weight: 850;
  padding-bottom: 7px;
}

.piano-key.white.is-active {
  background: var(--line);
  box-shadow: inset 0 0 0 2px rgba(5, 6, 4, 0.45);
}

.piano-key.black {
  position: absolute;
  top: 0;
  z-index: 2;
  width: 14px;
  height: 76px;
  border-radius: 0 0 4px 4px;
  background: #11120e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.38);
}

.piano-key.black.is-active {
  background: var(--cyan);
  box-shadow: inset 0 0 0 2px rgba(5, 6, 4, 0.38), 0 2px 8px rgba(0, 0, 0, 0.38);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.62);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: min(360px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0f100d;
  color: var(--text);
  font-weight: 900;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--line);
  color: var(--line);
  outline: none;
}

.chart-arm {
  cursor: pointer;
  transition: opacity 160ms ease;
}

.chart-line {
  stroke-width: 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px rgba(238, 252, 53, 0.22));
}

.chart-tick {
  stroke-width: 5;
  stroke-linecap: round;
}

.category-title {
  font-size: 21px;
  font-weight: 900;
  text-transform: uppercase;
  fill: var(--line);
  paint-order: stroke;
  stroke: #050604;
  stroke-width: 5px;
  stroke-linejoin: round;
}

.item-hit {
  cursor: pointer;
  fill: transparent;
  pointer-events: all;
}

.item-label {
  cursor: pointer;
  fill: var(--text);
  font-size: 15px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #050604;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.item-label .sub {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.item-dot {
  fill: #050604;
  stroke-width: 3;
}

.chart-item.is-active .item-dot {
  fill: var(--text);
}

.chart-item.is-active .item-label {
  fill: var(--line);
}

.center-ring {
  fill: #050604;
  stroke: var(--line);
  stroke-width: 8;
  filter: drop-shadow(0 0 18px rgba(238, 252, 53, 0.22));
}

.center-button {
  cursor: pointer;
  outline: none;
}

.center-button:focus-visible .center-ring {
  stroke: var(--text);
}

.center-hit {
  fill: transparent;
  pointer-events: all;
}

.center-label {
  fill: var(--line);
  font-weight: 900;
  text-anchor: middle;
  text-transform: uppercase;
  paint-order: stroke;
  stroke: #050604;
  stroke-width: 5px;
  stroke-linejoin: round;
}

.center-label .key {
  font-size: 44px;
}

.center-label .caption {
  font-size: 18px;
  fill: var(--text);
}

.key-picker {
  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.45));
}

.key-picker-bg {
  fill: rgba(12, 13, 10, 0.96);
  stroke: var(--line-soft);
  stroke-width: 2;
}

.key-choice {
  cursor: pointer;
}

.key-choice rect {
  fill: #1c1f17;
  stroke: var(--border);
  stroke-width: 1;
}

.key-choice text {
  fill: var(--text);
  font-size: 18px;
  font-weight: 850;
  pointer-events: none;
}

.key-choice:hover rect,
.key-choice.is-current rect {
  fill: rgba(238, 252, 53, 0.16);
  stroke: var(--line);
}

.key-choice.is-current text {
  fill: var(--line);
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .app-shell {
    padding: 10px;
  }

  .chart-frame,
  #chart {
    min-height: 480px;
  }

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

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

  .panel-header {
    flex-direction: column;
  }

  .compact-control {
    width: 100%;
  }
}
