@media (max-width: 900px) {
  html { background: #f3f7f6; }
  body { overflow-x: hidden; background: #f3f7f6; }
  button, select, input, textarea { touch-action: manipulation; }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 64px;
    padding: 3px 12px;
  }
  .brand-custom { width: 118px; height: 56px; }
  .topbar .subtle { min-height: 40px; }

  .app-shell { display: block; min-height: calc(100dvh - 64px); }
  .sidebar {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(125px, .72fr) minmax(170px, 1.28fr);
    gap: 8px;
    padding: 10px 12px 8px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }
  .new-patient { min-height: 44px; padding: 9px 10px; }
  .search { min-height: 44px; margin: 0; }
  .patient-list {
    grid-column: 1 / -1;
    display: flex;
    gap: 7px;
    width: calc(100vw - 24px);
    overflow-x: auto;
    padding: 1px 0 4px;
    scroll-snap-type: x proximity;
  }
  .patient-row {
    min-width: 166px;
    max-width: 210px;
    padding: 8px;
    border: 1px solid var(--line);
    background: #fff;
    scroll-snap-align: start;
  }
  .patient-row.selected { border-color: #8bcfba; box-shadow: inset 3px 0 var(--green); }
  .patient-row small { display: none; }

  .content { width: 100%; max-width: none; padding: 14px 12px 90px; }
  .empty-state { margin: 55px auto; padding: 0 12px; }
  #patientWorkspace, .panel { width: 100%; max-width: none; }
  .patient-header {
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(22,58,48,.05);
  }
  .patient-header h1 { font-size: 21px; line-height: 1.15; }
  .patient-header .muted { font-size: 12px; }
  .patient-header .subtle { min-height: 40px; }

  .tabs {
    position: sticky;
    top: 64px;
    z-index: 30;
    gap: 6px;
    margin: 12px -12px 14px;
    padding: 8px 12px;
    overflow-x: auto;
    border: 0;
    background: rgba(243,247,246,.96);
    backdrop-filter: blur(10px);
  }
  .tab {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
  }
  .tab.active { border: 1px solid var(--green); background: var(--green); color: #fff; }

  .consent-card, .extras-card, .record-card, .microphone-tools,
  .document-card, .history-item, .exam-card, .exam-result {
    border-radius: 14px;
    box-shadow: 0 5px 18px rgba(22,58,48,.045);
  }
  .consent-card { padding: 13px; }
  .consent-copy span { line-height: 1.4; }
  .extras-card { margin: 10px 0; }

  .record-card {
    position: sticky;
    bottom: 10px;
    z-index: 25;
    grid-template-columns: auto minmax(0,1fr) auto;
    padding: 13px;
    border-color: #cfdcda;
    box-shadow: 0 10px 30px rgba(21,57,48,.16);
  }
  .record-button { width: 52px; height: 52px; }
  .timer { font-size: 15px; }
  .service-status { padding: 0 3px; line-height: 1.4; }
  audio { min-height: 46px; }

  .section-heading { margin-top: 24px; }
  .section-heading h2 { font-size: 20px; }
  .section-heading p { line-height: 1.4; }
  textarea { min-height: 130px; border-radius: 12px; background: #fff; font-size: 16px; }
  #transcript { min-height: 230px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-grid label.wide { grid-column: auto; }
  .summary-grid textarea { min-height: 105px; }
  .secondary, .subtle, .primary { min-height: 44px; }
  .actions { gap: 8px; }
}

@media (max-width: 480px) {
  .sidebar { grid-template-columns: 1fr 1.35fr; }
  .pwa-controls { min-width: 0; }
  .install-app { display: none; }
  .patient-header { align-items: flex-start; }
  .patient-header .subtle { padding: 8px; }
  .extras-heading { display: grid; grid-template-columns: 1fr; }
  .extras-toggle { width: 100%; }
  .section-heading { display: grid; grid-template-columns: 1fr; }
  .section-heading .secondary { width: 100%; margin-top: 4px; }
  .actions { display: grid; grid-template-columns: 1fr; }
  .actions button { width: 100%; }
}
