/* ==========================================================================
   TaskFlow styles: CSS variables drive light/dark themes
   ========================================================================== */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e1e4ec;
  --text: #1a1d29;
  --text-muted: #5b6275;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-contrast: #ffffff;
  --focus: #6366f1;
  --link: #1d4ed8;

  --danger: #c81e1e;
  --danger-bg: #fdecec;
  --overdue-border: #e02424;

  --high-bg: #fde2e1;   --high-fg: #9b1c1c;   --high-dot: #e02424;
  --medium-bg: #fef3c7; --medium-fg: #854d0e; --medium-dot: #eab308;
  --low-bg: #dcfce7;    --low-fg: #166534;    --low-dot: #22c55e;

  --status-bg: #eef0f6; --status-fg: #3c4256;
  --progress-bg: #e0e7ff; --progress-fg: #3730a3;

  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  --shadow-md: 0 8px 24px rgb(16 24 40 / 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sk: #e6e9f0;
  --sk-shine: #f3f5f9;

  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6275' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --surface: #181b24;
    --surface-2: #20242f;
    --border: #2c3140;
    --text: #e8eaf0;
    --text-muted: #a0a7b8;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-contrast: #0f1117;
    --focus: #a5b4fc;
    --link: #60a5fa;
    --danger: #f87171;
    --danger-bg: #3a1618;
    --overdue-border: #f87171;
    --high-bg: #4c1d1d;   --high-fg: #fecaca;
    --medium-bg: #47380f; --medium-fg: #fde68a;
    --low-bg: #123823;    --low-fg: #bbf7d0;
    --status-bg: #262b38; --status-fg: #c9cede;
    --progress-bg: #2a2f5c; --progress-fg: #c7d2fe;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 12px 32px rgb(0 0 0 / 0.5);
    --sk: #232734;
    --sk-shine: #2d3242;
    --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a7b8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #20242f;
  --border: #2c3140;
  --text: #e8eaf0;
  --text-muted: #a0a7b8;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-contrast: #0f1117;
  --focus: #a5b4fc;
  --link: #60a5fa;
  --danger: #f87171;
  --danger-bg: #3a1618;
  --overdue-border: #f87171;
  --high-bg: #4c1d1d;   --high-fg: #fecaca;
  --medium-bg: #47380f; --medium-fg: #fde68a;
  --low-bg: #123823;    --low-fg: #bbf7d0;
  --status-bg: #262b38; --status-fg: #c9cede;
  --progress-bg: #2a2f5c; --progress-fg: #c7d2fe;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 12px 32px rgb(0 0 0 / 0.5);
  --sk: #232734;
  --sk-shine: #2d3242;
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a7b8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.2s, color 0.2s;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 1rem; top: -3rem;
  background: var(--primary); color: var(--primary-contrast);
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  z-index: 100; text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.muted { color: var(--text-muted); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 40px;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.05s, border-color 0.15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.65; cursor: not-allowed; }
.btn--primary {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  border: 0;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.18) inset, 0 6px 16px -6px rgb(79 70 229 / 0.6);
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.15s;
}
.btn--primary:hover:not(:disabled) {
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.2) inset, 0 10px 22px -8px rgb(109 40 217 / 0.65);
}
.btn--primary:active:not(:disabled) { transform: translateY(0) scale(0.98); }
/* Secondary action next to a primary button (e.g. Cancel) */
.btn--soft {
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 26%, transparent);
  color: var(--primary);
  transition: background-color 0.15s, border-color 0.15s, transform 0.12s;
}
.btn--soft:hover { background: color-mix(in srgb, var(--primary) 16%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.btn--soft:active { transform: scale(0.98); }
.btn--danger { background: var(--danger); color: #fff; }

.btn--danger:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--icon { width: 40px; padding: 0; font-size: 1.05rem; }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0.35rem 0.75rem; font-size: 0.875rem; }
.btn--danger-outline { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn--danger-outline:hover:not(:disabled) { background: var(--danger-bg); }
.btn--success { background: var(--low-bg); color: var(--low-fg); border-color: color-mix(in srgb, var(--low-dot) 55%, transparent); }
.btn--success:hover:not(:disabled) { background: color-mix(in srgb, var(--low-dot) 22%, var(--low-bg)); border-color: var(--low-dot); }
.btn__icon { flex-shrink: 0; display: block; }
.btn--outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn--outline:hover:not(:disabled) { background: var(--surface-2); }
.card-btn {
  min-height: 38px;
  padding: 0.4rem 0.75rem;
  gap: 0.4rem;
  font-size: 0.85rem;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.card-btn .btn__icon { width: 16px; height: 16px; }
.card-btn--edit { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.card-btn--edit:hover { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border-color: var(--primary); }
.card-btn--delete { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.card-btn--delete:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn--danger-ghost:hover { background: var(--danger-bg); color: var(--danger); }

.spinner {
  width: 1em; height: 1em;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 1rem; }
.form__title { font-size: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.875rem; font-weight: 600; }
.field--inline label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.hint { color: var(--text-muted); font-size: 0.8rem; }
.req { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.25rem;
  background-image: var(--caret);
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 12px;
}

.password-wrap { position: relative; }
.password-wrap input { padding-right: 2.9rem; }
.password-toggle {
  position: absolute; top: 50%; right: 0.35rem; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--surface-2); }
/* Hide the browser's built-in reveal button so there aren't two eyes */
input::-ms-reveal, input::-ms-clear { display: none; }

.form-error { color: var(--danger); font-size: 0.875rem; font-weight: 500; min-height: 0; }
.form-error:empty { display: none; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-2 .field--full { grid-column: 1 / -1; }
input[type="date"], input[type="time"] {
  width: 100%; min-height: 42px;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- Brand ---------- */

.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.2rem; }
.brand__logo {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-size: 1.1rem;
}

/* ---------- Auth ---------- */

.auth-view {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 45%),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, #8b5cf6 16%, transparent), transparent 45%),
    var(--bg);
}
.auth-card {
  position: relative;
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-md);
}
.auth-card { overflow: hidden; }
/* Soft purple glow behind the top of the card */
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 210px;
  background:
    radial-gradient(70% 100% at 50% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 70%),
    radial-gradient(40% 60% at 100% 0%, color-mix(in srgb, #8b5cf6 12%, transparent), transparent 70%);
  pointer-events: none;
}
.auth-card > * { position: relative; }
.auth-card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin: -0.4rem 0 1.5rem;
  padding-bottom: 1.05rem;
  /* Hairline divider that fades out at both ends */
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--primary) 30%, var(--border)), transparent) bottom / 100% 1px no-repeat;
}
/* Logo centered in the card; theme toggle pinned to the top-right corner of the page */
.auth-card__head { justify-content: center; }
.auth-card__head .mode-toggle { position: fixed; top: 16px; right: 16px; z-index: 10; }
.auth-card__head .brand { gap: 0.6rem; font-size: 1.12rem; letter-spacing: -0.01em; }
.auth-card__head .brand__logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  box-shadow: 0 6px 14px -6px rgb(79 70 229 / 0.65), 0 1px 0 rgb(255 255 255 / 0.25) inset;
}
.auth-main { flex: 1; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card__intro { text-align: center; margin-bottom: 1.5rem; }
.auth-card__title { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.025em; line-height: 1.2; }
.auth-card__brandword {
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.auth-card__tagline { color: var(--text-muted); margin-top: 0.4rem; font-size: 0.9rem; text-wrap: balance; }
/* ---------- Day / night mode toggle (segmented: sun | moon) ---------- */

.mode-toggle {
  position: relative;
  flex-shrink: 0;
  display: grid; grid-template-columns: 1fr 1fr; align-items: center; justify-items: center;
  width: 76px; height: 38px;
  padding: 4px;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  background: #ede9fe;
  box-shadow: inset 0 1px 2px rgb(76 29 149 / 0.12);
  cursor: pointer;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.mode-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.mode-toggle__thumb {
  position: absolute; top: 4px; left: 4px;
  width: calc(50% - 4px); height: calc(100% - 8px);
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  box-shadow: 0 2px 8px -1px rgb(109 40 217 / 0.55), 0 1px 0 rgb(255 255 255 / 0.25) inset;
  transition: transform 0.35s cubic-bezier(0.4, 1.25, 0.6, 1), background 0.35s ease, box-shadow 0.35s ease;
}
.mode-toggle__icon {
  position: relative; z-index: 1;
  width: 18px; height: 18px;
  transition: color 0.3s ease, transform 0.35s ease;
}
.mode-toggle__icon--sun { color: #ffffff; }
.mode-toggle__icon--moon { color: #8b7cc8; }
.mode-toggle:hover .mode-toggle__icon--moon { color: #6d28d9; }
.mode-toggle:hover { border-color: #a78bfa; }
.mode-toggle:active .mode-toggle__thumb { transform: scale(0.94); }

/* Night (matches the reference): navy track, slate thumb behind a white moon */
.mode-toggle[aria-checked="true"] { background: #050816; border-color: #1b2136; }
.mode-toggle[aria-checked="true"] .mode-toggle__thumb {
  transform: translateX(100%);
  background: #2d3654;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.4);
}
.mode-toggle[aria-checked="true"]:active .mode-toggle__thumb { transform: translateX(100%) scale(0.94); }
.mode-toggle[aria-checked="true"] .mode-toggle__icon--sun { color: #8b93a7; }
.mode-toggle[aria-checked="true"] .mode-toggle__icon--moon { color: #ffffff; transform: rotate(-12deg); }
.mode-toggle[aria-checked="true"]:hover .mode-toggle__icon--sun { color: #b4bccd; }



.tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 1.25rem;
}
.tab {
  border: 0; background: transparent;
  padding: 0.5rem; border-radius: 6px;
  font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Forgot / reset password */
.link-btn.auth-forgot { align-self: flex-end; margin-top: 0.15rem; font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.link-btn.auth-forgot:hover { text-decoration: underline; }
.auth-panel__head { text-align: center; }
/* Google / phone sign-in */
.auth-alt { margin-top: 1.25rem; }
.auth-alt__divider {
  display: flex; align-items: center; gap: 0.75rem;
  color: var(--text-muted); font-size: 0.78rem; font-weight: 600;
}
.auth-alt__divider::before, .auth-alt__divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-alt__buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.85rem; }
.auth-alt__btn {
  gap: 0.5rem; min-height: 42px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s, transform 0.12s;
}
.auth-alt__btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.auth-alt__btn:active { transform: scale(0.98); }
.auth-alt__btn svg { flex-shrink: 0; }
#phone-btn svg { color: var(--primary); }
.phone-sent { font-size: 0.86rem; color: var(--text-muted); margin-bottom: 0.6rem; }
#phone-step-number, #phone-step-code { display: flex; flex-direction: column; gap: 0.85rem; }
#phone-step-number[hidden], #phone-step-code[hidden] { display: none; }
/* Forgot / reset screens have their own heading, so hide the welcome intro */
.auth-card.is-recovery .auth-card__intro { display: none; }
.auth-panel__head h2 { font-size: 1.15rem; }
.auth-panel__head p { margin-top: 0.3rem; font-size: 0.88rem; }
.link-btn.auth-back { align-self: center; font-size: 0.85rem; text-decoration: none; color: var(--text-muted); }
.link-btn.auth-back:hover { color: var(--primary); }
.form-success { color: var(--low-fg); background: var(--low-bg); padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.86rem; font-weight: 500; }
.form-success:empty { display: none; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__actions { display: flex; align-items: center; gap: 0.5rem; }
.user-btn { padding: 0.25rem 0.6rem 0.25rem 0.25rem; }
.avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: var(--primary-contrast);
  font-size: 0.9rem; font-weight: 700;
}
.user-btn__name { white-space: nowrap; }
.logout-btn {
  min-height: 38px;
  padding: 0.4rem 0.95rem 0.4rem 0.8rem;
  gap: 0.45rem;
  margin-left: 0.25rem;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: color 0.15s, background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.logout-btn svg { color: var(--text-muted); transition: color 0.15s, transform 0.15s; }
.logout-btn:hover { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.logout-btn:hover svg { color: var(--danger); transform: translateX(2px); }

/* ---------- Layout ---------- */

.container {
  width: 100%; max-width: 1240px;
  margin: 0 auto;
  padding: 1.75rem clamp(1rem, 4vw, 2rem) 4rem;
}

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.hero h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.hero__sub { color: var(--text-muted); margin-top: 0.25rem; }
#greeting { display: flex; align-items: center; gap: 0.55rem; }
.greeting__icon {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 1.6em; height: 1.6em; border-radius: 10px;
}
.greeting__icon svg { width: 62%; height: 62%; }
.greeting__icon--morning { color: #ea580c; background: #ffedd5; }
.greeting__icon--afternoon { color: #d97706; background: #fef3c7; }
.greeting__icon--evening { color: #4f46e5; background: #e0e7ff; }
:root[data-theme="dark"] .greeting__icon--morning { background: #431407; color: #fdba74; }
:root[data-theme="dark"] .greeting__icon--afternoon { background: #451a03; color: #fcd34d; }
:root[data-theme="dark"] .greeting__icon--evening { background: #1e1b4b; color: #a5b4fc; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .greeting__icon--morning { background: #431407; color: #fdba74; }
  :root:not([data-theme="light"]) .greeting__icon--afternoon { background: #451a03; color: #fcd34d; }
  :root:not([data-theme="light"]) .greeting__icon--evening { background: #1e1b4b; color: #a5b4fc; }
}

.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.65rem;
}
.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem 0.75rem;
  display: flex; flex-direction: column; align-items: stretch; gap: 0.3rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s, background-color 0.15s;
}
.stat__top { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.stat__icon {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 7px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}
.stat--pending .stat__icon { color: var(--text-muted); background: var(--surface-2); }
.stat--done .stat__icon { color: var(--low-fg); background: var(--low-bg); }
.stat--danger .stat__icon { color: var(--danger); background: var(--danger-bg); }
.stat--muted .stat__icon { color: var(--text-muted); background: var(--surface-2); }
.stat:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat:active { transform: translateY(0); }
.stat[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  box-shadow: 0 0 0 1px var(--primary);
}
.stat__num { font-size: 1.45rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat__label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat[aria-pressed="true"] .stat__label { color: var(--text); font-weight: 600; }
.stat--danger .stat__num { color: var(--danger); }
.stat--danger[aria-pressed="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); background: color-mix(in srgb, var(--danger-bg) 60%, var(--surface)); }
.stat--muted .stat__num { color: var(--text-muted); }

/* ---------- Dashboard layout ---------- */

/* Phones: one column. The side columns use display: contents so their cards
   (stats, Today, Upcoming) slot straight into this grid in a sensible order. */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "stats" "today" "note" "upcoming" "list";
  gap: 1rem;
}
.layout__upcoming, .layout__today { display: contents; }
.layout__stats { grid-area: stats; }
.layout .today { grid-area: today; }
.layout .note { grid-area: note; }
.layout .reminders { grid-area: upcoming; }
.layout__list { grid-area: list; min-width: 0; }

.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.side-card__header { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.side-card__title { font-size: 0.95rem; font-weight: 700; }
.side-card__meta { font-size: 0.78rem; color: var(--text-muted); }

/* Today card */
.today__now {
  margin-top: 0.55rem;
  padding: 0.9rem 1rem 0.85rem;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border));
  border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 7%, var(--surface)), var(--surface));
}
.today__clock { display: flex; align-items: flex-start; justify-content: center; gap: 0.3rem; line-height: 1; }
.today__time {
  font-size: 2.1rem; font-weight: 650; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.today__colon { margin: 0 0.14em; position: relative; top: -0.06em; color: var(--text-muted); font-weight: 500; }
.today__ampm {
  margin-top: 0.2rem;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--text-muted);
}
/* Short divider between the time and the day/date */
.today__day {
  margin-top: 0.65rem; padding-top: 0.6rem;
  border-top: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  width: fit-content; margin-inline: auto; min-width: 110px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--primary);
}
.today__fulldate { margin-top: 0.25rem; font-size: 1rem; font-weight: 700; color: var(--text); }
.today__main { display: flex; align-items: center; gap: 0.9rem; margin: 0.8rem 0 0.85rem; }
.ring { position: relative; flex-shrink: 0; width: 68px; height: 68px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring__track { stroke: var(--surface-2); }
.ring__value { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset 0.7s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s; }
.ring.is-complete .ring__value { stroke: var(--low-dot); }
.ring__label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 0.9rem; font-weight: 800; font-variant-numeric: tabular-nums;
}
.today__count { font-size: 0.92rem; }
.today__count strong { font-weight: 800; }
.today__msg { margin-top: 0.15rem; font-size: 0.8rem; color: var(--text-muted); }

.today__add {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 0.35rem;
  margin-bottom: 0.7rem;
  padding: 0.5rem;
  border: 1.5px dashed color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  font: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.today__add:hover { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); border-color: var(--primary); }


/* ---------- Compact search & filters ---------- */

.toolbar.toolbar { padding: 0.7rem; gap: 0.55rem; }
.toolbar .search__icon { display: flex; left: 0.75rem; font-size: 0; }
.toolbar .search input { min-height: 36px; padding: 0.35rem 0.75rem 0.35rem 2.1rem; font-size: 0.88rem; }
.toolbar .filters { gap: 0.55rem; }
.toolbar .field { gap: 0.2rem; }
.toolbar .field--inline label { font-size: 0.66rem; }
.toolbar .select__trigger { min-height: 36px; padding: 0.25rem 0.5rem 0.25rem 0.6rem; }
.toolbar .select__content .status-opt { font-size: 0.85rem; }
.toolbar .select__content svg { width: 14px; height: 14px; }
.toolbar .select__content .badge { font-size: 0.72rem; padding: 0.15rem 0.5rem; }
.toolbar .select__chevron { width: 14px; height: 14px; }

/* ---------- Quick note (sticky note) ---------- */

:root {
  --note-bg: #fef9c3;
  --note-border: #fde68a;
  --note-text: #422006;
  --note-muted: #92400e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --note-bg: #2f2a14; --note-border: #4a4220; --note-text: #fef3c7; --note-muted: #fcd34d; }
}
:root[data-theme="dark"] { --note-bg: #2f2a14; --note-border: #4a4220; --note-text: #fef3c7; --note-muted: #fcd34d; }

.side-card.note {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.85rem 0.9rem 0.7rem;
  background: var(--note-bg);
  border-color: var(--note-border);
  box-shadow: 0 6px 16px -10px rgb(146 64 14 / 0.45);
}
.note__header { display: flex; align-items: center; gap: 0.4rem; }
/* Wider screens: icon, title and status sit in one row (the heading box only matters on phones) */
.note__icon { display: grid; place-items: center; color: var(--note-muted); }
.note__heading { display: contents; }
.note__title { font-size: 0.92rem; font-weight: 700; color: var(--note-text); }
.note__status { margin-left: auto; font-size: 0.7rem; font-weight: 600; color: var(--note-muted); opacity: 0.85; white-space: nowrap; }
.note__status.is-saving { opacity: 0.65; }
.note__status.is-error { color: var(--danger); opacity: 1; }
.note__text {
  width: 100%; min-height: 120px; max-height: 320px;
  padding: 0.1rem 0;
  border: 0; border-radius: 0;
  background:
    repeating-linear-gradient(transparent 0 1.55rem, color-mix(in srgb, var(--note-muted) 22%, transparent) 1.55rem calc(1.55rem + 1px));
  background-attachment: local;
  color: var(--note-text);
  font-size: 0.9rem; line-height: 1.55rem;
  resize: none;
  box-shadow: none;
}
.note__text:focus { outline: none; box-shadow: none; border: 0; }
.note__text::placeholder { color: var(--note-muted); opacity: 0.6; }
.note__footer { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.note__count { font-size: 0.68rem; color: var(--note-muted); opacity: 0.75; font-variant-numeric: tabular-nums; }
.note__clear {
  padding: 0.15rem 0.5rem; border: 0; border-radius: 6px;
  background: transparent; color: var(--note-muted);
  font: inherit; font-size: 0.75rem; font-weight: 700;
  cursor: pointer;
}
.note__clear:hover { background: color-mix(in srgb, var(--note-muted) 14%, transparent); }
/* The dropdown parts only show on phones; elsewhere the body's children sit straight in the card */
.note__body { display: contents; }
.note__toggle, .note__peek { display: none; }

/* ---------- Upcoming reminders ---------- */

.reminders {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.reminders__header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.reminders__title { font-size: 0.95rem; }
.reminders__sub { font-weight: 500; color: var(--text-muted); font-size: 0.82rem; }
.reminders__count { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }

.next-up {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.next-up:hover { background: color-mix(in srgb, var(--primary) 15%, var(--surface)); }
.next-up__label {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--primary-contrast); background: var(--primary);
  padding: 0.25rem 0.5rem; border-radius: 6px;
}
.next-up__main { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.next-up__title { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-up__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-muted); }
.next-up__countdown { font-weight: 700; color: var(--primary); white-space: nowrap; }
/* Due within 24h: same purple family as the card, just a stronger outline and glow */
.next-up--soon {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.next-up--soon:hover { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }

/* Nothing due in the next 7 days */
.upcoming-empty {
  margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 1.1rem 1rem;
  text-align: center;
  font-size: 0.85rem; color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.upcoming-empty strong { color: var(--text); font-size: 0.95rem; font-weight: 600; }

.upcoming-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.upcoming-list:empty { display: none; }
.upcoming-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.5rem;
  border: 0; border-top: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.upcoming-list li:first-child .upcoming-item { border-top: 0; }
.upcoming-item:hover { background: var(--surface-2); }
.upcoming-item__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--medium-dot); }
.upcoming-item__dot--high { background: var(--high-dot); }
.upcoming-item__dot--low { background: var(--low-dot); }
.upcoming-item__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming-item__when { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.upcoming-item__rel { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; min-width: 7ch; text-align: right; }

.toolbar {
  display: flex; flex-direction: column; gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.search { position: relative; }
.search__icon {
  position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1.15rem; pointer-events: none;
}
.search input { padding-left: 2.3rem; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }

/* ---------- Task list ---------- */

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }

.task-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--medium-dot);
  border-radius: var(--radius);
  padding: 1rem 1rem 1rem 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.2s, transform 0.2s, border-color 0.2s, background-color 0.2s;
}
.task-card.is-new { animation: card-in 0.2s ease-out; }
@keyframes card-in { from { opacity: 0; transform: translateY(4px); } }
.task-card--high { border-left-color: var(--high-dot); }
.task-card--low { border-left-color: var(--low-dot); }

.task-card.is-overdue {
  border-color: var(--overdue-border);
  border-left-color: var(--overdue-border);
  background: color-mix(in srgb, var(--danger-bg) 55%, var(--surface));
}
.task-card.is-completed { background: var(--surface-2); border-left-color: var(--border); }
.task-card.is-completed .task-card__title,
.task-card.is-completed .task-card__desc {
  text-decoration: line-through;
  color: var(--text-muted);
}
.task-card.is-completed .task-card__meta,
.task-card.is-completed .task-card__time { opacity: 0.7; }
.task-card.is-deleted { background: var(--surface-2); border-left-color: var(--border); border-style: dashed; border-left-style: solid; }
.task-card.is-deleted .task-card__title { color: var(--text-muted); }
.task-card.is-deleted .task-card__meta { opacity: 0.75; }
.trash-icon { display: grid; place-items: center; width: 26px; height: 26px; font-size: 1rem; opacity: 0.7; }
.task-card.is-removing { opacity: 0; transform: translateX(16px); }

.task-card__body { min-width: 0; }
.task-card:not(.skeleton) { cursor: pointer; }
.task-card:not(.skeleton):hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: var(--shadow-md); }
.task-card__open {
  padding: 0; border: 0; background: none;
  font: inherit; color: inherit; text-align: left;
  cursor: pointer;
}
.task-card__open:hover { color: var(--primary); }
.task-card.is-completed .task-card__open { text-decoration: line-through; }
.task-card__title { font-size: 1.02rem; font-weight: 650; overflow-wrap: anywhere; }
.task-card__desc {
  color: var(--text-muted);
  margin-top: 0.45rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.task-card__meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.task-card__time { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.chip--time { font-weight: 600; }
.chip--time time { font-weight: 600; }
.task-card__actions { display: flex; align-items: center; gap: 0.45rem; }
/* "Today" badge in the card's bottom-right corner (same cell as the actions, pinned to the bottom) */
.task-card__today {
  grid-column: 3; grid-row: 1;
  align-self: end; justify-self: end;
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  color: var(--primary);
  font-size: 0.72rem; font-weight: 700;
}
.task-card__actions { grid-column: 3; grid-row: 1; align-self: start; }
.task-card.is-completed .task-card__today { opacity: 0.7; }
/* Status button (opens the shared status menu) */
.status-trigger {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 0.4rem;
  padding: 0 0.55rem 0 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.status-trigger:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.status-trigger.is-open, .status-trigger:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
.status-trigger .status-opt { font-size: 0.85rem; min-width: 0; }
.status-trigger .status-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-trigger.is-open .select__chevron { transform: rotate(180deg); color: var(--primary); }
.detail .status-trigger { min-width: 170px; height: 40px; }

/* Shared floating status menu */
.combo__list.status-menu {
  position: fixed; z-index: 1000;
  right: auto; bottom: auto;
  max-width: none;
}

/* Status button, Edit and Delete on a card share one size */
.task-card__actions .status-trigger,
.task-card__actions .card-btn {
  width: 136px;
  height: 36px; min-height: 36px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}
.task-card__actions .card-btn { padding: 0 0.75rem; justify-content: center; }

/* Checkbox */
.check { position: relative; display: inline-grid; place-items: center; width: 26px; height: 26px; margin-top: 1px; cursor: pointer; }
.check__input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.check__box {
  width: 22px; height: 22px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  display: grid; place-items: center;
  transition: background-color 0.15s, border-color 0.15s;
}
.check__box::after {
  content: "";
  width: 6px; height: 11px;
  border: solid var(--primary-contrast);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px) scale(0);
  transition: transform 0.15s;
}
.check__input:checked + .check__box { background: var(--primary); border-color: var(--primary); }
.check__input:checked + .check__box::after { transform: rotate(45deg) translate(-1px, -1px) scale(1); }
.check__input:focus-visible + .check__box { outline: 3px solid var(--focus); outline-offset: 2px; }
.check:hover .check__box { border-color: var(--primary); }

/* Badges & chips */
.badge, .chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  line-height: 1.3;
}
.badge--high { background: var(--high-bg); color: var(--high-fg); }
.badge--medium { background: var(--medium-bg); color: var(--medium-fg); }
.badge--low { background: var(--low-bg); color: var(--low-fg); }
.badge--high::before, .badge--medium::before, .badge--low::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.badge--status { background: var(--status-bg); color: var(--status-fg); }
.badge--completed { background: var(--low-bg); color: var(--low-fg); }
.chip { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.chip--overdue { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.chip__rel { font-weight: 500; opacity: 0.85; }

/* Trash banner */
.trash-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Skeleton */
.skeleton { animation: none; border-left-color: var(--border); }
.sk {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, var(--sk) 25%, var(--sk-shine) 50%, var(--sk) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
.sk--check { width: 22px; height: 22px; border-radius: 50%; }
.sk--title { width: 45%; height: 16px; }
.sk--line { width: 80%; height: 12px; margin-top: 0.6rem; }
.sk--meta { width: 30%; height: 12px; margin-top: 0.6rem; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Empty state */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty__icon { font-size: 2.25rem; }
.empty__title { font-size: 1.1rem; margin-top: 0.5rem; }
.empty__text { color: var(--text-muted); margin-top: 0.25rem; }

/* ---------- Dialogs ---------- */

.dialog {
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
}
.dialog--sm { width: min(400px, calc(100vw - 2rem)); }

/* Compact New/Edit task dialog: header and actions stay pinned while the fields scroll */
.dialog--task {
  width: min(600px, calc(100vw - 2rem));
  max-height: min(88dvh, 800px);
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dialog--task .form { gap: 0.8rem; padding: 0 1.35rem; }
.dialog--task .dialog__header {
  position: sticky; top: 0; z-index: 5;
  padding: 1.05rem 0 0.35rem;
  background: var(--surface);
}
.dialog--task .dialog__header h2 { font-size: 1.15rem; }

/* New / Edit task heading */
.task-head { justify-content: flex-start; align-items: center; gap: 0.75rem; }
.task-head__icon {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  box-shadow: 0 6px 14px -6px rgb(79 70 229 / 0.6);
}
.task-head__text { flex: 1; min-width: 0; }
.task-head__text h2 { line-height: 1.2; letter-spacing: -0.01em; }
.task-head__sub { margin-top: 0.1rem; font-size: 0.8rem; color: var(--text-muted); }
.task-head__close {
  flex-shrink: 0; align-self: flex-start;
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.task-head__close svg { width: 16px; height: 16px; }
.task-head__close:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}
.task-head__close:active { transform: scale(0.94); }
.task-head__close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.dialog--task .task-title-input { font-size: 0.98rem; font-weight: 500; }
.dialog--task .task-title-input::placeholder { font-weight: 400; }
.dialog--task .dialog__footer {
  position: sticky; bottom: 0; z-index: 5;
  margin: 0.2rem -1.35rem 0;
  padding: 0.8rem 1.35rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.dialog--task .field { gap: 0.3rem; }
.dialog--task .field label, .dialog--task .field__label { font-size: 0.84rem; }
.dialog--task input:not([type="checkbox"]):not([type="file"]), .dialog--task select {
  min-height: 40px;
  padding-top: 0.45rem; padding-bottom: 0.45rem;
}
.dialog--task textarea { min-height: 76px; }
.label-optional { font-weight: 400; color: var(--text-muted); }

.task-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.8rem; }
.task-grid__half { grid-column: span 3; }
.task-grid__third { grid-column: span 2; }

/* One-tap due times under the date/time fields */
.quick-row { display: flex; align-items: flex-start; gap: 0.4rem; margin-top: 0.2rem; }
.quick-row__icon {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 7px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}
.time-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.time-chip {
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.time-chip:not(.is-active):hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); color: var(--primary); }
.time-chip.is-active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.time-chip.is-active:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.time-chip:disabled { opacity: 0.4; cursor: not-allowed; text-decoration: line-through; }

.dialog::backdrop { background: rgb(10 12 20 / 0.55); backdrop-filter: blur(2px); }
.dialog[open] { animation: dialog-in 0.18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dialog__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dialog__header h2 { font-size: 1.2rem; }
.dialog__body { display: flex; flex-direction: column; gap: 1rem; }
.dialog__footer { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.25rem; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 0.5rem 0; width: 100%; }

/* ---------- Links in descriptions ---------- */

.desc-link {
  color: var(--link);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.desc-link:hover { text-decoration-color: currentColor; }
.task-card.is-completed .desc-link { color: var(--text-muted); }
.link-copy {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  margin-left: 0.2rem;
  vertical-align: -0.3em;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.link-copy:hover { color: var(--link); border-color: var(--link); }
.link-copy.is-copied { color: var(--low-fg); background: var(--low-bg); border-color: transparent; }

/* ---------- Category picker (combobox) ---------- */

.combo { position: relative; }
.combo input { padding-right: 2.6rem; font-size: 0.88rem; font-weight: 500; }
.combo input::placeholder { font-weight: 400; }
.combo.has-lead input { padding-left: 2.15rem; }
.combo__lead {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  display: flex; color: var(--primary); pointer-events: none;
}
.combo__lead svg { width: 15px; height: 15px; }
.combo__toggle {
  position: absolute; top: 50%; right: 0.35rem; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  cursor: pointer;
  transition: transform 0.2s, color 0.15s, background-color 0.15s;
}
.combo__toggle:hover { color: var(--text); background: var(--surface-2); }
.combo.is-open .combo__toggle { transform: translateY(-50%) rotate(180deg); color: var(--primary); }

.combo__list {
  position: absolute; z-index: 20;
  top: calc(100% + 6px); left: 0;
  /* Wider than a narrow input so names and tags aren't squeezed */
  width: max(100%, 260px);
  max-width: calc(100vw - 2.5rem);
  max-height: 264px; overflow-y: auto;
  margin: 0; padding: 0.3rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgb(16 24 40 / 0.16), 0 2px 6px rgb(16 24 40 / 0.06);
  animation: combo-in 0.14s ease-out;
}
@keyframes combo-in { from { opacity: 0; transform: translateY(-4px); } }
.combo--up .combo__list { top: auto; bottom: calc(100% + 6px); animation-name: combo-in-up; }
@keyframes combo-in-up { from { opacity: 0; transform: translateY(4px); } }

.combo__option {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.45rem;
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.1s;
}
.combo__option:hover, .combo__option.is-active { background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.combo__option.is-active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent); }
.combo__option.is-selected .combo__label { font-weight: 700; }
.combo__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo__icon { display: inline-flex; vertical-align: -0.2em; margin-right: 0.5rem; color: var(--primary); }
.combo__icon svg { width: 15px; height: 15px; }
.combo__label mark { background: color-mix(in srgb, var(--primary) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.combo__count {
  min-width: 1.4rem; text-align: center;
  font-size: 0.68rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}
.combo__end { display: flex; align-items: center; gap: 0.3rem; }
.combo__check { color: var(--primary); font-weight: 800; margin-right: 0.15rem; }
.combo__option--create { grid-template-columns: auto minmax(0, 1fr); color: var(--primary); border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; margin-top: 0.25rem; }
.combo__option--create:first-child { border-top: 0; margin-top: 0; border-radius: 8px; }
.combo__plus {
  display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); color: var(--primary-contrast);
  font-weight: 800; font-size: 0.85rem; line-height: 1;
}
.combo__del, .combo__del-spacer { width: 24px; height: 24px; }
.combo__del {
  display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.12s, color 0.12s, background-color 0.12s;
}
.combo__del .btn__icon { width: 14px; height: 14px; }
.combo__option:hover .combo__del, .combo__option.is-active .combo__del, .combo__del:focus-visible { opacity: 1; }
.combo__del:hover { color: var(--danger); background: var(--danger-bg); opacity: 1; }
.combo__empty { padding: 0.75rem; color: var(--text-muted); font-size: 0.88rem; text-align: center; }

/* ---------- Styled selects ---------- */

.select { position: relative; }
.select__native {
  position: absolute !important; inset: 0;
  width: 100% !important; height: 100% !important;
  opacity: 0; pointer-events: none;
}
.select__trigger {
  width: 100%;
  min-height: 42px;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.4rem 0.6rem 0.4rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dialog--task .select__trigger { min-height: 40px; }
.select__trigger:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.select__trigger:focus-visible, .select.is-open .select__trigger {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
.select__chevron { flex-shrink: 0; color: var(--text-muted); transition: transform 0.2s, color 0.15s; }
.select.is-open .select__chevron { transform: rotate(180deg); color: var(--primary); }
.select__content { display: flex; align-items: center; min-width: 0; }
.select__content .badge { font-size: 0.78rem; padding: 0.2rem 0.6rem; }
/* Short option lists fit their own box (and must not overflow the dialog's right edge) */
.combo__list.select__list { width: 100%; min-width: 150px; }
/* Month names with the year ("November 2026") need more room than the box; it's the last filter, so open leftwards */
.select:has(#filter-month) .select__list { width: max-content; min-width: max(100%, 150px); left: auto; right: 0; }
.select__option { grid-template-columns: minmax(0, 1fr) auto; }

.status-opt { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; font-weight: 500; color: var(--text); }
.status-opt svg { flex-shrink: 0; }
.status-opt--pending svg { color: var(--text-muted); }
.status-opt--completed svg { color: var(--low-dot); }
.status-opt--all svg, .status-opt--sort svg, .status-opt--deleted svg { color: var(--text-muted); }
.status-opt--active svg { color: var(--primary); }
.status-opt--overdue svg { color: var(--danger); }
.status-opt--cat svg { color: var(--primary); }

/* ---------- Attachments ---------- */

.field__label { font-size: 0.875rem; font-weight: 600; }
.field__label-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.att-counter {
  font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.1rem 0.5rem; border-radius: 999px;
}
.att-counter.is-full { color: var(--medium-fg); background: var(--medium-bg); border-color: transparent; }

.dropzone {
  --dz-accent: var(--primary);
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.65rem 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  background: var(--surface-2);
  outline: 1.5px dashed color-mix(in srgb, var(--dz-accent) 30%, var(--border));
  outline-offset: -1.5px;
  transition: outline-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.dropzone:hover { outline-color: color-mix(in srgb, var(--dz-accent) 65%, var(--border)); background: color-mix(in srgb, var(--dz-accent) 5%, var(--surface-2)); }
.dropzone.is-dragover {
  outline: 2px solid var(--dz-accent);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--dz-accent) 10%, var(--surface));
  box-shadow: 0 6px 20px color-mix(in srgb, var(--dz-accent) 20%, transparent);
}
.dropzone.is-dragover .dropzone__badge { animation: dz-bounce 0.9s ease-in-out infinite; }
.dropzone.is-full { opacity: 0.55; pointer-events: none; }
@keyframes dz-bounce { 50% { transform: translateY(-3px); } }

.dropzone__badge {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--dz-accent);
  background: color-mix(in srgb, var(--dz-accent) 14%, var(--surface));
}
.dropzone__text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.dropzone__title { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.dropzone__title--drag { display: none; color: var(--dz-accent); }
.dropzone.is-dragover .dropzone__title--idle { display: none; }
.dropzone.is-dragover .dropzone__title--drag { display: inline; }
.dropzone__hint { font-size: 0.75rem; color: var(--text-muted); }
.dropzone__browse {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0.3rem 0.8rem;
  gap: 0.35rem;
  font-size: 0.82rem;
  background: var(--surface);
  color: var(--dz-accent);
  border: 1px solid color-mix(in srgb, var(--dz-accent) 40%, var(--border));
  border-radius: 999px;
}
.dropzone__browse:hover { background: var(--dz-accent); color: var(--primary-contrast); border-color: var(--dz-accent); }
.dropzone kbd {
  display: inline-block; min-width: 1.5em;
  margin: 0 0.05rem;
  padding: 0 0.3rem;
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-family: inherit; font-weight: 700; font-size: 0.7rem; line-height: 1.5; text-align: center; color: var(--text);
  vertical-align: 0.05em;
}
.link-btn {
  padding: 0; border: 0; background: none;
  color: var(--link); font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer;
}

.att-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.att-list:empty { display: none; }
.att-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.att-item--new { border-style: dashed; border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.att-item__thumb {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 1.25rem;
  overflow: hidden;
}
.att-item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-item__info { display: flex; flex-direction: column; min-width: 0; }
.att-item__name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-item__meta { font-size: 0.78rem; color: var(--text-muted); }
.att-item__new { color: var(--primary); font-weight: 700; }
.att-item__remove { width: 34px; min-height: 34px; font-size: 0.9rem; }
.att-item__actions { display: flex; gap: 0.4rem; }
.att-list--detail .att-item__thumb { width: 48px; height: 48px; }
.chip--att { font-variant-numeric: tabular-nums; }

/* ---------- Task details ---------- */

.dialog--detail { width: min(620px, calc(100vw - 2rem)); padding: 0; overflow: hidden; }
.detail { display: flex; flex-direction: column; gap: 1.1rem; padding: 1.5rem; border-top: 5px solid var(--medium-dot); }
.detail--high { border-top-color: var(--high-dot); }
.detail--low { border-top-color: var(--low-dot); }
.detail.is-overdue { border-top-color: var(--overdue-border); }
.detail.is-completed { border-top-color: var(--border); }
.detail__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.detail__heading { min-width: 0; }
.detail__title { font-size: 1.35rem; overflow-wrap: anywhere; }
.detail.is-completed .detail__title { text-decoration: line-through; color: var(--text-muted); }
.detail__heading .task-card__time { margin-top: 0.5rem; }

.detail__notice {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.9rem;
}
.detail__notice--danger { background: var(--danger-bg); color: var(--danger); font-weight: 600; }

.detail__label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.35rem; }
.detail__desc {
  white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 40vh; overflow-y: auto;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.detail__grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1.25rem;
  margin: 0;
}
.detail__row { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.detail__row dt { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.detail__row dd { margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; font-size: 0.92rem; }
.detail__sub { font-size: 0.8rem; color: var(--text-muted); }
.detail__overdue { color: var(--danger); font-weight: 700; }

.detail__footer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.detail__spacer { flex: 1; }
.detail__footer .btn { min-height: 44px; padding: 0.55rem 1.1rem; gap: 0.5rem; line-height: 1; border-radius: 10px; }

/* ---------- Clock time picker ---------- */

.time-field {
  width: 100%;
  min-height: 42px;
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.45rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dialog--task .time-field { min-height: 40px; }
.time-field:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.time-field:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.time-field svg { flex-shrink: 0; width: 17px; height: 17px; color: var(--primary); }
.time-field__value {
  min-width: 0;
  font-size: 0.93rem; font-weight: 500; letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.time-field__hint {
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.7rem; font-weight: 600;
  white-space: nowrap;
}
.time-field__hint.is-today { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); }
.time-field__hint.is-past { background: var(--danger-bg); color: var(--danger); }
.time-field__value.is-placeholder { color: var(--text-muted); }

.clock-dialog { width: min(264px, calc(100vw - 2rem)); padding: 0; overflow: hidden; }
.clock__header {
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  padding: 0.8rem 1rem;
  background: var(--primary);
  color: var(--primary-contrast);
}
.clock__time { display: flex; align-items: center; font-size: 2.5rem; font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.clock__colon { opacity: 0.6; padding: 0 0.05em; }
.clock__seg {
  padding: 0.1rem 0.2rem; border: 0; border-radius: 8px;
  background: transparent; color: inherit;
  font: inherit;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.15s, background-color 0.15s;
}
.clock__seg:hover { background: rgb(255 255 255 / 0.12); }
.clock__seg.is-active { opacity: 1; }
.clock__ampm { display: flex; flex-direction: column; gap: 0.15rem; }
.clock__period {
  padding: 0.15rem 0.4rem; border: 0; border-radius: 6px;
  background: transparent; color: inherit;
  font: inherit; font-size: 0.8rem; font-weight: 600;
  opacity: 0.55;
  cursor: pointer;
}
.clock__period:hover { background: rgb(255 255 255 / 0.12); }
.clock__period.is-active { opacity: 1; font-weight: 800; }

.clock__body { display: grid; place-items: center; padding: 1rem 0.75rem 0.25rem; }
.clock__face {
  position: relative;
  width: 208px; height: 208px; /* CLOCK_SIZE in app.js */
  border-radius: 50%;
  background: var(--surface-2);
  touch-action: none;
  user-select: none;
  cursor: pointer;
}
.clock__face:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.clock__hand {
  position: absolute; left: 50%; bottom: 50%;
  width: 2px; height: 80px; /* CLOCK_RADIUS in app.js */
  background: var(--primary);
  transform-origin: bottom center;
  transition: transform 0.12s ease;
  z-index: 1;
}
.clock__knob {
  position: absolute;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  transform: translate(-50%, -50%);
  transition: left 0.12s ease, top 0.12s ease, width 0.12s, height 0.12s;
  z-index: 1;
}
.clock__knob.is-small { width: 10px; height: 10px; }
.clock__center {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
  transform: translate(-50%, -50%);
  z-index: 1;
}
.clock__num {
  position: absolute;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  transform: translate(-50%, -50%);
  font-size: 0.85rem; font-variant-numeric: tabular-nums;
  color: var(--text);
  pointer-events: none;
  z-index: 2;
}
.clock__num.is-selected { color: var(--primary-contrast); font-weight: 700; }

.clock__footer { display: flex; align-items: center; gap: 0.1rem; padding: 0.35rem 0.5rem 0.55rem; }
.clock__spacer { flex: 1; }
.clock__btn { color: var(--primary); font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; font-size: 0.78rem; min-height: 34px; padding: 0.3rem 0.6rem; }
.clock__btn--muted { color: var(--text-muted); }

/* ---------- Calendar date picker ---------- */

.cal-dialog { width: min(264px, calc(100vw - 2rem)); } /* same width as the clock */
.cal__header { flex-direction: column; align-items: flex-start; gap: 0.1rem; padding: 0.7rem 1rem; }
.cal__year {
  padding: 0.05rem 0.3rem; margin-left: -0.3rem;
  border: 0; border-radius: 6px;
  background: transparent; color: inherit;
  font: inherit; font-size: 0.8rem; font-weight: 600;
  opacity: 0.7;
  cursor: pointer;
}
.cal__year:hover { background: rgb(255 255 255 / 0.14); opacity: 1; }
.cal__year.is-active { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }
.cal__date { font-size: 1.5rem; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }

.cal__nav { display: flex; align-items: center; justify-content: space-between; gap: 0.2rem; padding: 0.45rem 0.45rem 0.1rem; }
.cal__label {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 0.85rem; font-weight: 700;
  cursor: pointer;
}
.cal__label:hover { background: var(--surface-2); }
.cal__label svg { color: var(--text-muted); }
.cal__arrow {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-muted);
  cursor: pointer;
}
.cal__arrow:hover { background: var(--surface-2); color: var(--primary); }

.cal__body { padding: 0.15rem 0.5rem 0.3rem; }
.cal__body--days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 2px; justify-items: center; }
.cal__weekday { width: 32px; padding: 0.25rem 0; text-align: center; font-size: 0.68rem; font-weight: 700; color: var(--text-muted); }
.cal__day {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--text);
  font: inherit; font-size: 0.8rem; font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}
.cal__day:hover { background: var(--surface-2); }
.cal__day.is-outside { color: var(--text-muted); opacity: 0.55; }
.cal__day.is-today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary); font-weight: 700; }
.cal__day.is-selected { background: var(--primary); color: var(--primary-contrast); font-weight: 700; box-shadow: none; opacity: 1; }
.cal__day:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.cal__body--months, .cal__body--years { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; padding: 0.5rem 0.7rem; }
.cal__cell {
  padding: 0.55rem 0.2rem;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
}
.cal__cell:hover { background: var(--surface-2); }
.cal__cell.is-today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary); }
.cal__cell.is-selected { background: var(--primary); color: var(--primary-contrast); box-shadow: none; }

/* Compact task details popup */
.dialog--detail.dialog--detail { width: min(540px, calc(100vw - 2rem)); }
.detail.detail { gap: 0.85rem; padding: 1.15rem 1.25rem 1.1rem; border-top-width: 4px; }
.detail .detail__title { font-size: 1.15rem; }
.detail .detail__heading .task-card__time { margin-top: 0.35rem; }
.detail .detail__label { font-size: 0.68rem; margin-bottom: 0.3rem; }
.detail .detail__desc { padding: 0.6rem 0.75rem; font-size: 0.88rem; }
.detail .detail__grid { gap: 0.7rem 1rem; }
.detail .detail__row dt { font-size: 0.68rem; }
.detail .detail__row dd { font-size: 0.85rem; }
.detail .detail__sub { font-size: 0.75rem; }
.detail .detail__notice { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
.detail .status-trigger { height: 36px; min-width: 150px; }
.detail .detail__footer { padding-top: 0.8rem; gap: 0.5rem; }
.detail .detail__footer .btn { min-height: 38px; padding: 0.4rem 0.9rem; font-size: 0.88rem; border-radius: 9px; }
.detail .detail__footer .btn__icon { width: 16px; height: 16px; }
.detail .att-item__thumb { width: 40px; height: 40px; }

/* ---------- Confirmation dialog ---------- */

.dialog.confirm { width: min(420px, calc(100vw - 2rem)); padding: 0; overflow: hidden; border-radius: 18px; }
.confirm[open] { animation: confirm-in 0.18s ease-out; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } }
.confirm__body { display: flex; align-items: flex-start; gap: 0.9rem; padding: 1.25rem 1.3rem 1.1rem; }
.confirm__icon {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--danger);
  background: var(--danger-bg);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger-bg) 55%, transparent);
}
.confirm__copy { min-width: 0; padding-top: 0.1rem; }
.confirm__copy h2 { font-size: 1.08rem; line-height: 1.3; letter-spacing: -0.01em; }
.confirm__copy p { margin-top: 0.3rem; font-size: 0.88rem; line-height: 1.5; color: var(--text-muted); }
.confirm__footer {
  display: flex; justify-content: flex-end; gap: 0.6rem;
  padding: 0.8rem 1.3rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.confirm__footer .btn { min-height: 38px; padding: 0.4rem 1rem; border-radius: 10px; font-size: 0.88rem; }
.confirm__cancel { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.confirm__cancel:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text-muted) 40%, var(--border)); }
.confirm__ok { gap: 0.4rem; box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--danger) 60%, transparent); }
@media (max-width: 600px) {
  .confirm__footer { flex-direction: column-reverse; }
  .confirm__footer .btn { width: 100%; }
}

/* Polished task details */
.detail .detail__header { align-items: flex-start; gap: 0.8rem; }
.detail__badge {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 6px 14px -6px rgb(217 119 6 / 0.6);
}
.detail__badge--high { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 6px 14px -6px rgb(185 28 28 / 0.6); }
.detail__badge--low { background: linear-gradient(135deg, #22c55e, #15803d); box-shadow: 0 6px 14px -6px rgb(21 128 61 / 0.6); }
.detail .detail__heading { flex: 1; }
.detail .detail__title { font-size: 1.12rem; line-height: 1.3; letter-spacing: -0.01em; }
.detail__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.4rem; }
.detail__meta .chip--time { font-size: 0.72rem; }
.detail__cat {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--primary);
  font-size: 0.72rem; font-weight: 700;
}
.detail__cat svg { width: 13px; height: 13px; }
.detail__cat--plain { font-size: 0.8rem; }
.detail__close {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text-muted);
  cursor: pointer;
}
.detail__close:hover { background: var(--surface-2); color: var(--text); }

.detail .detail__desc {
  position: relative;
  padding: 0.65rem 0.8rem 0.65rem 0.95rem;
  border-radius: 10px;
  background: var(--surface-2);
}
.detail .detail__desc::before {
  content: ""; position: absolute; left: 0; top: 0.5rem; bottom: 0.5rem; width: 3px; border-radius: 3px;
  background: color-mix(in srgb, var(--primary) 60%, transparent);
}

.detail .detail__grid { gap: 0.55rem; }
.detail .detail__row {
  flex-direction: row; align-items: flex-start; gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.detail__row-icon {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}
.detail__row--priority .detail__row-icon { color: var(--medium-fg); background: var(--medium-bg); }
.detail__row--due .detail__row-icon { color: #0369a1; background: #e0f2fe; }
.detail__row--created .detail__row-icon, .detail__row--updated .detail__row-icon { color: var(--text-muted); background: var(--surface-2); }
.detail__row--deleted .detail__row-icon { color: var(--danger); background: var(--danger-bg); }
:root[data-theme="dark"] .detail__row--due .detail__row-icon { color: #7dd3fc; background: #0c2a3d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .detail__row--due .detail__row-icon { color: #7dd3fc; background: #0c2a3d; } }
.detail__row-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.detail .detail__row dd { gap: 0.25rem; }
.detail .status-trigger { height: 32px; min-width: 140px; }

.detail__pill { display: inline-block; padding: 0.08rem 0.45rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; }
.detail__pill--later { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.detail__pill--soon { color: var(--medium-fg); background: var(--medium-bg); }
.detail__pill--overdue { color: var(--danger); background: var(--danger-bg); }

/* Details footer buttons */
.detail .detail__footer .btn {
  min-height: 40px;
  padding: 0.45rem 1.05rem;
  gap: 0.45rem;
  border-radius: 11px;
  font-weight: 700; font-size: 0.88rem; letter-spacing: 0.005em;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background-color 0.15s, color 0.15s, border-color 0.15s, filter 0.15s;
}
.detail .detail__footer .btn:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.detail .detail__footer .btn__icon { width: 16px; height: 16px; }

/* Delete / Delete forever: soft red */
.detail .detail__footer .btn--danger-outline {
  background: var(--danger-bg);
  border: 1px solid transparent;
  color: var(--danger);
}
.detail .detail__footer .btn--danger-outline:hover {
  background: color-mix(in srgb, var(--danger) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

/* Mark complete: the main action */
.detail .detail__footer .btn--success {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  border: 0;
  color: #fff;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.2) inset, 0 6px 16px -6px rgb(22 163 74 / 0.7);
}
.detail .detail__footer .btn--success:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.2) inset, 0 10px 20px -8px rgb(22 163 74 / 0.75);
}

/* Mark as pending (completed tasks) */
.detail .detail__footer .btn--outline { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.detail .detail__footer .btn--outline:hover { background: var(--surface-2); }

/* Edit: soft purple */
.detail .detail__footer [data-detail-action="edit"] {
  background: color-mix(in srgb, var(--primary) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  color: var(--primary);
}
.detail .detail__footer [data-detail-action="edit"]:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
}

/* Restore (deleted tasks): solid purple */
.detail .detail__footer [data-detail-action="restore"] {
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
  border: 0; color: #fff;
  box-shadow: 0 6px 16px -6px rgb(79 70 229 / 0.6);
}
.detail .detail__footer [data-detail-action="restore"]:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 1000;
  display: flex; flex-direction: column; gap: 0.5rem;
  max-width: calc(100vw - 2rem);
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-md);
  font-weight: 500; font-size: 0.9rem;
  animation: toast-in 0.2s ease-out;
}
.toast { display: flex; align-items: center; gap: 1rem; }
.toast__action {
  margin-left: auto;
  border: 0; background: transparent;
  color: inherit; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px;
  padding: 0.15rem 0.25rem; border-radius: 4px;
  cursor: pointer;
}
.toast__action:hover { opacity: 0.8; }
.toast__action:focus-visible { outline-color: var(--bg); }
.toast--success { border-left: 4px solid var(--low-dot); }
.toast--error { border-left: 4px solid var(--high-dot); }
.toast.is-leaving { animation: toast-out 0.2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsive ---------- */

/* ---------- Laptop & desktop: denser type, sidebar layout ---------- */

@media (min-width: 900px) {
  html { font-size: 15px; }
  .topbar { padding-top: 0.55rem; padding-bottom: 0.55rem; }
  .brand { font-size: 1.1rem; }
  .brand__logo { width: 30px; height: 30px; font-size: 1rem; }
  .container { padding-top: 1.4rem; }
  .hero { margin-bottom: 1rem; }
  .hero h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
  .hero__sub { font-size: 0.9rem; }
  .btn { min-height: 38px; }
  .toolbar { padding: 0.85rem; gap: 0.7rem; margin-bottom: 1rem; }
  .task-list { gap: 0.6rem; }
  .task-card { padding: 0.8rem 0.9rem 0.8rem 0.85rem; gap: 0.75rem; }
  .task-card__title { font-size: 0.98rem; }
  .task-card__desc { font-size: 0.92rem; }
}

/* Tablet / small laptop: stats on top, Today and Upcoming side by side, then the list */
@media (min-width: 700px) and (max-width: 1199px) {
  .layout {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-areas: "stats stats" "today upcoming" "note upcoming" "list list";
    align-items: start;
  }
  .layout:has(.reminders[hidden]) .today,
  .layout:has(.reminders[hidden]) .note { grid-column: 1 / -1; }
}

/* Laptop & desktop: Upcoming | stats + tasks | Today */
@media (min-width: 1200px) {
  .container { max-width: 1440px; }
  .layout {
    grid-template-columns: 280px minmax(0, 1fr) 290px;
    grid-template-rows: auto 1fr;
    grid-template-areas: "upcoming stats today" "upcoming list today";
    align-items: start;
    gap: 1.1rem;
  }
  .layout__upcoming, .layout__today {
    display: flex; flex-direction: column; gap: 1rem;
    min-width: 0;
    position: sticky; top: 72px;
    max-height: calc(100dvh - 88px);
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .layout__today { grid-area: today; }
  .layout__upcoming { grid-area: upcoming; }
  /* Six stat cards share the middle column: keep every label on one line */
  .layout__stats { gap: 0.5rem; }
  .layout__stats .stat { padding: 0.6rem 0.6rem 0.65rem 0.7rem; }
  .layout__stats .stat__top { gap: 0.25rem; }
  .layout__stats .stat__label { font-size: 0.74rem; }
  .layout__stats .stat__icon { width: 22px; height: 22px; border-radius: 6px; }
  .layout__stats .stat__icon svg { width: 13px; height: 13px; }

  /* Narrow side column: stack the "Next up" card and use two-line upcoming rows */
  .layout__upcoming .reminders { gap: 0.6rem; }
  .layout__upcoming .reminders__header { flex-wrap: wrap; row-gap: 0.1rem; }
  .layout__upcoming .next-up { grid-template-columns: minmax(0, 1fr) auto; gap: 0.45rem 0.6rem; padding: 0.75rem 0.85rem; }
  .layout__upcoming .next-up__label { grid-column: 1 / -1; justify-self: start; font-size: 0.65rem; }
  .layout__upcoming .next-up__title { font-size: 0.95rem; white-space: normal; }
  .layout__upcoming .next-up__meta { font-size: 0.78rem; }
  .layout__upcoming .next-up__countdown { font-size: 0.85rem; align-self: start; }
  .layout__upcoming .upcoming-item { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 0.1rem; padding: 0.5rem 0.25rem; }
  .layout__upcoming .upcoming-item__dot { grid-row: 1 / span 2; }
  .layout__upcoming .upcoming-item__title { font-size: 0.88rem; }
  .layout__upcoming .upcoming-item__when { grid-column: 2; grid-row: 2; font-size: 0.74rem; }
  .layout__upcoming .upcoming-item__rel { grid-column: 3; grid-row: 1 / span 2; font-size: 0.75rem; min-width: 0; }

  /* Middle column is narrower: slightly smaller (still equal) card actions */
  .layout__list .task-card__actions .status-trigger,
  .layout__list .task-card__actions .card-btn { width: 128px; }
}


@media (max-width: 860px) {
  .trash-banner { flex-direction: column; align-items: stretch; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .user-btn__name { display: none; }
  .user-btn { padding: 0.25rem; }
  .logout-btn { padding: 0.4rem 0.7rem; }
  .hero { flex-direction: column; align-items: stretch; }
  .hero .btn { width: 100%; } /* full-width New task button on phones */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { gap: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .task-card { grid-template-columns: auto minmax(0, 1fr); }
  .task-card__actions { grid-column: 1 / -1; grid-row: auto; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 0.6rem; }
  .task-card__today { grid-column: 1 / -1; grid-row: auto; justify-self: end; }
  .task-card__actions .status-trigger { padding: 0 0.4rem 0 0.5rem; gap: 0.25rem; }
  .task-card__actions .status-trigger .status-opt { gap: 0.3rem; font-size: 0.8rem; }
  .task-card__actions .status-trigger .select__chevron { width: 14px; height: 14px; }
  /* A grid (not flex) so padding differences can't make one control wider than the others */
  .task-card__actions { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); }
  .task-card__actions .status-trigger,
  .task-card__actions .card-btn { width: 100%; height: 40px; }
  .dropzone { gap: 0.6rem; }
  .dropzone__hint { display: none; }
  .att-list--detail .att-item { grid-template-columns: auto minmax(0, 1fr); }
  .att-list--detail .att-item__actions { grid-column: 1 / -1; justify-content: flex-end; }
  .dialog { padding: 1.25rem; }
  .dialog--detail { padding: 0; }
  .dialog--task { padding: 0; max-height: 92dvh; }
  .dialog--task .form { padding: 0 1rem; }
  .dialog--task .dialog__footer { margin: 0.2rem -1rem 0; padding: 0.75rem 1rem 0.9rem; }
  .task-grid__third { grid-column: span 3; }
  .task-grid__category { grid-column: 1 / -1; } /* Category gets its own row */
  .quick-row__icon { display: none; } /* half-width columns are too narrow for the icon */
  .time-field__hint { display: none; } /* keep room for the date itself */
  .detail { padding: 1.25rem; }
  .detail__grid { grid-template-columns: 1fr 1fr; }
  .detail__footer .btn { flex: 1 1 auto; }
  .detail__spacer { display: none; }
  .next-up { grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem 0.75rem; }
  .next-up__label { grid-column: 1 / -1; justify-self: start; }
  .upcoming-item { grid-template-columns: auto minmax(0, 1fr) auto; }
  .upcoming-item__rel { display: none; }
}

@media (max-width: 380px) {
  .filters { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Task details: the description is the focus, the other fields are a compact secondary panel */
.detail .detail__desc {
  font-size: 1rem; line-height: 1.6; color: var(--text);
  padding: 0.9rem 1rem 0.9rem 1.15rem;
  min-height: 4.5rem; max-height: 45vh;
  background: color-mix(in srgb, var(--primary) 5%, var(--surface-2));
}
.detail .detail__desc::before { top: 0.6rem; bottom: 0.6rem; width: 4px; background: var(--primary); }
.detail .detail__desc.muted { color: var(--text-muted); font-style: italic; }
.detail .detail__label--info { margin: 0.2rem 0 -0.45rem; }
.detail .detail__grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.15rem 0.5rem;
  padding: 0.45rem 0.5rem;
  border-radius: 12px;
  background: var(--surface-2);
}
.detail .detail__row { border: 0; background: transparent; padding: 0.4rem 0.35rem; gap: 0.45rem; }
.detail .detail__row-icon { width: 20px; height: 20px; border-radius: 6px; }
.detail .detail__row-icon svg { width: 12px; height: 12px; }
.detail .detail__row dt { font-size: 0.62rem; }
.detail .detail__row dd { font-size: 0.78rem; color: var(--text-muted); }
.detail .detail__sub { font-size: 0.7rem; }
.detail .detail__row .badge, .detail .detail__cat--plain { font-size: 0.72rem; }
.detail .status-trigger { height: 28px; min-width: 0; max-width: 100%; font-size: 0.78rem; padding-inline: 0.5rem; }
@media (max-width: 560px) {
  .detail .detail__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Greeting: the user's name in brand purple */
.greeting__name {
  background: linear-gradient(135deg, #3730a3, #5b21b6);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
:root[data-theme="dark"] .greeting__name { background-image: linear-gradient(135deg, #a5b4fc, #c4b5fd); }

/* Top bar content lines up with the centred page container */
.topbar {
  --bar-gutter: clamp(1rem, 4vw, 2rem);
  padding-inline: max(var(--bar-gutter), calc((100% - 1240px) / 2 + var(--bar-gutter)));
}
@media (min-width: 1200px) {
  .topbar { padding-inline: max(var(--bar-gutter), calc((100% - 1440px) / 2 + var(--bar-gutter))); }
}

/* Top bar: soft purple tint instead of plain white */
.topbar {
  background:
    linear-gradient(90deg, color-mix(in srgb, #7c6cf0 34%, transparent), color-mix(in srgb, #9b6cf6 30%, transparent)),
    color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

/* Filters: Status, Priority, Category, Month, Sort */
/* Columns follow the toolbar's own width, so labels like "Newest first" never get cut off */
.toolbar { container-type: inline-size; }
.toolbar .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.toolbar .filters > :last-child { grid-column: 1 / -1; }
@container (min-width: 440px) {
  .toolbar .filters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .toolbar .filters > * { grid-column: span 2; }
  .toolbar .filters > :nth-child(n + 4) { grid-column: span 3; }
}
@container (min-width: 700px) {
  .toolbar .filters { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .toolbar .filters > *, .toolbar .filters > :nth-child(n + 4) { grid-column: auto; }
}
.select__content .status-opt { min-width: 0; }
.select__content .status-opt > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar .select__trigger { padding-inline: 0.6rem 0.45rem; gap: 0.3rem; }

/* Greeting: small "Good morning" label over the name, date and counts as chips aligned with the text */
.hero { --greet-icon: 52px; --greet-gap: 0.85rem; }
#greeting { gap: var(--greet-gap); align-items: center; }
#greeting .greeting__icon { width: var(--greet-icon); height: var(--greet-icon); border-radius: 14px; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent); }
#greeting .greeting__icon svg { width: 26px; height: 26px; }
.greeting__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.greeting__hello {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted);
}
.greeting__name {
  display: block; margin-top: 0.2rem;
  font-size: clamp(1.35rem, 2.6vw, 1.75rem); font-weight: 800; letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero__sub#summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  margin-top: 0.7rem; margin-left: calc(var(--greet-icon) + var(--greet-gap));
  font-size: 0.82rem;
}
.summary__short { display: none; }
@media (max-width: 600px) { .summary__short { display: inline; } }
.summary__date { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--text-muted); font-weight: 500; margin-right: 0.2rem; }
.summary__pill {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600;
  color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
}
.summary__pill--danger { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

@media (max-width: 600px) {
  .hero { --greet-icon: 44px; --greet-gap: 0.7rem; }
  #greeting .greeting__icon { border-radius: 12px; }
  #greeting .greeting__icon svg { width: 22px; height: 22px; }
  .greeting__name { font-size: min(1.35rem, 4.6vw); letter-spacing: 0; }
  .hero__sub#summary { margin-top: 0.5rem; gap: 0.3rem; font-size: 0.76rem; }
  .summary__date { gap: 0.25rem; margin-right: 0.1rem; }
  .summary__date svg { width: 12px; height: 12px; }
  .summary__pill { padding: 0.1rem 0.45rem; font-size: 0.7rem; }
  .summary__long { display: none; }
}

/* Phones: Log out becomes an icon button so the top bar fits */
@media (max-width: 600px) {
  .logout-btn { width: 38px; padding: 0; justify-content: center; margin-left: 0; }
  .logout-btn__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Phones: the four stat boxes form a 2 × 2 grid */
@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
  .stats .stat { padding: 0.45rem 0.7rem 0.5rem; gap: 0.1rem; border-radius: 12px; }
  .stats .stat__top { gap: 0.3rem; }
  .stats .stat__num { font-size: 1.25rem; line-height: 1.2; }
}

/* ---------- Filters panel ---------- */
.toolbar.toolbar {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--primary) 7%, var(--surface)), var(--surface) 70%);
  border-color: color-mix(in srgb, var(--primary) 20%, var(--border));
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 8px 24px -16px color-mix(in srgb, var(--primary) 45%, transparent);
  padding: 0.8rem;
}
.toolbar .search { display: flex; align-items: center; gap: 0.5rem; }
.toolbar .search input {
  flex: 1; min-width: 0; min-height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border-color: color-mix(in srgb, var(--primary) 22%, var(--border));
  transition: border-color 0.15s, box-shadow 0.15s;
}
.toolbar .search input:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.toolbar .search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.toolbar .search__icon { color: var(--primary); }
.toolbar__clear {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 0.35rem;
  min-height: 40px; padding: 0 0.85rem;
  font: inherit; font-size: 0.8rem; font-weight: 600;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.toolbar__clear:hover { color: var(--primary-contrast); background: var(--primary); }
.toolbar__clear[hidden] { display: none; }

.toolbar .field--inline label {
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.08em;
  color: color-mix(in srgb, var(--primary) 70%, var(--text-muted));
}
.toolbar .select__trigger {
  min-height: 38px; border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s, transform 0.1s;
}
.toolbar .select__trigger:hover {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
  box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--primary) 45%, transparent);
}
.toolbar .select__trigger .select__chevron { color: color-mix(in srgb, var(--primary) 60%, var(--text-muted)); }
/* A filter in use is highlighted (Sort always has a value, so it is left out) */
.toolbar .select:has(select:not(#sort) option:checked:not([value=""])) .select__trigger {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
}
.toolbar .select:has(select:not(#sort) option:checked:not([value=""])) .status-opt > span { color: var(--primary); font-weight: 600; }
@media (max-width: 600px) {
  .toolbar__clear { padding: 0 0.65rem; }
}

/* Today's Tasks stat */
.stat--today .stat__icon { color: #c2410c; background: #ffedd5; }
:root[data-theme="dark"] .stat--today .stat__icon { color: #fdba74; background: #431407; }
.status-opt--today svg { color: #ea580c; }
/* All stat boxes are the same size; slightly tighter spacing lets "Today's Tasks" fit on one line */
.stats .stat__top { gap: 0.25rem; }
.stats .stat__icon { width: 22px; height: 22px; border-radius: 6px; }
.stats .stat__icon svg { width: 13px; height: 13px; }
@media (min-width: 1200px) {
  .layout__stats .stat { padding-inline: 0.6rem 0.5rem; }
  .layout__stats .stat__label { font-size: 0.72rem; }
}
@media (max-width: 600px) {
  .stats .stat__label { font-size: 0.8rem; }
}

/* Phones: compact Today card, clock and progress side by side */
@media (max-width: 600px) {
  .today.side-card {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-areas: "head head" "now main" "add add";
    column-gap: 0.6rem;
    padding: 0.75rem;
  }
  .today > .side-card__header { grid-area: head; }
  .today .today__now { grid-area: now; margin-top: 0.45rem; padding: 0.55rem 0.4rem; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
  .today .today__time { font-size: 1.35rem; }
  .today .today__ampm { font-size: 0.6rem; margin-top: 0.1rem; }
  .today .today__day { margin-top: 0.4rem; padding-top: 0.35rem; min-width: 70px; font-size: 0.6rem; letter-spacing: 0.12em; }
  .today .today__fulldate { margin-top: 0.15rem; font-size: 0.78rem; }
  .today .today__main { grid-area: main; margin: 0.45rem 0 0; gap: 0.55rem; align-self: center; }
  .today .ring { width: 48px; height: 48px; }
  .today .ring__label { font-size: 0.72rem; }
  .today .today__count { font-size: 0.8rem; }
  .today .today__msg { font-size: 0.7rem; }
  .today .today__add { grid-area: add; margin: 0.6rem 0 0; padding: 0.4rem; font-size: 0.78rem; }
}

/* Compact task cards so more fit on screen (details live in the popup) */
.task-list { gap: 0.5rem; }
.task-card.task-card { padding: 0.65rem 0.8rem 0.65rem 0.75rem; column-gap: 0.7rem; row-gap: 0.4rem; border-radius: 12px; }
.task-card .task-card__title { font-size: 0.98rem; }
.task-card .task-card__time { display: none; } /* "Added …" is in the details popup */
.task-card .task-card__desc {
  margin-top: 0.15rem; font-size: 0.84rem;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.task-card .task-card__meta { margin-top: 0.35rem; gap: 0.3rem; }
.task-card .task-card__meta .badge, .task-card .task-card__meta .chip { font-size: 0.7rem; padding: 0.1rem 0.45rem; }
.task-card .task-card__meta .badge--status { display: none; } /* the status menu shows it */
.task-card .chip__rel { display: none; }
.task-card .task-card__today { padding: 0.1rem 0.45rem; font-size: 0.68rem; }
.task-card .task-card__today svg { width: 11px; height: 11px; }
/* Slim controls: status menu, then icon-only Edit and Delete */
.task-list .task-card .task-card__actions { display: flex; align-items: center; gap: 0.35rem; }
.task-list .task-card .task-card__actions .status-trigger { width: auto; min-width: 0; height: 32px; min-height: 32px; flex: 0 1 auto; padding: 0 0.45rem 0 0.55rem; border-radius: 8px; }
.task-list .task-card .task-card__actions .status-opt { font-size: 0.8rem; }
.task-list .task-card .task-card__actions .status-opt svg { width: 14px; height: 14px; }
.task-list .task-card .task-card__actions .card-btn { width: 32px; height: 32px; min-height: 32px; padding: 0; justify-content: center; border-radius: 8px; }
.task-list .task-card .task-card__actions .card-btn svg { width: 15px; height: 15px; }
.task-card .card-btn__label { display: none; }
/* Room for the controls and the Today badge stacked on the right */
@media (min-width: 601px) {
  .task-card:has(.task-card__today) .task-card__body { min-height: 62px; }
}

@media (max-width: 600px) {
  .task-card.task-card { padding: 0.6rem 0.65rem 0.6rem 0.6rem; column-gap: 0.55rem; }
  .task-card .task-card__title { font-size: 0.95rem; }
  .task-card .task-card__desc { font-size: 0.82rem; }
  .task-card .task-card__meta { gap: 0.25rem; }
  .task-card .task-card__meta .badge, .task-card .task-card__meta .chip { font-size: 0.68rem; padding: 0.1rem 0.4rem; }
  /* Today badge sits at the right end of the action row */
  .task-card .task-card__today { position: absolute; bottom: calc(0.6rem + 6px); right: 0.65rem; font-size: 0.66rem; }
  .task-list .task-card .task-card__actions { grid-column: 2; justify-content: flex-start; border-top: 0; padding-top: 0; }
  .task-list .task-card .task-card__actions .status-trigger { height: 30px; min-height: 30px; padding: 0 0.4rem 0 0.5rem; }
  .task-list .task-card .task-card__actions .status-opt { font-size: 0.76rem; }
  .task-list .task-card .task-card__actions .status-opt svg { width: 13px; height: 13px; }
  .task-list .task-card .task-card__actions .card-btn { width: 30px; height: 30px; min-height: 30px; }
  .task-list .task-card .task-card__actions .card-btn svg { width: 14px; height: 14px; }
}

/* Task details: each property is its own small tile with a coloured icon */
.detail .detail__grid { gap: 0.5rem; padding: 0.5rem; background: color-mix(in srgb, var(--primary) 5%, var(--surface-2)); }
.detail .detail__row {
  padding: 0.6rem 0.65rem; gap: 0.55rem;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--primary) 10%, var(--border));
  border-radius: 10px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.detail .detail__row:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); box-shadow: 0 4px 12px -8px color-mix(in srgb, var(--primary) 50%, transparent); }
.detail .detail__row-icon { width: 26px; height: 26px; border-radius: 8px; }
.detail .detail__row-icon svg { width: 14px; height: 14px; }
.detail__row--status .detail__row-icon { color: #4f46e5; background: #e0e7ff; }
.detail__row--category .detail__row-icon { color: #7c3aed; background: #ede9fe; }
.detail__row--created .detail__row-icon { color: #15803d; background: #dcfce7; }
.detail__row--updated .detail__row-icon { color: #0f766e; background: #ccfbf1; }
:root[data-theme="dark"] .detail__row--status .detail__row-icon { color: #a5b4fc; background: #1e1b4b; }
:root[data-theme="dark"] .detail__row--category .detail__row-icon { color: #c4b5fd; background: #2e1065; }
:root[data-theme="dark"] .detail__row--created .detail__row-icon { color: #86efac; background: #052e16; }
:root[data-theme="dark"] .detail__row--updated .detail__row-icon { color: #5eead4; background: #042f2e; }
.detail .detail__row dt { font-size: 0.6rem; letter-spacing: 0.08em; }
.detail .detail__row dd { color: var(--text); gap: 0.3rem; }
.detail__date { font-size: 0.8rem; font-weight: 650; color: var(--text); }
.detail__clock {
  display: inline-flex; align-items: center;
  padding: 0.05rem 0.4rem; border-radius: 6px;
  font-size: 0.7rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--text-muted); background: var(--surface-2);
}
.detail .detail__sub { font-size: 0.68rem; }
.detail__when { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.35rem; }
.detail .detail__row .status-trigger { min-width: 0; max-width: 100%; height: 30px; padding: 0 0.35rem 0 0.45rem; gap: 0.2rem; }
.detail .detail__row .status-trigger .status-opt { gap: 0.3rem; font-size: 0.78rem; }
.detail .detail__row .status-trigger .status-opt > span { white-space: nowrap; }
.detail .detail__row .status-trigger .select__chevron { width: 14px; height: 14px; }
/* Every tile the same size: equal columns and rows, icon in line with the label */
.detail .detail__grid { grid-auto-rows: 1fr; }
@media (min-width: 561px) {
  .detail .detail__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.detail .detail__row {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start;
  column-gap: 0.45rem; row-gap: 0.4rem;
}
.detail .detail__row-body { display: contents; }
.detail .detail__row-icon { grid-column: 1; grid-row: 1; width: 22px; height: 22px; border-radius: 6px; }
.detail .detail__row-icon svg { width: 12px; height: 12px; }
.detail .detail__row dt { grid-column: 2; grid-row: 1; align-self: center; }
.detail .detail__row dd { grid-column: 1 / -1; grid-row: 2; }

/* Phones: Upcoming and then Quick note fold into dropdowns */
.reminders__toggle { display: none; }
@media (max-width: 600px) {
  .layout { grid-template-areas: "stats" "today" "upcoming" "note" "list"; gap: 0.75rem; }
  .side-card.note { gap: 0; padding: 0.75rem 0.8rem; }
  /* Same layout as the Upcoming header: icon box, title · status, preview line under the title */
  .note__header { cursor: pointer; gap: 0.5rem; user-select: none; }
  .note__icon {
    flex-shrink: 0; width: 32px; height: 32px; border-radius: 9px;
    color: var(--note-bg); background: var(--note-muted);
    box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--note-muted) 70%, transparent);
  }
  .note__heading { display: block; flex: 1; min-width: 0; font-size: 0.95rem; line-height: 1.2; }
  .note__title { display: inline; font-size: 0.95rem; line-height: 1.2; }
  .note__status { margin: 0 0 0 0.3rem; font-size: 0.74rem; font-weight: 500; opacity: 1; }
  .note__toggle {
    display: grid; place-items: center; flex-shrink: 0;
    width: 30px; height: 30px; margin-left: 0.25rem; padding: 0;
    color: var(--note-muted);
    background: color-mix(in srgb, var(--note-muted) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--note-muted) 25%, transparent);
    border-radius: 8px; cursor: pointer;
  }
  .note__toggle svg { transition: transform 0.2s; }
  .note.is-open .note__toggle svg { transform: rotate(180deg); }
  .note:not(.is-open) .note__peek {
    display: block; margin-top: 0.15rem;
    font-size: 0.74rem; line-height: 1.5; color: var(--note-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .note:not(.is-open) .note__body { display: none; }
  .note.is-open .note__body { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.6rem; }
  .reminders .reminders__header { cursor: pointer; align-items: center; justify-content: flex-start; gap: 0.5rem; user-select: none; }
  .reminders .reminders__count { margin-left: auto; }
  .reminders__toggle {
    display: grid; place-items: center; flex-shrink: 0;
    width: 30px; height: 30px; margin-left: 0.25rem; padding: 0;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
    border-radius: 8px; cursor: pointer;
  }
  .reminders__toggle svg { transition: transform 0.2s; }
  .reminders.is-open .reminders__toggle svg { transform: rotate(180deg); }
  .reminders:not(.is-open) .reminders__body { display: none; }
  .reminders.is-open .reminders__body { margin-top: 0.6rem; }
  .reminders--empty .upcoming-empty { padding: 0.8rem; }
}

/* Today progress: tinted panel, gradient ring, done/left pills */
.today .today__main {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 9%, var(--surface)), color-mix(in srgb, #a855f7 6%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border));
}
.ring circle { stroke-width: 6.5; }
.ring .ring__track { stroke: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
.ring .ring__value { stroke: url(#ring-gradient); filter: drop-shadow(0 1px 2px color-mix(in srgb, var(--primary) 40%, transparent)); }
.ring.is-complete .ring__value { stroke: var(--low-dot); }
.ring__label { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; color: var(--text); }
.ring__caption { margin-top: 0.15rem; font-size: 0.5rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.ring__num { display: inline-flex; align-items: flex-start; letter-spacing: -0.02em; }
.ring__pct { margin: 0.08em 0 0 0.05em; font-size: 0.55em; font-weight: 700; color: var(--text-muted); }
.ring__num--full { font-size: 0.78em; }
/* All done: green on a soft green disc, no glow */
.ring.is-complete .ring__value { filter: none; }
.ring.is-complete circle { stroke-width: 5; }
.ring.is-complete .ring__label { inset: 17%; border-radius: 50%; background: var(--low-bg); color: var(--low-fg); }
.ring.is-complete .ring__pct { color: inherit; opacity: 0.75; }
.ring.is-complete .ring__caption { display: none; }
.today .today__count { font-size: 0.95rem; font-weight: 500; }
.today .today__count strong { color: var(--primary); }
.today__pills { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.today__pills[hidden] { display: none; }
.today__pill { padding: 0.08rem 0.5rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; }
.today__pill--done { color: var(--low-fg); background: var(--low-bg); }
.today__pill--left { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.today .today__msg { margin-top: 0.35rem; font-size: 0.76rem; }
@media (max-width: 600px) {
  /* Stacked and centred: ring, then the count, then the pills */
  .today .today__main { flex-direction: column; justify-content: center; gap: 0.35rem; padding: 0.5rem 0.4rem; text-align: center; align-self: stretch; }
  .today .ring { width: 52px; height: 52px; }
  .today .ring circle { stroke-width: 5.5; }
  .today .ring__caption { display: none; }
  .today .ring__label { font-size: 0.82rem; }
  .today .today__text { display: flex; flex-direction: column; align-items: center; min-width: 0; }
  .today .today__count { font-size: 0.72rem; white-space: nowrap; }
  .today__pills { justify-content: center; flex-wrap: nowrap; margin-top: 0.25rem; gap: 0.2rem; }
  .today__pill { font-size: 0.62rem; padding: 0.05rem 0.4rem; }
  .today .today__msg { display: none; } /* the pills say the same thing in less space */
}
.detail .detail__row .status-trigger { height: 28px; padding: 0 0.3rem 0 0.4rem; border-radius: 7px; }
.detail .detail__row .status-trigger .status-opt { font-size: 0.74rem; gap: 0.25rem; }
.detail .detail__row .status-trigger .status-opt svg { width: 13px; height: 13px; }
.detail .detail__row .status-trigger .select__chevron { width: 13px; height: 13px; }

/* Task details footer: flat buttons, no shadows */
.detail .detail__footer .btn,
.detail .detail__footer .btn:hover:not(:disabled) { box-shadow: none; }
.detail .detail__footer .btn--danger-outline { border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.detail .detail__footer .btn--danger-outline:hover { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

/* Task details: the whole popup scrolls when the content is taller than the screen */
.dialog--detail { max-height: calc(100dvh - 2rem); }
.dialog--detail[open] { display: flex; flex-direction: column; } /* only when open: a closed <dialog> must stay hidden */
.dialog--detail .detail { min-height: 0; max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; }
.detail .detail__desc { max-height: none; overflow: visible; }

/* Task details: slightly smaller tiles */
.detail .detail__grid { gap: 0.4rem; padding: 0.4rem; }
.detail .detail__row { padding: 0.45rem 0.55rem; row-gap: 0.3rem; column-gap: 0.4rem; border-radius: 9px; }
.detail .detail__row-icon { width: 20px; height: 20px; border-radius: 6px; }
.detail .detail__row-icon svg { width: 11px; height: 11px; }
.detail .detail__row dt { font-size: 0.58rem; }
.detail__date { font-size: 0.76rem; }
.detail__clock { font-size: 0.66rem; padding: 0.02rem 0.35rem; }
.detail .detail__sub { font-size: 0.64rem; }
.detail .detail__pill { font-size: 0.64rem; }
.detail .detail__row .badge, .detail .detail__cat { font-size: 0.7rem; padding: 0.1rem 0.45rem; }
.detail .detail__row .status-trigger { height: 26px; }
.detail .detail__row .status-trigger .status-opt { font-size: 0.72rem; }

/* Copy-link button: small purple pill with a label */
.link-copy.link-copy {
  display: inline-flex; align-items: center; gap: 0.25rem;
  width: auto; height: 22px;
  margin-left: 0.35rem; padding: 0 0.5rem 0 0.4rem;
  vertical-align: 0.05em;
  font: inherit; font-size: 0.68rem; font-weight: 700; line-height: 1;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: 999px;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.link-copy.link-copy svg { width: 12px; height: 12px; flex-shrink: 0; }
.link-copy.link-copy:hover { color: var(--primary-contrast); background: var(--primary); border-color: var(--primary); }
.link-copy.link-copy:active { transform: scale(0.95); }
.link-copy.link-copy.is-copied { color: var(--low-fg); background: var(--low-bg); border-color: color-mix(in srgb, var(--low-dot) 35%, transparent); }
/* Phones: Delete and Edit share the row equally, Mark complete spans underneath */
@media (max-width: 600px) {
  .detail .detail__footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail .detail__footer .detail__spacer { display: none; }
  .detail .detail__footer [data-detail-action="toggle"] { grid-column: 1 / -1; }
}
@media (min-width: 601px) {
  .detail .detail__footer .btn--danger-outline,
  .detail .detail__footer [data-detail-action="edit"] { min-width: 104px; justify-content: center; }
}

/* Jumping to the task list stops just below the sticky top bar */
#task-list { scroll-margin-top: 76px; }
@media (max-width: 600px) {
  #task-list { scroll-margin-top: 76px; }
  /* Enough room below the tasks that the list can always scroll up to the top bar */
  #task-list { min-height: calc(100dvh - 96px); }
  /* No matching tasks: the message sits right under the filters, the spare room goes below it */
  #task-list:empty { min-height: 0; }
  #task-list:empty + .empty { scroll-margin-top: 76px; margin-bottom: max(0px, calc(100dvh - 96px - 260px)); }
}

/* Upcoming header: bell tile, count pill */
.reminders .reminders__header { align-items: center; justify-content: flex-start; gap: 0.6rem; }
.reminders__icon {
  flex-shrink: 0; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  color: #b45309; background: linear-gradient(135deg, #fef3c7, #fde68a);
  box-shadow: inset 0 0 0 1px rgb(217 119 6 / 0.2);
}
:root[data-theme="dark"] .reminders__icon { color: #fcd34d; background: #451a03; }
.reminders__heading { min-width: 0; flex: 1; }
.reminders__peek { display: none; }
.reminders .reminders__count {
  margin-left: auto; padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700;
  color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}
/* Upcoming: an indigo card, as distinct and saturated as the yellow Quick note */
.reminders.side-card {
  background: color-mix(in srgb, var(--primary) 11%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
  box-shadow: 0 6px 16px -10px color-mix(in srgb, var(--primary) 60%, transparent);
}
.reminders .reminders__icon {
  color: var(--primary-contrast); background: var(--primary);
  box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--primary) 70%, transparent);
}
:root[data-theme="dark"] .reminders .reminders__icon { color: var(--primary-contrast); background: var(--primary); }
.reminders .reminders__title { color: color-mix(in srgb, var(--primary) 55%, var(--text)); }
.reminders .reminders__sub { color: color-mix(in srgb, var(--primary) 45%, var(--text-muted)); }
.reminders__toggle.reminders__toggle {
  background: color-mix(in srgb, var(--primary) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
}
.reminders .reminders__count { background: var(--surface); }
.reminders .upcoming-empty { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.reminders .next-up:not(.next-up--soon) { background: var(--surface); }
.reminders .next-up:not(.next-up--soon):hover { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
@media (max-width: 600px) {
  .reminders.side-card { padding: 0.75rem 0.8rem; }
  .reminders .reminders__title { font-size: 0.95rem; line-height: 1.2; }
  .reminders:not(.is-open) .reminders__peek {
    display: block; margin-top: 0.15rem;
    font-size: 0.74rem; color: color-mix(in srgb, var(--primary) 50%, var(--text-muted));
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .reminders__peek strong { color: var(--text); font-weight: 600; }
}

.reminders .reminders__sub { display: block; margin-top: 0.1rem; font-size: 0.74rem; }
@media (max-width: 600px) {
  .reminders .reminders__sub { display: inline; margin: 0; }
  .reminders .reminders__sub::before { content: "· "; }
  .reminders:not(.is-open) .reminders__peek { display: flex; align-items: baseline; gap: 0.35rem; }
  .reminders__peek-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reminders__peek-when { flex-shrink: 0; font-weight: 700; color: var(--primary); }
}

/* ---------- Greeting banner (New task stays outside it) ---------- */
.hero.hero { align-items: center; gap: 1rem; }
.hero__card {
  flex: 1; min-width: 0;
  position: relative; overflow: hidden; isolation: isolate;
  padding: 1.1rem 1.3rem;
  border-radius: 18px;
  background: linear-gradient(120deg, #eef2ff 0%, #f5f3ff 55%, #fdf4ff 100%);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  box-shadow: 0 10px 30px -22px rgb(79 70 229 / 0.6);
}
/* Soft decorative glows */
.hero__card::before, .hero__card::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; pointer-events: none;
}
.hero__card::before { width: 220px; height: 220px; right: -60px; top: -110px; background: radial-gradient(circle, rgb(139 92 246 / 0.22), transparent 70%); }
.hero__card::after { width: 180px; height: 180px; right: 22%; bottom: -120px; background: radial-gradient(circle, rgb(99 102 241 / 0.16), transparent 70%); }
:root[data-theme="dark"] .hero__card {
  background: linear-gradient(120deg, #1e1b4b 0%, #221a3f 55%, #2a1638 100%);
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}
.hero #greeting .greeting__icon { background: var(--surface); box-shadow: 0 4px 12px -6px rgb(79 70 229 / 0.45), inset 0 0 0 1px color-mix(in srgb, var(--primary) 15%, transparent); }
.hero .greeting__hello { color: color-mix(in srgb, var(--primary) 55%, var(--text-muted)); }
.hero .summary__date {
  padding: 0.15rem 0.55rem; border-radius: 999px;
  color: var(--text); font-weight: 600;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 14%, var(--border));
}
.hero .summary__date svg { color: var(--primary); }
.hero .summary__pill { background: var(--surface); }
.hero .summary__pill--danger { background: var(--danger-bg); }
.hero #new-task-btn { flex-shrink: 0; align-self: center; }
@media (max-width: 600px) {
  .hero.hero { gap: 0.75rem; align-items: stretch; }
  .hero__card { padding: 0.9rem 0.9rem 0.95rem; border-radius: 16px; }
  .hero__card::before { width: 160px; height: 160px; right: -50px; top: -80px; }
  .hero__card::after { display: none; }
  .hero #new-task-btn { align-self: stretch; }
}

/* Phones: the clock box and the progress box are the same size */
@media (max-width: 600px) {
  .today.side-card { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .today .today__now, .today .today__main { align-self: stretch; margin-top: 0.45rem; margin-bottom: 0; box-sizing: border-box; }
}

/* Desktop: New task is a tile the same height as the greeting banner */
.new-task__hint { display: none; }
@media (min-width: 601px) {
  .hero #new-task-btn {
    align-self: stretch;
    flex-direction: column; justify-content: center; gap: 0.35rem;
    min-width: 170px; padding: 0.9rem 1.2rem;
    border-radius: 18px;
    background: linear-gradient(140deg, #818cf8 0%, #8b5cf6 60%, #a855f7 100%);
    box-shadow: 0 12px 28px -18px rgb(99 102 241 / 0.6);
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  }
  .hero #new-task-btn:hover { transform: translateY(-2px); filter: brightness(1.04); box-shadow: 0 16px 32px -18px rgb(99 102 241 / 0.7); }
  .new-task__plus {
    display: grid; place-items: center;
    width: 38px; height: 38px; border-radius: 12px;
    font-size: 1.35rem; line-height: 1; font-weight: 600;
    background: rgb(255 255 255 / 0.18);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.3);
  }
  .new-task__label { font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; }
  .new-task__hint { display: block; font-size: 0.7rem; font-weight: 500; opacity: 0.8; }
  .new-task__hint kbd {
    display: inline-block; min-width: 1.3em; padding: 0 0.3em; margin-left: 0.15em;
    border-radius: 4px; font: inherit; font-weight: 700;
    background: rgb(255 255 255 / 0.2); box-shadow: inset 0 -1px 0 rgb(0 0 0 / 0.15);
  }
}

/* Completion time */
.chip.chip--done { color: var(--low-fg); background: var(--low-bg); border-color: color-mix(in srgb, var(--low-dot) 30%, transparent); font-weight: 600; }
.task-card.is-completed .chip--done { opacity: 1; text-decoration: none; }
.detail__row--completed .detail__row-icon { color: var(--low-fg); background: var(--low-bg); }
/* Deleted cards keep their Deleted / Completed / Removed-in row */
.task-card.is-deleted .task-card__time { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.task-card.is-deleted .task-card__time .chip { font-size: 0.7rem; padding: 0.1rem 0.45rem; }
/* "Added …" chip sits just below the title, styled like the due-date chip */
.task-card .task-card__time { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.task-card .task-card__time .chip { font-size: 0.7rem; padding: 0.1rem 0.45rem; }
@media (max-width: 600px) { .task-card .task-card__time .chip { font-size: 0.68rem; padding: 0.1rem 0.4rem; } }

/* Phones: compact task form so it fits on one screen without scrolling */
@media (max-width: 600px) {
  .dialog--task { width: calc(100vw - 1.25rem); max-height: 96dvh; }
  .dialog--task .form { gap: 0.55rem; padding: 0 0.9rem; }
  .dialog--task .dialog__header { padding: 0.8rem 0 0.1rem; }
  .dialog--task .dialog__header h2 { font-size: 1.05rem; }
  .dialog--task .task-head { gap: 0.6rem; }
  .dialog--task .task-head__sub { display: none; }
  .dialog--task .task-head__icon { width: 34px; height: 34px; border-radius: 10px; }
  .dialog--task .task-head__close { width: 32px; height: 32px; align-self: center; }
  .dialog--task .field { gap: 0.2rem; }
  .dialog--task .field label, .dialog--task .field__label { font-size: 0.78rem; }
  .dialog--task input:not([type="checkbox"]):not([type="file"]), .dialog--task select,
  .dialog--task .select__trigger, .dialog--task .time-field { min-height: 38px; }
  .dialog--task textarea { min-height: 46px; height: 46px; }
  /* Attachments: just the button (phones can't drag or paste files) */
  .dialog--task .dropzone { padding: 0.3rem; }
  .dialog--task .dropzone__badge, .dialog--task .dropzone__text { display: none; }
  .dialog--task .dropzone__browse { flex: 1; justify-content: center; }
  /* Quick picks stay on one line and scroll sideways if needed */
  .dialog--task .quick-row { margin-top: 0.1rem; }
  .dialog--task .time-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 0.15rem; }
  .dialog--task .time-chips::-webkit-scrollbar { display: none; }
  .dialog--task .time-chip { flex-shrink: 0; padding: 0.15rem 0.32rem; font-size: 0.7rem; }
  .dialog--task .time-chip[data-time="18:00"] { display: none; } /* only room for three: 10 AM, 12 PM, 10 PM */
  .dialog--task .task-grid { gap: 0.55rem 0.6rem; }
  .dialog--task .dialog__footer { margin: 0.1rem -0.9rem 0; padding: 0.55rem 0.9rem 0.7rem; }
  .dialog--task .dialog__footer .btn { min-height: 38px; padding-top: 0.4rem; padding-bottom: 0.4rem; }
}

/* Phones: shorter Today boxes (clock and progress) */
@media (max-width: 600px) {
  .today .today__now, .today .today__main { padding: 0.4rem; }
  .today .today__time { font-size: 1.2rem; }
  .today .today__day { margin-top: 0.25rem; padding-top: 0.25rem; }
  .today .today__fulldate { font-size: 0.74rem; }
  .today .today__main { gap: 0.2rem; }
  .today .ring { width: 42px; height: 42px; }
  .today .ring circle { stroke-width: 5; }
  .today .ring__label { font-size: 0.72rem; }
  .today .today__count { font-size: 0.7rem; }
  .today .today__pills { margin-top: 0.15rem; }
  .today .today__pill { padding: 0.03rem 0.4rem; font-size: 0.64rem; }
}
