/* Keep editing readable on iPhone without disabling the user's ability to zoom. */
.task-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 16px; border-top: 1px solid #edf0f3; }
.task-tools .delete { margin-right: 0; padding: 10px; min-height: 44px; }
#task-form .modal-actions { flex-wrap: wrap; gap: 10px; }
#task-form .modal-actions .button { min-height: 44px; }
.sync-status[hidden] { display: none !important; }
.module-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px; }
.module-card-main { min-width: 0; flex: 1; }
.module-card-main strong { font-size: 12px; }
.module-card-main p { margin-top: 5px; font-size: 10px; overflow-wrap: anywhere; }
.module-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.module-card-actions button, .module-edit, .module-delete, .document-link { border: 0; background: transparent; color: #4b83e4; font: inherit; font-size: 10px; font-weight: 700; cursor: pointer; padding: 8px; }
.module-delete { color: #c97575; }
.module-actions { display: flex; justify-content: flex-end; margin: 12px 0; }
.module-empty .button { margin-top: 12px; }
.document-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; color: inherit; cursor: pointer; }
.document-link { display: inline-block; padding: 7px 0; }
.workspace-form textarea { display: block; width: 100%; margin-top: 7px; border: 1px solid #e5e9ef; border-radius: 10px; padding: 12px; font: inherit; color: #313945; resize: vertical; }
.workspace-form .modal-actions { display: flex; justify-content: space-between; gap: 12px; }
.content-card { text-align: left; border: 1px solid #eceef0; }
@media(max-width:700px) { .module-card { align-items: flex-start; padding: 13px; } .module-card-actions { flex-direction: column; gap: 0; } .module-card-actions button, .module-edit, .module-delete { min-height: 40px; } }
.sync-status {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 19;
  padding: 8px 12px;
  background: #eef4ff;
  color: #253c65;
  text-align: center;
  font: 13px -apple-system, BlinkMacSystemFont, sans-serif;
}
/* Tablet: retain a compact, always-visible navigation rail and give content
   more room in both orientations. The calendar scrolls inside its own panel. */
@media (min-width: 701px) and (max-width: 1180px) {
  .sidebar { width: 76px; padding: 24px 10px; align-items: center; overflow-y: auto; }
  .brand { padding: 0 0 26px; }
  .brand > div, .nav-label, .sidebar-bottom { display: none; }
  .sidebar nav { width: 100%; align-items: stretch; flex-shrink: 0; }
  .nav-item { justify-content: center; flex-direction: column; min-height: 50px; padding: 4px 2px; gap: 3px; font-size: 9px; line-height: 1.1; text-align: center; }
  .nav-item .nav-icon { width: auto; font-size: 19px; }
  .nav-count { display: none; }
  .main-wrap { margin-left: 76px; width: calc(100% - 76px); min-width: 0; }
  .topbar { padding: 0 24px; }
  main { padding: 30px 24px 100px; }
  .schedule-grid { grid-template-columns: 58px repeat(7, minmax(115px, 1fr)); min-width: 863px; }
  .schedule-viewport { max-height: min(70vh, 720px); -webkit-overflow-scrolling: touch; }
  .modal { max-height: calc(100dvh - 32px); overflow-y: auto; }
  .overlay { overflow-y: auto; overscroll-behavior: contain; }
  .sync-status { left: 76px; }
  input:not([type="color"]):not([type="checkbox"]):not([type="radio"]),
  textarea, select, .quick-form input, .chat-input input, .search-wrap input,
  .today-quick input, .category-form input[name="name"], .modal input, .modal select {
    font-size: 16px;
    min-height: 44px;
  }
  .button, .task-filters button, .view-switch button, .settings-link { min-height: 44px; }
}
@media (max-width: 700px) {
  #task-form .modal-actions { display: grid; grid-template-columns: 1fr; }
  #task-form .modal-actions .button { width: 100%; white-space: normal; }
  .calendar-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 8px 0 12px; border-radius: 11px; background: #eef1f5; }
  .calendar-mode-switch button { min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: #8290a1; font-size: 12px; font-weight: 650; }
  .calendar-mode-switch button.selected { background: #fff; color: #344258; box-shadow: 0 1px 5px #25324816; }
  .calendar-agenda-card { padding: 0 16px 12px; }
  .calendar-agenda-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 0 12px; border-bottom: 1px solid #edf0f3; }
  .calendar-agenda-head > div { display: grid; gap: 4px; min-width: 0; }
  .calendar-agenda-head strong { overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; font-size: 13px; }
  .calendar-agenda-head span { color: #9aa5b2; font-size: 10px; }
  .calendar-agenda-head .button { min-height: 38px; padding: 8px 11px; white-space: nowrap; }
  .agenda-group { padding-top: 14px; }
  .agenda-group h3 { margin: 0 0 5px; color: #9aa5b2; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  .agenda-group h3 span { float: right; color: #adb6c1; }
  .agenda-group .task-row { min-height: 61px; gap: 10px; }
  .agenda-group .task-main strong { font-size: 12px; }
  .agenda-group .task-main .meta { font-size: 10px; }
  .calendar-agenda-empty { padding: 30px 8px 20px; text-align: center; }
  .calendar-agenda-empty > span { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto 12px; border-radius: 13px; background: #edf4ff; color: #4b83e4; font-size: 22px; }
  .calendar-agenda-empty strong { display: block; font-size: 12px; }
  .calendar-agenda-empty p { margin: 6px 0 14px; font-size: 11px; }
  .calendar-agenda-empty .button { min-height: 42px; }
  .phone-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 12px 0; }
  .phone-days button { display: grid; justify-items: center; gap: 4px; min-height: 54px; border: 0; border-radius: 11px; padding: 6px 2px; background: #f0f3f7; color: #6e7c8d; }
  .phone-days button span { font-size: 10px; text-transform: capitalize; }
  .phone-days button strong { font-size: 15px; }
  .phone-days button.active { background: #397df0; color: #fff; }
  .schedule-grid.phone-schedule { grid-template-columns: 58px minmax(0, 1fr); min-width: 0; }
  .schedule-grid.phone-schedule.phone-week { grid-template-columns: 44px repeat(3, minmax(0, 1fr)); min-width: 0; }
  .schedule-viewport { max-height: min(68dvh, 700px); -webkit-overflow-scrolling: touch; }
  .phone-schedule .schedule-title { font-size: 12px; }
  .phone-schedule .schedule-header { justify-content: flex-start; padding-left: 14px; }
  .phone-schedule .drag-handle { min-width: 30px; }
  .phone-schedule .all-day-cell { min-height: 48px; }
  .phone-week .schedule-header { justify-content: center; padding-left: 2px; }
  .phone-week .schedule-header span { font-size: 9px; }
  .phone-week .schedule-title { font-size: 9px; }
  .phone-week .drag-handle { min-width: 20px; font-size: 12px; }
  .phone-week .calendar-check { flex-basis: 15px; width: 15px; height: 15px; }
  .phone-week .schedule-card { gap: 1px; padding-left: 2px; }
  input:not([type="color"]):not([type="checkbox"]):not([type="radio"]),
  textarea, select,
  .quick-form input, .chat-input input, .search-wrap input,
  .today-quick input, .category-form input[name="name"], .modal input, .modal select {
    font-size: 16px;
  }
  input:not([type="color"]):not([type="checkbox"]):not([type="radio"]),
  textarea, select { min-height: 44px; }
  .overlay { overflow-y: auto; overscroll-behavior: contain; }
  .modal { max-height: calc(100dvh - 12px); overflow-y: auto; }
  .sync-status { bottom: calc(60px + env(safe-area-inset-bottom)); }
  main { padding-bottom: calc(145px + env(safe-area-inset-bottom)); }
  body:has(input:focus, textarea:focus, select:focus) .mobile-nav { display: none; }
  body:has(input:focus, textarea:focus, select:focus) .sync-status { bottom: env(safe-area-inset-bottom); }
}

/* Native date/time controls have a large intrinsic width in iOS Safari. Keep
   them inside the sheet and stack paired fields instead of letting the grid
   overflow horizontally on narrow screens. */
@media (max-width: 700px) {
  .overlay { padding: 0; }
  .modal {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }
  .modal form,
  .modal label,
  .form-grid,
  .form-grid > label { min-width: 0; max-width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .modal input,
  .modal select,
  .modal textarea {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}
