.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.menu-close,
.menu-backdrop {
  display: none;
}

@media (max-width: 900px) {
  body.menu-open { overflow: hidden; }

  .sidebar {
    display: flex;
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(82vw, 300px);
    height: 100dvh;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 10px 0 30px #17102f45;
    padding-top: max(22px, env(safe-area-inset-top));
  }

  .sidebar.open {
    display: flex;
    transform: translateX(0);
  }

  .sidebar .logo { padding: 7px 9px; margin: 0 10px 24px 0; }

  .menu-close {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: -8px -4px 0 0;
    border: 0;
    border-radius: 10px;
    background: #ffffff17;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
  }

  .menu-backdrop {
    display: block;
    position: fixed;
    z-index: 35;
    inset: 0;
    border: 0;
    background: #17102f99;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
  }

  .menu-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .nav-item { min-height: 48px; font-size: 15px; }
  .sidebar-foot { padding-bottom: max(8px, env(safe-area-inset-bottom)); }

  .topbar {
    height: auto;
    min-height: 76px;
    gap: 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }

  .menu-button {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #f1eef9;
    color: var(--purple);
    cursor: pointer;
  }
}

@media (max-width: 560px) {
  .page { padding: 14px; }
  .panel { padding: 15px; border-radius: 12px; }
  .topbar h2 { font-size: 18px; }

  dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    overflow: auto;
  }

  dialog form,
  .suggestion-dialog-content { padding: 18px 15px; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .button { flex: 1 1 auto; }
}
