/* Shared mobile-first layout safeguards. Loaded after page-specific styles. */

.mobile-menu-logout {
  display: none;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 0;
  overflow-x: hidden;
}

@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
  }
}

@supports (-webkit-touch-callout: none) {
  body {
    min-height: -webkit-fill-available;
  }
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input[type='button'],
input[type='submit'] {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  .user-pill-logout {
    display: none !important;
  }

  .user-pill .role-badge {
    display: none !important;
  }

  .projects-section {
    padding-top: 0.75rem !important;
  }

  .projects-section h2 {
    margin-bottom: 0.75rem !important;
  }

  .hotspots-row {
    margin-bottom: 0.5rem !important;
  }

  .auth-container {
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
    padding: 1.25rem 0.75rem calc(1.5rem + env(safe-area-inset-bottom));
    align-items: center;
  }

  .auth-card {
    width: 100%;
    max-width: 28rem;
    padding: 1.15rem;
    border-radius: 14px;
  }

  .auth-tabs {
    gap: 0.25rem;
    margin-bottom: 1rem;
  }

  .auth-tab,
  .auth-card .btn-primary,
  .btn-toggle-pw {
    min-height: 44px;
  }

  .form-group input,
  .form-group select {
    min-height: 44px;
    font-size: 16px;
  }

  .nav-links .mobile-menu-logout.visible {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: min(100%, 10rem);
    min-height: 30px;
    padding: 0.25rem 0.6rem;
    font-size: 0.8125rem;
    border: 1px solid rgba(239, 68, 68, 0.45);
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    font-weight: 700;
    cursor: pointer;
  }

  .nav-links {
    padding: 0.65rem 0.6rem !important;
    gap: 0.12rem !important;
  }

  .nav-links a {
    height: 24px !important;
    font-size: 0.8125rem !important;
    line-height: 1 !important;
  }

  .nav-links .nav-register-mobile {
    min-height: 30px !important;
    height: 30px !important;
    width: min(100%, 10rem);
    padding: 0.25rem 0.6rem !important;
    font-size: 0.8125rem !important;
  }

  body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .navbar-container {
    width: 100%;
    min-width: 0;
    /* A landscape notch can sit on either side depending on which way the phone is
       rotated - padding-inline with a single value only ever covered the left one. */
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .nav-logo {
    min-width: 0;
  }

  #report .report-item-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  #report .report-item-form > .input-field,
  #report .report-item-form > .form-row,
  #report .report-item-form > div:last-child {
    margin-block: 0 !important;
  }

  #report .report-item-form .report-type-selection {
    margin-bottom: 0 !important;
  }

  .nav-logo-full,
  .nav-logo-short {
    overflow: visible;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-actions {
    min-width: 0;
    gap: 0.5rem;
  }

  .auth-dashboard-link {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0.4rem 0.65rem !important;
    margin: 0 !important;
    font-size: 0.875rem !important;
    line-height: 1.1;
    text-align: center;
  }

  .nav-actions > * {
    flex-shrink: 1;
  }

  .nav-actions .theme-toggle,
  .nav-actions .notif-bell-btn,
  .nav-actions .menu-toggle {
    flex: 0 0 auto;
    width: 10.8rem;
    max-width: 100%;
  }

  .nav-signin-btn {
    max-width: 5.25rem;
    width: 50px;
    min-width: 50px;
    height: 36px !important;
    padding: 0 0.35rem !important;
    font-size: 0.8125rem !important;
    border-radius: 6px !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hero-section,
  .tools-section,
  .projects-section,
  .timeline-section,
  .contact-section,
  .page-section,
  .page-header {
    width: 100%;
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .hero-section {
    gap: 1.5rem;
  }

  .hero-name,
  .page-header h1 {
    overflow-wrap: anywhere;
  }

  .hero-buttons .btn,
  .hero-buttons a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .projects-grid,
  .browse-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-rows: auto;
    align-items: start;
    gap: 0.75rem;
  }

  .project-card,
  .item-card {
    min-width: 0;
    width: 100%;
  }

  .project-card {
    min-height: 0;
  }

  .projects-grid > .project-card {
    min-height: 0 !important;
    height: auto !important;
    align-self: start !important;
  }

  #itemsGrid {
    min-height: 0 !important;
    height: auto !important;
    display: grid !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    align-content: start !important;
    grid-template-rows: none !important;
    grid-auto-rows: auto !important;
    row-gap: 0.75rem !important;
  }

  /* Keep the first result close to the office filter on small screens. */
  .projects-section {
    display: block;
    padding-bottom: 1rem !important;
  }

  .projects-section + .section-divider + .tools-section {
    padding-top: 0.9rem !important;
  }

  .section-divider + .projects-section {
    padding-top: 0.5rem !important;
  }

  .projects-grid {
    min-height: 0 !important;
    margin-top: 0 !important;
    row-gap: 0.5rem !important;
  }

  #items .projects-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    column-gap: 0.5rem !important;
    row-gap: 0.5rem !important;
    grid-auto-rows: min-content !important;
    grid-template-rows: none !important;
    align-items: stretch !important;
    align-content: start !important;
    place-content: start !important;
    height: fit-content !important;
    min-height: 0 !important;
  }

  #items .projects-grid > .project-card,
  #items .projects-grid > .item-card {
    display: flex !important;
    min-height: 0 !important;
    height: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    align-self: stretch !important;
    box-sizing: border-box;
  }

  #items .project-card-header {
    min-width: 0;
  }

  #items .project-card-header > div {
    min-width: 0;
    width: 100%;
  }

  #items .item-card-meta-row {
    width: 100%;
    min-width: 0;
    position: relative;
    display: block;
    align-items: flex-start;
  }

  #items .item-card-category-ref {
    display: flex;
    min-width: 0;
    width: 100%;
    max-width: none;
    flex: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.08rem;
    overflow: visible;
    overflow-wrap: anywhere;
  }

  #items .item-card-category-ref .project-type {
    font-size: 0.8125rem;
    line-height: 1.1;
  }

  #items .item-card-category-ref .ref-code {
    margin-left: 0 !important;
    min-width: 0;
    width: max-content;
    max-width: 100%;
    overflow: visible;
    white-space: nowrap;
    text-overflow: clip;
    font-size: 0.8125rem;
    line-height: 1.1;
  }

  #items .item-badge {
    position: absolute;
    top: 0;
    right: -0.75rem;
    flex: none;
    min-width: 2.2rem;
    max-width: 3.5rem;
    box-sizing: border-box;
    padding: 0.17rem 0.3rem;
    font-size: 0.8125rem;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
  }

  #items .item-photo-placeholder {
    width: 100%;
    height: 180px;
    flex: 0 0 180px;
    margin: 0.6rem 0;
    border-radius: 8px;
    background: transparent;
  }

  #itemsGrid > * {
    margin-top: 0 !important;
    align-self: start !important;
  }

  .filter-row,
  .filter-bar,
  .results-header,
  .hotspots-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box,
  .search-wrap,
  .filter-group,
  .location-filter-wrap,
  .results-header > *,
  .sort-select {
    width: 100%;
    min-width: 0;
  }

  /* The desktop location wrapper has a 420px flex-basis. Reset it on mobile
     so the column layout does not reserve a large blank area below the select. */
  .location-filter-wrap,
  .sort-filter-wrap {
    flex: 0 0 auto !important;
    height: auto !important;
  }

  .filter-chips,
  .type-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .filter-chips .chip,
  .type-tabs .type-tab {
    min-height: 44px;
    padding-inline: 0.5rem;
  }

  .chip-my-vault {
    grid-column: 1 / -1;
  }

  .simple-card,
  .auth-card,
  .detail-card,
  .modal,
  .claim-card,
  .pin-card {
    max-width: 100%;
    padding: 1.15rem;
    border-radius: 12px;
  }

  .form-row,
  .type-switcher {
    grid-template-columns: minmax(0, 1fr);
    flex-direction: column;
  }

  .type-option,
  .input-field input,
  .input-field select,
  .input-field textarea,
  .form-control,
  .btn,
  .category-picker {
    min-height: 44px;
  }

  .input-field textarea {
    min-height: 110px;
  }

  .site-footer {
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 420px) {
  body {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
  }

  .navbar-container {
    position: relative !important;
    display: grid !important;
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto;
    min-height: 56px !important;
    padding-inline: 0.6rem;
  }

  .nav-logo {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    z-index: 2;
    max-width: none;
    min-width: 0;
  }

  .nav-actions {
    display: flex !important;
    align-items: center;
    justify-content: flex-end !important;
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: stretch;
    width: 100% !important;
    max-width: none;
    flex-wrap: wrap !important;
    position: static !important;
    transform: none;
    gap: 0.2rem;
    min-width: 0;
    padding-top: 0.25rem;
  }

  .nav-actions .theme-toggle,
  .nav-actions .notif-bell-btn,
  .nav-actions .menu-toggle {
    flex: 0 0 auto;
    align-self: flex-start;
  }

  .nav-actions .theme-toggle {
    margin-left: auto;
  }

  #userNavSlot,
  .user-nav-slot {
    order: 10;
    flex: 1 0 100%;
    width: 100%;
    max-width: none;
    justify-content: flex-end;
    padding: 0.15rem 0 0.4rem;
  }

  #userNavSlot .user-pill,
  .user-nav-slot .user-pill {
    max-width: 100% !important;
  }

  .nav-logo img {
    width: 30px;
    height: 30px;
  }

  .nav-signin-btn {
    max-width: 4.75rem;
    width: 50px;
    min-width: 50px;
    height: 36px !important;
    padding: 0 0.35rem !important;
    font-size: 0.8125rem !important;
    border-radius: 6px !important;
  }

  .nav-links {
    top: 92px !important;
  }

  .nav-actions .notif-bell-btn {
    display: inline-flex;
  }

  #userNavSlot,
  .user-nav-slot {
    min-width: 0;
    max-width: none !important;
    overflow: visible;
  }

  .user-pill {
    width: 100%;
    max-width: 100% !important;
    min-width: 0;
    height: 32px;
    min-height: 32px;
    gap: 0.18rem;
    padding-inline: 0.35rem;
    padding-block: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    white-space: nowrap;
  }

  .user-pill::-webkit-scrollbar {
    display: none;
  }

  .user-pill .user-name {
    flex: 0 0 auto;
    min-width: max-content;
    max-width: none !important;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    overflow-wrap: normal;
    line-height: 1;
  }

  .user-pill .role-badge {
    max-width: 3.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
    padding-inline: 0.2rem;
  }

  .user-pill-logout {
    flex: 0 0 auto;
    font-size: 0.8125rem;
    padding-inline: 0.15rem;
  }

  .nav-signin-btn {
    padding-inline: 0.55rem !important;
  }

  .hero-section,
  .tools-section,
  .projects-section,
  .timeline-section,
  .contact-section,
  .page-section,
  .page-header {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .hero-stats {
    gap: 0.5rem;
  }

  .stat-box {
    padding: 0.7rem 0.65rem;
  }

  .site-footer {
    display: flex;
    gap: 0;
    min-height: 0;
    padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
    align-items: center;
    flex-wrap: nowrap;
  }

  .footer-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding-inline: 0.75rem;
  }

  .site-footer .footer-left {
    min-width: 0;
    flex: 1 1 auto;
    gap: 0.35rem !important;
  }

  .site-footer .footer-left img {
    width: 1.25rem !important;
    height: 1.25rem !important;
    max-height: 1.25rem;
    flex: 0 0 1.25rem;
  }

  .site-footer .footer-left p,
  .site-footer .footer-right p {
    font-size: 0.8125rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .site-footer .footer-left > div {
    min-width: 0;
  }

  .footer-right {
    min-width: 0;
    flex: 0 1 auto;
    text-align: right;
  }
}

@media (min-width: 640px) and (max-width: 768px) {
  .footer-container {
    padding-inline: 1.5rem;
  }

  .site-footer .footer-left img {
    width: 1.5rem !important;
    height: 1.5rem !important;
    max-height: 1.5rem;
    flex-basis: 1.5rem;
  }

  .site-footer .footer-left p,
  .site-footer .footer-right p {
    font-size: 0.8125rem;
  }
}

@media (max-width: 360px) {
  .nav-actions {
    right: 0.45rem;
    max-width: calc(100vw - 4.25rem);
    gap: 0.12rem;
  }

  .nav-logo {
    gap: 0.2rem;
    font-size: 0.8125rem;
  }

  .nav-logo img {
    width: 26px;
    height: 26px;
  }

  .nav-actions .theme-toggle,
  .nav-actions .notif-bell-btn {
    width: 24px;
    min-width: 24px;
    height: 24px;
    font-size: 0.8125rem;
  }

  #userNavSlot,
  .user-nav-slot {
    max-width: 9rem !important;
    overflow: visible;
  }

  .user-pill {
    max-width: 9rem !important;
    font-size: 0.8125rem;
    gap: 0.12rem;
    padding-inline: 0.25rem;
  }

  .user-pill .role-badge {
    display: none !important;
  }

  .user-pill-logout {
    font-size: 0.8125rem;
    min-height: 19px;
    padding-inline: 0.3rem;
    margin-left: 0.08rem;
  }

  .nav-actions .menu-toggle {
    width: 20px;
    min-width: 20px;
    margin-inline: 0.05rem;
  }

  /* On the narrowest phones, this pill shares a nowrap row with the theme toggle,
     notification bell and hamburger - all fixed-width - so a long name can still
     push the row past the screen edge even after the width caps added elsewhere.
     Shed the chevron and shrink the avatar to buy back the room that needs. */
  .user-account-trigger {
    max-width: min(7rem, 30vw);
    gap: 0.3rem;
    padding-right: 0.35rem;
  }

  .user-account-avatar {
    flex-basis: 1.6rem;
    width: 1.6rem;
    height: 1.6rem;
    font-size: 0.6875rem;
  }

  .user-account-chevron {
    display: none;
  }

  .nav-signin-btn {
    min-width: 3.8rem;
    max-width: 4.2rem;
    font-size: 0.8125rem !important;
    padding-inline: 0.35rem !important;
  }
}

/* Tablet-phone header: prevent the legacy wrap rule from moving controls to a second row. */
@media (min-width: 421px) and (max-width: 768px) {
  .navbar:not(.admin-navbar) {
    min-height: 56px !important;
    height: 56px;
  }

  .navbar:not(.admin-navbar) .navbar-container {
    height: 56px !important;
    min-height: 56px !important;
    flex-wrap: nowrap !important;
    padding-inline: 0.85rem;
  }

  .navbar:not(.admin-navbar) .nav-actions {
    position: static !important;
    transform: none !important;
    flex: 0 1 auto !important;
    width: auto !important;
    max-width: calc(100vw - 8rem);
    height: 56px;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    gap: 0.3rem;
  }

  .navbar:not(.admin-navbar) .nav-actions > .nav-register-btn {
    display: none !important;
  }

  .navbar:not(.admin-navbar) .nav-actions .theme-toggle,
  .navbar:not(.admin-navbar) .nav-actions .notif-bell-btn,
  .navbar:not(.admin-navbar) .nav-actions .menu-toggle {
    flex: 0 0 auto;
    align-self: center !important;
  }

  .navbar:not(.admin-navbar) #userNavSlot,
  .navbar:not(.admin-navbar) .user-nav-slot {
    display: inline-flex !important;
    flex: 0 1 auto !important;
    width: auto !important;
    max-width: min(12rem, calc(100vw - 10rem)) !important;
    min-width: 0;
    overflow: visible;
    padding: 0;
  }

  .navbar:not(.admin-navbar) .user-pill .role-badge {
    display: none !important;
  }

  .navbar:not(.admin-navbar) .user-pill-logout {
    display: none !important;
  }

  .navbar:not(.admin-navbar) .nav-links {
    top: 56px !important;
  }
}

/* Final narrow-phone header: keep every control on one row. */
@media (max-width: 420px) {
  .navbar {
    min-height: 56px !important;
    height: 56px;
    overflow: visible;
  }

  .navbar-container {
    display: flex !important;
    position: relative !important;
    flex-wrap: nowrap !important;
    height: 56px !important;
    min-height: 56px !important;
    padding-inline: 0.55rem;
  }

  .nav-logo {
    flex: 1 1 auto !important;
    min-width: 0;
    max-width: none;
    z-index: 1;
  }

  .nav-actions {
    position: absolute !important;
    top: 0;
    right: 0.85rem;
    bottom: auto;
    height: 56px;
    display: flex !important;
    align-items: center;
    justify-content: flex-end !important;
    width: auto !important;
    max-width: calc(100vw - 5rem);
    flex-wrap: nowrap !important;
    padding: 0;
    gap: 0.2rem;
    transform: none !important;
    z-index: 1001;
  }

  .nav-logo,
  .nav-logo img,
  .nav-actions > *,
  #userNavSlot,
  .user-nav-slot {
    align-self: center !important;
  }

  .nav-actions .notif-bell-btn {
    display: inline-flex !important;
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    flex: 0 0 32px !important;
    font-size: 0.8125rem;
  }

  .nav-actions .theme-toggle {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    aspect-ratio: 1 / 1;
    border-radius: 50% !important;
    font-size: 0.8125rem;
    position: relative;
    z-index: 1002;
    pointer-events: auto;
    touch-action: manipulation;
  }

  #userNavSlot,
  .user-nav-slot {
    display: inline-flex !important;
    order: 2;
    flex: 0 1 auto !important;
    width: auto !important;
    max-width: min(10.5rem, calc(100vw - 8rem)) !important;
    min-width: 0;
    padding: 0;
    overflow: visible;
    gap: 0.2rem;
  }

  #userNavSlot .user-pill,
  .user-nav-slot .user-pill {
    width: auto !important;
    flex: 0 1 auto;
    max-width: 100% !important;
  }

  .user-pill {
    height: 32px;
    min-height: 32px;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.8125rem;
  }

  .user-pill .user-name {
    flex: 0 0 auto;
    max-width: none !important;
    white-space: nowrap;
  }

  .user-pill .role-badge {
    display: none !important;
    max-width: 3rem;
    font-size: 0.8125rem;
    padding-inline: 0.2rem;
  }

  .user-pill-logout {
    font-size: 0.8125rem;
    min-height: 22px;
    padding: 0 0.45rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 0.15rem;
  }

  .nav-signin-btn {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    height: 36px !important;
    padding: 0 0.35rem !important;
    font-size: 0.8125rem !important;
    border-radius: 6px !important;
    position: relative;
    z-index: 2;
    touch-action: manipulation;
  }

  .nav-actions .menu-toggle {
    order: 3;
    width: 24px;
    min-width: 24px;
    margin-left: 0.1rem;
    margin-right: 0.1rem;
  }

  .nav-links {
    top: 56px !important;
  }
}

@media (min-width: 769px) {
  .projects-grid,
  .browse-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }

  #items .item-card-category-ref {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.08rem;
  }

  #items .item-card-category-ref .ref-code {
    margin-left: 0 !important;
  }

  #items .item-card-meta-row {
    align-items: center;
  }
}

@media (min-width: 320px) and (max-width: 440px) {
  #anonymousFinderModal .modal-card {
    width: calc(100% - 1rem) !important;
    max-height: calc(100vh - 1rem) !important;
    padding: 1rem !important;
    border-radius: 14px !important;
    box-sizing: border-box;
  }

  #anonymousFinderModal .connect-avatar {
    width: 2.5rem !important;
    height: 2.5rem !important;
    font-size: 1.2rem !important;
  }

  #anonymousFinderModal .connect-field,
  #anonymousFinderModal .connect-toggle {
    padding: 0.55rem 0.6rem !important;
    margin-bottom: 0.65rem !important;
  }

  #anonymousFinderModal .connect-field-body input,
  #anonymousFinderModal .connect-field-body textarea {
    padding: 0.45rem !important;
    font-size: 1rem !important;
  }

  #anonymousFinderModal .connect-field-body textarea {
    min-height: 4.2rem;
    height: 4.2rem;
  }

  #anonymousFinderModal form > div:last-child {
    gap: 0.5rem !important;
  }

  #anonymousFinderModal form > div:last-child .btn {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.8125rem !important;
  }

  .category-picker-modal {
    width: 94%;
    padding: 1rem;
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem;
  }

  .category-option {
    min-height: 3.2rem;
    padding: 0.5rem;
    gap: 0.4rem;
    font-size: 0.8125rem;
    line-height: 1.2;
  }

  .category-option svg {
    width: 1.1rem;
    height: 1.1rem;
  }

  #report {
    padding-inline: 0.65rem !important;
  }

  #report > h2 {
    margin-bottom: 0.75rem !important;
    font-size: 1rem;
  }

  #report .simple-card {
    padding: 0.8rem !important;
    margin-bottom: 1rem;
    border-radius: 10px;
  }

  #report .input-field {
    gap: 0.12rem;
    margin-bottom: 0.45rem !important;
  }

  #report .form-row {
    gap: 0.45rem;
    margin-bottom: 0.45rem;
  }

  #report .input-field label {
    font-size: 0.875rem;
    line-height: 1.2;
  }

  #report .input-field input,
  #report .input-field select,
  #report .input-field textarea,
  #report .category-picker {
    min-height: 38px !important;
    height: 38px;
    padding: 0.45rem 0.6rem !important;
    font-size: 1rem !important;
    border-radius: 7px;
  }

  #report .input-field textarea {
    height: auto;
    min-height: 70px !important;
  }

  #report .photo-upload-area {
    min-height: 7.5rem;
    padding: 0.65rem;
    gap: 0.2rem;
  }

  #report .photo-upload-icon {
    height: 2.2rem;
  }

  #report .photo-upload-icon svg {
    width: 2.8rem;
    height: 2.2rem;
  }

  .filter-chips {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    grid-template-rows: minmax(36px, auto) !important;
    grid-auto-flow: column;
    gap: 0.3rem !important;
  }

  .filter-chips .chip {
    min-width: 0;
    min-height: 36px;
    padding: 0.3rem 0.12rem;
    font-size: 0.8125rem;
    white-space: nowrap;
  }

  .filter-chips .chip-my-vault {
    grid-column: auto !important;
    grid-row: 1 !important;
  }

  .filter-chips .my-belongings-icon,
  .filter-chips .my-belongings-count {
    display: none;
  }

  .type-switcher {
    display: flex !important;
    flex-direction: row !important;
    gap: 0.5rem !important;
    align-items: stretch;
  }

  .type-switcher .type-option {
    flex: 1 1 0;
    min-width: 0;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.45rem;
    font-size: 0.8125rem;
    line-height: 1.2;
    text-align: center;
  }

  #items .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
    align-items: stretch !important;
  }

  #items .projects-grid > .project-card,
  #items .projects-grid > .item-card {
    min-width: 0 !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0.75rem !important;
    box-sizing: border-box;
  }

  #items .item-card-meta-row {
    min-height: 2.35rem;
  }

  #items .item-card-category-ref {
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  #items .item-card-category-ref .ref-code {
    width: auto;
    max-width: 100%;
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: visible;
  }

  #items .item-badge {
    top: 0;
    right: 0;
    min-width: 2.15rem;
    padding: 0.16rem 0.28rem;
    font-size: 0.8125rem;
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .navbar-container {
    padding-inline: 1rem;
    gap: 0.65rem;
  }

  .footer-container {
    padding-inline: 1.5rem;
  }

  .nav-links {
    gap: 0.75rem;
  }

  .nav-actions {
    gap: 0.35rem;
  }

  .nav-btn-action,
  .nav-signin-btn {
    padding-inline: 0.65rem !important;
  }
}

@media (min-width: 1024px) {
  .footer-container {
    padding-inline: 2rem;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .hero-section {
    min-height: auto;
    padding-top: 2rem;
    padding-bottom: 2rem;
  }

  .page-header {
    padding-top: 1.5rem;
  }

  .site-footer {
    min-height: 0;
    padding-top: 0.45rem;
    padding-bottom: calc(0.45rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 768px) {
  :where(button, a, input, select, textarea) {
    touch-action: manipulation;
  }

  :where(button, a, input[type='button'], input[type='submit']) {
    -webkit-user-select: none;
    user-select: none;
  }

  :where(input, select, textarea) {
    max-width: 100%;
  }
}

.mobile-drawer-close,
.mobile-drawer-header,
.mobile-drawer-profile,
.mobile-drawer-footer,
.mobile-header-signin,
.mobile-header-notification {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 768px) {
  :root {
    --navbar-height: 56px;
  }

  .about-page .nav-actions > .about-navbar-signin,
  .about-page .mobile-drawer-footer .mobile-drawer-signin {
    display: none !important;
  }

  body.mobile-drawer-open {
    overflow: hidden;
  }

  .navbar.mobile-drawer-active {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .navbar-container {
    min-height: 56px !important;
    height: 56px;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem !important;
  }

  .nav-logo {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    gap: 0.45rem;
    font-size: 0.875rem;
  }

  .nav-logo img {
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px;
  }

  .nav-logo-full,
  .nav-logo-short {
    flex-shrink: 0;
  }

  .nav-actions {
    position: static !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    min-width: 0;
    margin-left: auto;
    padding: 0 !important;
    gap: 0.5rem;
    transform: none !important;
    flex-wrap: nowrap !important;
  }

  .nav-actions > .nav-register-btn,
  .nav-actions > .admin-profile,
  .nav-actions #userNavSlot .user-pill,
  .nav-actions .user-nav-slot .user-pill,
  .nav-actions #userNavSlot .nav-signin-btn,
  .nav-actions .user-nav-slot .nav-signin-btn {
    display: none !important;
  }

  .nav-actions #userNavSlot,
  .nav-actions .user-nav-slot {
    display: contents !important;
  }

  .nav-actions .user-account-trigger {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    gap: 0;
    justify-content: center;
    flex: 0 0 36px;
    border-radius: 50%;
    box-sizing: border-box;
  }

  .nav-actions .user-account-name,
  .nav-actions .user-account-chevron {
    display: none;
  }

  .nav-actions .theme-toggle,
  .nav-actions .notif-bell-btn.mobile-header-notification,
  .nav-actions .notif-bell-btn.mobile-header-notification-source,
  .navbar.mobile-authenticated.admin-navbar .mobile-header-notification {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    flex: 0 0 32px !important;
  }

  .nav-actions .notif-bell-btn {
    display: none !important;
  }

  .navbar.mobile-authenticated .nav-actions .notif-bell-btn.mobile-header-notification-source,
  .navbar.mobile-finder-notifications .nav-actions .notif-bell-btn.mobile-header-notification-source,
  .navbar.mobile-authenticated.admin-navbar .nav-actions .mobile-header-notification {
    display: inline-flex !important;
  }

  .nav-actions > .mobile-header-signin {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    min-height: 34px;
    padding: 0.4rem 0.7rem !important;
    border: 1px solid var(--blue-main) !important;
    border-radius: 9px !important;
    background: var(--blue-main) !important;
    color: #ffffff !important;
    font-size: 0.8125rem !important;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.2);
  }

  .navbar-container > .menu-toggle {
    display: flex !important;
    position: relative;
    z-index: 1004;
    order: 0;
    align-items: center;
    justify-content: center;
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    margin: 0 !important;
    padding: 10px !important;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(59, 130, 246, 0.09);
    gap: 4px;
  }

  .navbar-container > .menu-toggle span {
    height: 2px;
    background: var(--text-main);
  }

  .navbar-container > .menu-toggle.open span:first-child {
    transform: translateY(6px) rotate(45deg);
  }

  .navbar-container > .menu-toggle.open span:nth-child(2) {
    opacity: 0;
  }

  .navbar-container > .menu-toggle.open span:last-child {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* Remove the hamburger control from the open header; the drawer close button remains available. */
  .navbar.mobile-drawer-active .menu-toggle {
    display: none !important;
  }

  .nav-drawer-backdrop[hidden] {
    display: none !important;
  }

  .nav-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1001;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(2, 6, 23, 0.62);
    backdrop-filter: blur(3px);
    cursor: pointer;
    animation: nav-backdrop-in 0.2s ease both;
  }

  .nav-links,
  .navbar .nav-links {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: 1002;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.1rem !important;
    width: 78vw !important;
    max-width: 22rem;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0 !important;
    padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom)) !important;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--border);
    background: #18181b;
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.3);
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-105%);
    transition:
      transform 0.24s ease,
      visibility 0.24s ease;
  }

  [data-theme='light'] .nav-links,
  [data-theme='light'] .navbar .nav-links {
    background: #ffffff;
  }

  .nav-links.open,
  .navbar .nav-links.open {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  .navbar-container > .nav-logo {
    order: 1;
  }

  .navbar-container > .nav-actions {
    order: 2;
    gap: 0.5rem !important;
  }

  .navbar-container > .nav-actions > .theme-toggle {
    display: inline-flex !important;
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    flex: 0 0 32px !important;
  }

  /* Size and colours come from the capsule rule in styles.css; only placement here. */
  .navbar-container .notif-bell-btn .notif-badge {
    top: -0.3rem;
    right: -0.4rem;
    display: inline-flex;
  }

  .nav-links .mobile-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 25px;
    width: 25px;
    height: 25px;
    margin-left: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
  }

  .nav-links .mobile-drawer-close svg {
    display: block;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
  }

  .nav-links .mobile-drawer-header .mobile-drawer-brand {
    display: flex !important;
    align-items: center;
    gap: 0.55rem;
    width: auto;
    min-width: 0;
    min-height: 36px;
    height: auto !important;
    padding: 0;
    color: var(--blue-main);
    font-size: 0.9375rem !important;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2 !important;
    white-space: nowrap;
    cursor: default;
  }

  .mobile-drawer-brand img {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 50%;
    background: #ffffff;
    object-fit: contain;
    padding: 2px;
  }

  .mobile-drawer-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 72px;
    margin: 0.25rem 0 0.75rem;
    padding: 0.85rem 0.25rem 1rem;
    border-bottom: 1px solid var(--border);
  }

  .mobile-drawer-profile[hidden] {
    display: none !important;
  }

  .nav-links > .mobile-drawer-profile[hidden] + a {
    margin-top: 0.75rem;
  }

  .mobile-drawer-avatar {
    display: flex;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue-light);
    font-size: 0.875rem;
    font-weight: 800;
  }

  .mobile-drawer-account-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 0.2rem;
  }

  .mobile-drawer-account-details strong {
    overflow: hidden;
    color: var(--text-main);
    font-size: 0.9375rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-drawer-account-details > span {
    color: var(--text-muted);
    font-size: 0.8125rem;
  }

  .mobile-drawer-account-details .mobile-drawer-role-badge {
    display: inline-flex;
    align-self: flex-start;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.18);
    color: var(--blue-light);
    font-size: 0.8125rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .nav-links a {
    display: flex !important;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    min-height: 34px;
    height: auto !important;
    padding: 0.3rem 0.75rem;
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.875rem !important;
    letter-spacing: 0;
    line-height: 1.25 !important;
    text-decoration: none;
    white-space: normal;
  }

  .nav-links a::before {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    color: var(--blue-light);
    font-size: 1rem;
  }

  .nav-links a[data-mobile-icon='items']::before { content: '\25a3'; }
  .nav-links a[data-mobile-icon='report']::before { content: '\270e'; }
  .nav-links a[data-mobile-icon='about']::before { content: '\24d8'; }
  .nav-links a[data-mobile-icon='dashboard']::before { content: '\2302'; }
  .nav-links a[href$='about.html']::before {
    content: '?';
    width: 1.1rem;
    height: 1.1rem;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.8125rem;
    font-weight: 800;
    line-height: 1;
  }

  .nav-links a:hover,
  .nav-links a:focus-visible {
    background: rgba(59, 130, 246, 0.1);
    color: var(--blue-light);
  }

  .nav-links .nav-register-mobile {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 34px !important;
    height: auto !important;
    margin: 0.1rem 0 0;
    padding: 0.3rem 0.75rem !important;
    border-radius: 10px !important;
    background: rgba(59, 130, 246, 0.09) !important;
    font-size: 0.875rem !important;
  }

  .nav-links .nav-register-mobile::before {
    display: none;
  }

  .nav-links .mobile-menu-logout {
    display: none !important;
  }

  .mobile-drawer-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
  }

  .mobile-drawer-logout,
  .mobile-drawer-signin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 34px;
    padding: 0.3rem 0.75rem;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-drawer-signin {
    display: none;
  }

  .mobile-drawer-password {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 34px;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-drawer-footer:has(> .mobile-drawer-signin:only-child),
  .mobile-drawer-footer:empty {
    display: none;
  }

  .mobile-drawer-signin {
    border-color: var(--blue-main);
    background: var(--blue-main);
    color: #ffffff;
    text-decoration: none;
  }

  @keyframes nav-backdrop-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}

@media (max-width: 1024px), (pointer: coarse), (hover: none) {
  .keyboard-shortcuts-trigger,
  .search-shortcut-hint,
  .keyboard-shortcuts-menu-item {
    display: none !important;
  }
}
/* Header action controls stay square and identical at every compact breakpoint. */
@media (max-width: 900px) {
  .nav-actions .theme-toggle,
  .nav-actions .notif-bell-btn {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    flex: 0 0 32px !important;
    box-sizing: border-box !important;
  }
}

/* Small-device / 420px-wide viewport: keep both header controls identical. */
@media (max-width: 420px) {
  .nav-actions .theme-toggle,
  .nav-actions .notif-bell-btn {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    padding: 0 !important;
    margin-block: 0 !important;
    align-self: center !important;
    flex: 0 0 32px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
  }
}

/* Final viewport safeguards. These rules keep nested flex/grid content from
   establishing a wider intrinsic size than the viewport. */
html {
  max-width: 100%;
  overflow-x: hidden;
}

body,
main,
section,
header,
footer,
.navbar-container,
.site-footer .footer-container,
.simple-card,
.auth-card,
.detail-card,
.page-section,
.page-header {
  min-width: 0;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

input,
select,
textarea,
button {
  max-width: 100%;
}

.form-row > *,
.type-switcher > *,
.filter-row > *,
.filter-chips > *,
.hotspots-row > *,
.hero-section > *,
.site-footer .footer-left,
.site-footer .footer-right {
  min-width: 0;
}

.input-field input,
.input-field select,
.input-field textarea,
.form-control,
.search-box input,
.form-group input,
.form-group select {
  max-width: 100%;
}

/* The toast notification is anchored with a fixed `right` offset plus a fixed
   max-width (or no width limit at all - home.css's copy), so a long message on
   a narrow phone (<=360px) pushes its left edge past x=0. html/body's
   overflow-x: hidden above stops that from opening a horizontal scrollbar, but
   it still silently clips part of the message off-screen. Pinning both edges
   keeps it fully on screen at any width instead. */
@media (max-width: 480px) {
  .toast {
    left: 1rem;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
  }
}

/* .user-account-menu is anchored with `right: 0` against its own trigger button
   (.user-account-wrap, position: relative), not the viewport. On phones the
   trigger can sit well left of the true right edge, so the menu's up-to-
   near-full-width box opens leftward from there and its left edge pushes past
   x=0 - clipped off-screen the same way the toast above was. Pinning it to the
   viewport with position: fixed guarantees it always stays fully on screen;
   .nav-links already does the same thing nested under this same .navbar, so
   its backdrop-filter is confirmed not to break a fixed descendant here. */
@media (max-width: 480px) {
  .user-account-menu {
    position: fixed;
    top: calc(var(--navbar-height) + 0.5rem);
    right: 1rem;
    left: auto;
    width: min(16rem, calc(100vw - 2rem));
    max-width: none;
    max-height: calc(100dvh - var(--navbar-height) - 1.5rem);
    overflow-y: auto;
  }
}

@media (max-width: 768px) {
  .nav-actions .theme-toggle,
  .nav-actions .notif-bell-btn,
  .nav-actions .menu-toggle {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    flex: 0 0 32px !important;
  }

  .simple-card,
  .auth-card,
  .detail-card,
  .page-section {
    overflow: hidden;
  }

  .admin-table-card {
    max-width: 100%;
    overflow: hidden;
  }

  .admin-table-wrap,
  .admin-items-table-wrap {
    max-width: 100%;
    overflow: visible;
  }

  .qr-scanner-upload-btn {
    display: inline-flex;
  }
}

@media (max-width: 767px) {
  .admin-table-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 0.75rem;
  }

  #adminItemsTable,
  #adminUsersTable {
    width: 100%;
    min-width: 750px;
  }

  #adminItemsTable {
    table-layout: auto;
  }

  #adminItemsTable th,
  #adminItemsTable td,
  #adminUsersTable th,
  #adminUsersTable td {
    white-space: nowrap;
    overflow-wrap: normal;
  }

  #adminItemsTable th,
  #adminItemsTable td {
    overflow: visible;
  }

  #adminItemsTable .item-title-cell,
  #adminItemsTable .location-cell,
  #adminItemsTable .reporter-cell,
  #adminItemsTable .status-cell .badge,
  #adminItemsTable .actions-cell .action-btn {
    white-space: nowrap;
    overflow-wrap: normal;
  }
}

@media (max-width: 360px) {
  .navbar-container,
  .hero-section,
  .tools-section,
  .projects-section,
  .page-section,
  .page-header {
    padding-left: 0.65rem !important;
    padding-right: 0.65rem !important;
  }

  .hero-name {
    font-size: clamp(2rem, 14vw, 2.75rem) !important;
  }

  .filter-chips {
    grid-template-columns: 1fr !important;
  }

  .filter-chips .chip,
  .chip-my-vault {
    grid-column: auto !important;
    width: 100%;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .navbar-container {
    min-height: 52px;
  }

  .hero-section {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }

  .hero-seal {
    width: 96px;
    height: 96px;
  }

  .hero-avatar .hero-seal img {
    width: 72px;
    height: 72px;
  }

  .modal,
  .slip-overlay > div,
  [role='dialog'] {
    max-height: calc(100dvh - 1rem);
    overflow-y: auto;
  }
}

/* Standard form-like presentation for the generated QR result. */
.qr-modal-card {
  background: var(--card-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  width: min(86vw, 31rem) !important;
  max-height: calc(100dvh - 1rem) !important;
  padding: clamp(0.55rem, 1.8vw, 0.9rem) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45) !important;
}

/* The finder simulation is not part of the QR sticker modal. */
.qr-modal-card #anonymousDemoBox,
.qr-modal-card #demoToggleBtn {
  display: none !important;
}

.qr-modal-header {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start !important;
}

.qr-modal-header h2 {
  font-size: clamp(1.05rem, 3vw, 1.3rem) !important;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.qr-modal-header p {
  max-width: 42rem;
  line-height: 1.45;
}

#qrPrintArea {
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  padding: clamp(0.45rem, 1.5vw, 0.7rem) !important;
  margin-bottom: 0.65rem !important;
}

#qrPrintArea img#qrCodeImage {
  width: min(92px, 28vw) !important;
  height: auto !important;
  aspect-ratio: 1;
}

#qrPrintArea > div:nth-of-type(4) {
  padding: 0.4rem !important;
  border-radius: 8px !important;
  margin-bottom: 0.4rem !important;
}

.qr-feature-details > div {
  border-radius: 8px !important;
  padding: 0.48rem !important;
  line-height: 1.45;
}

.qr-actions {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-content: stretch !important;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.qr-actions .btn {
  min-width: 0;
  min-height: 35px;
  padding: 0.35rem 0.25rem !important;
  font-size: 0.8125rem;
  white-space: normal;
}

#demoToggleBtn {
  justify-content: center !important;
  align-items: center !important;
  text-align: center;
}

@media (max-width: 480px) {
  .card-actions {
    flex-wrap: nowrap !important;
    gap: 0.2rem !important;
    justify-content: center;
  }

  .card-actions .btn-sm {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.2rem 0.2rem !important;
    font-size: 0.8125rem;
    line-height: 1.05;
    text-align: center;
  }

  .card-actions .btn-qr {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .qr-modal-card {
    width: calc(100vw - 1rem) !important;
  }

  .qr-modal-header {
    gap: 0.5rem;
  }

  .qr-feature-details {
    font-size: 0.8125rem !important;
  }

  #qrPrintArea img#qrCodeImage {
    width: min(84px, 26vw) !important;
  }

  #qrPrintArea {
    padding: 0.4rem !important;
  }

  #qrPrintArea > div:first-child {
    margin-bottom: 0.3rem !important;
  }

  .qr-actions {
    gap: 0.35rem;
  }
  .qr-actions .btn {
    font-size: 0.8125rem;
  }
}

@media (min-width: 360px) and (max-width: 480px) {
  .card-actions .btn-qr {
    flex: 0 0 68px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .card-actions .btn-qr + .btn-outline {
    flex: 0 0 78px;
    max-width: 78px;
    white-space: normal;
    line-height: 1.05;
  }
}

/* Keep the QR modal compact on phone-sized viewports with limited height. */
@media (max-width: 480px) and (min-height: 600px) and (max-height: 760px) {
  .qr-modal-card {
    padding: 0.45rem !important;
  }

  .qr-modal-header {
    gap: 0.35rem;
    padding-bottom: 0.55rem !important;
    margin-bottom: 0.65rem !important;
  }

  .qr-modal-header h2 {
    font-size: 1rem !important;
    margin-top: 0.15rem !important;
  }

  .qr-modal-header p {
    font-size: 0.8125rem !important;
    line-height: 1.3;
  }

  #qrPrintArea {
    margin-bottom: 0.5rem !important;
  }

  #qrPrintArea img#qrCodeImage {
    width: 76px !important;
  }

  .qr-feature-details {
    gap: 0.35rem !important;
    margin-bottom: 0.65rem !important;
  }

  .qr-feature-details > div {
    padding: 0.36rem !important;
    line-height: 1.3;
  }

  .qr-feature-details strong {
    margin-bottom: 0.1rem !important;
  }

  .qr-actions {
    padding-top: 0.55rem !important;
  }
}

/* Fit the registration form on a 360px-wide by 640px-tall phone. */
@media (min-width: 360px) and (max-width: 480px) and (min-height: 640px) and (max-height: 1000px) {
  #registerBelongingModal .modal-card {
    width: calc(100vw - 2.5rem) !important;
    height: auto !important;
    max-height: calc(100dvh - 1rem) !important;
    overflow: hidden !important;
    padding: 0.5rem !important;
    border-radius: 12px !important;
  }

  #registerBelongingModal .modal-card > div:first-child {
    padding-bottom: 0.45rem !important;
    margin-bottom: 0.45rem !important;
  }

  #registerBelongingModal .modal-title {
    font-size: 1.05rem !important;
    line-height: 1.05 !important;
    margin: 0.25rem 0 0.1rem !important;
  }

  #registerBelongingModal .modal-subtitle {
    font-size: 0.8125rem !important;
    line-height: 1.25 !important;
  }

  #registerBelongingModal .modal-notice-box {
    padding: 0.35rem 0.45rem !important;
    margin-bottom: 0.5rem !important;
    font-size: 0.8125rem !important;
    line-height: 1.2 !important;
  }

  #registerBelongingModal form > .input-field,
  #registerBelongingModal .report-more .input-field {
    margin-bottom: 0.4rem !important;
  }

  #registerBelongingModal .report-more > summary {
    padding: 0.5rem 2.25rem 0.5rem 0.75rem !important;
  }

  #registerBelongingModal form > .modal-grid-2 {
    gap: 0.35rem !important;
    margin-bottom: 0.4rem !important;
  }

  #registerBelongingModal label {
    font-size: 0.875rem !important;
    line-height: 1.15 !important;
  }

  #registerBelongingModal input,
  #registerBelongingModal select,
  #registerBelongingModal textarea {
    padding: 0.32rem !important;
    font-size: 1rem !important;
  }

  #registerBelongingModal form > div:last-child {
    margin-bottom: 0.45rem !important;
  }

  #registerBelongingModal #regInstructions {
    height: 64px !important;
  }

  #registerBelongingModal form button {
    padding: 0.3rem 0.55rem !important;
    font-size: 0.8125rem !important;
  }
}

@media (max-width: 639px) {
  .filter-row {
    align-items: stretch;
  }

  .projects-section {
    padding-inline: 0.75rem !important;
  }

  /* Three chips per row keeps labels at a readable 12px with ~40px tap targets;
     "My Belongings" spans two columns. Guests see four chips on one row. */
  .filter-chips {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: none !important;
    grid-auto-flow: row !important;
    gap: 0.35rem;
    width: 100%;
  }

  .filter-chips:has(.chip-my-vault[style*='display: none']) {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .filter-chips .chip {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 2.5rem;
    padding: 0.45rem 0.25rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    white-space: nowrap;
    box-sizing: border-box;
  }

  .filter-chips .chip.chip-my-vault {
    grid-column: span 2 !important;
    grid-row: auto !important;
  }

  .filter-chips .my-belongings-icon,
  .filter-chips .my-belongings-count {
    display: none;
  }

  .hero-stats .stat-box {
    padding: 0.75rem;
  }

  .hero-stats .stat-lbl {
    font-size: 0.8125rem;
    line-height: 1.25;
  }

  #adminPanel > .page-header,
  #adminPanel .page-section {
    width: calc(100% - 1.5rem);
    padding-inline: 0;
  }

  #adminPanel .admin-search-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #adminPanel .admin-search-row .admin-search-wrap {
    grid-column: 1 / -1;
  }

  #adminPanel .admin-search-row > * {
    min-width: 0;
  }

  #adminPanel .admin-search-row #exportBtn {
    grid-column: 1 / -1;
  }

  #adminPanel .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #adminPanel .admin-stats .stat-card {
    min-width: 0;
    padding: 0.75rem;
    box-sizing: border-box;
  }

  #adminPanel .admin-stats .stat-number {
    font-size: 1.5rem;
  }

  #adminPanel .admin-stats .stat-label {
    font-size: 0.8125rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 340px) {
  .filter-chips .chip-my-vault {
    font-size: 0.8125rem !important;
  }
}

@media (min-width: 640px) {
  .filter-chips {
    display: flex;
    flex-wrap: wrap;
  }

  .filter-chips .chip {
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
  }

  /* "My Belongings" filters by ownership, not status like its siblings - a gap
     instead of a border keeps it grouped with the row while reading as its own
     thing, rather than a same-kind option that happens to look different. */
  .filter-chips .chip-my-vault {
    margin-left: 0.5rem;
  }

  .hero-stats .stat-box {
    padding: 1rem;
  }

  .hero-stats .stat-lbl {
    font-size: 0.9375rem;
  }

  #adminPanel .admin-stats .stat-card {
    padding: 1rem;
  }

  #adminPanel .admin-stats .stat-label {
    font-size: 0.9375rem;
  }
}

#items .projects-grid .project-card-header,
#items .projects-grid .item-card-header-content {
  min-width: 0;
  width: 100%;
}

#items .projects-grid .item-card-meta-row {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 0.5rem !important;
  width: 100%;
  min-width: 0;
  position: static !important;
}

#items .projects-grid .item-card-category-ref {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 0.08rem !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: 100%;
  overflow: hidden;
}

#items .projects-grid .item-card-category-ref .project-type,
#items .projects-grid .item-card-category-ref .ref-code {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-left: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  overflow-wrap: normal;
}

#items .projects-grid .item-badge {
  position: static !important;
  inset: auto !important;
  flex: 0 0 auto !important;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
}

#itemsGrid.registered-belongings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.75rem !important;
  width: 100%;
}

#itemsGrid.registered-belongings-grid > .registered-belonging-card {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 1rem;
}

#itemsGrid.registered-belongings-grid .registered-belonging-protection {
  min-width: 0;
  overflow-wrap: anywhere;
}

#itemsGrid.registered-belongings-grid .card-actions {
  display: flex;
  flex-wrap: wrap !important;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.5rem;
}

#itemsGrid.registered-belongings-grid .card-actions .btn-sm {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

@media (max-width: 480px) {
  #notificationsModal .notifications-modal-header {
    gap: 0.625rem;
  }

  #notificationsModal .notifications-modal-header-group {
    gap: 0.625rem;
  }
}

@media (max-width: 768px) {
  #itemsGrid.registered-belongings-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (min-width: 1200px) {
  #itemsGrid.registered-belongings-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* Shrink the floating QR scanner widget further on phones: 300px already
   reads as "nearly full width" on a narrow screen. Only applies to the
   screen-share flow - camera mode below goes full-screen instead. */
@media (max-width: 480px) {
  #qrScannerModal:not(.qr-scanner-modal--camera) .modal-card {
    max-width: 170px !important;
    padding: 0.7rem !important;
  }
  #qrScannerModal:not(.qr-scanner-modal--camera) .modal-heading {
    font-size: 0.85rem !important;
  }
  #qrScannerModal:not(.qr-scanner-modal--camera) .modal-subtitle {
    font-size: 0.7rem !important;
  }
  #qrScannerModal:not(.qr-scanner-modal--camera) .qr-scanner-viewport {
    max-width: 145px !important;
  }
  #qrScannerModal:not(.qr-scanner-modal--camera) .qr-scanner-status {
    font-size: 0.7rem !important;
  }
}

/* Camera mode (the common case on phones, since getDisplayMedia isn't
   available there) fills the whole screen as a real viewfinder instead of a
   postage-stamp preview - no need to screen-share or screenshot to scan. */
@media (max-width: 768px) {
  #qrScannerModal.qr-scanner-modal--camera .modal-card {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
  }
  #qrScannerModal.qr-scanner-modal--camera .modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    margin: 0;
    padding: 1rem 1.1rem;
    border-bottom: none;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
  }
  #qrScannerModal.qr-scanner-modal--camera .modal-heading,
  #qrScannerModal.qr-scanner-modal--camera .modal-subtitle {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    font-size: initial !important;
  }
  #qrScannerModal.qr-scanner-modal--camera .modal-close {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
  }
  #qrScannerModal.qr-scanner-modal--camera .qr-scanner-viewport {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: none !important;
    aspect-ratio: auto !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  #qrScannerModal.qr-scanner-modal--camera .qr-scanner-status {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 5.5rem;
    z-index: 2;
    margin: 0 !important;
    padding: 0 1.25rem;
    color: #fff;
    font-size: 0.9rem !important;
  }
  #qrScannerModal.qr-scanner-modal--camera .modal-actions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    margin: 0;
    padding: 1.1rem 1.25rem calc(1.1rem + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
  }
}
