/* ── Theme variables ─────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg:          #f4f4f5;
  --surface:     #ffffff;
  --surface-2:   #fafafa;
  --border:      #e4e4e7;
  --border-2:    #d4d4d8;
  --text:        #18181b;
  --text-2:      #52525b;
  --text-3:      #71717a;
  --text-4:      #a1a1aa;
  --text-5:      #d4d4d8;
  --blue:        #2563eb;
  --blue-dim:    #1d4ed8;
  --blue-bg:     #eff6ff;
  --blue-bg2:    #dbeafe;
  --blue-bd:     #93c5fd;
  --green:       #15803d;
  --green-bg:    #dcfce7;
  --green-bg2:   #bbf7d0;
  --green-light: #f0fdf4;
  --green-bd:    #bbf7d0;
  --amber:       #92400e;
  --amber-bg:    #fef3c7;
  --amber-bg2:   #fde68a;
  --amber-light: #fffbeb;
  --red:         #b91c1c;
  --red-bg:      #fef2f2;
  --red-bg2:     #fee2e2;
  --red-bd:      #fca5a5;
  --orange:      #b45309;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg:          #0a0a0c;
    --surface:     #18181b;
    --surface-2:   #1e1e22;
    --border:      #27272a;
    --border-2:    #3f3f46;
    --text:        #fafafa;
    --text-2:      #d4d4d8;
    --text-3:      #a1a1aa;
    --text-4:      #71717a;
    --text-5:      #52525b;
    --blue:        #60a5fa;
    --blue-dim:    #93c5fd;
    --blue-bg:     #172554;
    --blue-bg2:    #1e3a5f;
    --blue-bd:     #1e40af;
    --green:       #4ade80;
    --green-bg:    #052e16;
    --green-bg2:   #14532d;
    --green-light: #052e16;
    --green-bd:    #166534;
    --amber:       #fbbf24;
    --amber-bg:    #292524;
    --amber-bg2:   #422006;
    --amber-light: #1c1917;
    --red:         #f87171;
    --red-bg:      #450a0a;
    --red-bg2:     #7f1d1d;
    --red-bd:      #991b1b;
    --orange:      #fb923c;
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg:          #0a0a0c;
  --surface:     #18181b;
  --surface-2:   #1e1e22;
  --border:      #27272a;
  --border-2:    #3f3f46;
  --text:        #fafafa;
  --text-2:      #d4d4d8;
  --text-3:      #a1a1aa;
  --text-4:      #71717a;
  --text-5:      #52525b;
  --blue:        #60a5fa;
  --blue-dim:    #93c5fd;
  --blue-bg:     #172554;
  --blue-bg2:    #1e3a5f;
  --blue-bd:     #1e40af;
  --green:       #4ade80;
  --green-bg:    #052e16;
  --green-bg2:   #14532d;
  --green-light: #052e16;
  --green-bd:    #166534;
  --amber:       #fbbf24;
  --amber-bg:    #292524;
  --amber-bg2:   #422006;
  --amber-light: #1c1917;
  --red:         #f87171;
  --red-bg:      #450a0a;
  --red-bg2:     #7f1d1d;
  --red-bd:      #991b1b;
  --orange:      #fb923c;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg:          #f4f4f5;
  --surface:     #ffffff;
  --surface-2:   #fafafa;
  --border:      #e4e4e7;
  --border-2:    #d4d4d8;
  --text:        #18181b;
  --text-2:      #52525b;
  --text-3:      #71717a;
  --text-4:      #a1a1aa;
  --text-5:      #d4d4d8;
  --blue:        #2563eb;
  --blue-dim:    #1d4ed8;
  --blue-bg:     #eff6ff;
  --blue-bg2:    #dbeafe;
  --blue-bd:     #93c5fd;
  --green:       #15803d;
  --green-bg:    #dcfce7;
  --green-bg2:   #bbf7d0;
  --green-light: #f0fdf4;
  --green-bd:    #bbf7d0;
  --amber:       #92400e;
  --amber-bg:    #fef3c7;
  --amber-bg2:   #fde68a;
  --amber-light: #fffbeb;
  --red:         #b91c1c;
  --red-bg:      #fef2f2;
  --red-bg2:     #fee2e2;
  --red-bd:      #fca5a5;
  --orange:      #b45309;
}

/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

button, a, label, summary { touch-action: manipulation; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth ────────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 360px;
  margin: 2.5rem 1rem;
}

.auth-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.15rem; }

.subtitle { color: var(--text-3); font-size: 0.875rem; margin-bottom: 1.25rem; }

.error {
  background: var(--red-bg);
  border: 1px solid var(--red-bd);
  color: var(--red);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.9rem;
}

form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: var(--text-2);
}

form input[type="email"],
form input[type="password"],
form input[type="text"] {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}

form input:focus { border-color: var(--blue); }

.toggle-link {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-3);
  text-align: center;
}

/* ── App shell ───────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.logo { font-weight: 700; font-size: 1rem; flex-shrink: 0; color: var(--text); }

/* ── Theme toggle ────────────────────────────────────────── */
.btn-theme {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.2rem 0.45rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-3);
  line-height: 1.4;
  flex-shrink: 0;
}

.btn-theme:hover { background: var(--bg); color: var(--text); }

/* ── Hamburger (desktop: hidden) ─────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 5px;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-2);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* header-end groups theme toggle + hamburger for mobile */
.header-end { display: none; align-items: center; gap: 0.4rem; }

/* ── Mobile nav dropdown (desktop: hidden) ───────────────── */
.mobile-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 50;
  padding: 0.3rem 0;
}

.mobile-nav.open { display: block; }

.mobile-nav-item {
  display: block;
  padding: 0.7rem 1.1rem;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.mobile-nav-item:hover { background: var(--bg); text-decoration: none; }

.mobile-nav-divider { height: 1px; background: var(--border); margin: 0.3rem 0; }

.mobile-nav-email {
  display: block;
  padding: 0.4rem 1.1rem;
  font-size: 0.75rem;
  color: var(--text-4);
}

/* ── Desktop header actions ──────────────────────────────── */
.header-actions { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; }

.header-sep { color: var(--border-2); }
.user-email { color: var(--text-3); }

.btn-header {
  font-size: 0.78rem;
  color: var(--text-2);
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-header:hover { background: var(--bg); color: var(--text); text-decoration: none; }

/* ── Flash messages ──────────────────────────────────────── */
.flash {
  max-width: 640px;
  margin: 0.5rem auto 0;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-size: 0.82rem;
}

.flash-ok  { background: var(--green-light); border: 1px solid var(--green-bd); color: var(--green); }
.flash-err { background: var(--red-bg);      border: 1px solid var(--red-bd);   color: var(--red); }

/* ── Main ────────────────────────────────────────────────── */
main { max-width: 640px; margin: 1rem auto; padding: 0 0.9rem; }

/* ── New task form ───────────────────────────────────────── */
.new-task-form { display: flex; gap: 0.4rem; }

.new-task-form input {
  flex: 1;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  font-size: 1rem;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.new-task-form input:focus { border-color: var(--blue); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--blue-dim); }

.btn-clockin, .btn-clockout, .btn-delete {
  border: none;
  border-radius: 5px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn-clockin  { background: var(--green-bg);  color: var(--green); }
.btn-clockin:hover  { background: var(--green-bg2); }

.btn-clockout { background: var(--amber-bg);  color: var(--amber); }
.btn-clockout:hover { background: var(--amber-bg2); }

.btn-delete   { background: var(--bg);        color: var(--text-3); }
.btn-delete:hover   { background: var(--red-bg2); color: var(--red); }

/* ── Task list ───────────────────────────────────────────── */
.task-list { list-style: none; display: flex; flex-direction: column; gap: 0.2rem; }

.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  transition: border-color 0.1s;
}

.task-item:hover { border-color: var(--border-2); }

.task-item.active {
  border-color: var(--blue-bd);
  background: var(--blue-bg);
}

.task-item.done {
  background: var(--surface-2);
  border-color: var(--border);
  opacity: 0.6;
}

.task-item.done .task-title { text-decoration: line-through; color: var(--text-4); }
.task-item.done .task-time  { color: var(--text-5); }

.done-form { display: contents; }

.btn-done {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  border: 1.5px solid var(--border-2);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: transparent;
  transition: border-color 0.12s, background 0.12s;
}

.btn-done:hover { border-color: var(--blue); }

.btn-done.checked {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.task-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.task-title { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.task-title:hover { text-decoration: underline; }

.task-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
}

.task-item.active .task-time { color: var(--blue); font-weight: 600; }

.task-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

.empty { color: var(--text-4); text-align: center; margin-top: 3rem; }

/* ── Task row ────────────────────────────────────────────── */
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

/* ── Subtasks ────────────────────────────────────────────── */
.subtask-list {
  margin-top: 0.3rem;
  margin-left: 1rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--border);
}

.add-subtask { margin-top: 0.3rem; }

.add-subtask summary {
  font-size: 0.72rem;
  color: var(--text-4);
  cursor: pointer;
  user-select: none;
  width: fit-content;
}

.add-subtask summary:hover { color: var(--blue); }

.subtask-form { display: flex; gap: 0.35rem; margin-top: 0.35rem; }

.subtask-form input {
  flex: 1;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  font-size: 1rem;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.subtask-form input:focus { border-color: var(--blue); }

.subtask-form .btn-primary { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

/* ── Hover-reveal: hide empty controls until task is hovered */
.task-item:not(:hover):not(:focus-within) .ms-task-row,
.task-item:not(:hover):not(:focus-within) .add-subtask { display: none; }

.task-item:not(:hover):not(:focus-within) .sched-wrap:has(.sched-empty),
.task-item:not(:hover):not(:focus-within) .desc-wrap:has(.desc-empty) { display: none; }

/* ── Top forms bar ───────────────────────────────────────── */
.top-forms {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.top-forms .new-task-form { flex: 1; }

.ms-create-details { flex-shrink: 0; }

.ms-create-summary {
  font-size: 0.78rem;
  color: var(--text-2);
  cursor: pointer;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  list-style: none;
  white-space: nowrap;
}

.ms-create-summary:hover { background: var(--bg); }

.ms-new-form { display: flex; gap: 0.4rem; margin-top: 0.4rem; align-items: center; flex-wrap: wrap; }

.ms-new-form input[type="text"] {
  flex: 1;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
  min-width: 120px;
  background: var(--surface);
  color: var(--text);
}

.ms-new-form input[type="text"]:focus { border-color: var(--blue); }

.ms-new-form input[type="date"] {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.ms-new-form input[type="date"]:focus { border-color: var(--blue); }

/* ── Agenda view ─────────────────────────────────────────── */
.agenda-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.agenda-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.agenda-header-row h2 {
  font-size: 0.92rem;
  color: var(--text-2);
}

.agenda-window {
  font-size: 0.72rem;
  color: var(--text-4);
}

.agenda-bucket + .agenda-bucket {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.agenda-bucket-title {
  font-size: 0.76rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.agenda-bucket-title span {
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.agenda-overdue-title { color: var(--orange); }

.agenda-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.agenda-item {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  cursor: pointer;
  text-align: left;
}

.agenda-item:hover {
  border-color: var(--blue-bd);
  background: var(--blue-bg);
}

.agenda-item-static { cursor: default; }

.agenda-item-static:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.agenda-item-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.agenda-task-title {
  font-size: 0.84rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-ms {
  font-size: 0.68rem;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.02rem 0.35rem;
  background: var(--surface);
  white-space: nowrap;
}

.agenda-time {
  font-size: 0.74rem;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.agenda-empty {
  font-size: 0.78rem;
  color: var(--text-4);
}

/* ── Milestone group headers ─────────────────────────────── */
.task-group { margin-bottom: 0.75rem; }

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.65rem;
  border-radius: 6px 6px 0 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: none;
}

.group-header.group-complete { background: var(--green-light); border-color: var(--green-bd); }
.group-header.group-ungrouped { background: var(--surface-2); }

.group-header + .task-list,
.group-header + .group-empty {
  border-top: none;
  border-radius: 0 0 6px 6px;
}

.group-header-left  { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.group-header-right { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

.group-chevron { font-size: 0.65rem; color: var(--text-4); flex-shrink: 0; }

.group-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-due { font-size: 0.72rem; color: var(--text-3); white-space: nowrap; }

.ms-overdue { color: var(--orange) !important; font-weight: 500; }

.ms-progress-bar {
  width: 72px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.ms-progress-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.3s;
}

.group-complete .ms-progress-fill { background: var(--green); }

.ms-progress-label { font-size: 0.68rem; color: var(--text-4); white-space: nowrap; }

.group-empty {
  color: var(--text-4);
  font-size: 0.82rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  background: var(--surface);
}

/* ── Milestone selector on tasks ─────────────────────────── */
.ms-task-row { margin-top: 0.3rem; }

.ms-select {
  font-size: 0.72rem;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  background: var(--surface-2);
  cursor: pointer;
  outline: none;
  max-width: 100%;
}

.ms-select:focus { border-color: var(--blue); }

/* ── Schedule ────────────────────────────────────────────── */
.sched-wrap { margin-top: 0.3rem; }

.sched-display {
  display: inline-flex;
  align-items: center;
  font-size: 0.74rem;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  cursor: pointer;
  color: var(--blue);
  background: var(--blue-bg);
  transition: background 0.1s;
  min-height: 1.3rem;
}

.sched-display:hover { background: var(--blue-bg2); }

.sched-display.sched-empty {
  color: var(--text-4);
  background: transparent;
}

.sched-display.sched-empty::before { content: '🗓 Schedule…'; }

.sched-display.sched-overdue { color: var(--orange); background: var(--amber-light); }
.sched-display.sched-overdue:hover { background: var(--amber-bg); }

.sched-edit { display: flex; align-items: center; gap: 0.35rem; }

.sched-input {
  font-size: 1rem;
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.sched-input:focus { border-color: var(--blue); }

.sched-clear {
  border: none;
  background: none;
  color: var(--text-4);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
}

.sched-clear:hover { background: var(--red-bg2); color: var(--red); }

/* ── Description ─────────────────────────────────────────── */
.desc-wrap { margin-top: 0.35rem; }

.desc-preview {
  font-size: 0.85rem;
  color: var(--text-2);
  cursor: text;
  border-radius: 5px;
  padding: 0.3rem 0.45rem;
  min-height: 1.5rem;
  transition: background 0.1s;
}

.desc-preview:hover { background: var(--bg); }

.desc-preview.desc-empty::before {
  content: 'Add a description…';
  color: var(--text-5);
}

/* Markdown prose */
.desc-preview p              { margin: 0 0 0.35em; }
.desc-preview p:last-child   { margin-bottom: 0; }
.desc-preview ul,
.desc-preview ol             { margin: 0 0 0.35em 1.1em; padding: 0; }
.desc-preview li             { margin-bottom: 0.1em; }
.desc-preview code           { background: var(--bg); border-radius: 3px; padding: 0.1em 0.25em; font-size: 0.83em; }
.desc-preview pre            { background: var(--bg); border-radius: 5px; padding: 0.5rem; overflow-x: auto; margin: 0 0 0.35em; }
.desc-preview pre code       { background: none; padding: 0; }
.desc-preview h1,
.desc-preview h2,
.desc-preview h3             { margin: 0.35em 0 0.15em; font-size: 1em; font-weight: 600; }
.desc-preview blockquote     { margin: 0 0 0.35em; padding-left: 0.65rem; border-left: 2px solid var(--border-2); color: var(--text-3); }
.desc-preview a              { color: var(--blue); }

.desc-textarea {
  display: none;
  width: 100%;
  min-height: 3.5rem;
  resize: none;
  overflow: hidden;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  outline: none;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
}

.desc-textarea:focus { border-color: var(--blue); }

.desc-status { font-size: 0.68rem; color: var(--text-4); margin-left: 0.2rem; }
.desc-status.desc-saved { color: var(--green); }
.desc-status.desc-error { color: var(--red); }

/* ── Effort badge ────────────────────────────────────────── */
.task-effort {
  font-size: 0.7rem;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Edit button ─────────────────────────────────────────── */
.btn-edit {
  border: none;
  border-radius: 5px;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-3);
  white-space: nowrap;
}

.btn-edit:hover { background: var(--blue-bg); color: var(--blue); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 0.9rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  line-height: 1;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow-y: auto;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
}

.modal-input {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  width: 100%;
}

.modal-input:focus { border-color: var(--blue); }

.modal-textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  outline: none;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 6rem;
  width: 100%;
}

.modal-textarea:focus { border-color: var(--blue); }

.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border);
}

.modal-cancel {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-2);
}

.modal-cancel:hover { background: var(--bg); }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {

  /* Show header-end (theme toggle + hamburger), hide desktop actions */
  .header-actions { display: none; }
  .header-end { display: flex; }
  .hamburger { display: flex; }

  header { padding: 0.5rem 0.9rem; }
  main   { margin: 0.75rem auto; }

  /* Task row: stack actions below info */
  .task-row { flex-wrap: wrap; gap: 0.4rem; }
  .task-info { flex: 1 1 100%; min-width: 0; }
  .task-actions { flex: 0 0 auto; }

  /* Title wraps */
  .task-title { white-space: normal; overflow: visible; text-overflow: clip; }

  /* Larger touch targets */
  .btn-clockin, .btn-clockout, .btn-delete { padding: 0.5rem 0.9rem; font-size: 0.8rem; }
  .btn-done { width: 1.4rem; height: 1.4rem; }

  /* Group header wraps, hide progress bar */
  .group-header { flex-wrap: wrap; gap: 0.35rem; }
  .group-header-left { flex: 1 1 auto; min-width: 0; }
  .group-header-right { flex: 0 0 auto; }
  .ms-progress-bar, .ms-progress-label { display: none; }
  .group-title { white-space: normal; }

  .agenda-header-row { flex-wrap: wrap; }
  .agenda-item { align-items: flex-start; }
  .agenda-item-main { flex-direction: column; align-items: flex-start; gap: 0.18rem; }
  .agenda-task-title { white-space: normal; }

  /* Tighter subtask indentation */
  .subtask-list { margin-left: 0.5rem; padding-left: 0.4rem; }

  /* Top forms stack */
  .top-forms .new-task-form { flex: 1 1 100%; }
  .ms-create-details { flex: 1 1 100%; }

  /* Auth card */
  .auth-card { padding: 1.5rem 1.1rem; margin: 1.25rem 1rem; }

  /* Always show task controls on mobile (no hover available) */
  .task-item .ms-task-row,
  .task-item .sched-wrap,
  .task-item .add-subtask { display: block; }

  .task-item .sched-display.sched-empty { display: inline-flex; }
  .task-item .desc-preview.desc-empty   { display: block; }

  /* iOS zoom prevention on small-font inputs */
  .subtask-form input,
  .ms-new-form input[type="text"],
  .ms-new-form input[type="date"],
  .sched-input,
  .desc-textarea,
  .ms-select { font-size: 1rem; }
}

/* ── Offline banner ──────────────────────────────────────── */
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--amber-bg);
  border-bottom: 1px solid var(--amber-bg2);
  color: var(--amber);
  font-size: 0.8rem;
  padding: 0.4rem 1rem;
  text-align: center;
}

/* ── Pending (queued offline) task ───────────────────────── */
.task-item.pending { opacity: 0.55; }

.task-item.pending .task-title::after {
  content: ' ⏳';
  font-size: 0.75em;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  z-index: 300;
  pointer-events: none;
  transition: opacity 0.3s;
}
