/* Shared by index.html (owner home) and list.html (the collaborative list).
   Both pages render the same task rows, so their styles live together. */

:root {
  --paper: #fbfaf9;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --faint: #a8a29e;
  --line: #e7e5e4;
  --accent: #5850ec;
  --accent-soft: #eeedfd;
  --danger: #be123c;
  --warn: #b45309;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 4px 16px rgba(28, 25, 23, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17161a;
    --surface: #201f24;
    --ink: #ede9e6;
    --muted: #a1998f;
    --faint: #746d66;
    --line: #34323a;
    --accent: #9b95f5;
    --accent-soft: #292741;
    --danger: #fb7185;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 96px;
}

/* ---- page header ---- */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.page-head h1 {
  flex: 1;
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  min-width: 0;
}

/* The list name is an input styled as a heading — editing is just typing. */
input.title-field {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 2px 6px;
  margin-left: -6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
}

input.title-field:hover { border-color: var(--line); }
input.title-field:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.subhead {
  margin: 2px 0 24px;
  color: var(--muted);
  font-size: 13.5px;
}

.subhead .dot { margin: 0 7px; color: var(--faint); }

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s;
}

.btn:hover { border-color: var(--faint); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-quiet { background: none; border-color: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }

.head-actions { display: flex; gap: 6px; flex-shrink: 0; padding-top: 3px; }

/* ---- export dropdown ---- */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ' ▾'; color: var(--faint); }

.menu-body {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
}

.menu-body .btn { justify-content: flex-start; }

/* ---- tag filter bar ---- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.filters:empty { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

button.chip:hover { border-color: var(--faint); }
button.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .swatch { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ---- groups (ungrouped area + each section) ---- */
.group { margin-bottom: 26px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 0 6px 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.group-head input {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  margin-left: -6px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.group-head input:hover { border-color: var(--line); }
.group-head input:focus { outline: none; border-color: var(--accent); color: var(--ink); background: var(--surface); }

.group-count {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.group-head .btn-quiet { opacity: 0; transition: opacity 0.12s; }
.group:hover .group-head .btn-quiet,
.group-head .btn-quiet:focus-visible { opacity: 1; }

.group.is-dragover .tasks { background: var(--accent-soft); border-radius: 8px; }

/* ---- task rows ---- */
.tasks { min-height: 6px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 6px 5px 0;
  border-radius: 8px;
  position: relative;
}

.task:hover { background: var(--surface); }
.task.is-dragging { opacity: 0.4; }
.task.drop-before::before,
.task.drop-after::after {
  content: '';
  position: absolute;
  left: 26px;
  right: 6px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.task.drop-before::before { top: -1px; }
.task.drop-after::after { bottom: -1px; }

.handle {
  flex-shrink: 0;
  width: 18px;
  padding: 3px 0 0;
  background: none;
  border: 0;
  color: var(--faint);
  line-height: 1;
  font-size: 13px;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.12s;
}

.task:hover .handle, .handle:focus-visible { opacity: 1; }
.handle:active { cursor: grabbing; }

.check {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  margin-top: 4px;
  border: 1.5px solid var(--faint);
  border-radius: 5px;
  background: none;
  padding: 0;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}

.check:hover { border-color: var(--accent); }

.check[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
}

.check[aria-checked='true']::after {
  content: '';
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.task-main { flex: 1; min-width: 0; }

.task-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }

input.task-title {
  flex: 1;
  min-width: 140px;
  padding: 3px 6px;
  margin-left: -6px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
}

input.task-title:hover { border-color: var(--line); }
input.task-title:focus { outline: none; border-color: var(--accent); background: var(--paper); }

.task.is-done input.task-title { color: var(--faint); text-decoration: line-through; }

.badge {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.badge.is-overdue { color: var(--danger); font-weight: 600; }
.badge.is-soon { color: var(--warn); font-weight: 600; }

.task-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.tag {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.note-peek {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  padding: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.expand {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 5px;
  color: var(--faint);
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.12s;
}

.task:hover .expand, .expand:focus-visible, .expand.is-open { opacity: 1; }
.expand:hover { background: var(--accent-soft); color: var(--accent); }
.expand.is-open { transform: rotate(90deg); }

/* ---- task detail ---- */
.detail {
  margin: 2px 0 10px 43px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
}

.detail textarea {
  width: 100%;
  min-height: 62px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  font-size: 13.5px;
}

.detail-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.detail-foot { gap: 6px; }
.detail-foot .btn-danger { margin-left: auto; }
.detail-foot .btn[disabled] { opacity: 0.4; cursor: default; }

.field { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 150px; }

.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}

.field input {
  padding: 6px 9px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  /* Date and datetime inputs carry an intrinsic width that a flex item won't
     shrink past on its own, which would push the row wider than the page. */
  width: 100%;
  min-width: 0;
}

.detail textarea:focus, .field input:focus { outline: none; border-color: var(--accent); }

/* ---- inline add rows ---- */
.add-row { display: flex; align-items: center; gap: 8px; padding-left: 26px; }

.add-row input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  margin-left: -2px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
}

.add-row input::placeholder { color: var(--faint); }
.add-row input:hover { border-color: var(--line); }
.add-row input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.add-section { padding-left: 0; margin-top: -6px; }

/* ---- done section ---- */
.done-toggle {
  display: block;
  width: 100%;
  margin: 6px 0 10px;
  padding: 7px 0;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.done-toggle:hover { color: var(--ink); }

/* ---- toast (delete undo) ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 80px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 50;
}

.toast.is-shown { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast button {
  background: none;
  border: 0;
  padding: 2px 4px;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

/* ---- states ---- */
.state {
  padding: 48px 0;
  text-align: center;
  color: var(--muted);
}

.state h2 { margin: 0 0 6px; font-size: 17px; color: var(--ink); }

/* ---- owner home ---- */
.new-list {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.new-list input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.new-list input:focus { outline: none; border-color: var(--accent); }

.list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.list-card:hover { border-color: var(--faint); }
.list-card.is-archived { opacity: 0.62; }

.list-card-main { flex: 1; min-width: 0; }

.list-card a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 15.5px;
}

.list-card a:hover { color: var(--accent); }

.list-card .meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.progress {
  width: 46px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  flex-shrink: 0;
}

.progress span { display: block; height: 100%; background: var(--accent); }

.list-actions { display: flex; gap: 4px; flex-shrink: 0; }

.section-label {
  margin: 30px 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

/* --- timeline ------------------------------------------------------------- */
.view-tabs {
  display: flex;
  gap: 2px;
  margin: 14px 0 4px;
  padding: 3px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
}

.view-tab {
  padding: 5px 16px;
  border: none;
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.view-tab:hover { color: var(--ink); }

.view-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.timeline { margin-top: 18px; }

.tl-empty { color: var(--muted); font-size: 14px; margin: 20px 0; }

.tl-day { margin-bottom: 22px; }

.tl-day-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}

.tl-day-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.tl-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 5px 0;
}

.tl-time {
  flex-shrink: 0;
  width: 46px;
  padding-top: 5px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.tl-entry.is-grocery .tl-time { color: var(--accent); font-weight: 600; }

.tl-body { flex: 1; min-width: 0; }

.tl-line { display: flex; align-items: center; gap: 8px; min-height: 30px; }

.tl-title-text { flex: 1; min-width: 0; }

.tl-body.is-done .tl-title-text { color: var(--faint); text-decoration: line-through; }

input.tl-title {
  flex: 1;
  min-width: 120px;
  padding: 3px 6px;
  margin-left: -6px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  color: inherit;
}

input.tl-title:hover { border-color: var(--line); }
input.tl-title:focus { outline: none; border-color: var(--accent); background: var(--paper); }

/* The time already reads in the left column, so the field that edits it stays
   faint until you go for it. */
input.tl-when {
  flex-shrink: 0;
  padding: 3px 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--faint);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  opacity: 0.5;
  transition: opacity 0.12s;
}

.tl-entry:hover input.tl-when,
input.tl-when:focus { opacity: 1; color: var(--muted); }
input.tl-when:hover { border-color: var(--line); }
input.tl-when:focus { outline: none; border-color: var(--accent); background: var(--paper); }

.tl-entry .btn-quiet { opacity: 0; transition: opacity 0.12s; }
.tl-entry:hover .btn-quiet,
.tl-entry .btn-quiet:focus-visible { opacity: 1; }

.tl-sub {
  display: block;
  margin: 0 0 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.tl-moment {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.tl-moment::after {
  content: ' ▸';
  color: var(--faint);
}

.tl-moment.is-open::after { content: ' ▾'; }

.leftovers { margin-bottom: 22px; }
.leftovers.is-stale .grocery-name { color: var(--danger); }

.grocery-lines {
  margin: 2px 0 6px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.grocery-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 14px;
}

.grocery-line .check { opacity: 1; }

.grocery-name { flex: 1; min-width: 0; }

.grocery-line.is-done .grocery-name { color: var(--faint); text-decoration: line-through; }

.grocery-for {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--faint);
}

.grocery-badge {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Groceries inside a task's detail panel */
.groceries { margin-top: 12px; }

.groceries-label {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.grocery-remove {
  flex-shrink: 0;
  padding: 0 5px;
  border: none;
  background: none;
  font-size: 16px;
  line-height: 1;
  color: var(--faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
}

.grocery-line:hover .grocery-remove,
.grocery-remove:focus-visible { opacity: 1; }
.grocery-remove:hover { color: var(--danger); }

.grocery-add { margin-top: 4px; }

.grocery-add input {
  width: 100%;
  padding: 5px 8px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: none;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.grocery-add input::placeholder { color: var(--faint); }
.grocery-add input:focus { outline: none; border-style: solid; border-color: var(--accent); background: var(--surface); }

.add-event { padding-left: 58px; gap: 6px; }
.add-event input[type='text'] { flex: 1; }
.add-event input[type='datetime-local'] { flex-shrink: 0; width: auto; }

.tl-foot {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.tl-foot .field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input.horizon {
  width: 58px;
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

input.horizon:focus { outline: none; border-color: var(--accent); }

@media (max-width: 560px) {
  .wrap { padding: 22px 14px 90px; }
  .page-head h1, input.title-field { font-size: 22px; }
  .handle { display: none; }
  .expand, .task .check { opacity: 1; }
  .detail { margin-left: 25px; }
  .add-row { padding-left: 8px; }
  .list-card { flex-wrap: wrap; }
  /* No hover on touch — the row controls have to stay visible. */
  .tl-entry .btn-quiet, .grocery-remove, input.tl-when { opacity: 1; }
  .tl-entry { gap: 8px; }
  .tl-time { width: 40px; }
  .tl-line { flex-wrap: wrap; }
  /* Both of these carry an intrinsic width — drop them onto their own line
     rather than letting them push the page sideways. */
  input.tl-when { flex: 1 0 100%; margin-left: -6px; }
  .add-event { padding-left: 8px; flex-wrap: wrap; }
  .add-event input[type='datetime-local'] { flex: 1 0 auto; min-width: 0; }
  .grocery-line { flex-wrap: wrap; }
  .grocery-for { width: 100%; padding-left: 26px; }
}

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

/* Landing-page note under the on-this-device list. */
.fineprint {
  margin: 14px 2px 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--faint);
}
