/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 36px; padding: 0 10px; font-size: .9rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--tap); height: var(--tap); border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg, .btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

/* ---------- Sidebar ---------- */
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 10px;
  border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 500;
}
.nav-item svg { width: 20px; height: 20px; color: var(--text-muted); flex: none; }
.nav-item:hover { background: var(--surface-2); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 650; }
.nav-item[aria-current="page"] svg { color: currentColor; }
.nav-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { color: var(--text-muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.nav-count.alert { color: var(--overdue); font-weight: 650; }
.nav-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; margin: 0 4px; background: var(--dot, var(--p4)); }
.nav-heading { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 4px; padding-left: 10px; color: var(--text-muted); font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.drop-hover { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft) !important; }

/* ---------- Topbar / search ---------- */
.search input {
  width: 100%; height: var(--tap); padding: 0 12px 0 40px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.search svg { position: absolute; left: 12px; top: 12px; width: 20px; height: 20px; color: var(--text-muted); pointer-events: none; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }

/* ---------- Quick add ---------- */
.quickadd { padding: 10px calc(12px + var(--sar)) 8px calc(12px + var(--sal)); border-bottom: 1px solid var(--border); background: var(--bg); }
.quickadd-inner { max-width: 796px; margin: 0 auto; position: relative; }
.qa-row { display: flex; gap: 8px; }
.qa-row input {
  flex: 1; min-width: 0; height: var(--tap); padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
}
.qa-hint { font-size: .8rem; color: var(--text-muted); margin-top: 6px; min-height: 24px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; min-height: 24px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: .8rem; font-weight: 550; white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip.date { background: var(--accent-soft); color: var(--accent-soft-text); }
.chip.p1 { color: var(--p1); } .chip.p2 { color: var(--p2); } .chip.p3 { color: var(--p3); }
.chip.new { border: 1px dashed var(--border-strong); background: transparent; }
.chip.warn { color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.qa-ac {
  list-style: none; margin: 6px 0 0; padding: 4px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev, var(--surface)); color: var(--text);
  box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; z-index: 20;
}
.qa-ac[hidden] { display: none; }
.qa-ac [role="option"] {
  display: flex; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 0 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.qa-ac [role="option"][aria-selected="true"] { background: var(--surface-2); }

/* ---------- Page ---------- */
.page-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 12px; }
.page-head h1:focus { outline: none; }
.page-head .count { color: var(--text-muted); font-size: .9rem; }
.page-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.page-desc { color: var(--text-muted); margin-bottom: 12px; }
.offline-order-hint { font-size: .9em; opacity: .85; }

.filterbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; padding: 12px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .label, legend { font-size: .8rem; font-weight: 650; color: var(--text-muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: var(--tap); padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
}
.field textarea { resize: vertical; min-height: 96px; line-height: 1.4; }
.field.wide { grid-column: 1 / -1; }

.group { margin-bottom: 20px; }
.group-head { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); margin-bottom: 2px; min-height: 40px; }
.group-head h2 { flex: 1; min-width: 0; }
.group-head .count { color: var(--text-muted); font-weight: 400; font-size: .85rem; margin-left: 6px; }
.group-head.overdue h2 { color: var(--overdue); }

.task-list { min-height: 12px; }
.task-list.empty-drop { min-height: 44px; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--text-muted); display: flex; align-items: center; padding: 0 12px; font-size: .9rem; }

/* ---------- Task row ---------- */
.task-row { border-bottom: 1px solid var(--border); border-radius: var(--radius-sm); }
.task-row:focus-visible { outline-offset: -3px; }
.task-row:hover, .task-row:focus { background: var(--surface); }
.task-row.dragging { opacity: .35; }
.task { position: relative; display: flex; align-items: flex-start; gap: 2px; padding: 2px 0; }
.handle {
  flex: none; width: 24px; height: var(--tap); display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  opacity: 0; margin-left: -8px;
}
.handle svg { width: 16px; height: 16px; }
.task-row:hover .handle, .task-row:focus-within .handle, .task-row:focus .handle { opacity: .9; }
@media (pointer: coarse) {
  .handle { opacity: .7; width: 30px; margin-left: -6px; }
}
.no-drag .handle { display: none; }
.no-drag .task { padding-left: 16px; }
@media (pointer: coarse) { .no-drag .task { padding-left: 24px; } }
.task-row.no-drag .subtasks { margin-left: 0; }
.check {
  flex: none; width: var(--tap); height: var(--tap); border: 0; background: transparent; padding: 0;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.check .ring {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--pc, var(--p4)); display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--pc, var(--p4)) 12%, transparent); color: transparent; transition: background .15s;
}
.check .ring svg { width: 14px; height: 14px; }
.check:hover .ring { color: var(--pc, var(--p4)); }
.check[aria-checked="true"] .ring { background: var(--pc, var(--p4)); color: var(--bg); }
[data-priority="1"] { --pc: var(--p1); } [data-priority="2"] { --pc: var(--p2); }
[data-priority="3"] { --pc: var(--p3); } [data-priority="4"] { --pc: var(--p4); }
.task-body { flex: 1; min-width: 0; padding: 7px 0 7px 2px; }
.task-title {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 4px 0 2px; min-height: 24px;
  font-weight: 500; color: var(--text); overflow-wrap: anywhere; line-height: 1.35;
}
.task-row.done > .task .task-title { color: var(--text-muted); text-decoration: line-through; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .8rem; color: var(--text-muted); min-height: 20px; }
.meta .item { display: inline-flex; align-items: center; gap: 4px; }
.meta svg { width: 14px; height: 14px; }
.meta .due.overdue { color: var(--overdue); font-weight: 650; }
.meta .due.today { color: var(--success); font-weight: 600; }
.badge { display: inline-flex; align-items: center; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 600; min-height: 20px; }
.badge.prio { background: transparent; border: 1px solid currentColor; font-size: .72rem; }
.badge.prio.p1 { color: var(--p1); } .badge.prio.p2 { color: var(--p2); } .badge.prio.p3 { color: var(--p3); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--p4)); display: inline-block; }
.label-tag { color: var(--text-muted); }
.subtasks { margin: 0 0 4px 24px; border-left: 1px solid var(--border); }
.subtasks .task-row { border-bottom: 0; }
.subtasks .check { width: 40px; height: 40px; }
.subtasks .check .ring { width: 18px; height: 18px; }

/* ---------- Drag & drop ---------- */
svg.drag-ghost-layer { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; overflow: visible; }
.drag-ghost { display: inline-block; pointer-events: none; background: var(--bg-elev); border: 1px solid var(--accent); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 8px 12px; font-weight: 500; max-width: 80vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-indicator { height: 3px; margin: -1px 0; background: var(--accent); border-radius: 2px; list-style: none; pointer-events: none; }
.drag-strip {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; display: flex; gap: 8px; overflow-x: auto;
  padding: 10px calc(12px + var(--sar)) calc(10px + var(--sab)) calc(12px + var(--sal));
  background: var(--bg-elev); border-top: 1px solid var(--border-strong); box-shadow: var(--shadow);
}
.drag-strip .target { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 14px; border: 1px dashed var(--border-strong); border-radius: 999px; background: var(--surface); font-weight: 600; white-space: nowrap; }
body.is-dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }

/* ---------- Cards (projects/labels) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); text-decoration: none; }
.card:hover { background: var(--surface); }
.card .grow { flex: 1; min-width: 0; }
.card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.card .sub { font-size: .8rem; color: var(--text-muted); }
.card-wrap { position: relative; }
.card-wrap .edit { position: absolute; top: 10px; right: 6px; }
.card-wrap .card { padding-right: 52px; }

.empty { text-align: center; padding: 56px 16px; color: var(--text-muted); }
.empty svg { width: 48px; height: 48px; opacity: .55; margin-bottom: 8px; }
.empty h2 { font-size: 1.05rem; color: var(--text); margin-bottom: 4px; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; left: 50%; bottom: calc(16px + var(--sab)); transform: translateX(-50%); z-index: 95; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 8px 8px 16px; min-height: 48px; background: #20242b; color: #f2f4f7; border-radius: var(--radius); box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
:root[data-theme="dark"] .toast { background: #e9ebee; color: #14161a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="dark"]) .toast { background: #e9ebee; color: #14161a; } }
.toast .msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast button { min-height: 40px; padding: 0 12px; border: 0; background: transparent; color: #aab8ff; font-weight: 700; border-radius: var(--radius-sm); }
:root[data-theme="dark"] .toast button { color: #2a41a3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="dark"]) .toast button { color: #2a41a3; } }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Dialog ---------- */
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow); width: min(520px, calc(100vw - 24px)); max-height: 90dvh; }
dialog::backdrop { background: var(--scrim); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 8px 20px; }
.dlg-head h2 { font-size: 1.1rem; }
.dlg-body { padding: 4px 20px 8px; display: grid; gap: 12px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.dlg-foot .spacer { flex: 1; }
.err { color: var(--danger); font-size: .9rem; }
.kbd-table { width: 100%; border-collapse: collapse; }
.kbd-table td { padding: 5px 0; vertical-align: top; }
.kbd-table td:first-child { width: 45%; white-space: nowrap; }
kbd { font-family: var(--mono); font-size: .8rem; padding: 2px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
.kbd-cols { columns: 1; } .kbd-cols h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 12px 0 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.swatches span { display: block; width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 3px solid transparent; background-clip: padding-box; box-shadow: 0 0 0 1px var(--border-strong); }
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--text); }
.swatches input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---------- Detail panel ---------- */
.panel-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); }
.panel-head h2 { flex: 1; font-size: 1rem; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(24px + var(--sab)); display: grid; gap: 14px; align-content: start; -webkit-overflow-scrolling: touch; }
.panel .title-input { font-size: 1.1rem; font-weight: 600; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.quick-due { display: flex; flex-wrap: wrap; gap: 6px; }
.label-picks { display: flex; flex-wrap: wrap; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.label-picks label { position: relative; }
.label-picks input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.label-picks span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 999px; font-size: .9rem; }
.label-picks input:checked + span { background: var(--accent-soft); color: var(--accent-soft-text); border-color: var(--accent); font-weight: 650; }
.label-picks input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.sub-add { display: flex; gap: 8px; margin-top: 6px; }
.sub-add input { flex: 1; min-width: 0; min-height: var(--tap); padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); }
.panel-meta { font-size: .8rem; color: var(--text-muted); }
.panel .subtasks { margin-left: 0; border-left: 0; }
.panel .subtasks .task-row { border-bottom: 1px solid var(--border); }

.login-note { color: var(--text-muted); font-size: .9rem; }
.offline-banner { background: var(--danger-soft); color: var(--danger); padding: 6px 16px; font-size: .85rem; text-align: center; }
.offline-banner, .update-banner { padding: 6px calc(16px + var(--sar)) 6px calc(16px + var(--sal)); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; }
.offline-banner[hidden], .update-banner[hidden] { display: none; }
.update-banner { background: var(--accent-soft); color: var(--accent-soft-text); font-size: .85rem; text-align: center; }
.update-banner .btn, .offline-banner .btn { min-height: 32px; }
@media (pointer: coarse) { .update-banner .btn, .offline-banner .btn { min-height: var(--tap); } }

/* ---- shell extras ---- */
.nav-link-plain { color: inherit; text-decoration: none; }
.nav-link-plain:hover { color: var(--text); text-decoration: underline; }
.brand-bg { color: var(--accent); }
.card-wrap { position: relative; }
.card-wrap .icon-btn.edit { position: absolute; top: 4px; right: 4px; }
html.pre-collapsed .app { grid-template-columns: 0 minmax(0, 1fr); }
html.pre-collapsed .sidebar { visibility: hidden; }
@media (max-width: 1023px) { html.pre-collapsed .app { grid-template-columns: minmax(0, 1fr); } }
.grow { flex: 1; }
.noscript { padding: 2rem; }

/* toggle buttons (Smart order) and the Upcoming range segmented control */
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.seg { display: inline-flex; gap: 0; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: var(--radius-sm, 8px) 0 0 var(--radius-sm, 8px); margin-left: 0; }
.seg .btn:last-child { border-radius: 0 var(--radius-sm, 8px) var(--radius-sm, 8px) 0; }

/* Trash */
.trash-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--border); min-height: 52px; }
.trash-row .grow { flex: 1; min-width: 0; }
.trash-row .task-title { overflow-wrap: anywhere; }
.trash-row .sub { color: var(--text-muted); font-size: .8rem; }

.account-email { font-weight: 650; word-break: break-word; margin: 0; }
.account-actions { display: grid; gap: 8px; }
.account-actions .btn { width: 100%; justify-content: center; }
.account-install { display: grid; gap: 6px; margin-top: 4px; }
.account-install .btn { width: 100%; justify-content: center; }
.account-install-steps { margin: 0; color: var(--text-muted); font-size: .9rem; }
.account-install-status { margin: 0; font-size: .9rem; }
.account-install-status:empty { display: none; }
.icloud-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.icloud-heading { margin: 0; font-size: 1rem; font-weight: 650; }
.icloud-status { margin: 0; }
.icloud-cal-list { margin: 0; padding-left: 0; display: grid; gap: 8px; list-style: none; }
.icloud-cal-empty { color: var(--text-muted); list-style: none; margin: 0; }
#icloud-form { display: grid; gap: 10px; }

.icloud-cal-list { list-style: none; padding-left: 0; display: grid; gap: 8px; }
.icloud-cal-item {
  display: grid;
  grid-template-columns: 0.85rem 1fr;
  gap: 8px 10px;
  align-items: start;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2, var(--surface));
}
.icloud-cal-swatch {
  width: 0.85rem;
  height: 0.85rem;
  margin-top: 0.3rem;
  border-radius: 3px;
  border: 1px solid;
}
.icloud-cal-body { display: grid; gap: 4px; }
.icloud-cal-name { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
/* R1.1.7 §99.11: per-calendar inbound sync status */
.icloud-cal-status { margin: 0.1rem 0 0; font-size: 0.82rem; color: var(--text-muted); overflow-wrap: anywhere; }
.icloud-cal-status[data-state="error"] { color: var(--danger); }
.icloud-cal-status .icloud-cal-hint { display: block; color: var(--text-muted); }
.icloud-cal-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 450;
  cursor: pointer;
}
.icloud-cal-label input { margin-top: 0.15rem; flex: 0 0 auto; }
.icloud-refresh-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.icloud-refresh-status { margin: 0; font-size: 0.88rem; color: var(--text-muted); min-height: 1.2em; }
.icloud-sync { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.countdown { color: var(--text-muted); font-size: .9rem; margin: 0; }
.field-err { color: var(--danger); font-size: .85rem; margin: 4px 0 0; }
input[aria-invalid="true"] { border-color: var(--danger); }
@media (max-width: 430px) {
  dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
}

/* CSP-safe extras (no inline styles): palette classes set --dot/--c */
.dot.lg { width: 14px; height: 14px; }
.touch-row { min-height: 44px; }
.archived-block { margin-top: 28px; }
.archived-block .cards { margin-top: 10px; }
.saved-views-h { margin: 28px 0 8px; }
.ml-auto { margin-left: auto; }
.c-e03131 { --dot: #e03131; --c: #e03131; }
.c-e8590c { --dot: #e8590c; --c: #e8590c; }
.c-f08c00 { --dot: #f08c00; --c: #f08c00; }
.c-2f9e44 { --dot: #2f9e44; --c: #2f9e44; }
.c-0c8599 { --dot: #0c8599; --c: #0c8599; }
.c-3b5bdb { --dot: #3b5bdb; --c: #3b5bdb; }
.c-7048e8 { --dot: #7048e8; --c: #7048e8; }
.c-c2255c { --dot: #c2255c; --c: #c2255c; }
.c-5f6874 { --dot: #5f6874; --c: #5f6874; }
.c-1c7ed6 { --dot: #1c7ed6; --c: #1c7ed6; }
.c-3b82f6 { --dot: #3b82f6; --c: #3b82f6; }
.c-ef4444 { --dot: #ef4444; --c: #ef4444; }

.repeat-days { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; border: 0; padding: 0; }
.repeat-days label { display: flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--text); min-height: var(--tap); }
.repeat-days input { width: auto; min-height: 0; }
.repeat-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px; color: var(--text); }
.repeat-custom input[type=number] { width: 5.5rem; min-width: 0; }
.repeat-custom select { width: auto; }
.repeat-monthly { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px; color: var(--text); }
.repeat-monthly select { width: auto; min-width: 12rem; }
.repeat-unknown { margin: 4px 0 8px; color: var(--text-muted); font-size: .9rem; }
.repeat-from { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: .9rem; color: var(--text); min-height: var(--tap); }
.repeat-from input { width: auto; min-height: 0; }

/* ---- R1.0.4.1 public signup page (docs/11 §43): no sidebar, quick add, search or help ---- */
body.public-mode .app { grid-template-columns: minmax(0, 1fr); }
body.public-mode .sidebar, body.public-mode #search-form, body.public-mode #quickadd, body.public-mode #btn-menu,
body.public-mode #btn-help, body.public-mode #btn-account, body.public-mode #btn-calendar, body.public-mode .drawer-scrim, body.public-mode .panel, body.public-mode .panel-scrim { display: none; }
.signup-page { max-width: 480px; }
.signup-card { margin-top: 24px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.signup-card h1 { margin: 0 0 8px; font-size: 1.35rem; }
.signup-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.signup-form .page-actions { justify-content: flex-end; }
.signup-form input[aria-invalid="true"], .admin-invite-form input[aria-invalid="true"] { border-color: var(--danger); }

/* ---- R1.0.4.1 owner-only Admin view ---- */
.admin-section { margin-top: 24px; }
.admin-section h2 { font-size: 1.05rem; margin: 0 0 10px; }
.admin-subhead { font-size: .9rem; margin: 18px 0 8px; color: var(--text-muted); }
.admin-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: var(--tap); }
.admin-row + .admin-row { border-top: 1px solid var(--border); }
.admin-main { min-width: 0; }
.admin-title { font-weight: 600; overflow-wrap: anywhere; }
.admin-row .meta span { overflow-wrap: anywhere; }
.admin-status { font-weight: 650; }
.admin-status.is-active, .admin-status.is-pending { color: var(--success); }
.admin-status.is-disabled, .admin-status.is-revoked { color: var(--danger); }
.admin-status.is-used, .admin-status.is-expired { color: var(--text-muted); }
.admin-invite-form { display: flex; flex-direction: column; gap: 10px; }
.admin-onetime { margin: 0 0 16px; padding: 16px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-soft-text); }
.admin-onetime h3 { margin: 0 0 6px; font-size: 1rem; }
.admin-warn { margin: 0 0 10px; font-weight: 600; }
.admin-copy-row { display: flex; gap: 8px; align-items: center; }
.admin-copy-row .input { flex: 1; min-width: 0; font-family: var(--mono); font-size: .85rem; }
@media (max-width: 600px) { .admin-copy-row { flex-direction: column; align-items: stretch; } }

/* ---- R1.0.5 shared projects (§44) ---- */
.shared-badge { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 650; color: var(--text-muted); letter-spacing: 0; }
.shared-badge svg { width: 14px; height: 14px; }
.nav-item .shared-badge { margin-left: 4px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.share-add-form { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.share-dlg { max-width: 520px; width: calc(100vw - 32px); }
.admin-title .badge { margin-left: 8px; vertical-align: middle; }

.fav-btn[aria-pressed="true"] { color: var(--accent, #e8590c); }
.fav-btn[aria-pressed="true"] svg { fill: currentColor; }

/* R1.1.6 Stage 9: "Send scheduled tasks to" picker */
.icloud-dest { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.icloud-dest-label { font-weight: 600; font-size: 0.9rem; }
.icloud-dest select { max-width: 100%; }
.icloud-dest-help { margin: 0; }
.icloud-dest-status { margin: 0; font-size: 0.82rem; color: var(--text-muted); min-height: 1.1em; }
.icloud-dest.is-loading .icloud-dest-status::before { content: "\21bb  "; }
.icloud-cal-list[aria-busy="true"] { opacity: 0.7; }

/* R1.1.7 B05: view toolbar (headerActions + Filter) wraps instead of clipping in narrow panes (390 px phone,
   split calendar). Every control stays visible and in DOM/tab order; no overflow menu needed. */
.page-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; max-width: 100%; min-width: 0; }
.page-actions > * { flex: 0 0 auto; }
/* R1.1.7 B07: inline validation under the custom due range */
.field-error { grid-column: 1 / -1; flex-basis: 100%; margin: 4px 0 0; color: var(--danger, #b42318); font-size: .85rem; line-height: 1.35; }
.filterbar input[aria-invalid="true"] { border-color: var(--danger, #b42318); box-shadow: 0 0 0 1px var(--danger, #b42318); }
/* R1.1.7 B02: archived project banner */
.archived-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 12px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2, var(--surface)); color: var(--text); }
.archived-banner svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--text-muted); }
.archived-banner .grow { flex: 1 1 14rem; min-width: 0; }

/* ---- R1.2.0 OAuth consent (docs/11 §100.1): card only, theme-aware tokens, no inline styles ---- */
body.consent-mode #btn-logout { display: none; }
.consent-page { max-width: 480px; }
.consent-card { margin-top: 24px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.consent-title { margin: 0 0 12px; font-size: 1.35rem; }
.consent-title:focus { outline: none; }
.consent-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.consent-who { margin: 0 0 12px; overflow-wrap: anywhere; }
.consent-scopes-label { margin: 0 0 4px; }
.consent-scopes { margin: 0 0 16px; padding-left: 1.25rem; }
.consent-scopes li { margin: 2px 0; overflow-wrap: anywhere; }
.consent-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.consent-actions .btn:disabled { opacity: 0.6; cursor: default; }
.consent-msg { margin: 0 0 12px; }
.consent-status { min-height: 1.2em; margin: 10px 0 0; color: var(--danger); }

/* R1.3.0 (§101) mobile: 44px touch targets on touch screens, notch-safe dialogs, keyboard-aware dialogs. */
@media (pointer: coarse) {
  .subtasks .check { width: var(--tap); height: var(--tap); }
  .btn-sm { min-height: var(--tap); }
  .nav-heading .nav-link-plain { display: inline-flex; align-items: center; min-height: var(--tap); }
  button, a, input, select, textarea, label, summary, [role="button"] { touch-action: manipulation; }
}
dialog { max-width: calc(100vw - 16px - var(--sal) - var(--sar)); max-height: min(90dvh, calc(100dvh - 16px - var(--sat) - var(--sab))); }
@media (max-width: 430px) {
  dialog { max-height: calc(100dvh - 16px - var(--sat) - var(--sab)); }
}
/* On-screen keyboard open (app.js sets body.kb-open from visualViewport): pin small-screen dialogs to the top so the
   focused field stays above the keyboard instead of sitting in a centred dialog behind it. */
@media (max-width: 600px), (max-height: 500px) {
  body.kb-open dialog[open] { margin-top: calc(8px + var(--sat)); margin-bottom: auto; }
}
.draft-note { margin: 0; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: .88rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.draft-note[hidden] { display: none; }
.check[aria-busy="true"] { opacity: .55; cursor: progress; }
.check[aria-busy="true"] .ring { border-style: dashed; }
/* REVIEW-042 L-2: 44px swatch hit area on touch (the input covers the padded label); visual circle and spacing unchanged. */
@media (pointer: coarse) {
  .swatches { gap: 0; }
  .swatches label { padding: 4px; }
}

/* ---------- R1.3.1-a (docs/11 §102): Task details never wider than the viewport ---------- */
/* One shrinkable column; grid/flex children may shrink below their content (long titles, long <option> text). */
.panel-body { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.panel-body > *, .panel .field, .panel .row2 > *, .panel-head > *, .panel .sub-add > *, .panel .quick-due > *,
.panel .label-picks > *, .panel-schedule, .panel-schedule *, .panel-sync { min-width: 0; }
.panel input, .panel select, .panel textarea { max-width: 100%; min-width: 0; box-sizing: border-box; }
/* Long option text is cut with an ellipsis instead of widening the panel. */
.panel select { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Long parent titles wrap inside the "← parent" button. */
.panel .panel-parent { white-space: normal; text-align: left; justify-self: start; max-width: 100%; overflow-wrap: anywhere; height: auto; }
.panel .task-row, .panel .task-title, .panel-meta, .panel-sync, .panel-schedule { overflow-wrap: anywhere; }
/* The title is an auto-growing <textarea rows=1> (rows set from content in panel.js); it wraps, never scrolls sideways. */
.panel .title-input { min-height: var(--tap); line-height: 1.35; resize: none; overflow: hidden; overflow-wrap: anywhere; white-space: pre-wrap; }

/* ---------- R1.3.1-b (docs/11 §103): the whole task row is the click and drag target ---------- */
/* No text selection or iOS callout during a long-press, on the row only (titles stay fully readable; the panel's
   fields are unaffected). Touch still pans/scrolls the list (manipulation); the drag needs a long-press (dnd.js). */
.task-row { cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.task-row:not(.no-drag) > .task { cursor: grab; }
.task-row .task-title { cursor: inherit; }
.task-row .check, .task-row a[href], .task-row button:not(.task-title), .task-row [data-action] { cursor: pointer; }
.task-row .handle { cursor: grab; }
/* Long-press feedback (touch): the row lifts before it can be dragged. */
.task-row.lifted > .task { background: var(--surface-2, var(--surface)); box-shadow: var(--shadow); border-radius: var(--radius-sm); transform: scale(1.015); transition: transform .12s, box-shadow .12s; }
body.is-dragging, body.is-dragging .task-row, body.is-dragging .task-row > .task { cursor: grabbing; }
@media (prefers-reduced-motion: reduce) { .task-row.lifted > .task { transform: none; transition: none; } }

/* R1.4.0 item 3 (docs/11 §105): Account → Time zone. Never widens the dialog (R1.3.1-a rules): grid children get
   min-width 0, the select is capped at 100% and cuts long zone labels with an ellipsis. */
.account-tz { min-width: 0; border-top: 1px solid var(--border); padding-top: 12px; }
.tz-form { display: grid; gap: 6px; min-width: 0; }
.tz-h { margin: 0; font-size: 1rem; font-weight: 650; }
.tz-label { font-size: .9rem; color: var(--text-muted); }
.tz-select { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; min-height: 44px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tz-select[aria-invalid="true"] { border-color: var(--danger); }
.tz-help, .tz-hint { margin: 0; font-size: .9rem; color: var(--text-muted); overflow-wrap: anywhere; min-width: 0; }
.tz-detect-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.tz-detect-row .tz-hint { flex: 1 1 12rem; }
.tz-detect { min-height: 44px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: start; }
.tz-detected { font-weight: 650; color: var(--text); }
.tz-err { margin: 0; overflow-wrap: anywhere; }
.tz-actions { display: flex; justify-content: flex-end; }
.tz-actions .btn { min-height: 44px; }
.tz-actions .btn:disabled { opacity: 0.55; cursor: default; }
.tz-status { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.tz-status:empty { display: none; }
@media (max-width: 480px) { .tz-actions .btn, .tz-detect { width: 100%; justify-content: center; } }
