* { box-sizing: border-box; }
body { font-family: var(--font); font-size: var(--fs-base); line-height: var(--lh); margin: 0;
       background: var(--bg); color: var(--text); }
.container { max-width: 40rem; margin: 0 auto; padding: var(--space-4);
             padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
             padding-left: max(var(--space-4), env(safe-area-inset-left));
             padding-right: max(var(--space-4), env(safe-area-inset-right)); }
h1 { font-size: var(--fs-h1); line-height: 1.3; margin: var(--space-2) 0 var(--space-4); }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
.error { color: var(--overdue-color); }
.notice { min-height: 1.4em; margin: 0.25rem 0; }  /* reserved, so the list does not jump */

/* Keyboard focus is always visible. */
:focus-visible { outline: 3px solid var(--focus-color); outline-offset: 2px; }

/* Skip link: hidden until it gets keyboard focus. */
.skip-link { position: absolute; left: var(--space-2); top: -100px; z-index: 10;
             padding: var(--space-2) var(--space-3); background: var(--surface);
             border: 2px solid var(--accent); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--space-2); }

/* Controls: at least 44x44 px, and 16px text so phones do not zoom into fields. */
.btn, nav a, .pagination span, .task-actions a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px; padding: 0 var(--space-3); }
input[type=text], input[type=email], input[type=password], input[type=date], textarea {
  width: 100%; max-width: 30rem; min-height: 44px; padding: var(--space-2) var(--space-3);
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
textarea { resize: vertical; max-height: 20rem; }
label { display: inline-block; margin-bottom: var(--space-1); }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header__inner { display: flex; align-items: center; gap: var(--space-2);
                      justify-content: space-between; padding-top: var(--space-2);
                      padding-bottom: var(--space-2); }
.brand { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px;
         font-weight: var(--fw-600); font-size: var(--fs-lg); color: var(--text);
         text-decoration: none; }
.brand:hover { color: var(--text); }
.site-header__user { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.site-header__email { color: var(--muted); font-size: var(--fs-sm); overflow: hidden;
                      text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.messages { list-style: none; padding: 0; margin: 0 0 var(--space-4); display: grid;
            gap: var(--space-2); }

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

/* Filter tabs */
nav[aria-label="Filter tasks"] { display: flex; gap: 2px; margin: 0 0 var(--space-4); padding: 2px; background: #ececec;
        border-radius: var(--radius-md); }
nav[aria-label="Filter tasks"] a { flex: 1 1 auto; gap: var(--space-1); padding: 0 var(--space-2); color: var(--text);
          text-decoration: none; border-radius: var(--radius-sm); white-space: nowrap; }
nav[aria-label="Filter tasks"] a:hover { background: #dedede; color: var(--text); }
nav[aria-label="Filter tasks"] a.current { background: var(--accent); color: #fff; font-weight: var(--fw-600); }
.tab-count { font-size: var(--fs-sm); color: var(--muted); }
nav[aria-label="Filter tasks"] a.current .tab-count { color: #fff; }

/* Previous / Next stay visible on every page (PRD F4); the unavailable one is disabled. */
.pagination { margin-top: var(--space-4); display: flex; gap: var(--space-2); align-items: center;
              justify-content: space-between; }
.pagination a, .pagination .disabled { border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
              background: var(--surface); color: var(--text); text-decoration: none; font-weight: var(--fw-600); }
.pagination a:hover { background: #f0f0f0; color: var(--text); }
.pagination .disabled { color: var(--completed-text); background: transparent; border-color: var(--border);
                        font-weight: normal; }
.pagination .page-number { color: var(--muted); font-size: var(--fs-sm); text-align: center; padding: 0; }

/* Task list: each task is a card */
.tasks { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.task { display: grid; grid-template-columns: 44px 1fr auto; column-gap: var(--space-2); align-items: start;
        padding: var(--space-2); background: var(--surface); border: 2px solid var(--border);
        border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.task-body { min-width: 0; padding-top: 0.6rem; }
.task-title, .task-description { overflow-wrap: anywhere; word-break: break-word; }
.task-title { font-weight: var(--fw-600); }
.task-due { color: var(--muted); font-size: var(--fs-sm); }
.task-description { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--space-1); }
.task-description.is-clamped { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
                               -webkit-box-orient: vertical; overflow: hidden; }
.task-more { min-height: 44px; padding: 0; justify-content: flex-start; }
.task-actions { display: flex; gap: var(--space-2); }
.task[aria-busy="true"] { opacity: 0.6; }
.task--overdue { border: 2px solid var(--overdue-color); }
.task--overdue { background: var(--danger-bg); }
.overdue-label { color: var(--overdue-color); font-weight: bold; }
.overdue-label::before { content: "\26A0\00a0"; }
.task--completed { background: #f4f4f4; box-shadow: none; }
.task--completed .task-title { text-decoration: line-through; }
.task--completed .task-title, .task--completed .task-description,
.task--completed .task-due { color: var(--completed-text); }
.toggle { display: inline-flex; align-items: center; justify-content: center;
          min-width: 44px; min-height: 44px; margin: 0; }
.toggle { border-radius: var(--radius-sm); cursor: pointer; }
.toggle:hover { background: #e3e9f8; }
.task--overdue .toggle:hover { background: #f8cfd5; }
.task-toggle { width: 24px; height: 24px; accent-color: var(--accent); cursor: pointer; }

/* Empty state: text plus one next step */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.empty-state[hidden] { display: none; }

@media (max-width: 480px) {
  .task { grid-template-columns: 44px 1fr; }
  .task-actions { grid-column: 2; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
