/* Buttons: <a> and <button>. Variants: --primary, --secondary, --danger, --quiet. */
.btn { font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: var(--radius-sm);
       background: transparent; color: var(--text); text-decoration: none; font-weight: var(--fw-600);
       min-height: 44px; min-width: 44px; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); color: #fff; }
.btn--secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--secondary:hover { background: #f0f0f0; color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #8e001a; color: #fff; }
.btn--quiet { color: var(--accent); font-weight: normal; }
.btn--quiet:hover { background: #eef2fb; color: var(--accent-hover); }
.btn--danger-quiet { color: var(--danger); }
.btn--danger-quiet:hover { background: var(--danger-bg); color: #8e001a; }
.task--overdue .btn--danger-quiet:hover { background: #f8cfd5; color: #8e001a; }
.task--overdue .btn--quiet:hover { background: #f8cfd5; }
.btn .icon { margin-right: var(--space-1); flex: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }

/* Form fields (used from stage 2) */
.field { margin: 0 0 var(--space-4); }
.field__hint { display: block; color: var(--muted); font-size: var(--fs-sm); }
/* Hint-or-error on the left and the counter on the right share one line. */
.field__meta { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3);
               max-width: 30rem; margin-top: var(--space-1); }
.field__message { flex: 1; min-width: 0; }
.field__error { display: block; color: var(--danger); font-size: var(--fs-sm); }
.field__hint[hidden], .field__error[hidden] { display: none; }
.field__required { color: var(--danger); }
.field [aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }

/* Alerts: a glyph plus text, so meaning is not carried by color alone. */
.alert { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-2) var(--space-3);
         border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.alert__icon { font-weight: bold; line-height: var(--lh); }
.alert__text { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 0; }
.alert__close { margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-2)) calc(-1 * var(--space-2)) 0; }
.alert--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.alert--error { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

/* Badge, card, page header, empty state */
.badge { display: inline-block; padding: 0 var(--space-2); border-radius: 999px; font-size: var(--fs-sm);
         font-weight: var(--fw-600); }
.badge--danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
        box-shadow: var(--shadow-card); padding: var(--space-4); }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
               gap: var(--space-3); margin-bottom: var(--space-4); }
.page-header h1 { margin: 0; }
.empty-state { text-align: center; color: var(--muted); padding: var(--space-5) var(--space-4); }

/* Auth pages: a centered narrow card (used from stage 2) */
.container--auth { max-width: 26rem; }

@media (max-width: 480px) {
  .page-header .btn { width: 100%; }
}

/* Forms (stage 2) */
form.card .alert { margin-bottom: var(--space-4); }
.field label { display: block; font-weight: var(--fw-600); }
.field__counter { flex: none; color: var(--muted); font-size: var(--fs-sm); text-align: right; }
.field__password { display: flex; align-items: stretch; gap: var(--space-2); max-width: 30rem; }
.field__password input { flex: 1; min-width: 0; }
.form-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-4); }
.auth-switch { text-align: center; margin-top: var(--space-4); }
/* The text link is still a 44x44 touch target (PRD section 4). */
.auth-switch a { display: inline-flex; align-items: center; justify-content: center;
                 min-height: 44px; min-width: 44px; }

@media (max-width: 480px) {
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
}

/* Reserved line for the "Could not save" notice. */
.notice:not(:empty) { font-weight: var(--fw-600); }

/* Snackbars: flash messages fixed at the bottom of the screen; forms.js removes them after 3 s. */
.snackbars { position: fixed; left: 50%; transform: translateX(-50%); z-index: 20; margin: 0;
             bottom: max(var(--space-4), env(safe-area-inset-bottom));
             width: min(32rem, calc(100% - 2 * var(--space-4))); }
.snackbar { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18); align-items: center; }
/* Without JavaScript the snackbar still disappears by itself. */
html:not(.js) .snackbar { animation: snackbar-out 0.3s ease 3s forwards; }
@keyframes snackbar-out { to { opacity: 0; visibility: hidden; } }

/* Delete confirmation dialog */
.dialog { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4);
          width: min(26rem, calc(100% - 2 * var(--space-4))); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
          color: var(--text); background: var(--surface); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog__title { font-size: var(--fs-lg); margin: 0 0 var(--space-3); }
.dialog .task-title { overflow-wrap: anywhere; margin: 0 0 var(--space-2); }
