:root {
  --concrete: #E9ECEC;
  --surface: #FFFFFF;
  --ink: #1E2529;
  --muted: #5E6A70;
  --line: #C9D0D2;
  --tape: #3F86C6;
  --tape-ink: #F4F8FB;
  --safety: #F3C623;   /* reserved for warnings */
  --error: #B3261E;
  --focus: #1F5E96;
  --done: #2F7D4F;

  --font-body: 'Barlow', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --nav-h: 3.75rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --concrete: #171C1F;
    --surface: #22292D;
    --ink: #E6EAEB;
    --muted: #9AA6AB;
    --line: #3A4449;
    --tape: #3A78B0;
    --error: #F2867E;
    --focus: #8CC2F0;
    --done: #6CC08F;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  background: var(--concrete);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.loading { padding: 3rem 1.25rem; color: var(--muted); }

.shell {
  max-width: 34rem;
  margin: 0 auto;
  padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1.25rem
           calc(var(--nav-h) + 2rem + env(safe-area-inset-bottom, 0px));
}
.shell.no-nav { padding-bottom: 3rem; max-width: 26rem; padding-top: calc(2.5rem + env(safe-area-inset-top, 0px)); }

/* Painter's tape wordmark */
.tape {
  display: inline-block;
  padding: 0.3rem 1.2rem 0.4rem;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.06) 0 2px, transparent 2px 5px),
    var(--tape);
  transform: rotate(-2.5deg);
  clip-path: polygon(0 6%, 4% 0, 9% 7%, 15% 1%, 100% 0, 97% 30%, 100% 55%, 96% 78%, 100% 100%,
                     0 100%, 3% 72%, 0 48%, 4% 24%);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
  color: var(--tape-ink);
}
.tape.large { font-size: 2.6rem; margin: 0 0 2.25rem -0.5rem; }
.tape.small { font-size: 1.6rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

h1, h2 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; }
h1 { font-size: 1.9rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.25rem; margin: 1.75rem 0 0.5rem; color: var(--muted); }
h2.overdue { color: var(--error); }

.muted { color: var(--muted); }
.error { color: var(--error); font-weight: 500; margin: 0 0 0.9rem; }

/* Form controls */
label { font-weight: 500; font-size: 0.95rem; display: block; margin-bottom: 0.35rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: 0.7rem 0.85rem;
  width: 100%;
  min-height: 3rem;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus { border-color: var(--tape); outline: none; }

button {
  font: inherit;
  font-weight: 600;
  min-height: 3rem;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--concrete);
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--ink); }
button.quiet {
  background: none; border: none; color: var(--muted);
  font-weight: 500; min-height: 2.75rem; padding: 0.4rem 0.5rem;
}
button.danger { background: transparent; color: var(--error); border-color: var(--error); }
button:disabled { opacity: 0.6; cursor: progress; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.signin-form { display: grid; gap: 0.9rem; }
.signin-form button { width: 100%; margin-top: 0.25rem; }

/* Quick add */
.quick-add { display: flex; gap: 0.5rem; }
.quick-add input { flex: 1; }
.quick-add button { flex: none; }

/* Task rows */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}
.task-row:last-child { border-bottom: none; }

.check {
  flex: none;
  width: 2.75rem; height: 2.75rem;
  min-height: 0; padding: 0;
  display: grid; place-items: center;
  background: none; border: none; color: var(--ink);
}
.check::before {
  content: '';
  width: 1.4rem; height: 1.4rem;
  border: 2px solid var(--muted);
  border-radius: 50%;
}
.check[aria-checked="true"]::before {
  border-color: var(--done);
  background: var(--done)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3L15 7' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 80% no-repeat;
}

.task-open {
  flex: 1;
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 0.55rem 0;
  min-height: 2.75rem;
}
.task-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
.task-row.is-done .task-title { color: var(--muted); text-decoration: line-through; }
.task-meta { display: block; font-size: 0.9rem; color: var(--muted); }
.task-meta .late { color: var(--error); font-weight: 500; }
.prio-3 .task-title::before, .prio-2 .task-title::before {
  content: '';
  display: inline-block;
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  margin: 0 0.45rem 0.12rem 0;
  vertical-align: middle;
  background: var(--tape);
}
.prio-2 .task-title::before { background: transparent; border: 2px solid var(--tape); }

.empty { color: var(--muted); padding: 1.5rem 0; }

details.done-section { margin-top: 2rem; }
details.done-section summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--muted);
  min-height: 2.75rem;
  display: flex; align-items: center;
}

/* Task detail */
.back {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
.back:hover { color: var(--ink); }

input.title-input {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.85rem;
  line-height: 1.2;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 0.2rem 0;
  min-height: 0;
}
input.title-input:focus { border-bottom-color: var(--tape); }

.field { margin-top: 1.5rem; }
.due-row { display: flex; gap: 0.5rem; }
.due-row input { flex: 1; }

.segmented { display: flex; border: 1.5px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button {
  flex: 1; border: none; border-radius: 0;
  background: var(--surface); color: var(--ink); font-weight: 500;
}
.segmented button + button { border-left: 1.5px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--concrete); }

.status-bar { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.5rem; }
.status-bar .done-note { color: var(--done); font-weight: 500; }

.step-row .task-title { font-weight: 400; }
.step-delete {
  flex: none; background: none; border: none; color: var(--muted);
  width: 2.75rem; padding: 0; min-height: 2.75rem; font-size: 1.4rem; line-height: 1;
}
.saved { font-size: 0.85rem; color: var(--muted); min-height: 1.3rem; margin-top: 0.3rem; }

.delete-zone { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}
.bottom-nav a {
  flex: 1;
  max-width: 11rem;
  height: var(--nav-h);
  display: grid;
  place-items: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  border-top: 3px solid transparent;
}
.bottom-nav a[aria-current="page"] { color: var(--ink); border-top-color: var(--tape); font-weight: 600; }

@media (min-width: 40rem) {
  .shell { padding-top: calc(2.5rem + env(safe-area-inset-top, 0px)); }
}
