:root {
  --bg: #f5f2ea;
  --card: #fff;
  --ink: #111;      /* text on the page background */
  --line: #111;     /* borders */
  --shadow: #111;   /* hard offset shadows */
  --field: #f5f2ea; /* textarea/input background */
  --muted: #666;
  --text2: #444;
  --text3: #999;
  --yellow: #ffd60a;
  --coral: #ff5d5d;
  --green: #7ee787;
  --blue: #a5d8ff;
  --violet: #d0bfff;
  --orange: #ffb057;
  --grey: #c9c4b6;
}

/* Manual dark theme — toggled by tapping the TASKS logo, persisted.
   v3: only the PAGE goes dark. Cards stay dimmed paper with black borders
   and dark text, so items keep the daytime look and nothing glows white. */
:root.dark {
  --bg: #1a1813;
  --card: #ded8ca;
  --ink: #e9e4d8;   /* text sitting directly on the dark page */
  --line: #6e5f45;  /* warm bronze borders — visible on dark, not white */
  --shadow: #000;
  --field: #cbc5b6;
  --muted: #8d8778; /* mid tone: readable on dark page AND on paper cards */
  --text3: #8d8778;
  --text2: #4a4437;
  --grey: #a49d8d;
}
/* everything that sits on a paper or accent surface keeps dark text */
:root.dark .card, :root.dark .chip, :root.dark .btn, :root.dark .tab,
:root.dark select, :root.dark textarea, :root.dark input,
:root.dark .topbar .logo, :root.dark [data-stage] {
  color: #24211a;
}
:root.dark .card .label { color: #6e6759; }

* { box-sizing: border-box; margin: 0; }
/* the hidden attribute must always win, even over .topbar's display:flex —
   without !important, Brave/Android renders "hidden" bars anyway */
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, sans-serif;
  padding: 14px;
  max-width: 560px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}
.card {
  border: 3px solid var(--line);
  background: var(--card);
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 12px;
  margin-bottom: 14px;
}
.chip {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  font-family: inherit;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.chip.raised { box-shadow: 2px 2px 0 var(--shadow); }
.chip.raised:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.btn {
  border: 3px solid var(--line);
  color: var(--ink);
  font-weight: 900;
  font-size: 13px;
  font-family: inherit;
  padding: 8px 18px;
  box-shadow: 3px 3px 0 var(--shadow);
  background: var(--card);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn-coral { background: var(--coral); }
.btn-green { background: var(--green); }
.btn-yellow { background: var(--yellow); }
.label {
  font-size: 10px; font-weight: 900; letter-spacing: 1.5px;
  color: var(--muted); text-transform: uppercase; margin-bottom: 6px;
}
.swatch {
  width: 9px; height: 9px; border: 1.5px solid var(--line);
  display: inline-block; flex-shrink: 0; padding: 0;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  border: 3px solid var(--line); background: var(--card);
  box-shadow: 4px 4px 0 var(--shadow); padding: 10px 12px; margin-bottom: 14px;
  /* top matches body padding so the bar pins exactly where it sits — no shift */
  position: sticky; top: 14px; z-index: 20;
}
.topbar .logo {
  font-weight: 900; font-size: 18px; letter-spacing: -0.5px;
  font-family: inherit; color: var(--ink); background: none;
  border: none; padding: 0; cursor: pointer;
}
.tab {
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  padding: 3px 8px; font-size: 11px; font-weight: 800; font-family: inherit;
  cursor: pointer; margin-left: 6px;
}
.tab.active { background: var(--yellow); }
textarea, input[type=text], input[type=password] {
  border: 2px solid var(--line); background: var(--field); width: 100%;
  /* 16px minimum: anything smaller triggers iOS focus auto-zoom */
  font: inherit; font-size: 16px; padding: 8px; border-radius: 0;
}
select {
  border: 2px solid var(--line); background: var(--card); font: inherit;
  font-weight: 800; font-size: 12px; padding: 5px; border-radius: 0;
}
/* Custom persistent scrollbar for the task view: native bar hidden, blocky
   rail always visible on the right. */
html.custom-scroll { scrollbar-width: none; }
html.custom-scroll::-webkit-scrollbar { display: none; }
#scroll-rail {
  position: fixed; top: 4px; right: 4px; bottom: 4px; width: 10px;
  background: var(--card); border: 2px solid var(--line); z-index: 25;
}
#scroll-thumb {
  position: absolute; left: 0; right: 0; top: 0;
  background: var(--shadow); /* black in both themes */
  min-height: 24px;
}

@media (min-width: 900px) {
  body { max-width: 1300px; }
  .board { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; align-items: start; }
}
