@media (max-width: 480px) {
    .top-bar {
        padding: 10px;
        gap: 10px;
    }

    .user-avatar img {
        width: 40px;
        height: 40px;
    }

    .user-info {
        font-size: 14px;
    }
    /* 1. Reset the massive desktop margin pushing elements away */
    .app-title {
        font-size: 12px;
        margin-left: 10px;
        margin-right: 0; /* Add this to clear desktop constraint */
    }
    /* 2. Scale down the image so it fits smaller screens comfortably */
    .titleimg {
        max-width: 120px; /* Swap hardcoded height for flexible boundary */
        height: auto;
    }
    /* 3. Push the menu button cleanly to the right side of the flexbox row */
    .user-menu {
        margin-left: auto;
        margin-right: 0;
    }
}
@media (max-width: 600px) {
  /* 1. Das übergeordnete Element darf nicht mitwachsen */
  .grid-section {
    flex: 2 1 20px;
    max-width: 100%; /* Verhindert, dass die Section breiter als der Bildschirm wird */
    overflow: hidden; /* Schneidet ausbrechenden Inhalt ab */
  }

  /* 2. Der Container kontrolliert das Scrollen */
  #grid-container {
    width: 100%;       /* Nutzt den verfügbaren Platz der Section */
    max-width: 100%;   /* Erzwingt die Begrenzung auf die Bildschirmbreite */
    overflow-x: auto;  /* Zeigt den Scrollbalken nur HIER an */
    -webkit-overflow-scrolling: touch;
  }

  /* 3. Das Grid bricht absichtlich aus dem Container aus */
  #stats-grid {
    display: grid;     /* Stellt sicher, dass es als Grid agiert */
    min-width: 600px;  /* Drückt das Grid über die 100% Breite des Containers hinaus */
    width: max-content; /* Alternativ: Nimmt genau so viel Platz ein, wie die Zellen brauchen */
  }
}
@media (max-width: 900px) {
  /* 1. Das übergeordnete Element darf nicht mitwachsen */
  .grid-section {
    flex: 2 1 20px;
    max-width: 100%; /* Verhindert, dass die Section breiter als der Bildschirm wird */
    overflow: hidden; /* Schneidet ausbrechenden Inhalt ab */
  }

  /* 2. Der Container kontrolliert das Scrollen */
  #grid-container {
    width: 100%;       /* Nutzt den verfügbaren Platz der Section */
    max-width: 100%;   /* Erzwingt die Begrenzung auf die Bildschirmbreite */
    overflow-x: auto;  /* Zeigt den Scrollbalken nur HIER an */
    -webkit-overflow-scrolling: touch;
  }

  /* 3. Das Grid bricht absichtlich aus dem Container aus */
  #stats-grid {
    display: grid;     /* Stellt sicher, dass es als Grid agiert */
    min-width: 900px;  /* Drückt das Grid über die 100% Breite des Containers hinaus */
    width: max-content; /* Alternativ: Nimmt genau so viel Platz ein, wie die Zellen brauchen */
  }
}



.popup-content,
.journal-popup-content {
    width: 90vw;
    max-width: 500px;
}
@media (max-width: 480px) {
    .popup-content,
    .journal-popup-content {
        padding: 15px;
        width: 95vw;
    }

    .journal-main {
        flex-direction: column;
    }

    #journal-pie {
        width: 120px !important;
        height: 120px !important;
        margin: 0 auto;
    }
}
@media (max-width: 480px) {
    .extra-row {
        flex-direction: column;
        align-items: stretch;
    }

    .extra-row input {
        width: 100%;
        margin-bottom: 8px;
    }

    .extra-delete-btn {
        width: 100%;
    }

    #extra-popup-buttons {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
  #journal-page {
    padding: 10px 20px;
    width: 80%;
  }
    #journal-month-grid {
        grid-template-columns: 1fr;
    }
    .journal-month-box {
        padding: 5px;
    }
}
@media (max-width: 900px) { /*768px*/
    #journal-page {
      padding: 10px 20px;
      width: 90%;
    }
    #journal-month-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .journal-month-box {
        padding: 5px;
    }
}


@media (max-width: 480px) {
    .journal-nav button {
        padding: 12px 16px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .profile-card {
        max-width: 80%;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }
    button {
        min-height: 44px;
        min-width: 44px;
    }
}


/* IF AVATAR UPLOAD FAILS ON MOBILE

@media (max-width: 480px) {
    .avatar-upload-wrapper {
        max-width: 90%;
    }

    .avatar-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .avatar-upload-button {
        width: 100%;
        text-align: center;
    }

    .avatar-submit-btn {
        width: 100%;
    }
}*/
