/* ===== Responsive: Sidebar oben, Viewer darunter ===== */

/* ----- Breakpoints:  ----- */
@media (max-width: 1500px) {
  .type-grid.cols-4-extras {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 1200px) {
  .swatch-row {
    grid-template-columns: repeat(8, 1fr);
  }

  .type-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .type-tile:not(.viewer-buttons *) {
    aspect-ratio: 4 / 3;
  }

  .floating-window {
    display: none !important;
  }

  #gs-logo>address {
    display: none;
  }

}

@media (max-width: 900px) {

  #btn-export,
  #btn-import {
    display: none;
  }

  .type-tile__label {
    padding: 4px 6px;
  }

  #viewer-controls button {
    font-size: 1.08rem;
    padding: 4px 6px;
  }

  #btn-view-3d,
  #btn-view-2d {
    font-size: 0.66rem;
    padding: 4px 6px;
  }

  #btn-help {
    font-size: 0.8rem;
  }

  #viewer-controls .lang-globe-btn {
    font-size: 13px;
    padding: 3px 6px;
  }

  #viewer-controls .vc-sep {
    height: 18px;
    margin: 0 3px;
  }
}

@media (max-width: 768px) {

  html,
  body {
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  /* Die neuen Haupt-Container stapeln */
  #container-3D.is-active,
  #container-2D.is-active {
    display: flex !important;
    flex-direction: column !important;
    height: 100dvh;
    width: 100%;
  }

  /* Sidebar/Panel oben */
  #panel-container,
  #info-container {
    flex: 0 0 auto !important;
    /* Nicht starr 50%, sondern nach Inhalt */
    width: 100% !important;
    max-height: 50dvh !important;
    /* Dein gewünschter Wert */
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    border-bottom: 1px solid #ddd;
  }

  /* Viewer/SVG unten */
  #viewer-root,
  #svg-wrapper {
    flex: 1 1 auto !important;
    min-height: 30dvh !important;
    height: auto;
    background: #f8f8f8;
  }

  /* Vollansicht auf Mobile: Viewer füllt volle Höhe */
  #container-3D.viewer-maximized #panel-container {
    display: none !important;
  }
  #container-3D.viewer-maximized #viewer-root {
    height: 100dvh !important;
    min-height: 100dvh !important;
  }

  /* Hamburger: reguläre Tabs verstecken, Hamburger-Button zeigen */
  .panel-tabs>.panel-tab {
    display: none !important;
  }

  #panel-tabs-hamburger {
    display: flex;
    min-height: 44px;
  }

  /* Deine restlichen Styles bleiben erhalten */
  .panel-tab {
    padding: 2px 4px;
    min-height: 40px;
  }

  .panel-tabs {
    padding: 0px;
  }

  .layout-panel {
    top: 36px;
  }

  .layout-panel.second-panel {
    top: 110px;
  }

  .layout-panel.second-panel.has-cluster {
    top: 170px;
  }

  #gs-logo {
    max-width: 60px;
    top: 10px;
    /* Damit es nicht mit den Tabs kollidiert */
    right: 10px;
    opacity: 0.4;
  }

  #btn-undo,
  #btn-redo,
  #autosave-status,
  #btn-export,
  #btn-import {
    display: none;
  }
}

@media (max-width: 350px) {
  .swatch-row {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  .type-grid {
    grid-template-columns: 1fr;
  }

  .viewer-buttons {
    margin-left: 5%;
    width: 90%;
  }


  .type-tile:not(.viewer-buttons *) {
    aspect-ratio: 16 / 11;
  }

  #btn-reset-global {
    display: none;
  }
}

/* Touchgeräte: größere Ziele */
@media (hover: none) {

  /* Tooltip-Container */
  .app-tooltip {
    position: fixed;
    z-index: 9999;
    max-width: 320px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: rgba(22, 27, 34, .92);
    color: #fff;
    font: 12px/1.3 system-ui, Arial, sans-serif;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
    pointer-events: none;
    transform: translate(-50%, -100%);
    opacity: 0;
    transition: opacity .12s ease;
  }

  .app-tooltip.is-visible {
    opacity: 1;
  }
}