/* The website, the standalone routes and the embedded tools use the same panel material. */
html:root[lang][data-theme][data-theme][data-theme][data-theme],
:host([data-theme]) {
  --frost-panel: rgba(7, 20, 12, .88);
  --frost-chrome: rgba(5, 15, 9, .96);
  --frost-border: #477c50;
  --frost-shine: #c8f6ce4f;
  --frost-shadow: 0 0 14px #2dff3a21;
  --window-input: #06150de0;
  --glass-reflection: linear-gradient(142deg, #28533745, transparent 70%);
  --studio-plate: linear-gradient(145deg, #14291a, #050e08 76%);
}
html:root[lang][data-theme="light"][data-theme][data-theme][data-theme],
:host([data-theme="light"]) {
  --frost-panel: rgba(243, 251, 245, .92);
  --frost-chrome: rgba(249, 255, 250, .97);
  --frost-border: #6a9270;
  --frost-shine: #fff;
  --frost-shadow: 0 0 13px #25682e28;
  --window-input: #fff;
  --glass-reflection: linear-gradient(142deg, #fff8, #c3dfc725 77%);
  --studio-plate: linear-gradient(145deg, #fff, #edf7ee 80%);
}

html body .vault-start-link { text-decoration: none; white-space: nowrap; flex-shrink: 0; }
html body .public-studio-tools a {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 7px 10px;
  border: 1px solid var(--frost-border);
  border-radius: 10px;
  text-decoration: none;
  font: 700 14px/1.2 Barlow, system-ui, sans-serif;
}
html:root[lang][data-theme] body .public-studio-tools a {
  background-image: var(--studio-plate) !important;
  box-shadow: inset 0 1px var(--frost-shine), var(--frost-shadow) !important;
}
html:root[lang][data-theme] body .public-studio-tools a:hover { border-color: var(--active-control); }
html:root[lang][data-theme] body .public-studio-tools a span:first-child { color: var(--active-label) !important; font-size: 20px; }

html:root[lang][data-theme] body .app > .shell > .view:not(.mixdown) > .headline,
html:root[lang][data-theme] body .app > .shell :is(#looplab-view .ll-top, .radio-main),
html:root[lang][data-theme] body .vault-layout .app-window-page > header,
#vault-tool-content#vault-tool-content [data-vault-tool] .app-window-page > header {
  padding: clamp(14px, 2vw, 24px);
  border: 1px solid var(--frost-border);
  border-radius: 14px;
  background: var(--studio-plate);
  box-shadow: inset 0 1px var(--frost-shine), var(--frost-shadow);
}

@media(min-width:768px) {
  html body .app > .topbar .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
    scrollbar-width: thin;
    gap: 5px;
  }
  html body .app > .topbar .tabs .tab {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
    overflow-wrap: normal;
    padding-inline: 9px;
    font-size: 13px;
  }
}

/* Reuse the analyzer's plate, edge and focus treatment across both tool renderers. */
:root, :host {
  --studio-play: #4cf483;
  --studio-record: #ff637c;
  --studio-warn: #ffba66;
}
:root[data-theme="light"], :host([data-theme="light"]) {
  --studio-play: #176b39;
  --studio-record: #aa2347;
  --studio-warn: #8f4a0a;
}

html:root[data-theme] body .app > .shell > .view:not(.mixdown),
html:root[data-theme] body .vault-layout .app-window-page,
#vault-tool-content#vault-tool-content .studio-tool-page {
  min-width: 0;
  border: 1px solid var(--frost-border);
  border-radius: 16px;
  background: var(--glass-reflection), var(--frost-panel);
  box-shadow: inset 0 1px var(--frost-shine), var(--frost-shadow);
}
html:root[data-theme] body .app > .shell > .view:not(.mixdown) {
  padding: clamp(10px, 2vw, 22px);
}
html:root[data-theme] body .app > .shell > .view:not(.mixdown) :is(.glass-card,.glass-surface,.daw-lane,.card,.queue,.remix-card,.contest-hero,.library-card),
#vault-tool-content#vault-tool-content .studio-tool-page :is(.glass-card,.glass-surface,.daw-console,.glass-nav),
html:root[data-theme] body .vault-layout .app-window-page :is(.glass-card,.glass-surface),
html:root[data-theme] body #ue-dialog .ue-card {
  border-radius: 12px;
  border-color: var(--frost-border) !important;
  background-image: var(--glass-reflection) !important;
  background-color: var(--frost-panel) !important;
  box-shadow: inset 0 1px var(--frost-shine), var(--frost-shadow) !important;
}

html:root[data-theme] body :is(#ll-start,#daw-play,#main-play,.radio-play,[data-action="play"]):not(:disabled),
#vault-tool-content#vault-tool-content :is(button[aria-label="Play"],button[aria-label="Abspielen"]):not(:disabled) {
  --active-control: var(--studio-play);
  border-color: var(--studio-play) !important;
}
html:root[data-theme] body :is(#ll-record,[aria-invalid="true"]),
#vault-tool-content#vault-tool-content :is(button[aria-label="Record"],[aria-invalid="true"]) {
  border-color: var(--studio-record) !important;
}
html:root[data-theme] body .app [role="alert"],
#vault-tool-content#vault-tool-content [role="alert"] {
  border-inline-start: 3px solid var(--studio-warn);
  padding-inline-start: 10px;
}

.studio-directory { padding: clamp(12px, 3vw, 34px); }
.studio-directory section { margin-block: 18px; }
.studio-directory h2 { margin-block: 8px; }
.studio-directory-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%, 200px),1fr)); gap: 9px; }
:root[data-theme] body .studio-directory-link,
#vault-tool-content#vault-tool-content .studio-directory-link {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--frost-border);
  border-radius: 10px;
  background-image: var(--studio-plate) !important;
  box-shadow: inset 0 1px var(--frost-shine), var(--frost-shadow) !important;
  text-decoration: none;
  overflow-wrap: anywhere;
}
:root[data-theme] body .studio-directory-link:hover,
#vault-tool-content#vault-tool-content .studio-directory-link:hover { border-color: var(--active-control); }

#studio-mobile-menu { display: none; }
@media(max-width:767px) {
  html body .app > .topbar { gap: 7px; }
  html body .app > .topbar #studio-mobile-menu { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 9px; white-space: nowrap; }
  html body .app > .shell,
  html body .app:has(#looplab-view:not([hidden])) > .shell { width: 100%; padding-inline: 8px; }
  html body .app:has(#looplab-view:not([hidden])) > .shell { padding-top: 12px; }
  html body .app:has(#looplab-view:not([hidden])) #ll-mobile-tools { display: none; }
  html body .app > #studio-nav:not(.studio-menu-open) { display: none !important; }
  html body .app > #studio-nav.studio-menu-open {
    display: flex !important;
    width: min(286px, 86vw);
    top: calc(var(--mobile-header-height, 64px) + 5px);
    bottom: calc(var(--vault-player-height, 110px) + 8px);
    right: 5px;
    z-index: 32;
  }
  html body .app:has(#mixdown-view:not([hidden])) > #studio-nav.studio-menu-open {
    bottom: calc(var(--analyzer-player-height, 170px) + 12px);
  }
  html body .app #sequencer-view .daw-lane { min-width: 0; grid-template-columns: minmax(0,1fr); }
  html body .app #sequencer-view :is(.daw-top,.daw-project,.daw-browser,.daw-mix,.daw-fx,.daw-track-head) { min-width: 0; flex-wrap: wrap; }
  html body .app #sequencer-view .daw-steps { max-width: 100%; }
  html body .app #sequencer-view .daw-top { grid-template-columns: minmax(0,1fr); }
  html body:has(#sequencer-view:not([hidden])) .playerbar { display: none !important; }
}

html:root[data-theme] body .vault-layout main[data-vault-tool] {
  background: var(--glass-reflection), var(--frost-panel) !important;
  border-inline-start: 1px solid var(--frost-border);
}
@media(max-width:767px) {
  #vault-tool-content#vault-tool-content :is(.daw-arrangement-frame, .studio-tool-page input[type="file"]),
  html body .vault-layout :is(.daw-arrangement-frame, main input[type="file"]) { width: 100%; min-width: 0; max-width: 100%; }
  #vault-tool-content#vault-tool-content [data-vault-tool="/track-stamp"] :is(input,select,textarea),
  html body .vault-layout [data-vault-tool="/track-stamp"] :is(input,select,textarea) { min-width: 0; max-width: 100%; }
}

/* Analyzer work surfaces. Both the native workspace and the Remix shadow
   root inherit the same palette; covers and signal canvases keep their art. */
:root, :host {
  --desk-bg: #090d0d;
  --desk-face: #111717;
  --desk-control: #1a2321;
  --desk-edge: #34433e;
  --desk-ink: #f1f5ee;
  --desk-caption: #a2b3ad;
  --desk-brand: #2dff3a;
  --desk-active: #ff8500;
}
:root[data-theme="light"], :host([data-theme="light"]) {
  --desk-bg: #e9efeb;
  --desk-face: #fafcf9;
  --desk-control: #f1f6f1;
  --desk-edge: #bbc9c1;
  --desk-ink: #101e19;
  --desk-caption: #4f6257;
  --desk-brand: #176a21;
  --desk-active: #2dff3a;
}

:is(.app > .shell > #looplab-view, .app > .shell > #sequencer-view,
    .app > .shell > #library-view, .app > .shell > #studio-view,
    #vault-tool-content#vault-tool-content [data-vault-tool="/remix-studio"],
    .vault-layout [data-vault-tool="/remix-studio"]) {
  --reading-text: var(--desk-ink);
  --text: var(--desk-ink);
  --muted: var(--desk-caption);
  --frost-panel: var(--desk-face);
  --frost-border: var(--desk-edge);
  --glass-reflection: none;
  --frost-shadow: none;
  --frost-shine: transparent;
  --ll-panel: var(--desk-face);
  background: var(--desk-bg) !important;
  border: 1px solid var(--desk-edge) !important;
  border-radius: 12px;
  box-shadow: none !important;
  min-width: 0;

  & :is(.headline,.ll-top,.ll-transport,.ll-sessions,.ll-pad,.ll-browser,
        .ap,.daw-top,.daw-lane,.daw-browser,.library-panel,.set-generator,
        .glass-card,.glass-surface) {
    background: var(--desk-face) !important;
    border: 1px solid var(--desk-edge) !important;
    border-radius: 12px !important;
    box-shadow: none !important;
  }
  & :is(.headline,.ll-top) { padding: clamp(16px,2.5vw,32px); gap: 16px; }
  & h1 { font-size: clamp(2rem,4.1vw,4.5rem); letter-spacing: -.045em; line-height: 1.05; }
  & :is(.detail-kicker,.ll-pad-number,.daw-counter,.ll-beat) {
    --reading-text: var(--desk-brand);
    font-family: ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
  }
  & :is(p,small,.ll-state,.ll-session-state) { --reading-text: var(--desk-caption); }
  & :is(button:not(.daw-step),.btn-3d,.ll-file,select,input[type="search"],input[type="text"],input[type="number"]) {
    --reading-text: var(--desk-ink);
    background: var(--desk-control) !important;
    color: var(--desk-ink) !important;
    border: 1px solid var(--desk-edge) !important;
    border-radius: 7px !important;
    box-shadow: none !important;
    min-height: 44px;
    max-width: 100%;
  }
  & :is(.ll-primary,.auth-primary,#daw-play,.ll-preview-stop,
        button[aria-pressed="true"],button[aria-selected="true"],
        button.border-vault-green,.daw-step.on,.channel.active):not(:disabled) {
    --reading-text: #101710;
    color: var(--reading-text) !important;
    border-color: var(--desk-active) !important;
    background: var(--desk-active) !important;
    box-shadow: none !important;
  }
  & .ll-preview-stop:not(:disabled), & #ll-stop, & #daw-stop {
    background: var(--desk-control) !important;
    color: var(--desk-ink) !important;
    border: 2px solid var(--desk-caption) !important;
  }
  & #ll-record[aria-pressed="true"] { background: var(--studio-record) !important; }
  & .ll-pad[data-playing="true"] {
    border-color: var(--desk-active) !important;
    box-shadow: inset 3px 0 var(--desk-active) !important;
  }
  & :is(button,select,input,a,summary):focus-visible {
    outline: 3px solid var(--desk-brand) !important;
    outline-offset: 2px;
  }
  & button:not(:disabled):hover { border-color: var(--desk-brand) !important; }
  & button:disabled { opacity: .5; }
  & progress, & input[type="range"] { accent-color: var(--desk-active); }
  & :is([data-status],.ll-status,.ll-browser-status,.library-message):not(:empty) {
    --reading-text: var(--desk-ink);
    border-inline-start: 3px solid var(--desk-brand);
    padding-inline-start: 10px;
  }
}

@media(max-width:767px) {
  #looplab-view .ll :is(.ll-sound-row,.ap-actions,.ll-pad-actions) { gap: 8px; }
  #looplab-view .ll :is(.ll-sound-row,.ap-actions,.ll-playback,.ll-pad-actions) button,
  #library-view .library-panel button, #sequencer-view .daw-transport button,
  #vault-tool-content [data-vault-tool="/remix-studio"] button { min-height: 48px; }
  #looplab-view .ll .ap-actions { flex-wrap: wrap; }
  #looplab-view .ll .ap-actions > button { flex: 1 1 150px; white-space: normal; }
  #looplab-view .ll #ll-autoproducer { scroll-margin-top: calc(var(--mobile-header-height,64px) + 10px); }
  #library-view :is(.library-head, .library-head form, .generator-form) { flex-wrap: wrap; min-width: 0; }
  #library-view :is(.library-panel,.set-generator,.control) { min-width: 0; max-width: 100%; }
  #vault-tool-content [data-vault-tool="/remix-studio"] [class~="min-w-[280px]"] { min-width: min(100%, 220px); }
  #sequencer-view .daw-steps { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; }
  #sequencer-view .daw-step { min-height: 44px; width: 100%; }
}
@media(max-width:540px) {
  #looplab-view .ll .ll-grid { grid-template-columns: minmax(0,1fr); }
  #looplab-view .ll .ll-pad-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
  #looplab-view .ll .ll-pad-actions button { min-width: 0; }
}
