    @import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700&family=Sora:wght@500;700&family=IBM+Plex+Mono:wght@500&display=swap');

    :root {
      --bg-1: #0f1b2b;
      --bg-2: #1c2b3e;
      --bg-3: #10131b;
      --accent: #00f0ff;
      --accent-2: #00ff9a;
      --accent-3: #ffb100;
      --text: #e8f0ff;
      --muted: rgba(232, 240, 255, 0.6);
      --panel: rgba(16, 20, 28, 0.7);
      --panel-border: rgba(255, 255, 255, 0.08);
      --key-white: #f5f4f0;
      --key-black: #121212;
      --key-edge: #9f9f9f;
      --hit-line: rgba(0, 255, 154, 0.7);
      --text-xs: 10px;
      --text-sm: 11px;
      --text-md: 12px;
      --text-lg: 22px;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      font-family: 'Manrope', sans-serif;
      color: var(--text);
      min-height: 100vh;
      background:
        radial-gradient(circle at 15% 20%, rgba(0, 240, 255, 0.2), transparent 40%),
        radial-gradient(circle at 80% 10%, rgba(255, 177, 0, 0.2), transparent 45%),
        linear-gradient(160deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    header {
      padding: 4px 12px;
      display: grid;
      grid-template-columns: auto 1fr auto;
      gap: 8px;
      align-items: center;
      min-height: 40px;
      background: rgba(12, 16, 24, 0.7);
      backdrop-filter: blur(14px);
      border-bottom: 1px solid var(--panel-border);
      z-index: 20;
    }

    .title-block {
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    .app-icon {
      width: 26px;
      height: 26px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .app-icon svg {
      width: 100%;
      height: 100%;
      image-rendering: pixelated;
    }

    .title-block h1 {
      font-family: 'Sora', sans-serif;
      font-size: var(--text-lg);
      letter-spacing: 0.4px;
    }

    #center-meta {
      display: inline-flex;
      gap: 10px;
      align-items: center;
      justify-self: center;
      text-align: center;
    }

    #song-title {
      font-size: var(--text-md);
      color: var(--muted);
      letter-spacing: 0.2px;
    }

    #meta-row {
      display: inline-flex;
      gap: 8px;
      font-size: var(--text-sm);
      color: var(--muted);
      align-items: center;
      justify-content: center;
    }

    #tempo-readout, .key-pill {
      padding: 2px 8px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid rgba(255, 255, 255, 0.08);
      color: var(--muted);
      font: inherit;
    }

    .key-pill {
      cursor: pointer;
    }

    .key-pill.active {
      border-color: rgba(0, 240, 255, 0.6);
      color: var(--accent);
      box-shadow: 0 0 10px rgba(0, 240, 255, 0.35);
    }

    .hidden {
      display: none;
    }

    .header-tools {
      justify-self: end;
      display: inline-flex;
      align-items: center;
    }

    .help-btn {
      width: 30px;
      height: 30px;
      border-radius: 7px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
      font-size: 15px;
      line-height: 1;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: var(--text);
    }

    .help-btn.active {
      background: rgba(255, 196, 0, 0.18);
      border-color: rgba(255, 196, 0, 0.6);
      color: #ffd54d;
      box-shadow: 0 0 10px rgba(255, 196, 0, 0.35);
    }

    .help-tooltip {
      position: fixed;
      z-index: 60;
      max-width: min(320px, calc(100vw - 24px));
      padding: 8px 10px;
      border-radius: 6px;
      border: 1px solid rgba(222, 226, 240, 0.75);
      background: linear-gradient(180deg, #f7f8fc 0%, #e8ebf5 100%);
      color: #1b2232;
      font-size: 12px;
      font-weight: 600;
      line-height: 1.35;
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
      pointer-events: none;
    }

    button, select {
      font-family: 'Manrope', sans-serif;
      font-size: 13px;
      font-weight: 600;
      border-radius: 10px;
      border: 1px solid var(--panel-border);
      background: rgba(255, 255, 255, 0.06);
      color: var(--text);
      padding: 8px 14px;
      cursor: pointer;
      transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    button:not(.mini-btn):hover:not(:disabled), select:hover {
      transform: translateY(-1px);
      border-color: rgba(255, 255, 255, 0.5);
      background: rgba(255, 255, 255, 0.12);
    }

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

    button:focus-visible,
    .icon-btn:focus-visible,
    .mini-btn:focus-visible,
    input[type="range"]:focus-visible,
    select:focus-visible {
      outline: 2px solid rgba(0, 240, 255, 0.6);
      outline-offset: 2px;
    }

    select {
      appearance: none;
      padding-right: 28px;
      background-image:
        linear-gradient(45deg, transparent 50%, var(--accent) 50%),
        linear-gradient(135deg, var(--accent) 50%, transparent 50%),
        linear-gradient(to right, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
      background-position:
        calc(100% - 16px) 55%,
        calc(100% - 11px) 55%,
        calc(100% - 32px) 50%;
      background-size: 5px 5px, 5px 5px, 1px 18px;
      background-repeat: no-repeat;
    }

    #file-input {
      display: none;
    }

    main {
      flex: 1;
      display: grid;
      grid-template-rows: 1fr auto;
      position: relative;
    }

    #highway {
      position: relative;
      overflow: hidden;
      background: transparent;
    }

    #note-canvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
    }

    .time-pill {
      font-size: var(--text-sm);
      color: var(--muted);
      padding: 4px 8px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.12);
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      text-align: center;
      min-width: 0;
    }

    #controls-bar {
      display: grid;
      grid-template-columns: 1fr auto auto;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      border-top: 1px solid var(--panel-border);
      background: rgba(10, 12, 18, 0.9);
      backdrop-filter: blur(12px);
      z-index: 15;
      flex-wrap: nowrap;
    }

    .transport {
      display: grid;
      gap: 6px;
      align-items: center;
      justify-items: start;
      justify-self: start;
    }

    .transport-center {
      justify-self: end;
    }

    .seek-group {
      min-width: 260px;
      width: 100%;
      display: grid;
      grid-auto-flow: row;
      gap: 4px;
    }

    .seek-row {
      display: grid;
      grid-template-columns: auto minmax(220px, 1fr) auto auto;
      align-items: center;
      gap: 8px;
      overflow: visible;
    }

    .seek-wrap {
      position: relative;
      width: 100%;
      display: flex;
      align-items: center;
      height: 24px;
      z-index: 2;
      min-width: 0;
      overflow: hidden;
      max-width: 100%;
    }

    #seek-marks {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }

    .seek-loop {
      position: absolute;
      top: 0;
      height: 24px;
      border-radius: 0;
      background: rgba(0, 255, 154, 0.45);
      box-shadow: none;
      pointer-events: none;
    }

    .seek-mark {
      position: absolute;
      top: 0;
      width: 2px;
      height: 24px;
      background: rgba(255, 210, 0, 0.9);
      box-shadow: 0 0 6px rgba(255, 210, 0, 0.5);
      border-radius: 2px;
      pointer-events: none;
    }


    .seek-buttons {
      display: grid;
      grid-auto-flow: column;
      gap: 6px;
      align-items: center;
      justify-self: start;
    }

    #loop-readout {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      font-size: var(--text-sm);
      color: var(--muted);
      white-space: nowrap;
      min-width: 0;
      text-align: right;
    }

    #loop-readout.hidden {
      display: none;
    }

    .loop-time-input {
      width: 62px;
      height: 28px;
      padding: 0 6px;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, 0.18);
      background: rgba(255, 255, 255, 0.08);
      color: var(--text);
      font-size: 12px;
      text-align: center;
      font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
      outline: none;
    }

    .loop-time-input:focus {
      border-color: rgba(255, 255, 255, 0.45);
      background: rgba(255, 255, 255, 0.14);
    }

    .loop-time-sep {
      color: var(--muted);
      font-size: 11px;
      opacity: 0.9;
    }

    #time-readout {
      min-width: 0;
      text-align: right;
    }

    .time-metro {
      display: inline-flex;
      align-items: center;
      justify-self: end;
      gap: 8px;
      min-width: 0;
    }

    .mini-btn {
      display: grid;
      place-items: center;
      padding: 0;
      height: 24px;
      width: 24px;
      min-width: 24px;
      font-size: var(--text-xs);
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.2);
      background: rgba(255, 255, 255, 0.08);
      color: var(--text);
      line-height: 1;
    }

    .mini-btn:hover:not(:disabled) {
      transform: none;
      border-color: rgba(255, 255, 255, 0.2);
      background: rgba(255, 255, 255, 0.08);
      box-shadow: none;
    }

    .mini-btn svg {
      width: 12px;
      height: 12px;
      fill: currentColor;
    }

    .mini-btn.active {
      background: rgba(0, 255, 154, 0.2);
      border-color: rgba(0, 255, 154, 0.6);
      box-shadow: 0 0 10px rgba(0, 255, 154, 0.3);
    }

    .mini-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    .transport-center {
      display: grid;
      grid-auto-flow: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      flex: 0 0 auto;
    }

    .slider-group.compact {
      min-width: 80px;
      font-family: 'Sora', sans-serif;
      font-size: 10px;
      letter-spacing: 0.45px;
      text-transform: uppercase;
      color: rgba(232, 240, 255, 0.72);
    }

    .slider-group.compact input[type="range"] {
      width: 80px;
      height: 18px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      background: rgba(255, 255, 255, 0.06);
    }

    .slider-group.compact input[type="range"]::-webkit-slider-thumb {
      width: 3px;
      height: 18px;
      border-radius: 2px;
      background: rgba(220, 228, 245, 0.6);
      box-shadow: none;
    }

    .slider-group.compact input[type="range"]::-moz-range-thumb {
      width: 3px;
      height: 18px;
      border-radius: 2px;
      background: rgba(220, 228, 245, 0.6);
      box-shadow: none;
      border: none;
    }

    .sliders {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: nowrap;
      justify-content: flex-end;
      flex: 1 1 auto;
    }

    .icon-btn {
      width: 44px;
      height: 44px;
      border-radius: 12px;
      padding: 0;
      display: grid;
      place-items: center;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.2);
      position: relative;
      color: var(--text);
      transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    }

    .icon-btn svg {
      width: 18px;
      height: 18px;
      fill: currentColor;
      pointer-events: none;
    }

    .icon-btn:hover {
      transform: translateY(-1px);
      border-color: rgba(255, 255, 255, 0.5);
      background: rgba(255, 255, 255, 0.12);
    }

    .icon-btn:disabled:hover {
      transform: none;
      border-color: rgba(255, 255, 255, 0.2);
      background: rgba(255, 255, 255, 0.08);
    }

    .icon-btn select {
      position: absolute;
      inset: 0;
      opacity: 0.01;
      cursor: pointer;
      appearance: none;
      background: transparent;
      border: none;
      font-size: var(--text-sm);
    }

    .icon-btn select option {
      color: #f5f5f5;
      background: #0f1420;
    }

    .icon-btn select:focus {
      outline: none;
    }

    .instrument-btn {
      width: 44px;
      display: grid;
      align-items: center;
      place-items: center;
    }

    .file-icon input[type="file"] {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
    }

    .icon-btn.active {
      background: rgba(255, 255, 255, 0.18);
      border-color: rgba(255, 255, 255, 0.6);
      box-shadow: 0 0 14px rgba(255, 255, 255, 0.2);
    }

    .slider-group {
      display: grid;
      gap: 4px;
      min-width: 86px;
      color: var(--muted);
      font-size: var(--text-xs);
      text-align: center;
      justify-items: center;
    }

    input[type="range"] {
      -webkit-appearance: none;
      appearance: none;
      width: 80px;
      height: 24px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.12);
      outline: none;
    }

    input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 2px;
      height: 24px;
      border-radius: 2px;
      background: rgba(255, 255, 255, 0.9);
      box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
      cursor: pointer;
    }

    input[type="range"]::-moz-range-thumb {
      width: 2px;
      height: 24px;
      border-radius: 2px;
      background: rgba(255, 255, 255, 0.9);
      cursor: pointer;
      border: none;
    }

    #progress::-webkit-slider-thumb {
      background: rgba(255, 170, 0, 0.9);
      box-shadow: 0 0 6px rgba(255, 170, 0, 0.55);
    }

    #progress::-moz-range-thumb {
      background: rgba(255, 170, 0, 0.9);
    }

    #progress {
      width: 100%;
      background: rgba(255, 255, 255, 0.06);
      position: relative;
      z-index: 2;
      max-width: 100%;
      min-width: 0;
    }

    #metronome-indicator {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.2);
      position: static;
    }

    #metronome-indicator.flash {
      background: rgba(255, 230, 0, 0.95);
    }

    #progress.loop-active {
      box-shadow: none;
      background: rgba(255, 255, 255, 0.06);
    }

    #keyboard-shell {
      background: linear-gradient(180deg, #151923 0%, #10131b 100%);
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.55);
      padding: 0 14px 10px;
      position: relative;
    }

    #keyboard {
      position: relative;
      height: 170px;
      width: 100%;
      max-width: 1500px;
      margin: 0 auto;
      overflow: visible;
    }

    #white-keys {
      display: flex;
      align-items: flex-start;
      height: 170px;
      gap: 1px;
      position: relative;
      z-index: 1;
      width: 100%;
    }

    #black-keys {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 110px;
      z-index: 3;
      pointer-events: auto;
      width: 100%;
    }

    .white-key {
      flex: 1;
      min-width: 22px;
      height: 140px;
      background: linear-gradient(180deg, #faf9f5 0%, #f1efe9 55%, #dbd6c9 100%);
      border: 1px solid #b9b4aa;
      border-bottom: 8px solid #b1aa9b;
      border-radius: 0 0 6px 6px;
      position: relative;
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -8px 12px rgba(0, 0, 0, 0.08),
        0 10px 18px rgba(0, 0, 0, 0.35);
      z-index: 1;
    }

    .white-key.active {
      background: var(--active-color, #00ff9a);
      box-shadow:
        0 0 10px var(--active-color, #00ff9a),
        0 0 22px color-mix(in srgb, var(--active-color, #00ff9a), transparent 50%);
      border-color: color-mix(in srgb, var(--active-color, #00ff9a), #000 20%);
      transform: translateY(2px);
    }

    .black-key {
      position: absolute;
      top: 0;
      transform: none;
      width: 0;
      height: 95px;
      background: linear-gradient(180deg, #2c2c2c 0%, #111 70%);
      border: 1px solid #050505;
      border-radius: 0 0 4px 4px;
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        inset 0 -6px 10px rgba(0, 0, 0, 0.8),
        0 10px 16px rgba(0, 0, 0, 0.6);
      z-index: 3;
      pointer-events: auto;
    }

    .black-key.active {
      background: var(--active-color, #00ff9a);
      box-shadow:
        0 0 12px var(--active-color, #00ff9a),
        0 0 24px color-mix(in srgb, var(--active-color, #00ff9a), transparent 45%);
      transform: translateY(2px);
    }

    .key-flicker {
      animation: keyFlicker 0.12s ease;
    }

    @keyframes keyFlicker {
      0% { filter: brightness(1.1); }
      50% { filter: brightness(0.7); }
      100% { filter: brightness(1); }
    }

    .key-label {
      position: absolute;
      bottom: 8px;
      left: 50%;
      transform: translateX(-50%);
      font-size: 7px;
      font-weight: 600;
      color: #7e7e7e;
      font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
      pointer-events: none;
      letter-spacing: 0.2px;
    }

    .white-key.active .key-label,
    .black-key.active .key-label {
      color: #ffffff;
      text-shadow: 0 0 6px rgba(255, 255, 255, 0.7);
    }

    .key-out-of-scale::after {
      content: '';
      position: absolute;
      left: 50%;
      top: 55%;
      width: 0;
      height: 0;
      border-left: 5px solid transparent;
      border-right: 5px solid transparent;
      border-top: 8px solid rgba(255, 30, 30, 1);
      transform: translate(-50%, -50%);
      filter: drop-shadow(0 0 6px rgba(255, 30, 30, 0.95));
      pointer-events: none;
    }

    #keyboard.key-highlight-on .key:not(.key-in-scale):not(.active) {
      opacity: 0.45;
      filter: saturate(0.6);
    }

    .black-key .key-label {
      color: #5b5b5b;
      bottom: 4px;
      font-size: 6px;
    }

    #hit-line {
      position: absolute;
      left: 0;
      right: 0;
      height: 2px;
      background: var(--hit-line);
      bottom: 0;
      box-shadow: 0 0 12px rgba(0, 255, 154, 0.6);
      z-index: 4;
    }

    #toast {
      position: absolute;
      bottom: 20px;
      right: 20px;
      left: auto;
      transform: none;
      background: rgba(12, 18, 30, 0.92);
      border: 1px solid rgba(180, 206, 255, 0.28);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
      padding: 10px 14px;
      border-radius: 10px;
      color: var(--text);
      font-size: 13px;
      font-weight: 600;
      letter-spacing: 0.15px;
      opacity: 0;
      transition: opacity 0.3s ease;
      z-index: 20;
    }

    #toast.visible {
      opacity: 1;
    }

    @media (max-width: 980px) {
      header {
        grid-template-columns: 1fr auto;
        grid-template-areas:
          "title help"
          "meta meta";
        row-gap: 6px;
      }

      .title-block {
        grid-area: title;
      }

      #center-meta {
        grid-area: meta;
        justify-self: start;
      }

      .header-tools {
        grid-area: help;
      }

      #controls-bar {
        grid-template-columns: 1fr;
      }

      .seek-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
          "buttons seek seek"
          "loop time time";
        row-gap: 6px;
      }

      .seek-buttons {
        grid-area: buttons;
      }

      .seek-wrap {
        grid-area: seek;
      }

      #loop-readout {
        grid-area: loop;
      }

      .time-metro {
        grid-area: time;
      }

      .seek-buttons {
        justify-content: flex-start;
      }

      #loop-readout,
      #time-readout {
        text-align: right;
      }

      .sliders {
        justify-content: flex-start;
      }

      #progress {
        width: 100%;
      }
    }

    @media (max-width: 1200px) {
      .white-key {
        min-width: 0;
      }

      .key-label {
        display: none;
      }
    }

    @media (max-width: 420px) {
      .transport-center {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px;
      }
    }
