/* Phone-first overrides for the recovered Drdesk build. */
@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }

  .app-shell { display: block; min-width: 320px; }
  .sidebar {
    position: sticky;
    z-index: 15;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    width: 100%;
    height: auto;
    padding: 11px 14px 9px;
    border-right: 0;
    border-bottom: 1px solid #e8edf2;
  }
  .brand { min-width: 0; padding: 0; }
  .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .new-task { width: 38px; height: 38px; justify-content: center; margin: 0; padding: 0; font-size: 0; }
  .new-task svg { width: 19px; height: 19px; }
  .new-task kbd { display: none; }
  .nav-list {
    grid-column: 1 / -1;
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 1px 0 2px;
    scrollbar-width: none;
  }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; flex: 0 0 auto; min-height: 32px; padding: 0 9px; font-size: 11px; }
  .nav-item em { min-width: 17px; padding: 1px 4px; font-size: 9px; }
  .sidebar-bottom { display: none; }

  .main-content { padding: 22px 14px calc(34px + env(safe-area-inset-bottom)); }
  .topbar { align-items: flex-start; gap: 10px; }
  .page-heading { min-width: 0; gap: 8px; }
  .page-heading > div { min-width: 0; }
  .page-heading h1 { max-width: 260px; font-size: 21px; line-height: 1.28; }
  .page-heading p { line-height: 1.45; }
  .top-actions { flex: none; gap: 6px; }
  .top-actions .icon-button, .backup-button { display: none; }
  .account-button { width: 36px; min-height: 36px; justify-content: center; padding: 0; }
  .account-button-copy { display: none; }

  .day-overview { display: grid; grid-template-columns: 1fr; gap: 15px; min-height: 0; margin-top: 22px; padding: 17px; }
  .overview-copy { min-width: 0; }
  .overview-copy p { max-width: none; }
  .overview-meter { min-width: 0; padding-left: 0; border-left: 0; }
  .day-overview .outline-button { width: 100%; min-height: 38px; justify-content: center; margin-left: 0; }

  .focus-panel { margin-top: 21px; }
  .focus-header { min-height: 46px; padding: 0 16px; }
  .focus-body { align-items: flex-start; flex-direction: column; gap: 19px; min-height: 0; padding: 21px 17px; }
  .focus-task-copy { min-width: 0; }
  .focus-task-copy h2 { overflow-wrap: anywhere; font-size: 20px; line-height: 1.32; }
  .focus-task-copy p { line-height: 1.55; }
  .timer { width: 100%; min-width: 0; text-align: left; }
  .timer-button { min-height: 38px; }
  .focus-footer { display: grid; grid-template-columns: 1fr; gap: 9px; padding: 13px 17px; }
  .focus-footer span { align-items: flex-start; line-height: 1.45; }
  .focus-footer span svg { flex: none; margin-top: 1px; }
  .focus-footer button { width: 100%; min-height: 35px; justify-content: center; margin: 1px 0 0; border: 1px solid #dbe7f8; border-radius: 7px; background: #f8fbff; }

  .work-grid { gap: 28px; margin-top: 29px; }
  .section-heading { align-items: flex-start; gap: 12px; }
  .agenda-section .section-heading, .next-section .section-heading { align-items: center; }
  .schedule { margin-top: 15px; }
  .schedule-row { grid-template-columns: 44px 15px minmax(0, 1fr); min-height: 62px; }
  .schedule-row time { font-size: 10px; }
  .schedule-content strong, .schedule-content span { white-space: normal; overflow-wrap: anywhere; }
  .current-label { display: none; }
  .next-section { padding-top: 25px; }
  .next-item { min-height: 56px; }
  .next-item svg { opacity: 1; }

  .tasks-section { margin-top: 34px; }
  .task-heading { align-items: flex-start; flex-direction: column; }
  .task-tools { width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .task-tools > button { flex: 0 0 auto; }
  .add-inline { margin-left: 3px; }
  .task-table { margin-top: 12px; }
  .task-row { grid-template-columns: 21px 14px minmax(0, 1fr) 29px; column-gap: 7px; min-height: 59px; }
  .task-row .project-tag, .task-row .task-time, .task-row .priority { display: none; }
  .task-row .more-button { opacity: 1; }
  .mobile-project { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .workspace-view { padding-top: 1px; }
  .view-heading { align-items: flex-start; flex-direction: column; gap: 13px; }
  .view-heading > .primary-button, .view-actions { width: 100%; }
  .view-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .view-actions > button { justify-content: center; margin: 0; }
  .daily-task-toolbar { align-items: center; gap: 8px; }
  .daily-task-toolbar strong { flex: 1; min-width: 0; text-align: center; font-size: 12px; }
  .daily-task-toolbar .text-button { width: 100%; justify-content: center; margin-left: 0; }
  .workspace-row { grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px; padding: 12px 0; }
  .workspace-row-actions { flex-wrap: wrap; justify-content: flex-end; }
  .workspace-row-actions .workspace-action { min-height: 30px; padding: 5px 6px; }
  .workspace-row.task-item-row {
    grid-template-columns: 20px 14px minmax(0, 1fr);
    grid-template-areas:
      "check drag copy"
      "check drag actions";
    align-items: start;
    column-gap: 8px;
    row-gap: 7px;
    min-height: 0;
    padding: 14px 0;
  }
  .workspace-row.task-item-row > .task-complete-button { grid-area: check; margin-top: 5px; }
  .workspace-row.task-item-row > .task-drag-handle { grid-area: drag; margin-top: -1px; }
  .workspace-row.task-item-row > div:not(.workspace-row-actions) { grid-area: copy; min-width: 0; }
  .workspace-row.task-item-row > .workspace-row-actions {
    grid-area: actions;
    width: 100%;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .workspace-row.task-item-row > .workspace-row-actions .workspace-action {
    flex: 0 0 auto;
    min-height: 29px;
    padding: 5px 8px;
    white-space: nowrap;
  }
  .project-card footer > div { gap: 4px; }
  .project-card footer button { min-height: 29px; padding: 5px 8px; font-size: 11px; }
  .project-detail-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .project-detail-summary > div { padding: 11px 8px; }
  .project-detail-summary strong { font-size: 17px; }
  .project-card { min-height: 0; }

  .calendar-dialog, .cloud-sync-dialog, .task-progress-dialog { width: 100%; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: min(88dvh, 760px); border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
  .task-dialog, .review-dialog, .cloud-sync-dialog { padding: 20px 17px calc(20px + env(safe-area-inset-bottom)); }
  .modal-head { gap: 10px; margin-bottom: 18px; }
  .modal-head h2 { font-size: 19px; }
  .form-grid, .calendar-task-fields { grid-template-columns: 1fr; }
  .calendar-task-fields label:nth-child(2) { grid-column: auto; }
  .modal-actions { flex-wrap: wrap; gap: 8px; margin-top: 18px; }
  .modal-actions > button { flex: 1 1 118px; min-height: 40px; justify-content: center; }
  .modal-actions > .danger-button { flex-basis: 100%; }
  .calendar-toolbar { align-items: stretch; }
  .calendar-modes { width: 100%; }
  .calendar-modes button { flex: 1; }
  .calendar-period-bar { justify-content: space-between; }
  .calendar-grid-large > button { min-height: 42px; }
  .calendar-week-view { grid-template-columns: repeat(7, minmax(118px, 1fr)); }
  .calendar-year-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-add-form { grid-template-columns: 1fr 1fr; }
  .calendar-add-form input[name="title"], .calendar-add-form .primary-button { grid-column: 1 / -1; }
  .calendar-add-form .primary-button { justify-self: stretch; }

  .literature-shelf-bar { display: block; }
  .literature-shelf-bar p { max-width: none; text-align: left; }
  .sync-literature-button { min-height: 30px; padding: 5px 9px; }
  .literature-card-actions { align-items: flex-start; gap: 8px; }
  .literature-card-actions-right { flex-wrap: wrap; justify-content: flex-end; }
  .literature-card-actions > button { min-height: 30px; padding: 5px 8px; font-size: 11px; }
  .statistics-overview-grid, .statistics-detail-grid { grid-template-columns: 1fr; }
  .statistics-card { min-height: 126px; }
}

@media (max-width: 390px) {
  .brand span { font-size: 13px; }
  .page-heading h1 { font-size: 19px; }
  .calendar-jump { width: 33px; height: 33px; }
  .focus-header .quiet-button { font-size: 0; }
  .focus-header .quiet-button svg { width: 17px; height: 17px; }
  .task-tools > button:not(.add-inline) { padding-right: 7px; padding-left: 7px; }
  .project-detail-summary span { font-size: 9px; }
}
