/* Load after styles.css. Desktop keeps the existing sidebar layout. */
.mobile-menu-toggle,
.mobile-bottom-nav {
  display: none;
}

.upload-progress {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid #b9cec0;
  border-radius: 12px;
  background: #f0f6ef;
  overflow-wrap: anywhere;
}
.upload-progress strong {
  color: var(--green);
}
.upload-progress p {
  margin: 8px 0 0;
}
.upload-progress progress {
  display: block;
  width: 100%;
  height: 12px;
  margin-top: 12px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: #dbe5da;
  accent-color: var(--green);
}
.upload-progress progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #dbe5da;
}
.upload-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--green);
}
.upload-progress progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--green);
}
.operations-project-card .primary,
.photo-share-card button[type="submit"] {
  width: 100%;
  min-height: 56px;
  font-size: 17px;
  font-weight: 600;
}

@media (max-width: 800px) {
  :root {
    --mobile-header-height: calc(72px + env(safe-area-inset-top, 0px));
    --mobile-bottom-height: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  html {
    scroll-padding-top: calc(var(--mobile-header-height) + 12px);
    scroll-padding-bottom: calc(var(--mobile-bottom-height) + 16px);
  }
  body {
    min-width: 0;
  }
  #app,
  .shell,
  main,
  .pagehead,
  .pagehead > *,
  .panel,
  .grid > *,
  .two > * {
    min-width: 0;
    max-width: 100%;
  }

  header {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--mobile-header-height);
    min-height: var(--mobile-header-height);
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  }
  header .brand {
    flex-shrink: 0;
    font-size: 21px;
    line-height: 1.2;
  }
  header .brand span {
    margin-top: 3px;
    font-size: 9px;
  }
  header .prototype {
    display: none;
  }
  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 82px;
    min-height: 44px;
    margin-left: auto;
    padding: 9px 14px;
    border: 1px solid var(--border);
    background: #f5f7f2;
    font-size: 14px;
    font-weight: 600;
  }
  .mobile-menu-toggle[aria-expanded="true"] {
    border-color: var(--green);
    background: #e3eae2;
  }

  .shell {
    display: block;
    min-height: calc(100dvh - var(--mobile-header-height));
    padding-bottom: var(--mobile-bottom-height);
  }
  #main-nav {
    display: none;
  }
  .shell.menu-open::before {
    content: "";
    position: fixed;
    z-index: 40;
    inset: var(--mobile-header-height) 0 var(--mobile-bottom-height);
    background: rgb(26 44 35 / 28%);
  }
  .shell.menu-open #main-nav {
    position: fixed;
    top: calc(var(--mobile-header-height) + 8px);
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    z-index: 50;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 5px;
    max-height: calc(100dvh - var(--mobile-header-height) - var(--mobile-bottom-height) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 36px rgb(22 45 33 / 16%);
  }
  #main-nav .identity {
    width: 100%;
    margin-bottom: 4px;
    padding: 6px 12px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  #main-nav button {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 12px;
    text-align: left;
    font-size: 15px;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    min-height: var(--mobile-bottom-height);
    padding: 7px max(8px, env(safe-area-inset-right, 0px)) calc(7px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    border: 0;
    border-top: 1px solid var(--border);
    background: #fff;
    box-shadow: 0 -4px 18px rgb(31 55 42 / 6%);
  }
  .mobile-bottom-nav button {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 54px;
    padding: 8px 5px;
    border: 0;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 550;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .mobile-bottom-nav button.active,
  .mobile-bottom-nav button[aria-current="page"] {
    background: #e3eae2;
    color: #183d30;
    font-weight: 700;
  }
  .mobile-bottom-nav button[data-action="new-update"] {
    background: var(--green);
    color: #fff;
  }

  main {
    padding: 22px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  }
  h1 {
    font-size: 27px;
    line-height: 1.2;
    letter-spacing: -0.6px;
    overflow-wrap: anywhere;
  }
  h2 {
    font-size: 19px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  h3,
  p,
  .muted,
  .stage-summary,
  .project-title {
    overflow-wrap: anywhere;
  }
  .eyebrow {
    font-size: 10px;
    letter-spacing: 1.5px;
  }
  .pagehead {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }
  .pagehead > div:first-child {
    flex: 1 1 100%;
  }
  .pagehead > button,
  .pagehead > .button,
  .selected-project {
    width: 100%;
    max-width: 100%;
  }
  .grid,
  .two,
  .login-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .panel {
    margin-bottom: 16px;
    padding: 18px;
    border-radius: 14px;
  }
  .grid > .panel {
    margin-bottom: 0;
  }
  .row {
    align-items: flex-start;
    gap: 8px;
  }
  .project-title {
    font-size: 23px;
    line-height: 1.3;
  }
  .project-lists {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 20px;
  }
  .project-lists button {
    min-width: 0;
    min-height: 50px;
    padding: 9px 8px;
    font-size: 13px;
    line-height: 1.35;
  }
  .project-meta {
    flex-direction: column;
    gap: 5px;
  }
  .schedule-health {
    padding: 12px;
    font-size: 13px;
  }
  .actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
    gap: 8px;
    width: 100%;
  }
  .actions button {
    min-width: 0;
    padding-inline: 10px;
  }
  label {
    margin-top: 16px;
    font-size: 14px;
  }
  input,
  select,
  textarea {
    max-width: 100%;
    min-height: 48px;
    font-size: 16px;
  }
  textarea {
    min-height: 120px;
  }
  input[type="file"] {
    padding: 10px;
    font-size: 14px;
  }
  input[type="file"]::file-selector-button {
    min-height: 40px;
    margin-right: 8px;
    padding: 8px 10px;
    border: 1px solid #b7c7ba;
    border-radius: 7px;
    background: #eef3ea;
    color: var(--green);
    font: inherit;
    font-weight: 600;
  }
  form > button[type="submit"],
  form > button:not([type]),
  .photo-share-card .primary {
    width: 100%;
    min-height: 52px;
  }
  .photo-share-card input[type="file"] {
    min-height: 86px;
    padding: 16px 10px;
    border: 1px dashed #8ea78e;
    background: #f4f7f0;
  }
  .operations-project-card .primary,
  .photo-share-card .primary {
    min-height: 58px;
    font-size: 17px;
  }
  .upload-progress {
    padding: 14px;
  }
  .upload-progress progress {
    height: 14px;
  }
  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .photo-grid button {
    min-width: 0;
    padding: 12px 8px;
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  .photo-grid img {
    height: 150px;
  }
  .media-preview img,
  .media-preview video {
    max-height: 55dvh;
  }
  .timeline-item {
    margin-left: 5px;
    padding-left: 17px;
  }
  .timeline-item .row {
    gap: 5px;
  }
  .timeline-item h3 {
    flex: 1 1 150px;
  }
  .timeline-item .badge {
    flex-shrink: 0;
  }
  .step-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .step-actions button {
    min-width: 0;
    min-height: 44px;
    padding: 8px 4px;
    font-size: 12px;
  }
  .completion-control {
    padding: 14px;
  }
  .completion-control input[type="checkbox"] {
    min-height: 22px;
  }
  .chat-message {
    padding: 12px;
  }
  .chat-message.own {
    margin-left: 14px;
  }
  .login {
    margin: 8px auto;
    padding: 18px 16px;
  }
  .login-intro {
    padding: 0 2px;
  }
  .login-intro h1 {
    margin: 14px 0;
    font-size: 32px;
  }
  .login .panel {
    padding: 22px;
  }
  .preview-warning {
    padding: 9px 16px;
  }
  #install-controls {
    padding: 12px 16px calc(var(--mobile-bottom-height) + 14px);
    font-size: 12px;
  }
  #install-controls:empty {
    display: none;
  }
  footer {
    padding-top: 20px;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  main {
    padding-right: 12px;
    padding-left: 12px;
  }
  .panel {
    padding: 15px;
  }
  .mobile-bottom-nav button {
    font-size: 12px;
  }
}
