/* Lister – original stil inspireret af Android-to-do-apps. */
:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #e4e4e7;
  --accent: #2f6fde;
  --star: #c2410c;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 1px 1px rgba(0,0,0,.04);
  --card: #ffffff;
  --card-done: #eef1f6;
  --snack: #323232;
  --theme: #2f6fde;
  --theme-dark: #1f4fa8;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212; --surface: #1e1e1e; --surface-2: #2a2a2a; --ink: #ececec; --muted: #a0a0a6;
    --line: #2e2e30; --accent: #7aa7ff; --star: #fb923c;
    --card: #242426; --card-done: #1c1c1e; --snack: #e8e8e8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212; --surface: #1e1e1e; --surface-2: #2a2a2a; --ink: #ececec; --muted: #a0a0a6;
  --line: #2e2e30; --accent: #7aa7ff; --star: #fb923c;
  --card: #242426; --card-done: #1c1c1e; --snack: #e8e8e8;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  height: 56px; padding: 0 4px;
}
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
}
.icon-btn:active { background: rgba(127,127,127,.18); }
.icon-btn svg { width: 24px; height: 24px; }
.spacer { flex: 1; }

/* ---------- Forside ---------- */
.home { min-height: 100vh; min-height: 100dvh; background: var(--surface); padding-bottom: calc(80px + var(--safe-b)); }
.home .topbar { background: var(--surface); padding-left: 12px; }
.me { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; padding: 6px 4px; border-radius: 8px; text-align: left; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, #4f7fe0, #8a5cf0);
}
.me-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: 12.5px; color: var(--muted); }

.nav { list-style: none; margin: 4px 0 0; padding: 0; }
.nav a {
  display: flex; align-items: center; gap: 18px; height: 52px; padding: 0 20px;
  color: var(--ink); text-decoration: none;
}
.nav a:active { background: var(--surface-2); }
.nav .ico { width: 24px; height: 24px; flex: none; color: var(--c, var(--accent)); }
.nav .ico svg { width: 24px; height: 24px; }
.nav .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav .count { color: var(--muted); font-size: 14px; min-width: 20px; text-align: right; }
.divider { height: 1px; background: var(--line); margin: 6px 20px; }

.new-list {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; align-items: center; gap: 18px;
  height: calc(60px + var(--safe-b)); padding: 0 20px var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
  color: var(--accent); font-weight: 500; width: 100%;
}
.new-list svg { width: 24px; height: 24px; }

/* ---------- Listevisning ---------- */
.listpage {
  min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(170deg, var(--theme) 0%, var(--theme-dark) 100%) fixed;
  color: #fff; padding-bottom: calc(110px + var(--safe-b));
}
.listpage .topbar { background: transparent; transition: background .2s; }
.listpage .topbar.scrolled { background: var(--theme-dark); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.listpage .topbar .bar-title { font-weight: 600; font-size: 18px; opacity: 0; transition: opacity .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listpage .topbar.scrolled .bar-title { opacity: 1; }
.list-title {
  margin: 0; padding: 4px 20px 14px; font-size: 30px; font-weight: 700; line-height: 1.15;
  word-break: break-word; cursor: text;
}
.list-sub { padding: 0 20px 12px; margin-top: -8px; font-size: 13px; opacity: .85; }

.tasks { list-style: none; margin: 0; padding: 0 8px; }
.task {
  position: relative; overflow: hidden;
  margin-bottom: 2px; border-radius: 6px;
}
.task.dragging, .task.swiped { background: #c62828; } /* rød bagved, når man swiper for at slette */
.task-inner {
  position: relative; display: flex; align-items: center; gap: 4px;
  min-height: 56px; padding: 4px 4px 4px 6px;
  background: var(--card); color: var(--ink); border-radius: 6px;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
  transition: transform .2s ease;
}
.task.dragging .task-inner { transition: none; }
.task .trash-bg {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  color: #fff; width: 24px; height: 24px;
}
.task-body { flex: 1; min-width: 0; padding: 8px 4px; cursor: pointer; }
.task-title { font-size: 16px; word-break: break-word; }
.task-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.task-meta svg { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; }

.check {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none; border-radius: 50%;
}
.circle {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 2px solid var(--muted); display: grid; place-items: center;
  transition: background .15s, border-color .15s, transform .15s;
}
.circle svg { width: 14px; height: 14px; color: #fff; opacity: 0; transform: scale(.4); transition: opacity .15s, transform .2s cubic-bezier(.3,1.6,.6,1); }
.check:hover .circle svg { opacity: .55; transform: scale(1); color: var(--muted); }
.task.done .circle, .task.checking .circle, .detail .circle.on { background: var(--theme); border-color: var(--theme); }
.task.done .circle svg, .task.checking .circle svg, .detail .circle.on svg { opacity: 1; transform: scale(1); color: #fff; }
.task.checking .circle { transform: scale(1.12); }
.task.done .task-inner { background: var(--card-done); }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.checking .task-title { text-decoration: line-through; color: var(--muted); transition: color .2s; }
.task.leaving { animation: leave .28s ease forwards; }
@keyframes leave { to { opacity: 0; transform: translateY(6px); } }
.task.entering { animation: enter .25s ease; }
@keyframes enter { from { opacity: 0; transform: translateY(-6px); } }
.task.flash .task-inner { animation: flash 1s ease; }
@keyframes flash { 0%,100% { background: var(--card); } 30% { background: #fff4c2; } }

.star { color: var(--muted); }
.star.on { color: var(--star); }
.star.on svg path { fill: currentColor; }

.done-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 14px 8px 8px; padding: 6px 12px 6px 8px; border-radius: 6px;
  background: rgba(0,0,0,.22); color: #fff; font-weight: 600; font-size: 14px;
}
.done-toggle svg { width: 18px; height: 18px; transition: transform .2s; }
.done-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }

.empty { text-align: center; padding: 48px 32px; opacity: .9; }
.empty svg { width: 96px; height: 96px; margin: 0 auto 10px; opacity: .85; }
.empty p { margin: 4px 0; }

.fab {
  position: fixed; right: 18px; bottom: calc(22px + var(--safe-b)); z-index: 6;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--surface); color: var(--theme);
  box-shadow: 0 3px 8px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.2);
  display: grid; place-items: center;
}
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: scale(.95); }

/* ---------- Bundark ---------- */
.sheet-backdrop, .dialog-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.32); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--surface); color: var(--ink);
  border-radius: 14px 14px 0 0; padding: 8px 8px calc(6px + var(--safe-b));
  box-shadow: 0 -2px 12px rgba(0,0,0,.18);
  animation: up .18s ease;
}
@keyframes up { from { transform: translateY(30%); opacity: .4; } }
.sheet-row { display: flex; align-items: center; gap: 14px; padding: 8px 12px; }
.sheet-row .circle { border-color: var(--muted); }
.sheet-row input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 17px; padding: 8px 0; min-width: 0; }
.sheet-tools { display: flex; align-items: center; gap: 4px; padding: 0 4px; }
.sheet-hint { flex: 1; font-size: 13px; color: var(--muted); }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--theme); color: #fff; margin-right: 4px;
}
.send-btn:disabled { background: var(--surface-2); color: var(--muted); }
.send-btn svg { width: 22px; height: 22px; }
.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 4px 8px 2px; scrollbar-width: none; }
.suggestions:empty { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 16px; font-size: 14px;
  background: var(--surface-2); color: var(--ink);
}
.chip svg { width: 15px; height: 15px; color: var(--muted); }

/* ---------- Detalje ---------- */
.detail { min-height: 100vh; min-height: 100dvh; background: var(--bg); padding-bottom: calc(80px + var(--safe-b)); }
.detail .topbar { background: var(--bg); }
.detail .bar-title { font-size: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-card { background: var(--surface); margin: 0 0 8px; padding: 6px 4px 6px 6px; }
.d-head { display: flex; align-items: flex-start; gap: 4px; }
.d-title {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent;
  font-size: 22px; font-weight: 600; padding: 9px 4px; line-height: 1.3; min-height: 44px; overflow: hidden;
}
.d-title.done { text-decoration: line-through; color: var(--muted); }
.d-row { display: flex; align-items: center; gap: 16px; padding: 14px 16px; color: var(--muted); width: 100%; text-align: left; }
.d-row svg { width: 22px; height: 22px; flex: none; }
.d-row.on { color: var(--accent); }
.d-note { width: 100%; min-height: 120px; border: 0; outline: 0; background: transparent; resize: vertical; padding: 14px 16px; font-size: 15px; }
.d-select { flex: 1; border: 0; background: transparent; color: var(--ink); font-size: 15px; outline: 0; }
.d-foot {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center;
  height: calc(56px + var(--safe-b)); padding: 0 4px var(--safe-b) 16px;
  background: var(--surface); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.d-foot span { flex: 1; text-align: center; padding-left: 48px; }

/* ---------- Søg ---------- */
.search { min-height: 100vh; min-height: 100dvh; background: var(--surface); }
.search .topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 17px; min-width: 0; }
.search .tasks { padding: 8px; }
.search .task-inner { background: var(--surface-2); }
.search .group { padding: 14px 16px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Dialog, snackbar, login ---------- */
.dialog {
  position: fixed; z-index: 21; left: 50%; top: 40%; transform: translate(-50%,-50%);
  width: min(340px, calc(100vw - 48px)); background: var(--surface); color: var(--ink);
  border-radius: 14px; padding: 20px 20px 8px; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.dialog h2 { margin: 0 0 14px; font-size: 19px; font-weight: 600; }
.dialog p { margin: 0 0 12px; color: var(--muted); }
.dialog input[type=text] {
  width: 100%; border: 0; border-bottom: 2px solid var(--accent); outline: 0; background: transparent;
  font-size: 17px; padding: 8px 2px;
}
.dialog .btns { display: flex; justify-content: flex-end; gap: 4px; margin-top: 14px; }
.dialog .btns button { padding: 10px 14px; border-radius: 8px; color: var(--accent); font-weight: 600; }
.dialog .btns button.danger { color: #d32f2f; }
.dialog .btns button:active { background: var(--surface-2); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 4px 0 6px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: var(--ink); }
.menu-list button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 4px; text-align: left; }
.menu-list svg { width: 22px; height: 22px; color: var(--muted); }

.snackbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(92px + var(--safe-b)); z-index: 30;
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 8px 6px 16px;
  background: var(--snack); color: var(--bg); border-radius: 8px; box-shadow: 0 3px 10px rgba(0,0,0,.3);
  font-size: 14.5px; max-width: 560px; margin: 0 auto;
}
.snackbar span { flex: 1; }
.snackbar button { color: #8fb4ff; font-weight: 700; padding: 8px 10px; text-transform: uppercase; font-size: 14px; letter-spacing: .03em; }
:root[data-theme="dark"] .snackbar button { color: #1f4fa8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .snackbar button { color: #1f4fa8; } }

.offline {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); z-index: 40;
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
  font-size: 13px; padding: 6px 12px; border-radius: 16px; background: #b45309; color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: var(--surface); }
.login form { width: min(340px, 100%); text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 10px; }
.login h1 { margin: 0 0 4px; font-size: 26px; }
.login p { margin: 0 0 22px; color: var(--muted); }
.field { display: block; text-align: left; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 17px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); outline: 0;
}
.field input:focus { border-color: var(--accent); }
.primary {
  width: 100%; padding: 13px; border-radius: 10px; margin-top: 6px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 16px;
}
.err { color: #d32f2f; min-height: 1.4em; font-size: 14px; margin: 8px 0 0; }

.install {
  margin: 8px 16px 0; padding: 12px 14px; border-radius: 10px; background: var(--surface-2);
  display: flex; align-items: center; gap: 12px; font-size: 14px;
}
.install span { flex: 1; }
.install button { color: var(--accent); font-weight: 600; padding: 6px; }

@media (min-width: 720px) {
  .tasks, .list-title, .list-sub, .done-wrap { max-width: 760px; margin-left: auto; margin-right: auto; }
}

/* ---------- Flyt til toppen ---------- */
.top-btn { width: 40px; color: var(--muted); }
.top-btn svg { width: 22px; height: 22px; }

/* ---------- Træk og slip ---------- */
.task.lifted { z-index: 10; background: transparent; overflow: visible; }
.task.lifted .task-inner { box-shadow: 0 8px 20px rgba(0,0,0,.28); }
.task.lifted { transition: none; }
body.reordering { user-select: none; -webkit-user-select: none; touch-action: none; }

/* ---------- Deling ---------- */
.shared-ico { width: 18px; height: 18px; color: var(--muted); flex: none; }
.shared-ico svg { width: 18px; height: 18px; }
.list-sub { display: flex; align-items: center; gap: 6px; }
.list-sub svg { width: 15px; height: 15px; }
@media (hover: hover) and (pointer: fine) {
  .open-tasks .task-inner { cursor: grab; }
  body.reordering, body.reordering * { cursor: grabbing !important; }
}

/* Lister på forsiden kan flyttes (tryk og hold / træk med mus) */
.nav-lists > li { position: relative; background: var(--surface); }
.nav-lists > li > a { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.nav-lists > li.lifted { z-index: 5; box-shadow: 0 6px 18px rgba(0,0,0,.18); border-radius: 8px; }
@media (hover: hover) and (pointer: fine) { .nav-lists > li > a { cursor: grab; } }

/* Note med klikbare links */
.d-note-view { white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; color: var(--ink); }
.d-note-view a { color: var(--accent); text-decoration: underline; }

/* Grupper af lister (som i To Do) */
.new-list { padding-right: 8px; }
.new-list-btn { flex: 1; display: flex; align-items: center; gap: 18px; height: 100%; color: var(--accent); font-weight: 500; text-align: left; }
.new-list-btn svg, .new-list .icon-btn svg { width: 24px; height: 24px; }
.new-list .icon-btn { color: var(--accent); }
.nav-lists > li.grp { display: flex; align-items: center; margin-top: 6px; }
.grp-head {
  flex: 1; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 4px 0 20px; cursor: pointer;
  font-weight: 600; font-size: 14px; letter-spacing: .02em; text-transform: uppercase; color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.grp-head .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grp-head .count { color: var(--muted); font-weight: 400; font-size: 13px; }
.grp-chev { width: 22px; height: 22px; color: var(--accent); transition: transform .2s ease; transform: rotate(-90deg); }
.grp.open .grp-chev { transform: none; }
.grp-chev svg { width: 22px; height: 22px; }
.grp-more { color: var(--muted); }
.nav-lists > li.in-grp { margin-left: 22px; border-left: 2px solid var(--line); }
.nav-lists > li.in-grp > a { padding-left: 18px; }
.nav-lists > li.folded, .nav-lists > li.drag-hidden { display: none; }
.grp-empty { height: 44px; display: flex; align-items: center; padding-left: 20px; color: var(--muted); font-size: 14px; font-style: italic; }
@media (hover: hover) and (pointer: fine) { .grp-head { cursor: grab; } }
