/* ==========================================================================
   Doit.

   Bred skärm: sidofält som i OmniFocus och Mail, med vyerna och projekten.
   Smal skärm: menyn längst ner. Systemets typsnitt (SF Pro på Mac och
   iPhone) så att appen känns som en del av datorn; Poppins bara i ordmärket.
   Orange flagga som i OmniFocus. Mörkt läge följer systemet.

   Poppins självhostas, licens i fonts/OFL.txt.
   ========================================================================== */

@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("fonts/poppins-600.woff2") format("woff2"); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #FFFFFF;
  --sidebar: #F4F5F7;
  --surface: #F4F5F7;
  --hover: rgb(0 0 0 / 0.045);
  --active: rgb(0 0 0 / 0.075);
  --line: #E9EBEE;
  --text: #1B1F24;
  --muted: #6E7781;
  --faint: #A6ADB6;
  --accent: #1F66C1;
  --accent-tint: rgb(31 102 193 / 0.09);
  --on-accent: #FFFFFF;
  --brand: #0B3D6B;
  --flag: #F07D18;
  --ok: #1F8A5B;
  --danger: #C2362B;
  --shadow: 0 12px 40px rgb(15 23 42 / 0.18), 0 2px 8px rgb(15 23 42 / 0.08);

  --radius: 10px;
  --gutter: 16px;
  --tab-height: 58px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191F;
    --sidebar: #1C2027;
    --surface: #20252D;
    --hover: rgb(255 255 255 / 0.05);
    --active: rgb(255 255 255 / 0.09);
    --line: #2A3039;
    --text: #E8EBEF;
    --muted: #97A0AB;
    --faint: #5E6773;
    --accent: #5C9DF0;
    --accent-tint: rgb(92 157 240 / 0.14);
    --on-accent: #0E1116;
    --brand: #E8EBEF;
    --flag: #F79A45;
    --shadow: 0 12px 40px rgb(0 0 0 / 0.5), 0 2px 8px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Ikonspriten. Inte display:none — ett inline style-attribut stoppas av CSP:n. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; }
.mono { font-family: var(--mono); font-size: 0.88em; word-break: break-all; }
.muted { color: var(--muted); }

kbd {
  display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 5px;
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--bg);
  font: 500 11px/17px var(--mono); color: var(--muted); text-align: center;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Ramen ─────────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100dvh; }
.pane { flex: 1; min-width: 0; }

.sidebar {
  display: none;
  position: sticky; top: 0; height: 100dvh; flex: none; width: 248px;
  flex-direction: column; gap: 2px;
  padding: 18px 10px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar__brand {
  font: 600 19px/1 "Poppins", var(--font); letter-spacing: -0.02em; color: var(--brand);
  padding: 4px 10px 16px;
}

.sidebar__group { display: flex; flex-direction: column; gap: 1px; }

.sidebar__heading {
  margin: 18px 0 4px; padding: 0 10px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint);
}
.sidebar__heading:hover, .sidebar__heading.is-active { color: var(--muted); }

.sidebar__projects { flex: 0 1 auto; }
.sidebar__tags { flex: 1; }
.side__hash { flex: none; width: 17px; text-align: center; color: var(--faint); font-weight: 600; }
.side__item.is-active .side__hash { color: var(--accent); }

.sidebar__foot { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }

.side__item {
  display: flex; align-items: center; gap: 9px;
  min-height: 30px; padding: 0 10px; border-radius: 7px;
  color: var(--text); font-size: 14px;
}
.side__item:hover { background: var(--hover); }
.side__item.is-active { background: var(--active); font-weight: 600; }
.side__item .icon { width: 17px; height: 17px; color: var(--muted); }
.side__item.is-active .icon { color: var(--accent); }
.side__item--flag .icon { color: var(--flag) !important; }
.side__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; font-weight: 400; }
.side__item--muted { color: var(--faint); }
.side__item.is-paused .side__label { color: var(--faint); }

.side__dot {
  flex: none; width: 9px; height: 9px; margin: 0 4px; border-radius: 50%;
  border: 1.5px solid var(--accent); opacity: 0.85;
}
.is-paused .side__dot, .project--paused .side__dot { border-color: var(--faint); border-style: dashed; }

.side__hint {
  font: inherit; font-size: 12px; color: var(--faint); background: none; border: 0; cursor: pointer;
  padding: 2px 10px; text-align: left;
}
.side__hint:hover { color: var(--muted); }

.topbar {
  display: flex; align-items: center;
  padding: max(env(safe-area-inset-top), 12px) var(--gutter) 10px;
  border-bottom: 1px solid var(--line);
}
.topbar__brand { font: 600 19px/1 "Poppins", var(--font); color: var(--brand); letter-spacing: -0.02em; }

.main {
  max-width: 780px; margin: 0 auto;
  padding: 20px var(--gutter) calc(var(--tab-height) + env(safe-area-inset-bottom) + 32px);
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  height: calc(var(--tab-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab__item {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--faint); font-size: 10.5px; font-weight: 500;
}
.tab__item .icon { width: 22px; height: 22px; }
.tab__item.is-active { color: var(--accent); }
.tab__item--flag.is-active { color: var(--flag); }
.tab__count {
  position: absolute; top: 5px; left: calc(50% + 7px);
  min-width: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--surface); color: var(--muted); font-size: 10.5px; line-height: 17px; text-align: center;
}

@media (min-width: 860px) {
  .sidebar { display: flex; }
  .topbar, .tabbar { display: none; }
  .main { padding: 44px 56px 64px; }
}

/* ── Sidhuvud ──────────────────────────────────────────────────────────── */

.page-head { margin-bottom: 18px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
.page-title--flag { color: var(--flag); }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.project-note { white-space: pre-wrap; }

.crumb { margin-bottom: 10px; font-size: 13px; }
.crumb a { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.crumb a:hover { color: var(--text); }
.crumb .icon { width: 15px; height: 15px; }

/* ── Inmatningen ───────────────────────────────────────────────────────── */

.capture { display: flex; gap: 8px; margin-bottom: 18px; }

.capture__input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 16px; /* 16+ px, annars zoomar iPhone in vid fokus */
  padding: 11px 14px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.capture__input::placeholder { color: var(--faint); }
.capture__input:focus { outline: none; background: var(--bg); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

.capture__button {
  flex: none; width: 44px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); cursor: pointer;
  display: grid; place-items: center;
}
.capture__button:hover { filter: brightness(1.08); }

/* ── Listorna ──────────────────────────────────────────────────────────── */

.section { margin-top: 32px; }
.section__title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--faint); margin-bottom: 8px;
}
.section__count { font-weight: 400; }

.tasks, .projects, .rows { list-style: none; }

.task {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 8px; margin: 0 -8px;
  border-radius: 8px;
  position: relative;
}
.task + .task::before {
  content: ""; position: absolute; top: 0; left: 40px; right: 8px; border-top: 1px solid var(--line);
}
.task:hover { background: var(--hover); }
.task:hover::before, .task:hover + .task::before,
.task.is-selected::before, .task.is-selected + .task::before { border-color: transparent; }
.task.is-selected { background: var(--accent-tint); }

.task form { display: contents; }

.task__check {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--faint); background: transparent; color: var(--bg);
  cursor: pointer; display: grid; place-items: center;
  transition: border-color 0.12s, background 0.12s;
}
.task__check:hover { border-color: var(--ok); background: rgb(31 138 91 / 0.1); }
.task__check .icon { width: 12px; height: 12px; stroke-width: 3; opacity: 0; }
.task--closed .task__check .icon { opacity: 1; }
.task--flagged .task__check { border-color: var(--flag); }
.task--closed .task__check { background: var(--faint); border-color: var(--faint); }
.task--closed .task__flag { visibility: hidden; }

.task__body {
  flex: 1; min-width: 0; padding: 11px 0;
  color: var(--text); display: flex; align-items: baseline; gap: 10px;
}
.task__title { overflow-wrap: anywhere; }
.task--closed .task__title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.task__project {
  flex: none; font-size: 12px; color: var(--accent);
  padding: 1px 8px; border-radius: 10px; background: var(--accent-tint);
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task__has-note { color: var(--faint); }

.task__flag {
  flex: none; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
  color: var(--faint); display: grid; place-items: center;
}
.task__flag:hover { color: var(--muted); background: var(--hover); }
.task__flag .icon { width: 16px; height: 16px; }
.task__flag[aria-pressed="true"] { color: var(--flag); }
.task__flag[aria-pressed="true"] .icon { fill: currentColor; }

/* På en dator syns den ofyllda flaggan bara när man pekar på raden. */
@media (hover: hover) {
  .task__flag[aria-pressed="false"] { opacity: 0; }
  .task:hover .task__flag, .task.is-selected .task__flag { opacity: 1; }
}

.task.is-leaving { opacity: 0.35; transition: opacity 0.15s; }

.project a {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 0 8px; margin: 0 -8px; border-radius: 8px; color: var(--text);
}
.project + .project a { box-shadow: inset 0 1px 0 var(--line); }
.project a:hover { background: var(--hover); }
.project a.is-selected { background: var(--accent-tint); box-shadow: none; }
.project__name { flex: 1; font-weight: 500; }
.project--paused .project__name { color: var(--muted); }
.project__count { color: var(--faint); min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.project__flagged { display: inline-flex; align-items: center; gap: 3px; color: var(--flag); font-size: 13px; }
.project__flagged .icon { width: 13px; height: 13px; fill: currentColor; }

.pill {
  display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 10px;
  background: var(--surface); color: var(--muted); vertical-align: middle; letter-spacing: 0;
}

.empty { color: var(--faint); padding: 18px 0; }
.more { margin-top: 18px; font-size: 14px; }
.meta, .hint { color: var(--muted); font-size: 13px; }
.meta { margin-top: 24px; }

/* ── Formulär ──────────────────────────────────────────────────────────── */

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--muted); }

input[type="text"], textarea, select {
  font: inherit; font-size: 15px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
  width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input[type="text"]:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 18px; height: 18px; accent-color: var(--flag); }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 12px 0; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions--secondary { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.actions form { display: inline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.btn:hover { background: var(--hover); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--text); }
.btn--sm { padding: 5px 10px; font-size: 13px; }
.btn--block { width: 100%; }
.btn .icon { width: 15px; height: 15px; }

.linklike { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }

details { margin-top: 12px; }
details.edit { margin-top: 36px; border-top: 1px solid var(--line); padding-top: 16px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
details summary:hover { color: var(--text); }

/* ── Meddelanden och kort ──────────────────────────────────────────────── */

.flash {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 18px;
  background: var(--surface); font-size: 14px;
}
.flash form { display: inline; }
.flash--error { color: var(--danger); }

.notice { padding: 10px 14px; border-radius: 8px; margin: 12px 0; background: var(--surface); font-size: 14px; }
.notice--error { color: var(--danger); }

.card { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; }
.card h3 { font-size: 14px; margin: 14px 0 6px; }
.card h3:first-child { margin-top: 0; }
.card p { margin-bottom: 8px; }
.card--accent { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.token { font-size: 13px; }

.steps { padding-left: 20px; margin: 8px 0; }
.steps li { margin-bottom: 6px; }

.row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.row > span:first-child { flex: 1; min-width: 160px; }
.row__meta { color: var(--muted); font-size: 13px; }
.row--muted { opacity: 0.5; }

.section p { margin-bottom: 8px; }

.keys { border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; }
.keys td { padding: 5px 18px 5px 0; vertical-align: top; }
.keys td:first-child { white-space: nowrap; }

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--tab-height) + env(safe-area-inset-bottom) + 12px);
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px;
  box-shadow: var(--shadow);
}
.toast .linklike { color: var(--bg); text-decoration: underline; }
@media (min-width: 860px) { .toast { bottom: 24px; left: calc(50% + 124px); } }

/* ── ⌘K och hjälprutan ─────────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 14vh 16px 16px;
  background: rgb(15 20 30 / 0.28);
}

.dialog {
  width: 100%; max-width: 580px; max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}

.palette__input {
  font: inherit; font-size: 17px; padding: 16px 18px;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text);
}
.palette__input:focus { outline: none; }

.palette__list { list-style: none; overflow-y: auto; padding: 6px; }
.palette__group { padding: 10px 12px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.palette__item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.palette__item .icon { width: 16px; height: 16px; color: var(--muted); }
.palette__item.is-selected { background: var(--accent-tint); }
.palette__item.is-selected .icon { color: var(--accent); }
.palette__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__meta { font-size: 12px; color: var(--faint); }
.palette__empty { padding: 16px 12px; color: var(--faint); font-size: 14px; }
.palette__flag { color: var(--flag) !important; }

.help { padding: 18px 22px 20px; overflow-y: auto; }
.help h2 { font-size: 16px; margin-bottom: 4px; }
.help h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 16px 0 6px; }
.help table { border-collapse: collapse; width: 100%; font-size: 14px; }
.help td { padding: 4px 0; }
.help td:first-child { width: 1%; padding-right: 24px; white-space: nowrap; }

/* ── Inloggningen ──────────────────────────────────────────────────────── */

.centred { display: grid; place-items: center; padding: var(--gutter); }
.signin { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.signin__brand { font: 600 42px/1.1 "Poppins", var(--font); color: var(--brand); letter-spacing: -0.03em; margin-bottom: 8px; }
.signin .card { text-align: left; }
.ms-mark { width: 18px; height: 18px; }

/* ── Taggar ────────────────────────────────────────────────────────────── */

.tag-pill {
  flex: none; font-size: 12px; color: var(--muted);
  padding: 0 7px; border-radius: 10px; border: 1px solid var(--line);
  white-space: nowrap;
}
.tag-pill--inherited { border-style: dashed; }

.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-choice {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 13px; padding: 4px 10px; border-radius: 14px;
  border: 1px solid var(--line); color: var(--muted); user-select: none;
}
.tag-choice input { position: absolute; opacity: 0; pointer-events: none; }
.tag-choice:has(input:checked) { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.tag-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tag-choice--inherited { cursor: default; border-style: dashed; }

.context-editor { font-family: var(--mono); font-size: 13px; line-height: 1.55; min-height: 360px; }
.context-preview {
  white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  background: var(--surface); border-radius: var(--radius); padding: 14px 16px; color: var(--muted);
}
.danger { color: var(--danger) !important; }
.page-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.page-head--split { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
