/* chek app shell (DESIGN.md section 7). Mobile first; 16 px minimum text; 44 px targets. */
:root {
  --bg: #f5f6f3;
  --card: #ffffff;
  --text: #1d2420;
  --muted: #5f6b64;
  --line: #dde2dc;
  --accent: #2f7d5b;
  --accent-text: #ffffff;
  --done: #9aa59f;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.05);
  --tabbar: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --card: #1b211e;
    --text: #e6ebe7;
    --muted: #9aa8a0;
    --line: #2c3530;
    --accent: #4fb388;
    --accent-text: #0d1a14;
    --done: #66726b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.empty { color: var(--muted); padding: 24px 4px; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { margin: 0; font-size: 22px; letter-spacing: -0.02em; color: var(--accent); }
.icon-btn {
  flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  display: grid; place-items: center; color: var(--accent);
  -webkit-tap-highlight-color: transparent;
}

/* refresh (F33): header button, and the pull-to-refresh pill that slides out under the header */
.refresh {
  margin-left: auto; margin-right: 8px; flex: none;
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  display: grid; place-items: center; font-size: 22px; line-height: 1; color: var(--accent);
  -webkit-tap-highlight-color: transparent;
}
.refresh-icon, .ptr-icon { display: inline-block; }
@keyframes chek-spin { to { transform: rotate(360deg); } }
.refreshing .refresh-icon, .ptr.busy .ptr-icon { animation: chek-spin 0.8s linear infinite; }
.ptr {
  position: fixed; left: 50%; z-index: 4; /* under the sticky header (z 5) */
  top: calc(env(safe-area-inset-top) + 20px);
  transform: translate(-50%, 0); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 20px; font-size: 16px;
  background: var(--card); color: var(--muted); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform 0.2s, opacity 0.2s;
}
.ptr.dragging { transition: none; }
.ptr.armed, .ptr.busy { color: var(--accent); border-color: var(--accent); }
.ptr-icon { font-size: 18px; line-height: 1; }
.ptr.busy { transform: translate(-50%, 60px); opacity: 1; }

/* panels */
#panels { max-width: 960px; margin: 0 auto; padding: 16px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.day-head h2 { margin: 0; font-size: 20px; }

/* Today checklist */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 640px; }
.task {
  width: 100%; min-height: 64px; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.task:active { transform: scale(0.99); }
.task .box {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--accent); display: grid; place-items: center;
}
.task-text { display: grid; gap: 2px; min-width: 0; }
.task-title { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.task-detail { font-size: 16px; color: var(--muted); }
.task.done { opacity: 0.6; box-shadow: none; }
.task.done .box { background: var(--done); border-color: var(--done); }
.task.done .box::after {
  content: ""; width: 12px; height: 7px; margin-top: -3px;
  border: solid var(--card); border-width: 0 0 3px 3px; transform: rotate(-45deg);
}
.task.done .task-title { text-decoration: line-through; color: var(--done); }
/* Today row (F34): a container card holding the .box checkbox button and the .task-open
   title button; .task above is its card base. */
.task-row { padding: 0 0 0 9px; gap: 0; cursor: default; align-items: stretch; }
.task-row .box {
  align-self: center; width: 44px; height: 44px; padding: 0; margin: 0;
  border: 0; border-radius: 50%; background: none; cursor: pointer;
  display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
}
.task-row .box-mark {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--accent); display: grid; place-items: center;
}
.task-row.done .box { background: none; }
.task-row.done .box::after { content: none; }
.task-row.done .box-mark { background: var(--done); border-color: var(--done); }
.task-row.done .box-mark::after {
  content: ""; width: 12px; height: 7px; margin-top: -3px;
  border: solid var(--card); border-width: 0 0 3px 3px; transform: rotate(-45deg);
}
.task-open {
  flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center;
  margin: 0; padding: 14px 16px 14px 7px; border: 0; border-radius: 0 14px 14px 0;
  background: none; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.task-row .box:focus-visible { outline: 3px solid var(--accent); outline-offset: -2px; }
.task-open:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.task:focus-visible, .tab:focus-visible, .icon-btn:focus-visible, .refresh:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* bottom tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; overflow-x: auto; scrollbar-width: none;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 1 0; min-width: 0; min-height: var(--tabbar); padding: 0 6px; /* equal halves */
  border: 0; background: none; cursor: pointer; font-size: 16px; color: var(--muted);
  border-top: 3px solid transparent;
}
.tab.active { color: var(--accent); font-weight: 600; border-top-color: var(--accent); }

/* settings sheet */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 480px; background: var(--card); color: var(--text);
  border-radius: 18px 18px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: calc(100dvh - env(safe-area-inset-top) - 12px); overflow-y: auto; overscroll-behavior: contain;
}
@media (min-width: 600px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 18px; }
}
.sheet-card h2 { margin: 0 0 12px; font-size: 20px; }
.settings:not(:empty) { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.link { margin-top: 12px; min-height: 44px; width: 100%; border: 0; background: none; color: var(--muted); cursor: pointer; }
#panels { overflow-x: clip; position: relative; }
/* Settings Close: a real button at the end of the sheet */
#sheet-close {
  margin-top: 16px; min-height: 48px;
  border-radius: 12px; background: var(--accent); color: var(--accent-text);
  font: inherit; font-size: 17px; font-weight: 600;
}
#sheet-close:active { filter: brightness(0.92); }
#sheet-close:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }

/* swiping between tabs (setupSwipe in app.js moves the panels) */
#panels.swiping > .panel { will-change: transform; }
#panels.swiping { user-select: none; -webkit-user-select: none; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 16px; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Wide screens (iPad): one centred 640px column; the header lines up with it. */
@media (min-width: 768px) {
  #panels { max-width: 672px; }
  .top { padding-left: max(16px, calc((100% - 640px) / 2)); padding-right: max(16px, calc((100% - 640px) / 2)); }
  .tabs { justify-content: center; }
  .tab { flex: 0 0 320px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .refreshing .refresh-icon, .ptr.busy .ptr-icon { animation: none; }
  .refreshing .refresh { opacity: 0.5; } /* still show it is working, without spinning */
}
