:root {
  color-scheme: dark;
  --bg: #0d1011;
  --panel: #181b1f;
  --panel-2: #22262b;
  --panel-3: #111416;
  --line: #363c43;
  --text: #f4f0e8;
  --muted: #aaa49a;
  --accent: #d9a441;
  --accent-2: #4fb4a7;
  --danger: #d7655d;
  --key: #e9e0d0;
  --key-dark: #2b2e33;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(79, 180, 167, 0.1), transparent 34%),
    radial-gradient(circle at 86% 0%, rgba(217, 164, 65, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 36%),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

html {
  margin: 0;
  padding: 0;
  overscroll-behavior-x: none;
}

button,
select,
input,
textarea {
  font: inherit;
}

button,
select,
textarea,
input[type="number"],
input[type="text"] {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
}

button {
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

button:hover {
  border-color: var(--accent);
}

button:active,
button.is-active {
  transform: translateY(1px);
  background: #34383d;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: 100%;
  min-height: 100vh;
  padding: 0;
  gap: 6px;
}

.sidebar-collapsed .app-shell {
  grid-template-columns: 34px minmax(0, 1fr);
}

.top-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(54, 60, 67, 0.72);
  background:
    linear-gradient(90deg, rgba(79, 180, 167, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    rgba(10, 12, 14, 0.62);
}

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

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(217, 164, 65, 0.58);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(217, 164, 65, 0.18), rgba(17, 20, 22, 0.9));
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-2);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.55rem, 2.1vw, 2.35rem);
  letter-spacing: 0;
  line-height: 0.96;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.transport,
.control-surface,
.phrase-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.transport button,
.phrase-bank button {
  padding: 0 18px;
}

.transport button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.88rem;
  font-weight: 800;
}

.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(79, 180, 167, 0.5);
  border-radius: 7px;
  background: rgba(17, 20, 22, 0.72);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.header-link:hover {
  border-color: var(--accent);
}

.danger {
  border-color: rgba(215, 101, 93, 0.65);
  color: #ffd8d5;
}

.control-surface {
  grid-column: 2;
  display: grid;
  grid-template-columns: minmax(190px, 1.1fr) minmax(190px, 1.1fr) minmax(190px, 1.1fr) minmax(180px, 0.65fr) minmax(220px, 0.8fr);
  align-items: stretch;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(12, 14, 16, 0.76);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.sequencer {
  grid-column: 2;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(100px, 130px) minmax(130px, 170px) auto;
  gap: 5px;
  align-items: end;
  padding: 6px;
  border: 1px solid rgba(54, 60, 67, 0.82);
  border-radius: 7px;
  background: rgba(17, 20, 22, 0.72);
}

.sequence-panel {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.sequence-panel.script {
  min-width: 0;
}

textarea {
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  resize: vertical;
}

.script-carousel {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 3px;
  scrollbar-color: rgba(79, 180, 167, 0.55) transparent;
}

.script-tab {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) auto;
  gap: 4px;
  align-content: center;
  flex: 0 0 auto;
  min-height: 46px;
  padding: 3px;
  border: 1px solid rgba(79, 180, 167, 0.38);
  border-radius: 7px;
  background: rgba(17, 20, 22, 0.48);
  font-size: 0.82rem;
}

.script-select {
  display: grid;
  gap: 2px;
  min-height: 38px;
  padding: 0 10px;
  border-color: rgba(79, 180, 167, 0.38);
  font-size: 0.82rem;
  text-align: left;
}

.script-rename {
  width: 100%;
  min-width: 96px;
  min-height: 38px;
  padding: 0 9px;
  border-color: var(--accent);
  background: var(--panel-3);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
}

.script-tab.is-active {
  border-color: var(--accent);
  background: rgba(217, 164, 65, 0.12);
}

.script-tab.is-active .script-select {
  color: var(--accent);
}

.script-delete-controls {
  display: inline-flex;
  gap: 3px;
}

.script-delete,
.script-delete-confirm,
.script-delete-cancel {
  min-width: 30px;
  min-height: 38px;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 900;
}

.script-delete {
  border-color: rgba(215, 101, 93, 0.48);
  color: #ffd8d5;
}

.script-delete-confirm {
  border-color: rgba(79, 180, 167, 0.7);
  color: #bff4d0;
}

.script-delete-cancel {
  border-color: rgba(215, 101, 93, 0.62);
  color: #ffd8d5;
  font-size: 1rem;
}

.script-select strong,
.script-select span {
  display: block;
  line-height: 1.1;
}

.script-select strong {
  font-size: 0.86rem;
}

.script-select span {
  color: var(--muted);
  font-size: 0.68rem;
}

.notation-readout {
  display: grid;
  gap: 7px;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid rgba(54, 60, 67, 0.78);
  border-radius: 7px;
  background: rgba(10, 12, 14, 0.74);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.35;
}

.notation-line {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.notation-line span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.notation-input {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  resize: vertical;
  border-color: transparent;
  background: rgba(34, 38, 43, 0.72);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 0 12px;
}

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

.sequence-actions input,
.sequence-actions #addScriptBtn,
.sequence-actions #deleteScriptBtn,
.sequence-actions #saveTuneBtn {
  grid-column: span 2;
}

.timeline-panel {
  grid-column: 2;
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  align-self: start;
  gap: 2px;
  padding: 2px;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(54, 60, 67, 0.82);
  border-radius: 7px;
  background: rgba(12, 14, 16, 0.78);
}

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  min-height: 30px;
  padding: 0;
}

.timeline-head strong {
  display: inline;
  font-size: 0.82rem;
}

.timeline-head .eyebrow {
  display: inline;
  margin: 0 8px 0 0;
  font-size: 0.64rem;
}

.timeline-actions {
  display: flex;
  flex-wrap: wrap;
  flex: 0 0 auto;
  gap: 4px;
}

.view-toggle {
  display: flex;
  gap: 2px;
  padding: 1px;
  border: 1px solid rgba(79, 180, 167, 0.42);
  border-radius: 7px;
  background: rgba(10, 12, 14, 0.72);
}

.view-toggle button {
  min-height: 24px;
  padding: 0 7px;
  border-color: transparent;
  font-size: 0.78rem;
}

.view-toggle button.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(217, 164, 65, 0.12);
}

.timeline-actions button {
  min-height: 26px;
  padding: 0 8px;
}

.timeline-actions select,
.timeline-actions input[type="text"] {
  min-height: 28px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 800;
}

.timeline-actions select {
  width: 132px;
  padding: 0 8px;
}

.timeline-actions input[type="text"] {
  width: 150px;
  padding: 0 9px;
}

.timeline-head-play {
  min-width: 32px;
  border-color: rgba(217, 164, 65, 0.58);
  color: var(--accent);
  font-weight: 900;
  background: #202329;
}

.timeline-head-time {
  min-width: 58px;
  min-height: 26px;
  border-color: rgba(54, 60, 67, 0.72);
  background: rgba(17, 20, 23, 0.9);
  color: var(--accent);
  font-size: 0.78rem;
}

.timeline-zoom {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  overflow: hidden;
  border: 1px solid rgba(79, 180, 167, 0.42);
  border-radius: 7px;
  background: rgba(17, 20, 22, 0.82);
}

.timeline-zoom button {
  min-width: 28px;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 900;
}

.timeline-zoom output {
  min-width: 48px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.timeline-transport {
  display: block;
  padding: 0;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(54, 60, 67, 0.78);
  border-radius: 7px;
  background: linear-gradient(180deg, #15181b, #0b0d0f);
}

.timeline-scrub-shell {
  position: relative;
  min-height: 112px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior-x: contain;
  border: 1px solid rgba(54, 60, 67, 0.72);
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(79, 180, 167, 0.16) 1px, transparent 1px) 0 0 / 80px 100%,
    rgba(10, 12, 14, 0.76);
}

.timeline-scrub-shell::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 8px;
  right: 8px;
  height: 20px;
  border: 1px solid rgba(170, 164, 154, 0.24);
  border-radius: 3px;
  background:
    repeating-linear-gradient(90deg, rgba(244, 240, 232, 0.22) 0 1px, transparent 1px 10%),
    linear-gradient(180deg, #24282e, #111417);
  pointer-events: none;
}

.timeline-transport input[type="range"] {
  position: absolute;
  top: 0;
  left: 8px;
  width: calc(100% - 16px);
  height: 32px;
  margin: 0;
  opacity: 0.001;
  cursor: ew-resize;
  z-index: 4;
}

.canvas-view .performance,
.canvas-view .phrase-bank {
  display: none;
}

body.canvas-view {
  height: 100vh;
  overflow: hidden;
}

.canvas-view .app-shell {
  grid-template-rows: auto auto auto minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.canvas-view .saved-sidebar {
  grid-row: 2 / -1;
}

.canvas-view .timeline-panel {
  grid-template-rows: auto minmax(0, 1fr);
  align-self: stretch;
  min-height: 0;
  overflow: hidden;
}

.canvas-view .timeline-transport {
  min-height: 0;
  overflow: hidden;
}

.keys-view .timeline-transport {
  display: none;
}

.keys-view .timeline-panel {
  padding-bottom: 2px;
}

.canvas-view .timeline-scrub-shell {
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

.timeline-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  z-index: 3;
  background: var(--accent);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 0 12px rgba(217, 164, 65, 0.42);
  pointer-events: none;
}

.timeline-playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 12px;
  height: 12px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: translateX(-50%);
}

.timeline-ruler {
  position: relative;
  height: 26px;
  min-width: 100%;
  border-bottom: 1px solid rgba(54, 60, 67, 0.72);
}

.timeline-tick {
  position: absolute;
  top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  transform: translateX(4px);
}

.timeline-track {
  position: relative;
  height: 82px;
  min-width: 100%;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(244, 240, 232, 0.04) 0 1px,
      transparent 1px 69px,
      rgba(79, 180, 167, 0.18) 69px 70px
    );
}

.timeline-empty {
  display: grid;
  height: 82px;
  place-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.timeline-track-label {
  position: absolute;
  left: 8px;
  z-index: 1;
  max-width: 160px;
  overflow: hidden;
  color: rgba(170, 164, 154, 0.58);
  font-size: 0.62rem;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.timeline-item {
  position: absolute;
  top: 10px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(217, 164, 65, 0.72);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(217, 164, 65, 0.22), rgba(34, 38, 43, 0.95));
  color: var(--text);
  cursor: grab;
  user-select: none;
}

.timeline-item:active {
  cursor: grabbing;
}

.timeline-item strong,
.timeline-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-item strong {
  font-size: 0.86rem;
}

.timeline-item span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.timeline-delete {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-color: rgba(215, 101, 93, 0.48);
  color: #ffd8d5;
}

.saved-tunes {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  min-height: 38px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-color: rgba(79, 180, 167, 0.55) transparent;
}

.saved-sidebar {
  grid-column: 1;
  grid-row: 2 / span 4;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  padding: 8px;
  border: 1px solid rgba(54, 60, 67, 0.82);
  border-radius: 0 7px 7px 0;
  background: rgba(17, 20, 22, 0.82);
}

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

.sidebar-head strong {
  display: block;
  color: var(--text);
  font-size: 1.08rem;
}

.sidebar-toggle {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  min-height: 28px;
  place-items: center;
  padding: 0;
  border-color: rgba(79, 180, 167, 0.5);
  color: var(--accent-2);
  font-size: 1.35rem;
  line-height: 1;
}

.saved-sidebar.is-collapsed {
  padding: 6px 2px;
  gap: 0;
  border-left: 0;
  border-radius: 0 6px 6px 0;
}

.saved-sidebar.is-collapsed .sidebar-head {
  display: grid;
  justify-items: center;
}

.saved-sidebar.is-collapsed .sidebar-head > div,
.saved-sidebar.is-collapsed .saved-tunes {
  display: none;
}

.saved-sidebar .saved-tunes {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 2px 2px 0;
}

.saved-tune {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(96px, auto) auto auto;
  gap: 4px;
  align-items: center;
  padding: 3px;
  border: 1px solid rgba(79, 180, 167, 0.44);
  border-radius: 7px;
  background: rgba(17, 20, 22, 0.72);
}

.saved-sidebar .saved-tune {
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.saved-sidebar .saved-tune button:first-child {
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-tune button {
  min-height: 32px;
  padding: 0 10px;
  border-color: transparent;
  font-size: 0.82rem;
}

.saved-tune.is-confirming-delete {
  border-color: rgba(215, 101, 93, 0.72);
}

.saved-tune.is-confirming-delete button:nth-child(2) {
  color: #bff4d0;
}

.saved-tune.is-confirming-delete button:nth-child(3) {
  color: #ffd8d5;
}

.saved-empty {
  display: grid;
  min-height: 36px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.panel.compact {
  max-width: none;
}

label,
.status-card span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

select {
  width: 100%;
  padding: 0 14px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.stepper {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 6px;
  align-items: center;
}

output {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
  color: var(--accent);
  font-weight: 800;
}

.performance {
  grid-column: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  gap: 6px;
  min-height: 0;
}

.keyboard-wrap {
  display: grid;
  align-content: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
}

.keyboard-row {
  display: grid;
  gap: 6px;
}

.keyboard-row.upper {
  grid-template-columns: repeat(13, minmax(42px, 1fr));
  padding-left: 0;
}

.keyboard-row.home {
  grid-template-columns: repeat(11, minmax(48px, 1fr));
}

.keyboard-row.lower {
  grid-template-columns: repeat(10, minmax(48px, 1fr));
  padding-left: 0;
}

.key {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  min-height: clamp(98px, 10vh, 132px);
  padding: 12px;
  border: 1px solid #b9ad9d;
  border-radius: 7px;
  background: linear-gradient(180deg, #fff8e9, var(--key));
  color: #151515;
  text-align: left;
  overflow: hidden;
  box-shadow:
    inset 0 -5px 0 rgba(217, 164, 65, 0.36),
    0 10px 24px rgba(0, 0, 0, 0.18);
}

.key.is-komal,
.key.is-tivra {
  background: linear-gradient(#383c42, var(--key-dark));
  color: var(--text);
  border-color: #555b64;
}

.key.is-assignable {
  background: linear-gradient(180deg, #262a30, #1a1d21);
  color: var(--text);
  border-color: rgba(79, 180, 167, 0.48);
  box-shadow: inset 0 0 0 1px rgba(79, 180, 167, 0.1);
}

.upper .key {
  min-height: clamp(94px, 11vh, 132px);
}

.key kbd {
  display: block;
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1;
}

.key strong {
  align-self: end;
  color: inherit;
  font-size: clamp(1.25rem, 1.45vw, 2rem);
  line-height: 1;
}

.key span {
  color: inherit;
  font-size: clamp(0.72rem, 0.82vw, 0.98rem);
  line-height: 1.15;
  opacity: 0.78;
  overflow-wrap: anywhere;
}

.key .western-note {
  font-size: clamp(0.7rem, 0.78vw, 0.9rem);
  font-weight: 900;
  opacity: 0.9;
}

.key small {
  color: inherit;
  font-size: clamp(0.62rem, 0.7vw, 0.78rem);
  font-weight: 800;
  line-height: 1.1;
  opacity: 0.66;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.set-key {
  width: 100%;
  min-height: 34px;
  margin-top: 8px;
  padding: 0 9px;
  border-color: rgba(79, 180, 167, 0.44);
  border-radius: 5px;
  font-size: 0.75rem;
  background: #171a1d;
}

.key.is-listening {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(217, 164, 65, 0.36),
    0 0 0 2px rgba(217, 164, 65, 0.18);
}

.key.is-listening .set-key {
  background: rgba(217, 164, 65, 0.18);
  color: var(--accent);
}

.key.in-raga {
  border-color: var(--accent);
  box-shadow: inset 0 -4px 0 rgba(217, 164, 65, 0.42);
}

.key.is-playing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(217, 164, 65, 0.28);
  transform: translateY(2px);
}

.side-rack {
  display: grid;
  gap: 6px;
  align-content: center;
}

.layer-button,
.status-card {
  display: grid;
  gap: 8px;
  min-height: 102px;
  padding: 18px;
  text-align: left;
}

.layer-button strong,
.status-card strong {
  color: var(--accent);
  font-size: 1.4rem;
}

.status-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}

.phrase-bank {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 0;
}

.phrase-bank button {
  min-width: 0;
  min-height: 52px;
  border-color: rgba(79, 180, 167, 0.55);
}

.docs-body {
  overflow-x: hidden;
}

.docs-shell {
  display: grid;
  gap: 12px;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.docs-header {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid rgba(54, 60, 67, 0.82);
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(79, 180, 167, 0.1), transparent 44%),
    rgba(12, 14, 16, 0.78);
}

.docs-header .header-link {
  justify-self: start;
}

.docs-header h1 {
  white-space: normal;
}

.docs-header p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.docs-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.docs-nav a {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid rgba(79, 180, 167, 0.44);
  border-radius: 7px;
  background: rgba(17, 20, 22, 0.74);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.docs-section {
  padding: 16px;
  border: 1px solid rgba(54, 60, 67, 0.82);
  border-radius: 7px;
  background: rgba(17, 20, 22, 0.72);
}

.docs-section h2,
.docs-section h3,
.docs-section p,
.docs-section ol,
.docs-section ul {
  margin-top: 0;
}

.docs-section h2 {
  margin-bottom: 10px;
  font-size: 1.35rem;
}

.docs-section h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.docs-section p,
.docs-section li {
  color: var(--muted);
  line-height: 1.55;
}

.docs-section li + li {
  margin-top: 6px;
}

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

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

.docs-grid article {
  padding: 12px;
  border: 1px solid rgba(54, 60, 67, 0.78);
  border-radius: 7px;
  background: rgba(10, 12, 14, 0.52);
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid rgba(54, 60, 67, 0.82);
  border-radius: 7px;
}

.docs-table th,
.docs-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(54, 60, 67, 0.72);
  text-align: left;
  vertical-align: top;
}

.docs-table th {
  color: var(--text);
  background: rgba(34, 38, 43, 0.82);
}

.docs-table td {
  color: var(--muted);
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

code {
  color: #ffe2a7;
}

pre {
  overflow-x: auto;
  padding: 12px;
  border: 1px solid rgba(54, 60, 67, 0.78);
  border-radius: 7px;
  background: rgba(10, 12, 14, 0.82);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 6px;
  }

  .top-bar,
  .saved-sidebar,
  .control-surface,
  .sequencer,
  .timeline-panel,
  .performance,
  .phrase-bank {
    grid-column: 1;
  }

  .saved-sidebar {
    grid-row: auto;
    max-height: 240px;
  }

  .sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .top-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
  }

  .control-surface,
  .sequencer,
  .timeline-panel,
  .performance {
    grid-template-columns: 1fr;
  }

  .canvas-view .app-shell {
    grid-template-rows: auto auto auto minmax(0, 1fr);
  }

  .canvas-view .saved-sidebar {
    grid-row: 2;
    min-height: 0;
    max-height: 160px;
    overflow: hidden;
  }

  .canvas-view .timeline-panel {
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

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

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

  .status-card,
  .side-rack select {
    grid-column: span 2;
  }
}

@media (max-width: 850px) {
  h1 {
    font-size: clamp(1.35rem, 7vw, 1.9rem);
    white-space: normal;
  }

  .docs-shell {
    padding: 8px;
  }

  .docs-header,
  .docs-section {
    padding: 12px;
  }

  .docs-grid,
  .docs-grid.two {
    grid-template-columns: 1fr;
  }

  .brand-subtitle {
    display: none;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .keyboard-row.upper,
  .keyboard-row.home,
  .keyboard-row.lower {
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    padding-left: 0;
  }

  .key {
    min-height: 108px;
    padding: 9px;
  }

  .key kbd {
    font-size: 0.88rem;
  }

  .key strong {
    font-size: 1.05rem;
  }

  .key span {
    font-size: 0.68rem;
  }

  .key small {
    display: none;
  }

  .notation-line {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .set-key {
    min-height: 30px;
    padding: 0 6px;
    font-size: 0.68rem;
  }

  .phrase-bank,
  .side-rack {
    grid-template-columns: 1fr;
  }

  .status-card,
  .side-rack select {
    grid-column: auto;
  }
}
