/* ===== Tablet (≤ 900px) ===== */
@media (max-width: 900px) {
  aside#panel {
    width: 260px;
  }
  .toolbar-group--end {
    margin-left: 0;
  }
}

/* ===== Mobile (≤ 640px) ===== */
@media (max-width: 640px) {
  header {
    padding: 8px 12px;
  }

  .header-brand .sub {
    display: none;
  }

  .toolbar {
    width: 100%;
    gap: 4px;
  }

  .toolbar-group {
    border-left: none;
    padding: 2px 0;
    flex-wrap: wrap;
    gap: 4px;
  }

  input[type=text], select {
    min-width: 90px;
  }

  /* Panel becomes a bottom-sheet on mobile */
  aside#panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 60vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .1);
    z-index: 100;
    padding: 8px 16px 20px;
  }

  aside#panel.open {
    animation: slideUp .22s ease-out both;
  }

  /* Drag handle */
  aside#panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin: 0 auto 14px;
  }

  .legend {
    display: none;
  }
}

/* ===== Small mobile (≤ 400px) ===== */
@media (max-width: 400px) {
  input[type=text], select {
    min-width: 72px;
    font-size: 12px;
  }
  .btn {
    padding: 0 8px;
    font-size: 12px;
  }
}

/* ===== Animation ===== */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===== Accessibility: reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  aside#panel.open { animation: none; }
  .btn, input[type=text], select { transition: none; }
}
