* {
  box-sizing: border-box;
}

:root {
  --icon-button-size: 36px;
  --icon-button-padding: 6px;
  --icon-button-radius: 10px;
  --icon-button-hover-bg: rgba(148, 163, 184, 0.18);
  --icon-button-active-bg: rgba(30, 64, 175, 0.22);
  --icon-button-focus-bg: rgba(59, 130, 246, 0.28);
  --icon-button-icon-size: 22px;
  --icon-button-icon-filter: none;
  --hub-toolbar-height: 48px;
  --hub-toolbar-padding-y: 10px;
  --hub-control-size: 34px;
  --hub-control-icon-size: 22px;
  --hub-gap-large: 15px;
  --hub-gap-small: 0px;
  --global-app-toolbar-height: 38px;
  
  /* z-index Hierarchie */
  --z-content: 1;
  --z-header: 100;
  --z-welcome: 200;
  --z-modal: 1000;
  --z-tooltip: 9999;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f5f7;
  color: #1f2933;
  min-height: 100vh;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hub-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--hub-gap-small, 10px) var(--hub-gap-large, 24px);
  padding: var(--hub-toolbar-padding-y, 10px) 16px;
  background: #f7f7f8;
  min-height: var(--hub-toolbar-height, 56px);
  position: relative;
  z-index: var(--z-header);
}

.hub-leading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 36px;
}

.icon-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--hub-gap-large, 24px);
}

.hub-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--hub-gap-small, 10px);
}

.hub-language {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hub-language .temperament-display {
  font-family: 'Quicksand', sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: #1f2933;
  padding: 6px 10px;
  height: var(--hub-control-size, 36px);
  min-width: 80px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.hub-language .temperament-display:hover {
  background: var(--icon-button-hover-bg);
}

.hub-language .temperament-display:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--icon-button-focus-bg);
}

.hub-home-button,
.hub-help-button {
  width: var(--hub-control-size, 36px);
  height: var(--hub-control-size, 36px);
  border: none;
  border-radius: 8px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  transition: opacity 0.2s ease;
}

.hub-home-button:hover,
.hub-help-button:hover {
  opacity: 0.7;
}

.hub-home-button:focus-visible,
.hub-help-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.hub-home-button img,
.hub-help-button img {
  width: var(--hub-control-icon-size, 22px);
  height: var(--hub-control-icon-size, 22px);
  filter: none;
}

.hub-toolbar .icon-button {
  width: var(--hub-control-size, 36px);
  height: var(--hub-control-size, 36px);
}

.hub-toolbar .icon-button img {
  width: var(--hub-control-icon-size, 22px);
  height: var(--hub-control-icon-size, 22px);
}

.icon-button {
  width: var(--icon-button-size);
  height: var(--icon-button-size);
  padding: 0;
  border: none !important;
  border-radius: var(--icon-button-radius);
  background: transparent !important;
  background-color: transparent !important;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s ease, transform 0.2s ease;
  position: relative;
  z-index: var(--z-content);
}

.icon-button:focus {
  outline: none;
}

.icon-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--icon-button-focus-bg);
}

.icon-button:hover {
  background-color: var(--icon-button-hover-bg);
}

.icon-button.active,
.icon-button:active {
  background-color: var(--icon-button-active-bg);
  transform: scale(0.96);
}

.icon-button img {
  width: var(--icon-button-icon-size);
  height: var(--icon-button-icon-size);
  object-fit: contain;
  filter: grayscale(100%) opacity(0.5);
  pointer-events: none;
  transition: filter 0.2s ease;
}

.hub-toolbar .icon-button img {
  filter: grayscale(100%) opacity(0.5);
}

.icon-button.active img {
  filter: none;
}

.hub-toolbar .icon-button.active img {
  filter: none;
}

.viewport-container {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-top: none;
}

.app-frame {
  position: absolute;
  inset: 0;
  display: flex;
  background: #020617;
  transition: opacity 0.35s ease;
  opacity: 1;
}

.app-frame iframe {
  flex: 1 1 auto;
  border: none;
  width: 100%;
  height: 100%;
  background: #020617;
}

.app-frame.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.welcome-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: var(--welcome-icon-offset, 35vh);
  background: #f7f7f8;
  z-index: var(--z-welcome);
  transition: opacity 0.35s ease;
  opacity: 1;
}

.welcome-screen.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.welcome-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
}

.welcome-icon {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  --welcome-icon-scale: 1;
  transition: transform 0.25s ease, filter 0.2s ease;
  filter: blur(var(--welcome-icon-blur, 0.5px));
  transform: scale(var(--welcome-icon-scale));
  will-change: transform;
}

.welcome-icon-visual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translate(var(--welcome-icon-shift-x, 0px), var(--welcome-icon-shift-y, 0px));
  transition: transform 0.25s ease;
  will-change: transform;
}

.welcome-icon:focus {
  outline: none;
}

.welcome-icon:focus-visible {
  outline: 2px solid #1f2933;
  outline-offset: 4px;
}

.welcome-icon img {
  width: var(--welcome-icon-size, 100px);
  height: var(--welcome-icon-size, 100px);
  object-fit: contain;
  filter: saturate(var(--welcome-icon-saturation, 0.7)) brightness(var(--welcome-icon-brightness, 1));
  transition: transform var(--wave-transition, 1.4s) ease-in-out, filter 0.2s ease;
  will-change: transform, filter;
  transform: translate(var(--wave-tx, 0px), var(--wave-ty, 0px)) scale(var(--wave-scale, 1)) rotate(calc(var(--wave-rot, 0deg) + var(--welcome-click-rot, 0deg)));
}

.welcome-icons:hover .welcome-icon:not(:hover) {
  filter: blur(var(--welcome-icon-blur, 0.5px));
}

.welcome-icon:hover {
  filter: none;
  --welcome-icon-scale: var(--welcome-icon-hover-scale, 1.1);
}

.welcome-icon:hover img {
  filter: saturate(var(--welcome-icon-hover-saturation, 1)) brightness(var(--welcome-icon-hover-brightness, 1));
}

.welcome-icon.is-activating {
  filter: none;
  --welcome-icon-scale: var(--welcome-click-scale, 1.6);
}

.welcome-icon.is-activating .welcome-icon-visual {
  transition-duration: var(--welcome-click-duration, 520ms);
}

.welcome-icon.is-activating img {
  transition-duration: var(--welcome-click-duration, 520ms);
}

.welcome-transition-overlay {
  position: fixed;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: calc(var(--z-welcome) + 5);
  transition: opacity 0.3s ease;
}



.welcome-description-container {
  margin-top: var(--welcome-icon-text-gap, 48px);
  max-width: 640px;
  text-align: left;
}

.welcome-title {
  font-family: "Quicksand", "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 20px 0;
  line-height: 1.2;
}

.welcome-description {
  font-size: var(--welcome-description-font-size, 14px);
  font-family: inherit;
  line-height: var(--welcome-description-line-height, 1.6);
  color: #1f2933;
  min-height: 28px;
  margin: 0;
}

body.is-welcome-active .hub-toolbar {
  background: transparent;
  justify-content: flex-end;
}

body.is-welcome-active .icon-bar,
body.is-welcome-active .hub-help-button,
body.is-welcome-active .hub-home-button {
  display: none;
}

body.is-welcome-active .hub-actions {
  margin-left: 0;
  gap: 0;
}

body.is-welcome-active .hub-actions > *:not(.hub-language) {
  display: none;
}

/* Fixierter Button unten rechts im Willkommensfenster */
.welcome-impressum-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 10px 14px;
  border-radius: 4px;
  border: 0px solid rgba(31, 41, 51, 0.25);
  background: rgba(255, 255, 255, 1);
  color: #1f2933;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
  z-index: calc(var(--z-welcome) + 10);
}

.welcome-impressum-button:hover {
  background: rgba(255, 255, 255, 0.3);
}

.welcome-impressum-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Hub-Modal allgemeine Gestaltung (wie Anleitungsfenster) */
.hub-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 1;
  transition: opacity 0.2s ease;
}

.hub-modal.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.hub-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.hub-modal-dialog {
  position: relative;
  width: min(500px, 92vw);
  height: min(78vh, 760px);
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hub-modal-content {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
}

.hub-modal-content iframe {
  border: none;
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
}

/* Header App-Icons: leichtes Hover-Zoom */
.icon-bar .icon-button:hover {
  transform: scale(1.1);
}

/* Smooth transform for both button and inner image */
.icon-button,
.icon-button img {
  transition: transform 0.14s ease, filter 0.14s ease;
}

/* --- Globale Tooltips für Icon-Buttons --- */
.icon-button[data-tooltip]:not([data-tooltip=""]) {
  position: relative;
}

.global-tooltip-layer {
  position: fixed;
  left: -9999px;
  top: -9999px;
  display: inline-block;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: var(--z-tooltip);
  transition: opacity 0.08s ease;
}

.global-tooltip-layer.is-measuring {
  visibility: hidden;
  opacity: 0;
}

.global-tooltip-layer.is-visible {
  opacity: 1;
  visibility: visible;
}

.global-tooltip-layer__bubble {
  position: relative;
  background: #2b2b2b;
  color: #ffffff;
  padding: 6px 8px;
  border-radius: 2px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  max-width: min(280px, calc(100vw - 24px));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.global-tooltip-layer.is-wrapped .global-tooltip-layer__bubble {
  white-space: normal;
}

.global-tooltip-layer__arrow {
  position: absolute;
  left: 50%;
  transform: translateX(calc(-50% + var(--tooltip-arrow-shift, 0px)));
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 6px 0 6px;
  border-color: #2b2b2b transparent transparent transparent;
  bottom: -6px;
}

.global-tooltip-layer.is-below .global-tooltip-layer__arrow {
  top: -4px;
  bottom: auto;
  border-width: 0 6px 6px 6px;
  border-color: transparent transparent #2b2b2b transparent;
}

.icon-button[data-tooltip]:hover,
.icon-button[data-tooltip]:focus,
.icon-button[data-tooltip]:focus-visible {
  z-index: var(--z-tooltip);
}

/* Ensure focus ring is not shown on the tooltip itself. Keep focus styles on the button minimal. */
.icon-button:focus-visible {
  box-shadow: 0 0 0 3px var(--icon-button-focus-bg);
  outline: none;
}

/* Dropdown/Popup Styles */
.toolbar-popup {
  position: fixed;
  z-index: 1100;
  background: #ffffff;
  border: none;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 0;
  display: block;
  overflow: visible;
  min-width: 150px;
  max-width: min(90vw, 300px);
  --arrow-center: 40px;
}

.toolbar-popup[data-placement="top"] .popup-arrow {
  top: auto;
  bottom: -7px;
  border-top: none;
  border-left: none;
  border-right: 1px solid #c8c8c8;
  border-bottom: 1px solid #c8c8c8;
}

.toolbar-popup[data-placement="bottom"] .popup-arrow {
  bottom: auto;
  top: -7px;
  border-bottom: none;
  border-left: 1px solid #c8c8c8;
  border-top: 1px solid #c8c8c8;
}

.toolbar-popup .toolbar-popup-content {
  padding: 6px 0;
  max-height: min(70vh, 400px);
  overflow-y: auto;
}

.toolbar-popup .popup-arrow {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border: none;
  transform: rotate(45deg);
  top: -7px;
  left: calc(var(--arrow-center, 40px) - 7px);
  z-index: -1;
}

.temperament-picker-popup.toolbar-popup {
  display: block;
  min-width: 120px;
  max-width: 180px;
}

.temperament-picker-popup .toolbar-popup-content {
  padding: 6px 0;
}

.temperament-picker-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12px;
  font-family: 'Quicksand', sans-serif;
  color: #1f2933;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  white-space: nowrap;
}

.temperament-picker-item:hover {
  background: var(--icon-button-hover-bg);
}

.temperament-picker-item.active {
  background: var(--icon-button-active-bg);
}

.tonecount-picker-popup .toolbar-popup-content {
  padding: 6px 0;
}
