beethoven-assistant.beethoven-host {
  color: var(--app-ink, #171526);
  font: 400 16px/1.5 Manrope, system-ui, sans-serif;
}
:root { --beethoven-rail-width: 24rem; }

beethoven-assistant[hidden] { display: none !important; }

.beethoven-trigger {
  position: fixed;
  z-index: 65;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(max(var(--beethoven-bottom-clearance, 0px), env(safe-area-inset-bottom, 0px)) + 1rem);
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: .5rem .9rem;
  border: 1px solid var(--app-panel-border, #d7d5e3);
  border-radius: 999px;
  background: var(--app-panel, #fff);
  color: var(--app-ink, #171526);
  box-shadow: 0 8px 28px rgb(26 21 55 / .16);
  font: 700 14px/1.2 Manrope, system-ui, sans-serif;
  cursor: pointer;
}

/* Keep the manual launcher from covering the first-visit demo's primary action. */
.beethoven-host--trigger-suppressed .beethoven-trigger { visibility: hidden; pointer-events: none; }

.beethoven-panel {
  position: fixed;
  z-index: 65;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(max(var(--beethoven-bottom-clearance, 0px), env(safe-area-inset-bottom, 0px)) + 4.6rem);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  width: min(28rem, calc(100vw - 2rem));
  max-height: min(64dvh, 36rem);
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--app-panel-border, #d7d5e3);
  border-radius: 1rem;
  background: var(--app-panel, #fff);
  color: var(--app-ink, #171526);
  box-shadow: 0 12px 40px rgb(26 21 55 / .2);
  overscroll-behavior: contain;
}

.beethoven-header,
.beethoven-actions,
.beethoven-modes {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.beethoven-header {
  position: sticky;
  top: 0;
  z-index: 1;
  flex-shrink: 0;
  justify-content: space-between;
  background: var(--app-panel, #fff);
}
.beethoven-header-copy { min-width: 0; }
.beethoven-kicker,
.beethoven-progress {
  margin: 0;
  color: var(--app-ink-soft, #5b586c);
  font-size: 14px;
  font-weight: 700;
}

.beethoven-header h2,
.beethoven-step-title {
  margin: .15rem 0 0;
  color: var(--app-ink, #171526);
  font: 700 20px/1.25 "Space Grotesk", Manrope, system-ui, sans-serif;
}

.beethoven-close,
.beethoven-button,
.beethoven-mode,
.beethoven-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border: 1px solid var(--app-panel-border, #d7d5e3);
  border-radius: .75rem;
  padding: .55rem .8rem;
  background: var(--app-panel, #fff);
  color: var(--app-ink, #171526);
  font: 700 14px/1.3 Manrope, system-ui, sans-serif;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.beethoven-close { width: 2.75rem; padding: 0; font-size: 1.25rem; }
.beethoven-button--primary {
  border-color: var(--app-accent-strong-contrast, #0a7d72);
  background: var(--app-accent-strong-contrast, #0a7d72);
  color: var(--app-on-accent-strong, #fff);
}
.beethoven-button:disabled { cursor: not-allowed; opacity: .55; }
.beethoven-host--workspace-open .beethoven-button:disabled {
  opacity: 1;
  background: var(--app-panel-muted, #fafafe);
  color: var(--app-ink-soft, #5b586c);
  border-color: var(--app-panel-border, #d7d5e3);
}
.beethoven-modes { border-bottom: 1px solid var(--app-panel-border, #d7d5e3); padding-bottom: .5rem; }
.beethoven-mode { flex: 1; }
.beethoven-mode[aria-pressed="true"] { border-color: var(--app-focus-ink, #40308f); outline: 2px solid var(--app-focus-ink, #40308f); outline-offset: 1px; }
.beethoven-body { display: grid; gap: .75rem; }
.beethoven-copy { margin: 0; color: var(--app-ink-soft, #5b586c); font-size: 16px; line-height: 1.5; }
.beethoven-step-title { margin-top: 0; }
.beethoven-progress { font-variant-numeric: tabular-nums; }
.beethoven-actions { flex-wrap: wrap; }
.beethoven-hint { margin: 0; color: var(--app-ink-soft, #5b586c); font-size: 14px; }
.beethoven-label { display: block; margin-bottom: .35rem; color: var(--app-ink, #171526); font-size: 14px; font-weight: 700; }
.beethoven-question {
  display: block;
  width: 100%;
  min-height: 6rem;
  resize: vertical;
  border: 1px solid var(--app-panel-border, #d7d5e3);
  border-radius: .75rem;
  padding: .75rem;
  background: var(--app-bg, #fff);
  color: var(--app-ink, #171526);
  font: 400 16px/1.5 Manrope, system-ui, sans-serif;
}
.beethoven-response { display: grid; gap: .5rem; }
.beethoven-question::placeholder { color: var(--app-ink-soft, #5b586c); opacity: 1; }
.beethoven-transcript { display: grid; gap: .75rem; max-height: 30dvh; overflow-y: auto; overflow-wrap: anywhere; overscroll-behavior: contain; }
.beethoven-transcript:empty { display: none; }
.beethoven-user-message { margin: 0; padding: .75rem; border-radius: var(--radius-md, 10px); background: var(--app-panel-muted, #fafafe); color: var(--app-ink, #171526); white-space: pre-wrap; }
.beethoven-note-reference { margin: 0; color: var(--app-link-ink, #40308f); font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.beethoven-answer .beethoven-copy { white-space: pre-wrap; overflow-wrap: anywhere; }
.beethoven-measure { min-height: 2.75rem; width: 100%; margin-bottom: .75rem; resize: none; }
.beethoven-excerpt summary { display: flex; align-items: center; min-height: 2.75rem; font-size: 14px; color: var(--app-link-ink, #40308f); cursor: pointer; }

/* Workspace help never floats on top of score/export controls. Below the rail
   breakpoint it becomes a normal section before the workspace; the existing
   focus-save action minimizes it and returns to actual export controls. */
.beethoven-host--workspace-open { display: block; margin: 1rem; padding-top: 3rem; }
.beethoven-host--workspace-open .beethoven-panel {
  position: relative;
  inset: auto;
  width: 100%;
  max-height: none;
  margin: 0;
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-sm, none);
  scroll-margin-top: 1rem;
}
@media (min-width: 1024px) {
  body:has(.beethoven-host--workspace-open:not([hidden])) :is(#root, #score-root) { padding-right: var(--beethoven-rail-width); }
  .beethoven-host--workspace-open { margin: 0; padding: 0; }
  .beethoven-host--workspace-open .beethoven-panel {
    position: fixed;
    top: 5rem;
    right: 1rem;
    bottom: auto;
    left: auto;
    width: calc(var(--beethoven-rail-width) - 2rem);
    max-height: calc(100dvh - 7rem);
  }
  .beethoven-host--workspace-open .beethoven-panel:has(.beethoven-body--music) { height: calc(100dvh - 7rem); overflow: hidden; }
  .beethoven-body--music { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .beethoven-body--music .beethoven-private { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .beethoven-body--music .beethoven-response,
  .beethoven-body--music > .beethoven-actions { flex-shrink: 0; }
  /* Error text + retry must retain their height. In this state scroll the
     rail as one flow, rather than letting the footer cover a clipped retry. */
  .beethoven-host--workspace-open .beethoven-panel:has(.beethoven-body--music .beethoven-response:not(:empty)) { overflow-y: auto; }
  .beethoven-body--music:has(.beethoven-response:not(:empty)),
  .beethoven-body--music:has(.beethoven-response:not(:empty)) .beethoven-private { flex: 0 0 auto; }
  .beethoven-body--music:has(.beethoven-response:not(:empty)) .beethoven-transcript { flex: none; min-height: 0; max-height: 30dvh; }
  .beethoven-body--music .beethoven-transcript { flex: 1; min-height: 4rem; max-height: none; }
  .beethoven-body--music form { flex-shrink: 0; }
  .beethoven-body--music .beethoven-question:not(.beethoven-measure) { min-height: 4.5rem; max-height: 8rem; }
}
.beethoven-answer { display: grid; gap: .5rem; border: 1px solid var(--app-panel-border, #d7d5e3); border-radius: var(--radius-lg, 1rem); padding: .75rem; background: var(--app-bg, #fff); }
.beethoven-answer-label { margin: 0; color: var(--app-accent-ink, #40308f); font-size: 14px; font-weight: 700; }
.beethoven-result-link { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--app-link-ink, #40308f); font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: .2em; }
.beethoven-host .beethoven-context { display: grid; gap: .35rem; }
.beethoven-host .beethoven-context-title { margin: 0; color: var(--app-ink, #171526); font-size: 14px; font-weight: 700; }
.beethoven-host .beethoven-context-links { display: flex; flex-wrap: wrap; align-items: stretch; gap: .5rem; }
.beethoven-host .beethoven-context-links .beethoven-result-link { border: 1px solid var(--app-panel-border, #d7d5e3); border-radius: .65rem; padding: .45rem .7rem; background: var(--app-panel, #fff); text-decoration: none; }
.beethoven-notice { margin: 0; border-left: 3px solid var(--app-accent-strong, #5b45c7); padding: .5rem .75rem; color: var(--app-ink, #171526); font-size: 14px; }
.beethoven-nudge { position: fixed; z-index: 65; right: max(1rem, env(safe-area-inset-right, 0px)); bottom: calc(max(var(--beethoven-bottom-clearance, 0px), env(safe-area-inset-bottom, 0px)) + 4.6rem); width: min(20rem, calc(100vw - 2rem)); border: 1px solid var(--app-panel-border, #d7d5e3); border-radius: 1rem; padding: .9rem; background: var(--app-panel, #fff); color: var(--app-ink, #171526); box-shadow: 0 10px 32px rgb(26 21 55 / .18); }
.beethoven-nudge p { margin: 0 0 .6rem; font-size: 16px; }

beethoven-assistant.beethoven-host--inline { display: block; width: 100%; }
.beethoven-host--inline .beethoven-panel {
  position: static;
  width: 100%;
  max-height: none;
  box-shadow: none;
}

.beethoven-host :focus-visible { outline: 2px solid var(--app-focus-ink, #40308f); outline-offset: 2px; }

@media (max-width: 640px) {
  .beethoven-panel {
    right: max(.5rem, env(safe-area-inset-right, 0px));
    left: max(.5rem, env(safe-area-inset-left, 0px));
    bottom: calc(max(var(--beethoven-bottom-clearance, 0px), env(safe-area-inset-bottom, 0px)) + 3.8rem);
    width: auto;
    max-height: min(44dvh, 25rem);
    padding: .85rem;
  }
  .beethoven-nudge {
    right: max(.5rem, env(safe-area-inset-right, 0px));
    bottom: calc(max(var(--beethoven-bottom-clearance, 0px), env(safe-area-inset-bottom, 0px)) + 3.8rem);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .beethoven-trigger,
  .beethoven-button,
  .beethoven-mode,
  .beethoven-link-button { transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease; }
}

@media (prefers-reduced-motion: reduce) {
  .beethoven-trigger,
  .beethoven-button,
  .beethoven-mode,
  .beethoven-link-button { scroll-behavior: auto; transition: none; animation: none; }
}

.beethoven-host--workspace-open .beethoven-trigger { display: none; }
.beethoven-modes { flex-shrink: 0; }
.beethoven-mode { min-width: 0; padding-inline: .5rem; }
.beethoven-learning-video { display: block; width: 100%; aspect-ratio: 16/9; border-radius: var(--radius-md, .75rem); background: var(--app-panel-muted); }
.beethoven-body[data-beethoven-body="learn"] summary { min-height: var(--control-min-size, 2.75rem); display: flex; align-items: center; cursor: pointer; }
@media (max-width: 1023px) {
  .beethoven-host--workspace-open { padding-top: 0; }
  .beethoven-host--workspace-open .beethoven-panel { max-height: min(70dvh, 36rem); }
  /* In the mobile workspace, scroll the page around the composer instead of
     clipping Send inside a second scroll area. The transcript keeps its cap. */
  .beethoven-host--workspace-open .beethoven-panel:has(.beethoven-body--music) { max-height: none; }
}
