/* Phone layer: sits on top of the app for phones (upright and sideways) and upright tablets. Sideways tablets and desktop keep the full studio. */
/* When the screen stops being phone-sized (a tablet turned sideways), hide everything the lab added. */
/* The app's own fonts (as on desktop): Inter, with the app's Arabic and Persian fonts on those pages. */
:root { --pl-font: 'Inter', sans-serif; } [lang="ar"] { --pl-font: 'Cairo', sans-serif; } [lang="fa"] { --pl-font: 'Vazirmatn', sans-serif; }
html:not(.pl-phone) :is(.pl-beat, .pl-beat-back, .pl-ai-btn, .pl-tones, .pl-desktop-note, .pl-row-editor) { display: none !important; }
@media (max-width: 599px), (orientation: portrait) and (max-width: 1023px) {
  /* ---------- Bottom area: one slim bar, extras open on demand ---------- */
  #mobile-bottom-chrome {
    display: grid !important;
    /* First column is exactly half, so Volume (left) and Tempo (right) get equal halves. */
    grid-template-columns: calc(50% - 4px) minmax(0, 1fr) auto auto;
    grid-template-areas:
      "ai ai ai ai"
      "tones tones tones tones"
      "status status vol bpm"
      "vs bs bs bs"
      "tabs tabs tabs tabs"
      "msg msg msg msg";
    column-gap: 8px;
    row-gap: 0; /* hidden rows must not leave gaps; visible rows get their own top margin */
    padding: 8px 12px calc(6px + env(safe-area-inset-bottom)) !important;
  }
  #mobile-master-sliders, #mobile-vol-slot, #mobile-bpm-slot { display: contents !important; }
  #mobile-main-ai-controls { grid-area: ai; display: none !important; }
  html.pl-ai-open #mobile-main-ai-controls { display: block !important; }
  #mobile-cockpit-status-slot { grid-area: status; display: flex !important; align-items: center; gap: 8px; min-width: 0; }
  #mobile-status-readout-vol { grid-area: vol; }
  #mobile-status-readout-bpm { grid-area: bpm; }
  #cockpit-volume-block { grid-area: vs; display: none !important; }
  #cockpit-bpm-block { grid-area: bs; display: none !important; }
  html.pl-tempo-open #cockpit-volume-block, html.pl-tempo-open #cockpit-bpm-block { display: flex !important; align-items: center; gap: 10px; }
  html.pl-tempo-open #cockpit-volume-block::before, html.pl-tempo-open #cockpit-bpm-block::before {
    font: 600 13px var(--pl-font); color: rgba(255, 255, 255, 0.75); width: 64px; flex-shrink: 0;
  }
  html.pl-tempo-open #cockpit-volume-block::before { content: var(--pl-t-volume, "Volume"); }
  html.pl-tempo-open #cockpit-bpm-block::before { content: var(--pl-t-tempo, "Tempo"); }
  #cockpit-volume-block input, #cockpit-bpm-block input { flex: 1; }
  #bottom-status-bar { grid-area: tabs; margin-top: 8px; }
  /* Drum Kits / Mixer / Export / Share span the same width as the rows above. */
  html body #bottom-status-bar#bottom-status-bar { padding-left: 0 !important; padding-right: 0 !important; }
  html.pl-ai-open #mobile-main-ai-controls { margin-bottom: 8px; }
  html.pl-tempo-open #cockpit-volume-block, html.pl-tempo-open #cockpit-bpm-block { margin-top: 8px; }
  #mobile-master-action-bar-status-slot { grid-area: msg; }

  /* Volume and BPM read-outs become buttons that open the two sliders. */
  #mobile-status-readout-vol, #mobile-status-readout-bpm {
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    min-width: 58px; height: 48px; padding: 0 8px; border-radius: 10px;
    border: 1px solid rgba(25, 196, 204, 0.45); background: rgba(25, 196, 204, 0.08); cursor: pointer;
  }
  html.pl-tempo-open #mobile-status-readout-vol, html.pl-tempo-open #mobile-status-readout-bpm { background: rgba(25, 196, 204, 0.22); border-color: #19c4cc; }
  #mobile-status-readout-vol .bottom-status-bar__vol-icon svg { width: 16px; height: 16px; }
  #bottom-status-volume-pct, #bottom-status-bpm-value { font-size: 15px !important; font-weight: 700 !important; line-height: 1.1 !important; }
  .bottom-status-bar__bpm-label { font-size: 11px !important; letter-spacing: 0.06em; }

  /* AI button that this layer adds next to play and record. */
  .pl-ai-btn {
    height: 44px; padding: 0 12px; border-radius: 10px; flex-shrink: 0;
    border: 1px solid #7c3aed; background: rgba(124, 58, 237, 0.18); color: #e9ddff;
    font: 700 14px var(--pl-font); letter-spacing: 0.04em; cursor: pointer;
  }
  html.pl-ai-open .pl-ai-btn { background: #6d28d9; color: #fff; }
  #transport-controls { gap: 8px !important; }
  /* Portrait: the full name for the brand, on as many lines as it needs. */
  #top-nav .logotype-desc { max-width: 104px; }
  #top-nav div:has(> #homeLink), #top-nav #homeLink, #top-nav .logotype-desc { flex-shrink: 0 !important; min-width: 100px; margin-right: 6px; }
  html body #top-nav#top-nav .top-nav-icon-btn, html body #top-nav#top-nav .top-nav-unique-kit-btn { padding: 0 5px !important; }
  html body #top-nav#top-nav #top-nav-share-btn { display: none !important; }
  html body #top-nav#top-nav .logotype-desc, html body #top-nav#top-nav .logotype-desc h1, html body #top-nav#top-nav .logotype-desc h1 > span {
    white-space: normal !important; overflow: visible !important; text-overflow: clip !important; max-height: none !important; height: auto !important; -webkit-line-clamp: none !important; line-clamp: none !important; display: block !important;
  }
  html body #top-nav#top-nav .logotype-desc h1 > span:last-child { display: block !important; }
  #top-nav { height: auto !important; }
  html body #top-nav#top-nav .logotype-desc h1 { font-size: 13px !important; line-height: 1.1 !important; }
  html body #top-nav#top-nav .logotype-desc h1 > span:last-child { font-size: 12px !important; line-height: 1.1 !important; margin-top: 1px; }
  #top-nav { min-height: 0 !important; padding-top: 4px !important; padding-bottom: 4px !important; }

}

/* Shared by portrait and sideways phones. */
@media (max-width: 599px), (orientation: portrait) and (max-width: 1023px), (orientation: landscape) and (max-height: 500px) and (max-width: 1023px) {
  /* ---------- Readable text (nothing under 13px for words people need to read) ---------- */
  #mobile-master-action-bar-status-slot, #mobile-master-action-bar-status-slot *,
  #statusMessage, #statusMessage *,
  #mobile-master-action-bar-status-slot #statusMessage.master-action-bar-status-item { font-size: 13px !important; line-height: 1.35 !important; }
  #mobile-master-action-bar-status-slot { min-height: 22px; }
  /* Status line locked to one line on phones: a long message gets "..." instead of wrapping, so Play never moves. */
  #mobile-master-action-bar-status-slot #statusMessage.master-action-bar-status-item {
    display: block !important; box-sizing: border-box; height: 22px !important; min-height: 22px !important; max-height: 22px !important;
    line-height: 22px !important; padding-top: 0 !important; padding-bottom: 0 !important;
    white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis; -webkit-line-clamp: unset !important;
  }
  #generateVariationBtn, #easyListeningJamBtn { font-size: 13px !important; min-height: 44px !important; }
  #mobile-main-ai-controls .cockpit-variation, #mobile-main-ai-controls .cockpit-easy-jam-evolution,
  #mobile-main-ai-controls .cockpit-variation *, #mobile-main-ai-controls .cockpit-easy-jam-evolution * { font-size: 13px !important; }
  .bottom-status-bar__tab { font-size: 14px !important; min-height: 44px !important; }
  #bottom-status-share-btn { min-height: 44px !important; min-width: 44px !important; }
  .cockpit-status-monitor__clear-label { font-size: 10px !important; }

  /* ---------- Full-width row editor ---------- */
  .pl-row-editor {
    position: fixed; left: 0; right: 0; top: var(--pl-nav-h, 60px); bottom: var(--pl-chrome-h, var(--mobile-bottom-chrome-height, 170px)); z-index: 900;
    display: none; flex-direction: column; gap: 10px; padding: 12px 14px 14px; overflow-y: auto;
    background: #0d1a24; border-top: 2px solid var(--pl-accent, #19c4cc); box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
    font-family: var(--pl-font); color: rgba(255, 255, 255, 0.92);
  }
  .pl-row-editor.is-open { display: flex; }
  .pl-ed-head { display: flex; align-items: center; gap: 8px; }
  .pl-ed-title { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
  .pl-ed-title h2 { margin: 0; font: 700 20px var(--pl-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pl-ed-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--pl-accent, #19c4cc); flex-shrink: 0; }
  .pl-ed-nav, .pl-ed-close {
    width: 44px; height: 44px; border: 1px solid rgba(25, 196, 204, 0.45); background: rgba(25, 196, 204, 0.08);
    color: #5fd8de; font: 700 22px var(--pl-font); line-height: 1; cursor: pointer; flex-shrink: 0;
  }
  .pl-ed-close { font-size: 16px; color: rgba(255, 255, 255, 0.85); border-color: rgba(255, 255, 255, 0.25); background: transparent; }
  .pl-ed-beats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .pl-ed-beats span { display: none; }
  .pl-ed-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
  .pl-ed-pad {
    position: relative; aspect-ratio: 1 / 1; border-radius: 10px; border: 1px solid #2b3a48; background: #1f2a35; cursor: pointer;
    color: rgba(255, 255, 255, 0.55); -webkit-tap-highlight-color: transparent; padding: 0;
  }
  /* Each line of 4 is one beat: the first step of every beat is a shade lighter, like the main grid's numbers. */
  .pl-ed-pad:nth-child(4n + 1) { background: #26333f; }
  .pl-ed-num { position: absolute; left: 7px; top: 5px; font: 600 13px var(--pl-font); }
  .pl-ed-pad[data-s="1"], .pl-ed-pad[data-s="2"] { background: var(--pl-accent); border-color: var(--pl-accent); color: rgba(0, 0, 0, 0.7); }
  .pl-ed-pad[data-s="3"] { background: color-mix(in srgb, var(--pl-accent) 40%, #1f2a35); border-color: var(--pl-accent); color: rgba(255, 255, 255, 0.85); }
  .pl-ed-pad[data-s="2"] .pl-ed-mark::before, .pl-ed-pad[data-s="2"] .pl-ed-mark::after {
    content: ""; position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: rgba(0, 0, 0, 0.55);
  }
  .pl-ed-pad[data-s="2"] .pl-ed-mark::before { left: calc(50% - 10px); }
  .pl-ed-pad[data-s="2"] .pl-ed-mark::after { left: calc(50% + 2px); }
  .pl-ed-pad[data-s="3"] .pl-ed-mark::before { content: var(--pl-t-soft, "soft"); position: absolute; left: 0; right: 0; bottom: 6px; font: 600 12px var(--pl-font); text-align: center; }
  .pl-ed-pad.is-now { outline: 3px solid var(--tr-brand, #19c4cc); outline-offset: 1px; }
  .pl-ed-pad:disabled { opacity: 0.25; }
  .pl-ed-hint { margin: 2px 0 0; font-size: 14px; line-height: 1.45; text-align: center; }
  .pl-ed-actions { display: flex; gap: 10px; }
  .pl-ed-btn {
    flex: 1; height: 46px; border: 1px solid #19c4cc; background: transparent;
    font: 700 14px var(--pl-font); cursor: pointer;
  }
  .pl-ed-menu {
    position: absolute; z-index: 2; width: 160px; padding: 6px; border-radius: 12px; background: #142430; border: 1px solid #19c4cc;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; gap: 4px;
  }
  .pl-ed-menu[hidden] { display: none; }
  .pl-ed-menu-title { font: 600 12px var(--pl-font); color: rgba(255, 255, 255, 0.6); padding: 4px 8px; letter-spacing: 0.05em; text-transform: uppercase; }
  .pl-ed-menu button { height: 44px; border: 0; background: transparent; color: #fff; font: 600 15px var(--pl-font); text-align: left; padding: 0 10px; cursor: pointer; }
  .pl-ed-menu button:active, .pl-ed-menu button:focus-visible { background: rgba(25, 196, 204, 0.2); outline: none; }

  /* ---------- Editor mix strip: mute, solo, row volume ---------- */
  .pl-ed-mix { display: flex; align-items: center; gap: 8px; }
  .pl-ed-chip {
    height: 40px; min-width: 64px; padding: 0 12px; cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.22); background: transparent; color: rgba(255, 255, 255, 0.85);
    font: 700 13px var(--pl-font);
  }
  .pl-ed-mute[aria-pressed="true"] { background: #b91c1c; border-color: #ef4444; color: #fff; }
  .pl-ed-solo[aria-pressed="true"] { background: #047857; border-color: #10b981; color: #fff; }
  .pl-ed-vol { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .pl-ed-vol-val { font: 600 13px var(--pl-font); text-align: right; }
  .pl-ed-vol input { width: 100%; accent-color: var(--pl-accent, #19c4cc); height: 24px; }
  .pl-row-editor.is-muted .pl-ed-grid { opacity: 0.45; }

  /* ---------- Beat view: the whole beat on one screen ---------- */
  .pl-beat, .pl-beat-back { display: none; }
  html.pl-beatview .pl-beat { display: block; }
  html.pl-beatview #sequencer-wrapper, html.pl-beatview #slicer-desktop-notice-slot { display: none !important; }
  html:not(.pl-beatview) .pl-beat-back {
    display: block; margin: 6px 12px 0 auto; height: 36px; padding: 0 14px; border-radius: 10px; cursor: pointer;
    border: 1px solid #19c4cc; background: rgba(25, 196, 204, 0.08); color: #5fd8de; font: 700 13px var(--pl-font);
  }
  .pl-beat, .pl-beat-back { grid-column: 1 / -1; min-width: 0; }
  .pl-beat { padding: 6px 2px calc(var(--pl-chrome-h, var(--mobile-bottom-chrome-height, 170px)) + 12px); font-family: var(--pl-font); }
  .pl-beat-top { display: grid; grid-template-columns: 84px 1fr; column-gap: 0; margin-bottom: 2px; }
  .pl-beat-nums span:first-child { padding-left: 8px; }
  .pl-beat-nums { grid-column: 2; display: flex; }
  .pl-beat-nums span { flex: 1 1 0; }
  .pl-beat-nums span + span { margin-left: 4px; }
  .pl-beat-nums span { font: 700 13px var(--pl-font); color: rgba(255, 255, 255, 0.55); padding-left: 2px; }
  .pl-beat-rows { display: flex; flex-direction: column; gap: 1px; }
  .pl-beat-row {
    display: grid; grid-template-columns: 84px 1fr; align-items: center; height: 30px; width: 100%; padding: 0;
    border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; color: inherit;
    -webkit-tap-highlight-color: transparent;
  }
  .pl-beat-row:active { background: rgba(25, 196, 204, 0.12); }
  .pl-beat-name {
    display: flex; align-items: center; gap: 5px; min-width: 0; padding: 0 6px 0 8px; height: 100%;
    border-left: 3px solid var(--pl-accent); font: 600 13px var(--pl-font);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .pl-beat-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .pl-beat-row.is-empty .pl-beat-name { color: rgba(255, 255, 255, 0.5); border-left-color: color-mix(in srgb, var(--pl-accent) 35%, transparent); }
  .pl-badge { flex-shrink: 0; font: 800 10px var(--pl-font); width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 4px; color: #fff; }
  .pl-badge-m { background: #b91c1c; } .pl-badge-s { background: #047857; }
  .pl-beat-cells { display: flex; gap: 2px; height: 24px; }
  /* Flex shares the space after margins, so every step is the same width. */
  .pl-beat-cells i { flex: 1 1 0; display: block; border-radius: 4px; background: #1f2a35; position: relative; }
  /* A little more space between beats so the four groups read at a glance. */
  .pl-beat-cells i:nth-child(4n + 1):not(:first-child) { margin-left: 2px; }
  .pl-beat-cells i:nth-child(4n + 1) { background: #26333f; }
  .pl-beat-cells i[data-s="1"], .pl-beat-cells i[data-s="2"] { background: var(--pl-accent); box-shadow: 0 0 6px color-mix(in srgb, var(--pl-accent) 55%, transparent); }
  .pl-beat-cells i[data-s="3"] { background: color-mix(in srgb, var(--pl-accent) 45%, #1f2a35); }
  .pl-beat-cells i[data-s="2"]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); }
  .pl-beat-cells i[data-s="x"] { opacity: 0.2; }
  .pl-beat-cells i.is-now { outline: 2px solid var(--tr-brand, #19c4cc); outline-offset: 0; }
  .pl-beat-row.is-silent .pl-beat-cells { opacity: 0.35; }
  .pl-beat-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 13px; }
  .pl-beat-switch {
    height: 36px; padding: 0 14px; cursor: pointer;
    border: 1px solid rgba(25, 196, 204, 0.45); background: transparent; font: 700 13px var(--pl-font);
  }

  /* ---------- The app's own instrument panel: readable labels ---------- */
  #mobile-instrument-controls-sheet .control-label { font-size: 12px !important; letter-spacing: 0.05em; }
  #mobile-instrument-controls-sheet .custom-sample-upload-btn, #mobile-instrument-controls-sheet .notes-mode-btn { font-size: 13px !important; min-height: 36px; }

  /* ---------- Kits, Mixer, Export and AI: readable words (13px) and thumb-size buttons ---------- */
  .kit-btn, #randomizeSettingsBtn span, #defaultTonesBtn span, #flattenTonesBtn span, #balanceInstrumentsBtn span,
  #saveSettingsBtn span, #loadSettingsBtn span, #loadMidiBtn span { font-size: 14px !important; line-height: 1.2 !important; }
  .kit-btn { min-height: 40px !important; }
  [id$="ValueContainer"] span, [id$="ValueContainer"] .master-controls-units, #cockpit-humanize-block span { font-size: 13px !important; }
  .swing-resolution-btn { font-size: 13px !important; min-height: 32px !important; padding: 0 10px !important; }
  .pattern-add-btn { font-size: 13px !important; min-height: 40px !important; }
  #chainCount span, .master-action-bar-label, .export-length, .master-action-bar-stems-label span { font-size: 14px !important; }
  .master-action-bar-export-btn span { font-size: 13px !important; }
  .master-action-bar-export-btn { min-height: 40px !important; }
  #generateVariationBtnText, .easy-listening-jam-btn { font-size: 13px !important; }
  /* The app's drawer rules ('#drawer-panel-kit button' and friends) are very specific; the doubled id outranks them. */
  #control-drawer#control-drawer button.kit-btn { font-size: 14px !important; letter-spacing: 0.02em !important; padding-left: 2px !important; padding-right: 2px !important; }
  #control-drawer#control-drawer button.swing-resolution-btn,
  #control-drawer#control-drawer button.pattern-add-btn { font-size: 15px !important; }
  #mobile-main-ai-controls#mobile-main-ai-controls .easy-listening-jam-btn { font-size: 13px !important; }
  #control-drawer#control-drawer button.pattern-add-btn, #control-drawer#control-drawer button.kit-btn { min-height: 40px !important; }
  #chainCount#chainCount, #chainCount#chainCount * { font-size: 14px !important; }
  /* Long labels at 13px: drop the extra letter spacing so they stay inside their buttons. */
  #control-drawer#control-drawer :is(#randomizeSettingsBtn, #defaultTonesBtn, #flattenTonesBtn, #balanceInstrumentsBtn),
  #control-drawer#control-drawer :is(#randomizeSettingsBtn, #defaultTonesBtn, #flattenTonesBtn, #balanceInstrumentsBtn) span,
  #control-drawer#control-drawer .master-action-bar-export-btn, #control-drawer#control-drawer .master-action-bar-export-btn span {
    letter-spacing: 0 !important; padding-left: 2px !important; padding-right: 2px !important;
  }
  #control-drawer#control-drawer :is(#randomizeSettingsBtn, #defaultTonesBtn, #flattenTonesBtn, #balanceInstrumentsBtn) span { text-transform: none !important; }
  #user-sidebar .lang-link, #user-sidebar .auth-subtext, #user-sidebar .auth-subtext * { font-size: 13px !important; }
  #mobileClearAllCustomSamplesBtn .cockpit-status-monitor__clear-label, .bottom-status-bar__bpm-label { font-size: 12px !important; }

  /* ---------- Typography: follow the app (capitals with spaced letters on buttons, lighter weights, cyan text) ---------- */
  .pl-mode, .pl-rec, .pl-ed-btn, .pl-ed-chip, .pl-beat-switch, .pl-beat-back, .pl-tone, .pl-ai-btn, .pl-desktop-note button {
    font-family: inherit !important; text-transform: uppercase; font-weight: 600 !important; letter-spacing: 0.07em !important;
  }
  .pl-mode, .pl-beat-switch, .pl-ed-btn, .pl-beat-back { color: #99f7ff; }
  .pl-ed-title h2 { font-family: inherit; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; font-size: 18px; color: #e8fcff; }
  .pl-beat-name { font-family: inherit; font-weight: 500; color: #e8fcff; }
  .pl-beat-nums span, .pl-ed-num { font-family: inherit; font-weight: 400; }
  .pl-ed-hint, .pl-pads-hint, .pl-beat-foot { font-weight: 300; letter-spacing: 0.02em; color: rgba(255, 255, 255, 0.72); }
  .pl-ed-vol-val { font-family: inherit; font-weight: 500; color: #99f7ff; }

  /* ---------- Modes row: Steps/Pads, then the song (Steps) or Tap into track (Pads) ---------- */
  .pl-beat-modes { min-height: 40px; }
  .pl-mode { font-size: 13px !important; }
  .pl-song { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; overflow-x: auto; scrollbar-width: none; padding-left: 4px; }
  html.pl-padmode .pl-song { display: none; }
  .pl-song-chip, .pl-song-add, .pl-song-trash {
    position: relative; flex-shrink: 0; height: 36px; min-width: 34px; padding: 0 6px; cursor: pointer;
    font: 600 15px inherit; font-family: inherit; border: 1px solid #2b3a48; background: #1f2a35; color: #e8fcff;
  }
  .pl-song-chip.is-edit { background: #19c4cc; border-color: #19c4cc; color: #04262a; }
  .pl-song-chip.is-playing::after { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; }
  .pl-song-add { color: #99f7ff; border-style: dashed; border-color: rgba(25, 196, 204, 0.6); background: transparent; font-size: 20px; line-height: 1; }
  .pl-song-trash { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, 0.7); background: transparent; }
  .pl-song-trash span:empty { display: none; }
  /* While asking "Delete B?", the letters step aside so the question fits. */
  .pl-song.is-confirm .pl-song-chip, .pl-song.is-confirm .pl-song-add { display: none; }
  .pl-song-trash.is-armed { background: #b91c1c; border-color: #ef4444; color: #fff; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }

  /* ---------- Tone buttons + Clip: in the bottom area, just above play and record ---------- */
  .pl-tones { grid-area: tones; display: flex; gap: 6px; margin: 0 0 8px; }
  .pl-tone {
    --c: #19c4cc; flex: 1 1 0; min-width: 0; height: 36px; padding: 0 2px; cursor: pointer; font-size: 12px !important; line-height: 1.05;
    letter-spacing: 0.02em !important; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    border: 1px solid var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
  }
  .pl-tone[data-k="random"] { --c: #e879f9; }
  .pl-tone[data-k="default"] { --c: #5fd8de; }
  .pl-tone[data-k="flatten"] { --c: #fbbf24; }
  .pl-tone[data-k="balance"] { --c: #4ade80; }
  .pl-tone[data-k="clip"] { --c: #e8fcff; flex: 0.85 1 0; }
  .pl-tone:active, .pl-tone.is-fired { background: var(--c); color: #0b141b; }
  .pl-tone.is-fired { animation: pl-fire 0.35s ease-out forwards; }
  @keyframes pl-fire { to { background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--c); } }
  .pl-clip.is-busy { --c: #ef4444; animation: pl-pulse 0.8s ease-in-out infinite alternate; }
  @keyframes pl-pulse { to { background: color-mix(in srgb, #ef4444 35%, transparent); } }

  /* ---------- Which pattern you are on ---------- */
  .pl-pat-label { grid-column: 1; align-self: end; padding-left: 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.03em; text-transform: uppercase; color: rgba(255, 255, 255, 0.6); white-space: nowrap; overflow: visible; }
  .pl-pat-label b { font-size: 15px; font-weight: 700; color: #19c4cc; margin-left: 1px; }
  .pl-pat-label i { font-style: normal; display: block; font-size: 10px; color: #4ade80; letter-spacing: 0.06em; }
  .pl-pat-label.is-note { color: #fbbf24; text-transform: none; letter-spacing: 0; font-size: 12px; white-space: normal; line-height: 1.2; }
  .pl-beat-nums { grid-row: 1; }
  .pl-beat-rows { touch-action: pan-y; }
  .pl-beat-rows.pl-slide-l { animation: pl-in-l 0.22s ease-out; }
  .pl-beat-rows.pl-slide-r { animation: pl-in-r 0.22s ease-out; }
  @keyframes pl-in-l { from { transform: translateX(28px); opacity: 0.4; } }
  @keyframes pl-in-r { from { transform: translateX(-28px); opacity: 0.4; } }
  .pl-song-undo { flex-shrink: 0; height: 36px; min-width: 36px; cursor: pointer; margin-left: auto; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #2b3a48; background: transparent; color: rgba(255, 255, 255, 0.75); }
  .pl-song-undo + .pl-song-trash { margin-left: 0; }
  .pl-install { height: 36px; padding: 0 12px; cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.3); background: transparent;
    color: #e8fcff; font-family: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
  .pl-beat-foot { flex-wrap: wrap; }

  /* ---------- Pads: the app's own pad look (flat tiles; lit = colour with the white glow of a lit step) ---------- */
  .pl-pad {
    position: relative; border-radius: 10px; cursor: pointer; padding: 0; -webkit-tap-highlight-color: transparent;
    background: color-mix(in srgb, var(--pl-accent) 7%, transparent); border: 1px solid color-mix(in srgb, var(--pl-accent) 28%, transparent);
  }
  .pl-pad span {
    position: absolute; left: 8px; right: 6px; bottom: 7px; text-align: left; font-family: inherit; font-size: 13px; font-weight: 500;
    color: #e8fcff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .pl-pad.is-beat { border-color: var(--pl-accent); background: color-mix(in srgb, var(--pl-accent) 22%, transparent); }
  .pl-pad.is-hit { background: var(--pl-accent); border: 1px solid var(--pl-accent); box-shadow: 0 0 14px color-mix(in srgb, var(--pl-accent) 60%, transparent); }
  .pl-pad.is-hit.is-soft { background: color-mix(in srgb, var(--pl-accent) 55%, transparent); }
  .pl-pad.is-hit span { color: rgba(0, 0, 0, 0.78); }
  .pl-pad.is-rolling { border-color: #e8fcff; }
  .pl-pad.is-silent { opacity: 0.45; }
  .pl-pad.is-silent::after { content: "M"; position: absolute; top: 6px; right: 7px; font-size: 11px; font-weight: 800; color: #fff; background: #b91c1c; border-radius: 4px; padding: 1px 4px; }

  /* ---------- Mood list: a bottom sheet that swipes down to close ---------- */
  #atmospherePanel#atmospherePanel {
    position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: auto !important;
    max-width: none !important; max-height: 72vh !important; border-radius: 16px 16px 0 0 !important; padding: 26px 14px calc(14px + env(safe-area-inset-bottom)) !important;
    overscroll-behavior: contain;
  }
  #atmospherePanel#atmospherePanel::before {
    content: ""; position: absolute; top: 9px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: rgba(255, 255, 255, 0.35);
  }
  #atmospherePanel#atmospherePanel .atmosphere-option { font-size: 15px !important; min-height: 40px !important; padding: 0 8px !important; }
  #atmospherePanel#atmospherePanel .atmosphere-group__title { font-size: 13px !important; margin-top: 10px; }

  /* ---------- Mixer: two columns of cards (name and value on top, slider below), bigger text ---------- */
  #drawer-panel-beat#drawer-panel-beat .cockpit-master-sliders, #drawer-panel-beat#drawer-panel-beat .cockpit-tempo-mini {
    display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; row-gap: 14px !important; column-gap: 28px !important; height: auto !important;
  }
  #drawer-panel-beat#drawer-panel-beat #eqPanel { display: contents !important; }
  #drawer-panel-beat#drawer-panel-beat .cockpit-slider-row {
    grid-template-columns: 1fr auto auto !important; grid-auto-rows: auto; row-gap: 0 !important; height: auto !important; min-height: 0 !important; align-items: center; min-width: 0;
  }
  #drawer-panel-beat#drawer-panel-beat .cockpit-slider-row > input[type="range"] { grid-column: 1 / -1 !important; grid-row: 2 !important; width: 100% !important; }
  #drawer-panel-beat#drawer-panel-beat .cockpit-slider-row__extra { grid-column: 1 / -1 !important; grid-row: 3 !important; justify-content: flex-start !important; }
  #drawer-panel-beat#drawer-panel-beat [id$="ValueContainer"] span, #drawer-panel-beat#drawer-panel-beat [id$="ValueContainer"] input,
  #drawer-panel-beat#drawer-panel-beat #cockpit-humanize-block span { font-size: 14px !important; }
  #drawer-panel-beat#drawer-panel-beat .master-controls-units { font-size: 12px !important; padding-left: 3px; }
  #drawer-panel-beat#drawer-panel-beat [id$="ValueContainer"] input { width: 54px !important; min-width: 54px !important; text-align: right; }

  /* ---------- Drawers on phones: the song editor lives on the beat view, the tone buttons above play ---------- */
  #control-drawer #pattern-timeline-section, #control-drawer .tone-buttons-row { display: none !important; }

  /* ---------- Loading: the desktop's cyan sweep behind the name of the instrument being loaded ---------- */
  .pl-beat-row.is-loading .pl-beat-name, .pl-pad.is-loading, .pl-row-editor.is-loading .pl-ed-title { position: relative; overflow: hidden; }
  .pl-beat-row.is-loading .pl-beat-name::after, .pl-pad.is-loading::before, .pl-row-editor.is-loading .pl-ed-title::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: -42%; width: 42%; pointer-events: none; z-index: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(0, 255, 255, 0.24) 32%, rgba(0, 255, 255, 0.78) 50%, rgba(0, 255, 255, 0.24) 68%, transparent 100%);
    animation: customSampleLoadingSweepX var(--custom-sample-load-cycle, 1.2s) linear infinite;
  }
  .pl-beat-row.is-loading .pl-beat-name { background: rgba(0, 255, 255, 0.10); }

  /* ---------- Stage: full screen pads ---------- */
  .pl-stage-btn {
    display: none; height: 36px; padding: 0 12px; cursor: pointer; margin-left: auto;
    border: 1px solid rgba(232, 252, 255, 0.5); background: transparent; color: #e8fcff;
    font-family: inherit; font-size: 13px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  }
  html.pl-padmode .pl-stage-btn { display: inline-flex; align-items: center; }
  html.pl-padmode .pl-stage-btn + .pl-rec { margin-left: 0; }
  .pl-stage-head, .pl-stage-foot, .pl-stage-tip { display: none; }
  html.pl-stage #top-nav, html.pl-stage #mobile-bottom-chrome, html.pl-stage .pl-beat-modes, html.pl-stage .pl-pads-hint,
  html.pl-stage .pl-desktop-note, html.pl-stage #control-drawer { display: none !important; }
  html.pl-stage .pl-beat {
    position: fixed; inset: 0; z-index: 950; display: flex; flex-direction: column; gap: 10px; margin: 0; width: auto; height: auto;
    padding: calc(14px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    background: radial-gradient(120% 70% at 50% 0%, #10222c 0%, #0b141b 60%);
  }
  html.pl-stage .pl-stage-head { display: block; text-align: center; }
  .pl-stage-title { font-size: 15px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: #e8fcff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pl-stage-meta { margin-top: 3px; font-size: 13px; font-weight: 400; letter-spacing: 0.06em; color: rgba(232, 252, 255, 0.65); }
  .pl-stage-meta b { color: #19c4cc; font-weight: 700; }
  html.pl-stage .pl-pads { flex: 1; height: auto !important; min-height: 0; gap: 10px; }
  html.pl-stage .pl-pad.is-beat { box-shadow: 0 0 22px color-mix(in srgb, var(--pl-accent) 55%, transparent); }
  html.pl-stage .pl-pad.is-hit { box-shadow: 0 0 30px var(--pl-accent); }
  html.pl-stage .pl-stage-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
  .pl-stage-play {
    grid-column: 2; width: 60px; height: 60px; cursor: pointer; border: 2px solid #22c55e; background: rgba(34, 197, 94, 0.15); position: relative;
  }
  .pl-stage-play::before { content: ""; position: absolute; left: 50%; top: 50%; margin: -11px 0 0 -6px; border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent #22c55e; }
  .pl-stage-play.is-playing { border-color: #fbbf24; background: rgba(251, 191, 36, 0.15); }
  .pl-stage-play.is-playing::before { border: 0; width: 18px; height: 20px; margin: -10px 0 0 -9px; background: linear-gradient(90deg, #fbbf24 0 6px, transparent 6px 12px, #fbbf24 12px 18px); }
  .pl-stage-mark { grid-column: 1; grid-row: 1; font-size: 12px; font-weight: 500; letter-spacing: 0.08em; color: rgba(232, 252, 255, 0.45); }
  .pl-stage-exit { grid-column: 3; grid-row: 1; justify-self: end; width: 44px; height: 44px; border: 1px solid rgba(255, 255, 255, 0.2); background: transparent; color: rgba(255, 255, 255, 0.7); font-size: 16px; cursor: pointer; }
  html.pl-stage .pl-stage-tip:not([hidden]) {
    display: block; align-self: center; margin-top: 8px; max-width: 100%; text-align: center;
    padding: 8px 14px; border-radius: 10px; background: rgba(11, 20, 27, 0.92); border: 1px solid rgba(25, 196, 204, 0.5); color: #e8fcff; font-size: 13px;
  }

  /* ---------- "More on desktop" card ---------- */
  /* Floats over the page (fixed), so it never pushes the beat down when it appears. */
  .pl-desktop-note {
    position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 8px; right: 8px; z-index: 60;
    margin: 0; padding: 12px 14px; border-radius: 12px;
    border: 1px solid rgba(25, 196, 204, 0.45);
    background: linear-gradient(180deg, rgba(25, 196, 204, 0.16), rgba(25, 196, 204, 0.06)), #08171c;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.92); font: 14px/1.45 var(--pl-font);
    animation: pl-note-in 0.25s ease-out;
  }
  @keyframes pl-note-in { from { opacity: 0; transform: translateY(-8px); } }
  .pl-desktop-note b { color: #5fd8de; }
  .pl-desktop-note .pl-row { display: flex; gap: 8px; margin-top: 10px; }
  .pl-desktop-note button {
    height: 40px; padding: 0 14px; border-radius: 10px; font: 700 13px var(--pl-font); cursor: pointer;
    border: 1px solid #19c4cc; background: #19c4cc; color: #04262a;
  }
  .pl-desktop-note button.pl-ghost { background: transparent; color: #5fd8de; }
  /* ---------- Steps / Pads switch and finger pads ---------- */
  .pl-beat-modes { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
  .pl-mode {
    height: 40px; min-width: 84px; padding: 0 16px; cursor: pointer; font: 700 14px var(--pl-font); letter-spacing: 0.04em;
    border: 1px solid rgba(25, 196, 204, 0.45); background: transparent; color: #5fd8de;
  }
  .pl-mode[data-mode="pads"] { margin-left: -8px; }
  .pl-mode[aria-selected="true"] { background: #19c4cc; color: #04262a; border-color: #19c4cc; }
  .pl-rec {
    display: none; margin-left: auto; height: 40px; padding: 0 14px; cursor: pointer; align-items: center; gap: 8px;
    border: 1px solid rgba(239, 68, 68, 0.6); background: transparent; color: #fca5a5; font: 700 13px var(--pl-font);
  }
  html.pl-padmode .pl-rec { display: flex; }
  .pl-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }
  .pl-rec[aria-pressed="true"] { background: #b91c1c; border-color: #ef4444; color: #fff; }
  .pl-rec[aria-pressed="true"] .pl-rec-dot { background: #fff; }
  html.pl-recording .pl-rec-dot { animation: pl-blink 0.9s steps(2, start) infinite; }
  @keyframes pl-blink { to { visibility: hidden; } }
  .pl-pads, .pl-pads-hint { display: none; }
  html.pl-padmode .pl-pads { display: grid; }
  html.pl-padmode .pl-pads-hint { display: block; }
  html.pl-padmode .pl-beat-top, html.pl-padmode .pl-beat-rows, html.pl-padmode .pl-beat-foot { display: none; }
  .pl-pads {
    grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 8px;
    height: calc(100dvh - var(--pl-nav-h, 60px) - var(--pl-chrome-h, var(--mobile-bottom-chrome-height, 170px)) - 112px); min-height: 300px;
    touch-action: none; user-select: none; -webkit-user-select: none;
  }
  .pl-pads-hint { margin: 8px 2px 0; font-size: 13px; line-height: 1.4; color: rgba(255, 255, 255, 0.65); }

/* ---------- Top bar on phones: words instead of mystery icons, text-only title, no About button ---------- */
  #top-nav #title-image-placeholder, #top-nav #top-nav-about-info-btn, #top-nav .top-nav-btn__face { display: none !important; }
  #top-nav .logotype-desc h1 { font-size: 15px !important; line-height: 1.15 !important; margin: 0 !important; }
  #top-nav .logotype-desc h1 > span:last-child { display: inline !important; font-size: 13px; font-weight: 500 !important; letter-spacing: 0.02em; color: rgba(232, 252, 255, 0.85); }
  html body #top-nav#top-nav .top-nav-icon-btn, html body #top-nav#top-nav .top-nav-unique-kit-btn {
    width: auto !important; min-width: 0 !important; height: 44px !important; display: inline-flex !important; align-items: center; justify-content: center;
    border-radius: 4px !important;
  }
  html body #top-nav#top-nav button .top-nav-icon-btn__label, html body #top-nav#top-nav .get-unique-kit-label {
    display: block !important; position: static !important; width: auto !important; height: auto !important; clip: auto !important; overflow: visible !important; margin: 0 !important;
    font: 500 12px/1.15 var(--pl-font) !important; letter-spacing: 0 !important; text-transform: none !important; text-align: center; white-space: normal !important; color: inherit;
  }
  html body #top-nav#top-nav .get-unique-kit-label { max-width: 62px; }
  html body #top-nav#top-nav #top-nav-about-info-btn { display: none !important; }

/* ---------- New buttons get the same square-ish corners as the app's own buttons (4px); pads keep theirs ---------- */
  .pl-tone, .pl-ai-btn, .pl-ok, .pl-ghost, .pl-song-chip, .pl-song-add, .pl-song-undo, .pl-song-trash, .pl-install, .pl-beat-switch, .pl-rec, .pl-stage-btn,
  .pl-stage-exit, .pl-stage-play, .pl-ed-btn, .pl-ed-nav, .pl-ed-close, .pl-ed-chip, .pl-beat-back, .pl-ed-menu button,
  #mobile-status-readout-vol, #mobile-status-readout-bpm { border-radius: 4px !important; }
  .pl-mode[data-mode="steps"] { border-radius: 4px 0 0 4px !important; }
  .pl-mode[data-mode="pads"] { border-radius: 0 4px 4px 0 !important; }

/* ---------- Round 10: tone buttons say what they change; slimmer title; Volume and Tempo side by side ---------- */
  .pl-tone[data-src], .pl-tone.pl-clip { flex-direction: column; gap: 1px; }
  .pl-tone small { display: block; font-size: 10px; font-weight: 500; letter-spacing: 0.05em; opacity: 0.8; }
  html body #top-nav#top-nav #top-nav-share-btn { display: none !important; }
  html.pl-tempo-open #cockpit-volume-block::before, html.pl-tempo-open #cockpit-bpm-block::before { width: auto !important; }
  html.pl-tempo-open #cockpit-volume-block, html.pl-tempo-open #cockpit-bpm-block { min-width: 0; gap: 8px !important; }
  #cockpit-volume-block input, #cockpit-bpm-block input { min-width: 0; }

/* ---------- Row editor: Key, Scale, Chord rhythm and Suggest for Bassline and Chords ---------- */
  .pl-ed-notes { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; grid-area: notes; }
  .pl-ed-notes[hidden], .pl-n-field[hidden] { display: none !important; }
  .pl-n-field { display: flex; flex-direction: column; gap: 3px; flex: 1 1 0; min-width: 0; }
  .pl-n-field > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pl-n-field select {
    height: 40px; width: 100%; min-width: 0; padding: 0 8px; border-radius: 4px; border: 1px solid rgba(25, 196, 204, 0.45);
    background: #0b141b; color: #e8fcff; font: 500 15px var(--pl-font);
  }
  .pl-n-field select:disabled { opacity: 0.5; }
  .pl-ed-btn.pl-n-suggest {
    flex: 1 1 0; min-width: 120px; height: 40px; padding: 0 8px !important; white-space: nowrap; border-color: var(--pl-accent) !important; color: #04262a !important;
    background: var(--pl-accent) !important; font-weight: 700;
  }
}

/* ---------- Phone turned sideways ---------- */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1023px) {
  html body #top-nav#top-nav .top-nav-icon-btn, html body #top-nav#top-nav .top-nav-unique-kit-btn { padding: 0 7px !important; }
  :root { --pl-nav-h: 48px; }
  /* Slim top bar: title on one line, labelled buttons. */
  #top-nav { height: 48px !important; min-height: 0 !important; padding-top: 2px !important; padding-bottom: 2px !important; overflow: hidden; }
  #top-nav .logotype-desc h1 { white-space: nowrap; }
  /* Bottom area: one line. AI and sliders open above it. */
  #mobile-bottom-chrome {
    display: grid !important; grid-template-columns: auto auto auto 1fr; column-gap: 10px; row-gap: 0;
    grid-template-areas: "ai ai ai ai" "vs vs bs bs" "tones tones tones tones" "status vol bpm tabs" "msg msg msg msg";
    padding: 6px 12px calc(2px + env(safe-area-inset-bottom)) !important; align-items: center;
  }
  #mobile-master-sliders, #mobile-vol-slot, #mobile-bpm-slot { display: contents !important; }
  #mobile-main-ai-controls { grid-area: ai; display: none !important; margin-bottom: 6px; }
  html.pl-ai-open #mobile-main-ai-controls { display: block !important; }
  #mobile-cockpit-status-slot { grid-area: status; display: flex !important; align-items: center; gap: 8px; }
  #mobile-status-readout-vol { grid-area: vol; } #mobile-status-readout-bpm { grid-area: bpm; }
  #cockpit-volume-block { grid-area: vs; display: none !important; } #cockpit-bpm-block { grid-area: bs; display: none !important; }
  html.pl-tempo-open #cockpit-volume-block, html.pl-tempo-open #cockpit-bpm-block { display: flex !important; align-items: center; gap: 10px; margin-bottom: 6px; }
  html.pl-tempo-open #cockpit-volume-block::before, html.pl-tempo-open #cockpit-bpm-block::before { font: 600 13px var(--pl-font); color: rgba(255, 255, 255, 0.75); width: 60px; flex-shrink: 0; }
  html.pl-tempo-open #cockpit-volume-block::before { content: var(--pl-t-volume, "Volume"); } html.pl-tempo-open #cockpit-bpm-block::before { content: var(--pl-t-tempo, "Tempo"); }
  #cockpit-volume-block input, #cockpit-bpm-block input { flex: 1; }
  #bottom-status-bar { grid-area: tabs; margin: 0 !important; min-width: 0; }
  #mobile-master-action-bar-status-slot { grid-area: msg; min-height: 0 !important; }
  #mobile-master-action-bar-status-slot #statusMessage.master-action-bar-status-item { padding: 0 !important; }
  #playPauseBtn, #liveRecBtn { width: 44px !important; height: 44px !important; }
  #mobile-status-readout-vol, #mobile-status-readout-bpm {
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    min-width: 58px; height: 44px; padding: 0 8px; border-radius: 10px; cursor: pointer;
    border: 1px solid rgba(25, 196, 204, 0.45); background: rgba(25, 196, 204, 0.08);
  }
  #bottom-status-volume-pct, #bottom-status-bpm-value { font-size: 15px !important; font-weight: 700 !important; line-height: 1.1 !important; }
  .pl-ai-btn { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid #7c3aed; background: rgba(124, 58, 237, 0.18); color: #e9ddff; font: 700 14px var(--pl-font); cursor: pointer; }
  html.pl-ai-open .pl-ai-btn { background: #6d28d9; color: #fff; }
  .pl-desktop-note { display: none; }
  /* Wider steps: tap them directly; names stay readable. */
  .pl-beat-top, .pl-beat-row { grid-template-columns: 112px 1fr; }
  .pl-beat-modes { margin-bottom: 4px; } .pl-mode, .pl-rec { height: 34px; }
  .pl-beat-rows { gap: 2px; }
  .pl-beat-row { height: 32px; }
  .pl-beat-cells { height: 28px; gap: 4px; }
  .pl-beat-cells i:nth-child(4n + 1):not(:first-child) { margin-left: 6px; }
  .pl-beat-nums span + span { margin-left: 6px; }
  .pl-beat-foot span::after { content: var(--pl-t-tapstep, " Tap a step to switch it on or off."); }
  /* Editor: all 16 steps in two lines of 8. */
  /* Header on top; mix and the two buttons share one line; steps below. */
  .pl-row-editor.is-open { display: grid; grid-template-columns: 1fr auto; align-content: start; }
  .pl-row-editor { padding: 6px 14px 8px; gap: 6px 12px; }
  .pl-ed-head { grid-area: head; gap: 8px; } .pl-ed-mix { grid-area: mix; } .pl-ed-actions { grid-area: actions; }
  .pl-ed-nav, .pl-ed-close { height: 40px; }
  .pl-ed-btn { height: 40px; padding: 0 16px; flex: none; }
  .pl-ed-grid { grid-area: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
  .pl-ed-pad { aspect-ratio: auto; height: 52px; }
  .pl-ed-beats { display: none; }
  .pl-tones { margin-bottom: 5px; } .pl-tone { height: 30px; }
  #mobile-master-action-bar-status-slot { display: none !important; }
  .pl-ed-hint { display: none; }
  /* Pads: two rows of eight, big enough for thumbs. */
  .pl-pads { grid-template-columns: repeat(8, 1fr); height: calc(100dvh - var(--pl-nav-h) - var(--pl-chrome-h, var(--mobile-bottom-chrome-height, 80px)) - 96px); min-height: 150px; }
  .pl-pads-hint { margin-top: 6px; }
/* Sideways with the notch at one side: keep content clear of it. */
  #top-nav, #mobile-bottom-chrome, .pl-beat, .pl-row-editor { padding-left: max(12px, env(safe-area-inset-left)) !important; padding-right: max(12px, env(safe-area-inset-right)) !important; }

/* ---------- Sideways: the Mixer shows every control without scrolling ---------- */
  html:has(#control-drawer.is-open) .pl-tones { display: none !important; }
  #drawer-panel-beat#drawer-panel-beat .cockpit-master-sliders, #drawer-panel-beat#drawer-panel-beat .cockpit-tempo-mini {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important; row-gap: 2px !important; column-gap: 18px !important;
  }
  #top-nav .logotype-desc h1 { font-size: 13px !important; } #top-nav .logotype-desc h1 > span:last-child { font-size: 12px !important; }
  #top-nav .top-nav-bar__leading, #top-nav .top-nav-bar__col--left { align-self: center !important; align-items: center !important; }
  .pl-row-editor.is-open { grid-template-areas: "head head" "mix actions" "notes notes" "grid grid" !important; }
  .pl-ed-btn.pl-n-suggest { flex: 1.2 1 0; height: 38px; }
  .pl-n-field select { height: 38px; }
  .pl-row-editor.is-open:has(.pl-ed-notes:not([hidden])) .pl-ed-pad { height: 42px !important; }
}

/* ---------- Opened from the Home Screen (full screen) ---------- */
@media (display-mode: standalone) and (max-width: 1023px) {
  :root { --pl-nav-h: calc(60px + env(safe-area-inset-top)); }
  #top-nav { padding-top: env(safe-area-inset-top) !important; height: auto !important; }
  #app-container { padding-top: env(safe-area-inset-top); }
  .pl-install { display: none; }
}

/* ---------- Upright tablets: the phone layout, sized up to fill the screen ---------- */
@media (orientation: portrait) and (min-width: 600px) and (max-width: 1023px) {
  .pl-beat { padding-left: 12px; padding-right: 12px; }
  .pl-beat-top, .pl-beat-row { grid-template-columns: 140px 1fr; }
  .pl-beat-row { height: clamp(32px, calc((100dvh - var(--pl-nav-h, 60px) - var(--pl-chrome-h, 200px) - 130px) / 16), 64px); }
  .pl-beat-rows { gap: 3px; }
  .pl-beat-cells { height: calc(100% - 4px); gap: 5px; }
  .pl-beat-cells i:nth-child(4n + 1):not(:first-child) { margin-left: 8px; }
  .pl-beat-nums span + span { margin-left: 8px; }
  .pl-beat-name { font-size: 15px !important; }
  .pl-beat-nums span { font-size: 14px; }
  .pl-mode, .pl-rec, .pl-stage-btn { height: 44px; }
  .pl-tone { height: 42px !important; font-size: 13px !important; }
  .pl-tone small { font-size: 11px; }
  .pl-pads { gap: 12px; }
  .pl-pad { font-size: 16px; }
  .pl-ed-pad { aspect-ratio: auto !important; height: 96px; }
  /* Room for the pattern editor in Export (the tone buttons stay at the bottom, always visible). */
  #control-drawer #pattern-timeline-section { display: block !important; }
}
@media (max-width: 599px) {
  /* Narrow phones: two per line (Key + Scale, then Rhythm + Suggest; Bassline's Suggest takes the whole second line). */
  .pl-ed-notes > .pl-n-field, .pl-ed-notes > .pl-n-suggest { flex: 1 1 calc(50% - 4px) !important; min-width: 0 !important; }
  .pl-n-field select { font-size: 14px; }
  /* With the Key/Scale strip showing, slightly shorter steps keep all 16 on screen. */
  .pl-row-editor.is-open:has(.pl-ed-notes:not([hidden])) .pl-ed-pad { aspect-ratio: auto !important; height: 62px; }
}

/* ---------- Share as video: a bottom sheet (opened from the Share Video button) ---------- */
.pl-vsheet { position: fixed; inset: 0; z-index: 5000; display: none; align-items: flex-end; background: rgba(0, 0, 0, 0.35); font-family: var(--pl-font); }
.pl-vsheet.is-open { display: flex; }
.pl-vs-card {
  /* Same look as the Drum Kits / Mixer / Export drawers: glass, thin cyan top line, wide pill handle. */
  position: relative; width: 100%; max-width: 560px; margin: 0 auto; color: #e8fcff;
  background: var(--tr-dock-glass-bg, rgba(12, 15, 23, 0.86)); -webkit-backdrop-filter: var(--tr-dock-glass-backdrop, blur(14px)); backdrop-filter: var(--tr-dock-glass-backdrop, blur(14px));
  border-top: 1px solid #00ffff47; box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.28), 0 -20px 48px rgba(0, 0, 0, 0.18);
  padding: 0 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px;
  max-height: 90dvh; overflow-y: auto;
}
.pl-vs-handle { display: flex; justify-content: center; align-items: center; min-height: 34px; margin: 0 -16px -8px; touch-action: none; cursor: grab; }
.pl-vs-handle::after { content: ""; width: min(88vw, 200px); height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.28); box-shadow: 0 0 0 1px rgba(0, 242, 255, 0.18); }
.pl-vs-head { display: flex; align-items: center; justify-content: space-between; }
.pl-vs-head h2 { margin: 0; font: 600 15px var(--pl-font); letter-spacing: 0.08em; text-transform: uppercase; color: #99f7ff; }
.pl-vs-close { width: 40px; height: 40px; border: 0; border-radius: 4px; background: transparent; color: #e8fcff; font-size: 18px; }
.pl-vs-intro, .pl-vs-len { margin: 0; font-size: 14px; line-height: 1.4; color: rgba(232, 252, 255, 0.8); }
.pl-vs-len { font-size: 13px; color: rgba(232, 252, 255, 0.6); }
.pl-vs-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pl-vs-group > span { flex: 0 0 64px; font: 500 13px var(--pl-font); text-transform: uppercase; letter-spacing: 0.06em; color: rgba(232, 252, 255, 0.7); }
.pl-vs-group button {
  flex: 1 1 0; min-height: 40px; padding: 0 8px; border-radius: 4px; border: 1px solid rgba(153, 247, 255, 0.3); background: #13232f;
  color: #e8fcff; font: 500 13px var(--pl-font);
}
.pl-vs-group button[aria-pressed="true"] { background: #19c4cc; border-color: #19c4cc; color: #04262a; font-weight: 600; }
.pl-vs-make, .pl-vs-share, .pl-vs-save {
  width: 100%; min-height: 48px; border-radius: 4px; border: 0; background: #19c4cc; color: #04262a;
  font: 600 15px var(--pl-font); letter-spacing: 0.08em; text-transform: uppercase;
}
.pl-vs-make:disabled { opacity: 0.5; }
.pl-vs-done { display: flex; flex-direction: column; gap: 8px; }
.pl-vs-done[hidden], .pl-vs-progress[hidden], .pl-vs-card [hidden] { display: none !important; }
.pl-vs-save { background: #13232f; color: #e8fcff; border: 1px solid rgba(153, 247, 255, 0.3); }
.pl-vs-progress { display: flex; flex-direction: column; gap: 6px; }
.pl-vs-bar { height: 8px; border-radius: 4px; background: #13232f; overflow: hidden; }
.pl-vs-bar i { display: block; height: 100%; width: 0; background: #19c4cc; transition: width 0.15s linear; }
.pl-vs-step { font-size: 13px; color: rgba(232, 252, 255, 0.75); }
.pl-vs-audio {
  width: 100%; min-height: 44px; border-radius: 4px; border: 1px solid rgba(153, 247, 255, 0.45); background: transparent;
  color: #99f7ff; font: 500 13px var(--pl-font); letter-spacing: 0.06em; text-transform: uppercase;
}
.pl-vs-name { width: 100%; box-sizing: border-box; min-height: 44px; padding: 0 12px; border-radius: 4px; border: 1px solid rgba(153, 247, 255, 0.3);
  background: rgba(19, 35, 47, 0.8); color: #e8fcff; font: 500 15px var(--pl-font); }
.pl-vs-name::placeholder { color: rgba(232, 252, 255, 0.45); }
.pl-vs-field { display: flex; flex-direction: column; gap: 6px; }
.pl-vs-field > span { font: 500 13px var(--pl-font); text-transform: uppercase; letter-spacing: 0.06em; color: rgba(232, 252, 255, 0.7); }

/* Right-to-left pages (Arabic, Persian): time still runs left to right in the step grids, as in the desktop sequencer. */
[dir="rtl"] :is(.pl-beat-top, .pl-beat-rows, .pl-ed-head, .pl-ed-grid, .pl-ed-beats, .pl-ed-vol-val) { direction: ltr; }

/* Narrowest phones: tone buttons a touch smaller so long words (Russian, German) fit. */
@media (max-width: 374px) {
  html.pl-phone .pl-tones { gap: 4px !important; }
  html.pl-phone .pl-tone { font-size: 11px !important; letter-spacing: 0 !important; padding: 0 1px !important; }
  html.pl-phone .pl-tone small { font-size: 9.5px; letter-spacing: 0.02em; }
}
/* Layout shift at load (phones): the bottom bar used to start at 98px and grow to 156px, then 200px, as the app and this layer
   moved controls into it. It is pinned to the bottom, so each step moved it, and the grid padding that follows its height.
   Start it at its settled height (it is never shorter upright; AI and Tempo only make it taller) with rows packed at the bottom,
   so rows that arrive later fill space that is already there. */
@media (max-width: 599px), (orientation: portrait) and (max-width: 1023px) {
  #mobile-bottom-chrome { min-height: 200px; box-sizing: border-box; align-content: end; }
  #mobile-master-action-bar-status-slot { min-height: 32px; box-sizing: border-box; }
}
@media (orientation: portrait) and (min-width: 600px) and (max-width: 1023px) { #mobile-bottom-chrome { min-height: 206px; } }
/* Sideways phone: same idea, settled bar is 101px. The play button leaves the top bar for the bottom bar a moment after load;
   keeping it out of the top bar from the start stops the title from re-centring. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1023px) {
  #mobile-bottom-chrome { min-height: 101px; box-sizing: border-box; align-content: end; }
  #top-nav #transport-controls { display: none !important; }
}
/* The beat grid is built after the page shows; until then the text under the app sat on screen and was then pushed away.
   Reserve the screen height minus 200px (always less than the finished grid, so no gap is left behind). */
@media (max-width: 599px), (orientation: portrait) and (max-width: 1023px), (orientation: landscape) and (max-height: 500px) and (max-width: 1023px) {
  html body #app-grid-container { min-height: calc(100vh - 200px); }
}
/* Steady space under the app on phones. The app re-measures the bottom bar three times while loading (240, 156, 200 px); following each one moved the text below the app (layout shift on guide pages). These are the settled values. */
html.pl-phone .machine-drawer-layout__main { padding-bottom: 206px !important; }
@media (min-width: 600px) { html.pl-phone .machine-drawer-layout__main { padding-bottom: 212px !important; } }
