/* ================================================================
   MOBILE VIEW  — active when body.is-mobile-view
   All classes prefixed with m- to avoid conflicts.
   ================================================================ */

/* Hide desktop when mobile mode is active */
body.is-mobile-view .app__header,
body.is-mobile-view .sidebar,
body.is-mobile-view .plan-meta,
body.is-mobile-view .canvas,
body.is-mobile-view #userDropdown {
  display: none !important;
}

/* ---- Overlay shell ---- */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: var(--bg-surface);
  flex-direction: column;
  overflow: hidden;
  font-family: inherit;
}
body.is-mobile-view .mobile-overlay { display: flex; }

/* ---- Header ---- */
.m-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--bg-line);
  flex-shrink: 0;
  gap: 10px;
}
.m-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-100);
}
.m-brand-mark {
  font-weight: 700; letter-spacing: -.02em;
  background: linear-gradient(135deg, #3b82f6 0%, #14b8a6 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; white-space: nowrap;
}
.m-brand-mark em { font-style: italic; font-weight: 400; }
.m-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.m-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.m-user-name { font-size: 11px; font-weight: 600; color: var(--ink-100); }
.m-user-role { font-size: 9px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.4px; }

/* ---- Scrollable content area ---- */
.m-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none; /* disables browser pull-to-refresh so ours takes over */
  padding-bottom: max(env(safe-area-inset-bottom, 0), 8px);
}

/* ---- Hero section ---- */
.m-hero {
  padding: 14px 16px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--bg-line);
}
.m-hero__label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}
.m-hero__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.m-hero__title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink-100);
  line-height: 1.1;
}
.m-add-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity .15s;
}
.m-add-btn:active { opacity: .8; }
.m-hero__actions { display: flex; align-items: center; gap: 8px; }
.m-refresh-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: transparent;
  border: 1.5px solid var(--bg-line);
  border-radius: 50%;
  color: var(--ink-300);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.m-refresh-btn:active { color: var(--accent); border-color: var(--accent); }
.m-hero__stats {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-300);
}

/* ---- Filter chips bar ---- */
.m-search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--bg-line);
  border-radius: var(--radius-sm); padding: 0 14px;
  margin: 10px 16px 0;
  transition: border-color .12s;
}
.m-search-wrap:focus-within { border-color: var(--accent); }
.m-search-wrap i { color: var(--ink-400); font-size: 15px; flex-shrink: 0; }
#m-tasks-search {
  flex: 1; border: 0; background: transparent; color: var(--ink-100);
  font-family: var(--font-body); font-size: 19px;
  padding: 5px 0; outline: none; min-width: 0;
}
#m-tasks-search::placeholder { color: var(--ink-400); }

.m-filter-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-line);
  flex-shrink: 0;
}
.m-filter-bar::-webkit-scrollbar { display: none; }
.m-filter-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-line);
  border-radius: 999px;
  font-size: 11px;
  color: var(--ink-200);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color .12s, color .12s;
}
.m-filter-chip.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.m-filter-chip i { font-size: 9px; }

/* ---- Task list ---- */
.m-task-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 12px 12px;
  gap: 8px;
}
.m-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-400);
  font-size: 13px;
}

/* ---- Task card ---- */
.m-task-card {
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  border: 1px solid transparent;
}
.m-task-card:active { transform: scale(.98); }
.m-task-card.is-done { opacity: .55; }
/* When a bucket background color is applied, force a contrasting text color */
.m-task-card.has-bucket-color,
.m-task-card.has-bucket-color .m-task-path,
.m-task-card.has-bucket-color .m-task-title,
.m-task-card.has-bucket-color .m-task-meta,
.m-task-card.has-bucket-color .m-task-meta * { color: var(--bucket-text) !important; }

.m-task-row1 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.m-task-imp { color: #e05040; font-size: 13px; flex-shrink: 0; display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.m-task-no-imp { color: #22c55e; font-size: 16px; flex-shrink: 0; }
.m-task-name {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-100);
  line-height: 1.2;
}
.m-task-plan-icon { color: var(--accent); font-size: 14px; flex-shrink: 0; }
img.m-task-plan-icon { width: 18px; height: 18px; object-fit: cover; border-radius: 4px; }
.m-task-pct {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-200);
  flex-shrink: 0;
}

.m-task-row2, .m-task-row3 {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
}
.m-task-path { flex: 1; font-size: 12px; color: var(--ink-300); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-task-label, .m-task-alabel, .m-task-dlabel { font-size: 11px; color: var(--ink-400); }

.m-task-row4 {
  display: flex;
  justify-content: space-between;
  margin-top: 1px;
}
.m-task-assignee { font-size: 12px; color: var(--ink-200); font-weight: 500; }
.m-task-dates { font-size: 12px; color: var(--ink-200); }

/* ---- Projects list ---- */
.m-project-list { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.m-project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-line);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .12s;
}
.m-project-card.is-active { border-color: var(--accent); background: var(--accent-soft); }
.m-project-card__name { font-size: 14px; font-weight: 700; color: var(--ink-100); }
.m-project-card__sub { font-size: 11px; color: var(--ink-300); margin-top: 2px; }
.m-project-card__stats { font-size: 11px; color: var(--ink-400); margin-top: 6px; }

/* ---- Unsupported view ---- */
.m-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 24px;
  color: var(--ink-400);
  text-align: center;
}
.m-unsupported i { font-size: 36px; }
.m-unsupported p { font-size: 13px; line-height: 1.5; }

/* ---- Bottom sheet ---- */
.m-sheet {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.m-sheet.is-open { pointer-events: auto; opacity: 1; }
.m-sheet__inner {
  width: 100%;
  background: var(--bg-elevated);
  border-radius: 18px 18px 0 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
}
.m-sheet.is-open .m-sheet__inner { transform: translateY(0); }
.m-sheet__inner--short { max-height: 60vh; }
.m-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  border-bottom: 1px solid var(--bg-line);
  flex-shrink: 0;
}
.m-sheet__head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-100);
}
.m-sheet__cancel {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}
.m-sheet__body {
  padding: 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---- Form fields in sheet ---- */
.m-form-field { display: flex; flex-direction: column; gap: 5px; }
.m-form-field label { font-size: 11px; font-weight: 600; color: var(--ink-300); text-transform: uppercase; letter-spacing: 0.3px; }
.m-input {
  padding: 7px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-line);
  border-radius: 8px;
  color: var(--ink-100);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s;
  width: 100%;
  box-sizing: border-box;
}
.m-input:focus { border-color: var(--accent); }
.m-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.m-textarea { resize: none; min-height: 80px; }
/* Keep every focusable control ≥16px so mobile Chrome doesn't auto-zoom on focus */
.m-sheet input, .m-sheet textarea, .m-sheet select,
body.is-mobile-view .desc-viewer-input { font-size: 16px; }
/* Date row: gap between start/end */
.m-form-row { display: flex; gap: 14px; }
.m-form-row .m-form-field { flex: 1; min-width: 0; }
/* Date inputs — keep ≥16px so iOS Safari won't auto-zoom on focus */
.m-date-row { gap: 10px; }
.m-date-row .m-input[type="date"] { font-size: 16px; padding: 7px 4px; min-width: 0; flex: 1; }
.m-date-row .ol-date-input-wrap { width: 100%; }
.m-date-row .ol-date-clear { width: 22px; height: 22px; font-size: 15px; flex-shrink: 0; }
/* Stack date fields on the narrowest phones rather than overflow */
@media (max-width: 340px) { .m-date-row { flex-wrap: wrap; } }
/* Range slider for progress */
.m-range { width: 100%; accent-color: var(--accent); cursor: pointer; height: 36px; margin: 0; }
/* Dep dropdown widget styled to match .m-input */
.m-form-field .dep-select-wrap { width: 100%; }
.m-form-field .dep-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-line);
  border-radius: 8px;
  color: var(--ink-100);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  box-sizing: border-box;
  text-align: left;
}
.m-form-field .dep-select-btn:focus { border-color: var(--accent); outline: none; }
/* Comment input slot — no separator, no extra top space on mobile */
.m-comment-no-sep .comment-input-wrap { border-top: none; padding-top: 0; margin-top: 0; }
/* "Add comment" rendered as a link/button after Description */
.comment-add-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 2px 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.comment-add-link:active { opacity: .7; }
/* Prevent iOS auto-zoom on the reason/comment modal textarea */
body.is-mobile-view .date-reason-input { font-size: 16px; }
.m-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-200);
  cursor: pointer;
}
.m-check-input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
/* Inline checkbox sitting inside a paired form-field cell — height matches
   the range slider so the checkbox lines up with the slider thumb */
.m-check-inline {
  min-height: 0;
  height: 36px;
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  justify-content: flex-start;
  align-items: center;
}
.m-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.m-btn-flex { flex: 1; margin-top: 0; width: auto; }
.m-btn-row .m-create-btn,
.m-btn-row .m-cancel-btn,
.m-btn-row .m-delete-btn { margin-top: 0; flex: 1; }
.m-cancel-btn {
  padding: 14px;
  background: var(--bg-surface);
  color: var(--ink-200);
  border: 1px solid var(--bg-line);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: opacity .15s;
}
.m-cancel-btn:active { opacity: .85; }
.m-create-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity .15s;
}
.m-create-btn:active { opacity: .85; }
.m-delete-btn {
  padding: 14px 10px;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: opacity .15s;
}
.m-delete-btn:active { opacity: .7; }

/* ---- Filter option list in sheet (multi-select) ---- */
.m-filter-options { overflow-y: auto; padding: 4px 0 max(env(safe-area-inset-bottom, 0), 12px); }
.m-filter-opt-multi {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 20px;
  font-size: 15px;
  color: var(--ink-200);
  cursor: pointer;
  box-sizing: border-box;
  transition: background .1s;
}
.m-filter-opt-multi:active { background: var(--bg-surface); }
.m-filter-opt-multi input[type=checkbox] {
  width: 20px; height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

/* ---- New task shake ---- */
.m-task-card.is-new-flash {
  animation: new-task-shake .55s ease;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---- Header right action group ---- */
.m-hdr-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ---- Mobile theme toggle ---- */
.m-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1.5px solid var(--bg-line);
  border-radius: 50%;
  color: var(--ink-300);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.m-theme-btn:active { color: var(--accent); border-color: var(--accent); }

/* ---- Mobile AI chat button ---- */
.m-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #3b82f6 0%, #14b8a6 100%);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59,130,246,.4);
  transition: opacity .15s, box-shadow .15s;
}
.m-chat-btn:active { opacity: .85; }
.m-chat-btn.is-active { box-shadow: 0 2px 12px rgba(20,184,166,.55); }

/* ---- Mobile chat backdrop ---- */
.m-chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9050;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
body.is-mobile-view .m-chat-backdrop { display: block; }
.m-chat-backdrop.is-open { opacity: 1; pointer-events: auto; }

/* ---- Mobile AI chat panel (bottom sheet) ---- */
body.is-mobile-view #asst-toggle { display: none !important; }

body.is-mobile-view #asst-panel {
  z-index: 9100;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: 100%;
  height: 90dvh;
  max-height: 90dvh;
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--bg-line);
  border-bottom: none;
  /* Slide up from below — no spring bounce for a full panel */
  opacity: 1;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
  pointer-events: none;
}
body.is-mobile-view #asst-panel.asst-open {
  transform: translateY(0);
  pointer-events: auto;
}

/* Drag handle hint — first flex item above the chat header */
body.is-mobile-view #asst-panel::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  background: var(--bg-line);
  border-radius: 999px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

/* Chat font sizes scaled 2× from desktop defaults — !important to beat
   assistant.css ID-scoped rules (e.g. #asst-panel .asst-msg) which have
   higher specificity than a class-only or class+element selector. */
body.is-mobile-view .asst-title          { font-size: 19px !important; }
body.is-mobile-view .asst-plan-select    { font-size: 19px !important; }
body.is-mobile-view .asst-msg            { font-size: 19px !important; line-height: 1.55 !important; }
body.is-mobile-view .asst-msg code       { font-size: 19px !important; }
body.is-mobile-view .asst-scope-note     { font-size: 19px !important; }
body.is-mobile-view #asst-input          { font-size: 19px !important; }
body.is-mobile-view .asst-settings-label { font-size: 19px !important; }
body.is-mobile-view .asst-settings select{ font-size: 19px !important; }
body.is-mobile-view .asst-icon-btn       { width: 39px !important; height: 39px !important; font-size: 19px !important; }
body.is-mobile-view .asst-send-btn       { width: 50px !important; height: 50px !important; font-size: 18px !important; }
body.is-mobile-view .asst-chart-title    { font-size: 18px !important; }
body.is-mobile-view .asst-chart-legend   { font-size: 16px !important; }
body.is-mobile-view .asst-chart svg      { max-width: 220px !important; }
body.is-mobile-view .asst-chart-dot      { width: 14px !important; height: 14px !important; }

/* Smooth momentum scroll for messages */
body.is-mobile-view .asst-messages { -webkit-overflow-scrolling: touch; }

/* ---- Pull-to-refresh indicator ---- */
.m-pull-indicator {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}
.m-pull-indicator i {
  font-size: 18px;
  color: var(--ink-300);
  transition: color .2s;
}
.m-pull-indicator.is-ready   i { color: var(--accent); }
.m-pull-indicator.is-loading i { animation: fa-spin .8s linear infinite; color: var(--accent); }
