/* Todo · Things-geïnspireerde stijl */
:root {
  --bg: #ffffff;
  --sb: #f4f5f7;
  --sb-sel: #e2e4e8;
  --text: #1d1d1f;
  --muted: #8a8a8e;
  --faint: #c7c7cc;
  --line: #ececee;
  --card: #ffffff;
  --card-shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 24px rgba(0,0,0,.10);
  --chk: #b9b9be;
  --blue: #1b6ef3;
  --c-inbox: #1d8cf0;
  --c-today: #f4c01e;
  --c-upcoming: #e8364d;
  --c-anytime: #2fa395;
  --c-someday: #c9a46b;
  --c-logbook: #4bb34f;
  --c-trash: #9a9aa0;
  --c-area: #5e9b5f;
  --red: #e8364d;
  --chip: #f0f1f3;
  --pop: #ffffff;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --sb: #242426; --sb-sel: #3a3a3d; --text: #f2f2f4; --muted: #98989d;
    --faint: #5a5a5e; --line: #2f2f32; --card: #2a2a2d; --chk: #6c6c70; --chip: #363639; --pop: #2e2e31;
    --card-shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 14.5px/1.4 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
#login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--sb); }
.login-box { width: min(320px, 88vw); text-align: center; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px; background: var(--blue); display: grid; place-items: center; color: #fff; }
.login-logo svg { width: 34px; height: 34px; }
.login-box h1 { margin: 0; font-size: 24px; }
.login-box p { color: var(--muted); margin: 4px 0 22px; }
.login-box input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--faint); background: var(--bg); outline: none; }
.login-box input:focus { border-color: var(--blue); }
.login-box button { width: 100%; margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 600; }
.login-err { color: var(--red); min-height: 20px; margin-top: 8px; font-size: 13px; }

/* ---------- layout ---------- */
#app { display: flex; height: 100vh; height: 100dvh; }
#sidebar { width: 260px; flex: none; background: var(--sb); display: flex; flex-direction: column; padding: 14px 10px 10px; padding-top: max(14px, env(safe-area-inset-top)); }
#main { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
#content { flex: 1; overflow-y: auto; padding: 46px 56px 140px; -webkit-overflow-scrolling: touch; }
.topbar { display: none; }

/* ---------- sidebar ---------- */
.sb-search { display: flex; align-items: center; gap: 6px; background: var(--sb-sel); border-radius: 8px; padding: 6px 9px; margin: 0 4px 14px; color: var(--muted); }
.sb-search svg { width: 14px; height: 14px; }
.sb-search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; font-size: 13.5px; }
#nav { flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 5px 10px; border-radius: 7px; cursor: pointer; user-select: none; min-height: 31px; }
.nav-item:hover { background: rgba(0,0,0,.035); }
.nav-item.sel { background: var(--sb-sel); }
.nav-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .cnt { color: var(--muted); font-size: 13px; }
.nav-item .cnt.red { color: #fff; background: var(--red); border-radius: 9px; padding: 0 6px; font-size: 12px; font-weight: 600; }
.nav-gap { height: 14px; }
.nav-area { font-weight: 600; margin-top: 10px; }
.nav-area svg { color: var(--c-area); }
.nav-item.drop { outline: 2px solid var(--blue); }
.sb-foot { display: flex; align-items: center; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.sb-btn { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 7px; color: var(--muted); flex: 1; text-align: left; }
.sb-btn svg { width: 14px; height: 14px; }
.sb-btn:hover, .sb-icon:hover { background: rgba(0,0,0,.04); }
.sb-icon { padding: 6px; border-radius: 7px; color: var(--muted); }

.ic-inbox { color: var(--c-inbox); } .ic-today { color: var(--c-today); } .ic-upcoming { color: var(--c-upcoming); }
.ic-anytime { color: var(--c-anytime); } .ic-someday { color: var(--c-someday); } .ic-logbook { color: var(--c-logbook); }
.ic-trash { color: var(--c-trash); } .ic-area { color: var(--c-area); }

/* voortgangscirkel van een project */
.pie { width: 16px; height: 16px; border-radius: 50%; border: 1.6px solid var(--blue); flex: none; position: relative; overflow: hidden; }
.pie::after { content: ""; position: absolute; inset: 1.5px; border-radius: 50%; background: conic-gradient(var(--blue) calc(var(--p) * 1%), transparent 0); }
.pie.big { width: 24px; height: 24px; border-width: 2px; }
.pie.big::after { inset: 2.5px; }

/* ---------- koppen ---------- */
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.head > svg, .head .pie.big { width: 28px; height: 28px; }
.head h1 { font-size: 27px; font-weight: 700; margin: 0; letter-spacing: -.3px; flex: 1; min-width: 0; }
.htitle { font-size: 27px; font-weight: 700; letter-spacing: -.3px; border: 0; outline: none; background: none; flex: 1; min-width: 0; padding: 0; }
.head .icon-btn { color: var(--muted); }
.hnotes { width: 100%; border: 0; outline: none; background: none; resize: none; color: var(--muted); margin: 4px 0 6px 40px; padding: 0; min-height: 22px; width: calc(100% - 40px); }
.hmeta { margin: 0 0 8px 40px; color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.hmeta .red { color: var(--red); }
.icon-btn { padding: 6px; border-radius: 7px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--chip); }

.group { margin-top: 26px; }
.group-h { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 15px; padding: 0 0 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--text); }
.group-h .day { font-size: 22px; line-height: 1; }
.group-h .sub { color: var(--muted); font-weight: 500; }
.group-h.link { cursor: pointer; }
.group-h svg { width: 15px; height: 15px; align-self: center; }

.empty { color: var(--faint); text-align: center; margin-top: 90px; font-size: 15px; }
.empty svg { width: 54px; height: 54px; display: block; margin: 0 auto 10px; opacity: .45; }

/* ---------- to-do rij ---------- */
.list { margin-top: 10px; }
.todo { display: flex; align-items: flex-start; gap: 10px; padding: 5px 8px; margin: 0 -8px; border-radius: 7px; cursor: default; user-select: none; position: relative; }
.todo:hover { background: rgba(0,0,0,.025); }
.todo.sel { background: #dbe8fd; }
@media (prefers-color-scheme: dark) { .todo.sel { background: #24406b; } .todo:hover { background: rgba(255,255,255,.03); } }
.chk { width: 15px; height: 15px; border: 1.5px solid var(--chk); border-radius: 4px; flex: none; margin-top: 2.5px; position: relative; transition: .15s; background: var(--bg); }
.chk:hover { border-color: var(--blue); }
.todo.done .chk, .ci.done .chk { background: var(--blue); border-color: var(--blue); }
.todo.done .chk::after, .ci.done .chk::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.todo.done .ttitle { color: var(--muted); }
.todo.someday-chk .chk { border-style: dashed; }
.tmain { flex: 1; min-width: 0; }
.tline { display: flex; align-items: center; gap: 6px; min-height: 20px; }
.ttitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ttitle.ph { color: var(--faint); }
.tline svg { width: 12px; height: 12px; color: var(--muted); }
.tline .star { color: var(--c-today); }
.tsub { color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; }
.tag { background: var(--chip); color: var(--muted); border-radius: 9px; padding: 0 7px; font-size: 11.5px; line-height: 18px; white-space: nowrap; }
.tright { font-size: 12.5px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.tright svg { width: 12px; height: 12px; }
.tright.red { color: var(--red); }
.todo.dr { -webkit-touch-callout: none; }
.dragging { opacity: .3; }
.drop-before { box-shadow: inset 0 2px 0 var(--blue); }
.drop-after { box-shadow: inset 0 -2px 0 var(--blue); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; background: var(--card); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.22); opacity: .95; margin: 0; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }
#nav [data-drag] { -webkit-touch-callout: none; }

/* project-/gebiedsrij in een lijst */
.prow { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 7px; cursor: pointer; font-weight: 600; }
.prow:hover { background: rgba(0,0,0,.03); }
.prow .cnt { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 13px; }

/* ---------- open to-do (kaart) ---------- */
.todo.open { display: block; background: var(--card); box-shadow: var(--card-shadow); padding: 12px 14px 10px; margin: 12px -14px 16px; border-radius: 10px; cursor: auto; user-select: text; }
.todo.open:hover { background: var(--card); }
.erow { display: flex; align-items: flex-start; gap: 10px; }
.etitle { flex: 1; border: 0; outline: none; background: none; padding: 0; font-size: 15px; min-width: 0; }
.enotes { display: block; width: 100%; border: 0; outline: none; background: none; resize: none; margin: 8px 0 4px; padding: 0 0 0 25px; color: var(--text); min-height: 22px; overflow: hidden; }
.enotes::placeholder, .etitle::placeholder, .ci input::placeholder { color: var(--faint); }
.echeck { margin: 6px 0 6px 25px; }
.ci { display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); padding: 3px 0; }
.ci .chk { width: 13px; height: 13px; margin: 0; border-radius: 50%; }
.ci.done .chk::after { left: 3px; top: 0; width: 3.5px; height: 7px; }
.ci input { flex: 1; border: 0; outline: none; background: none; padding: 2px 0; min-width: 0; }
.ci.done input { color: var(--muted); text-decoration: line-through; }
.ci .rm { opacity: 0; color: var(--muted); }
.ci:hover .rm { opacity: 1; }
.ci .rm svg { width: 12px; height: 12px; }
.etags { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 2px 25px; align-items: center; }
.etags .tag { cursor: pointer; }
.etags .tag:hover { text-decoration: line-through; }
.etags input { border: 0; outline: none; background: none; font-size: 12.5px; width: 120px; padding: 1px 0; }
.ebar { display: flex; align-items: center; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--chip); border-radius: 6px; padding: 3px 8px; font-size: 12.5px; cursor: pointer; }
.chip svg { width: 12px; height: 12px; }
.chip .x { opacity: .5; } .chip .x:hover { opacity: 1; }
.chip.red { color: var(--red); }
.ebar .spacer { flex: 1; }
.ebar .icon-btn { color: var(--muted); }
.ebar .icon-btn svg { width: 16px; height: 16px; }
.eloc { color: var(--muted); font-size: 12.5px; margin-left: 4px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.eloc svg { width: 12px; height: 12px; }

.more-done { margin-top: 24px; color: var(--muted); font-size: 13px; }
.more-done button { color: var(--muted); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- popover / menu ---------- */
#pop { position: fixed; z-index: 50; background: var(--pop); border-radius: 11px; box-shadow: 0 10px 40px rgba(0,0,0,.22), 0 0 0 .5px rgba(0,0,0,.12); padding: 6px; min-width: 220px; max-height: 70vh; overflow-y: auto; }
.mi { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border-radius: 7px; text-align: left; }
.mi:hover { background: var(--blue); color: #fff; }
.mi:hover svg { color: #fff !important; }
.mi.danger { color: var(--red); }
.mi.danger:hover { background: var(--red); color: #fff; }
.mi .k { margin-left: auto; opacity: .55; font-size: 12px; }
.msep { height: 1px; background: var(--line); margin: 5px 4px; }
.mhead { font-size: 11.5px; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .4px; }
.mdate { display: flex; gap: 6px; padding: 6px 8px; }
.mdate input { flex: 1; padding: 6px 8px; border: 1px solid var(--faint); border-radius: 7px; background: var(--bg); min-width: 0; }
.mdate button { padding: 6px 10px; border-radius: 7px; background: var(--blue); color: #fff; }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.3); display: grid; place-items: center; padding: 20px; }
.mbox { background: var(--bg); border-radius: 14px; padding: 24px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.mbox h2 { margin: 0 0 4px; font-size: 20px; }
.mbox h3 { font-size: 14px; margin: 20px 0 6px; }
.mbox p, .mbox li { color: var(--muted); font-size: 13.5px; }
.mbox ol { padding-left: 18px; margin: 6px 0; }
.mbox code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.urlbox { display: flex; gap: 6px; margin-top: 6px; }
.urlbox input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--faint); background: var(--sb); font-size: 12.5px; font-family: ui-monospace, Menlo, monospace; }
.btn { padding: 8px 14px; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 600; white-space: nowrap; }
.btn.ghost { background: var(--chip); color: var(--text); font-weight: 500; }
.btn.danger { background: none; color: var(--red); border: 1px solid var(--line); font-weight: 500; }
.mfoot { display: flex; gap: 8px; justify-content: space-between; margin-top: 24px; flex-wrap: wrap; }
.field { width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--faint); background: var(--bg); outline: none; margin-top: 12px; }
.field:focus { border-color: var(--blue); }

#toast { position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #2c2c2e; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 13.5px; z-index: 70; display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
#toast button { color: #6ea8ff; font-weight: 600; }

/* ---------- FAB ---------- */
#fab { position: fixed; z-index: 20; right: 28px; bottom: calc(28px + env(safe-area-inset-bottom)); width: 50px; height: 50px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(27,110,243,.45); transition: transform .15s; }
#fab:hover { transform: scale(1.06); }
#fab svg { width: 22px; height: 22px; }

/* ---------- mobiel (iPhone) ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  #sidebar { width: 100%; background: var(--bg); padding: max(16px, env(safe-area-inset-top)) 14px 10px; }
  #app.m-home #main { display: none; }
  #app:not(.m-home) #sidebar { display: none; }
  .nav-item { min-height: 42px; padding: 8px 10px; font-size: 16.5px; }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item.sel { background: none; }
  .sb-search { margin: 4px 2px 18px; padding: 9px 11px; }
  .sb-search input { font-size: 16px; }
  .sb-foot { padding-right: 76px; padding-bottom: env(safe-area-inset-bottom); }
  .topbar { display: flex; align-items: center; gap: 4px; padding: max(8px, env(safe-area-inset-top)) 10px 0; min-height: 44px; }
  .topbar #back { color: var(--blue); }
  .topbar #back svg { width: 22px; height: 22px; }
  .topbar-title { font-weight: 600; opacity: 0; transition: opacity .15s; }
  .topbar.scrolled .topbar-title { opacity: 1; }
  #content { padding: 6px 20px 140px; }
  .head h1, .htitle { font-size: 26px; }
  .todo { padding: 8px 8px; }
  .chk { width: 19px; height: 19px; border-radius: 5px; margin-top: 1px; }
  .todo.done .chk::after { left: 5.5px; top: 2px; width: 5px; height: 10px; }
  .todo.open { margin: 10px -10px 14px; padding: 14px 14px 10px; }
  .etitle { font-size: 16.5px; }
  .enotes, .echeck, .etags { padding-left: 0; margin-left: 29px; width: calc(100% - 29px); }
  .enotes { padding-left: 0; }
  .ci .rm { opacity: 1; }
  #fab { right: 20px; bottom: calc(22px + env(safe-area-inset-bottom)); width: 56px; height: 56px; }
  #pop { left: 10px !important; right: 10px; top: auto !important; bottom: calc(10px + env(safe-area-inset-bottom)); min-width: 0; }
  .mi { padding: 11px 12px; font-size: 16px; }
}
