:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --line: #e5e5ea;
  --fill: #eeeef3;
  --accent: #14936b;
  --danger: #ff3b30;
  --bar: rgba(242, 242, 247, 0.88);
  --tabbar: rgba(249, 249, 251, 0.9);
  --tab-h: 50px;
  color-scheme: light;
}

/* Themes. --accent is set from Settings in app.js. "Automatiskt" (no data-theme) follows the phone. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #8e8e93;
    --line: #2c2c2e;
    --fill: #2c2c2e;
    --danger: #ff453a;
    --bar: rgba(0, 0, 0, 0.82);
    --tabbar: rgba(22, 22, 24, 0.9);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --text: #f2f2f7;
  --muted: #8e8e93;
  --line: #2c2c2e;
  --fill: #2c2c2e;
  --danger: #ff453a;
  --bar: rgba(0, 0, 0, 0.82);
  --tabbar: rgba(22, 22, 24, 0.9);
  color-scheme: dark;
}

:root[data-theme="midnatt"] {
  --bg: #0b1020;
  --card: #161d33;
  --text: #e8ecf8;
  --muted: #8b93ad;
  --line: #262f4d;
  --fill: #232b47;
  --danger: #ff6b6b;
  --bar: rgba(11, 16, 32, 0.85);
  --tabbar: rgba(14, 19, 36, 0.9);
  color-scheme: dark;
}

:root[data-theme="papper"] {
  --bg: #f3ede2;
  --card: #fffaf1;
  --text: #2b2620;
  --muted: #8a7f70;
  --line: #e5dac8;
  --fill: #ece3d4;
  --bar: rgba(243, 237, 226, 0.88);
  --tabbar: rgba(247, 242, 233, 0.92);
  color-scheme: light;
}

:root[data-theme="skog"] {
  --bg: #0f1a15;
  --card: #18271f;
  --text: #e6f0e9;
  --muted: #8ea597;
  --line: #24382d;
  --fill: #22362b;
  --danger: #ff7a6b;
  --bar: rgba(15, 26, 21, 0.85);
  --tabbar: rgba(17, 29, 23, 0.9);
  color-scheme: dark;
}

:root[data-theme="hav"] {
  --bg: #eaf3f8;
  --card: #ffffff;
  --text: #13232e;
  --muted: #6f8796;
  --line: #d6e5ee;
  --fill: #e1edf4;
  --bar: rgba(234, 243, 248, 0.88);
  --tabbar: rgba(240, 247, 251, 0.92);
  color-scheme: light;
}

:root { --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

#view {
  padding: 0 16px calc(var(--tab-h) + 40px + env(safe-area-inset-bottom));
  max-width: 680px;
  margin: 0 auto;
}

/* Tab bar */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--tabbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--line);
}
.tabbar button {
  flex: 1;
  height: var(--tab-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
}
.tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.on { color: var(--accent); }

/* Navigation bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -16px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 44px;
}
.bar .title { font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .left { justify-self: start; min-width: 0; max-width: 100%; }
.bar .right { justify-self: end; display: flex; gap: 4px; }
.bar-btn { color: var(--accent); display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 4px; max-width: 100%; }
.bar-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.bar-btn.icon svg { width: 26px; height: 26px; stroke-width: 2; }

.large-title { font-size: 34px; font-weight: 700; letter-spacing: 0.01em; margin: 4px 0 14px; }
.top-pad { height: calc(env(safe-area-inset-top) + 20px); }

/* Groups (iOS inset grouped lists) */

.section-label {
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 26px 16px 7px;
}
.section-hint { font-size: 13px; color: var(--muted); margin: 7px 16px 0; line-height: 1.4; }

.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 16px;
  position: relative;
  width: 100%;
  text-align: left;
}
.row + .row::before, .row + .text::before {
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 0;
  border-top: 0.5px solid var(--line);
}
.row label, .row .label { flex: 1; }
.row .value { color: var(--muted); }
.row input[type="number"], .row input[type="time"], .row select, .date-wrap input {
  border: 0;
  background: var(--fill);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 34px;
  text-align: right;
  -webkit-appearance: none;
  appearance: none;
}
.row input[type="number"] { width: 80px; }
.row select { text-align: left; padding-right: 10px; }

/* Date field with an explicit clear button: iOS's own "Nollställ" can't always clear a value. */
.date-wrap { display: flex; align-items: center; gap: 6px; }
.date-wrap input { min-width: 130px; }
.date-wrap input.empty { color: var(--muted); }
.date-wrap .clear {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: none;
}
.date-wrap .clear svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.date-wrap:not(.has-value) .clear { visibility: hidden; }

.text {
  display: block;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 12px 16px;
  resize: none;
  min-height: 46px;
  line-height: 1.4;
  position: relative;
}
textarea.text { min-height: 92px; overflow: hidden; }
.text::placeholder { color: var(--muted); opacity: 0.75; }
.text.title-input { font-size: 22px; font-weight: 600; min-height: 56px; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) {
  .pair { grid-template-columns: 1fr; gap: 0; }
}

/* Swatches (accent and goal colors) */

.swatches { display: flex; flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
.swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--c);
  position: relative;
  display: grid;
  place-items: center;
}
.swatch.sel::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2.5px solid var(--c);
}
.swatch svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.swatch.sel svg { opacity: 1; }
.swatch.custom { background: conic-gradient(#ff3b30, #ff9500, #ffcc00, #34c759, #0a84ff, #5e5ce6, #af52de, #ff3b30); }
.swatch.custom.sel { background: var(--c); }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; padding: 0; }

/* Theme picker */

.theme-row .preview {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 0.5px solid rgba(128, 128, 128, 0.35);
  flex: none;
  display: grid;
  place-items: center;
}
.theme-row .preview i { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.theme-row .tick { color: var(--accent); width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; flex: none; }
.theme-row.sel .tick { visibility: visible; }
.theme-row small { display: block; color: var(--muted); font-size: 13px; }

/* Switch */

.row .switch, .switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--fill); transition: background 0.2s; }
.switch span::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.switch input:checked + span { background: #34c759; }
.switch input:checked + span::after { transform: translateX(20px); }

/* Buttons */

.primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: 12px;
  min-height: 50px;
  margin-top: 16px;
}
.secondary {
  display: block;
  width: 100%;
  background: var(--card);
  color: var(--accent);
  font-weight: 600;
  border-radius: 12px;
  min-height: 50px;
  margin-top: 10px;
}
.link-row { color: var(--accent); text-decoration: none; }
.link-row.danger { color: var(--danger); }
.chev { color: var(--muted); opacity: 0.6; font-size: 20px; }

/* Goal cards (achieved list) */

.goal-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border-left: 4px solid var(--g, var(--accent));
}
.goal-card h2 { font-size: 18px; font-weight: 600; margin: 0 0 4px; overflow-wrap: anywhere; }
.goal-card h2.untitled { color: var(--muted); }
.meta { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: 2px;
  margin-left: 6px;
}
.badge.late { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.progress { height: 6px; background: var(--fill); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--g, var(--accent)); border-radius: 99px; transition: width 0.25s; }

/* Home: one full-screen page per active goal, swiped sideways */

.pager {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.pager::-webkit-scrollbar { display: none; }
.page {
  flex: 0 0 100%;
  height: 100%;
  overflow-y: auto;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overscroll-behavior-y: contain;
  padding: calc(env(safe-area-inset-top) + 18px) 16px 64px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--g) 26%, var(--bg)) 0, var(--bg) 420px);
}
.page-inner { max-width: 600px; margin: 0 auto; }
.page.plain { background: var(--bg); }

.page-dots {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 10px);
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 99px;
  background: var(--tabbar);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 6;
}
.page-dots button { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: 0.4; transition: opacity 0.2s, background 0.2s; }
.page-dots button.on { opacity: 1; background: var(--text); }
.page-dots button.plus { border-radius: 2px; }

.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.eyebrow { text-transform: uppercase; font-size: 12.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--g); }
.brand { height: 22px; width: auto; flex: none; display: block; }
.hero-title { font-size: 34px; line-height: 1.12; font-weight: 800; letter-spacing: -0.01em; margin: 8px 0 8px; overflow-wrap: anywhere; }
.hero-title.untitled { color: var(--muted); }
.hero-desc { margin: 0 0 6px; color: var(--muted); font-size: 16px; line-height: 1.45; white-space: pre-line; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0 12px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px 12px 10px; }
.stat b { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--g); }
.stat span { font-size: 12.5px; color: var(--muted); }
.timeline { margin: 4px 2px 0; }
.timeline .progress { margin-top: 0; }
.timeline .ends { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.m-card { background: var(--card); border-radius: 16px; padding: 16px; margin-top: 12px; }
.m-card h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.m-card h3 svg { width: 20px; height: 20px; flex: none; stroke: var(--g); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.m-card .why { font-size: 20px; line-height: 1.4; font-weight: 600; margin: 0; white-space: pre-line; }
.m-card .missing { color: var(--muted); font-size: 15px; margin: 0; }
.m-card .missing button { color: var(--g); font-weight: 600; }
.m-card ul { margin: 0; padding: 0; list-style: none; }
.m-card li { position: relative; padding-left: 20px; margin: 6px 0; line-height: 1.4; }
.m-card li::before { content: ""; position: absolute; left: 4px; top: 0.55em; width: 7px; height: 7px; border-radius: 50%; background: var(--g); }


.ob { display: grid; gap: 3px; padding: 10px 0; }
.ob:first-of-type { padding-top: 2px; }
.ob + .ob { border-top: 0.5px solid var(--line); }
.ob-h { font-size: 14px; color: var(--muted); }
.ob-l { font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.ob-l::before { content: "→"; color: var(--g); font-weight: 700; }

.now-sprint { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; width: 100%; text-align: left; }
.now-sprint b { font-size: 17px; }
.now-sprint span { font-size: 13px; color: var(--muted); white-space: nowrap; }
.mini-acts { margin-top: 6px; }
.mini-act { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 7px 0; font-size: 15.5px; }
.mini-act .ring { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; }
.mini-act .ring svg { width: 12px; height: 12px; stroke: #fff; fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.mini-act.done .ring { background: var(--g); border-color: var(--g); }
.mini-act.done .ring svg { opacity: 1; }
.mini-act.done .t { color: var(--muted); text-decoration: line-through; }
.mini-act .d { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.mini-act .d.late { color: var(--danger); }
.text-btn { color: var(--g, var(--accent)); font-weight: 600; font-size: 15px; margin-top: 6px; min-height: 32px; }

.empty { text-align: center; padding: 40px 12px 10px; color: var(--muted); }
.empty svg { width: 72px; height: 72px; stroke: var(--accent); fill: none; stroke-width: 1.6; margin-bottom: 12px; }
.empty h2 { color: var(--text); font-size: 24px; margin: 0 0 8px; }
.empty p { line-height: 1.45; margin: 0 auto; max-width: 340px; }

/* Rating scales */

.scale { padding: 12px 16px 14px; }
.scale + .scale { border-top: 0.5px solid var(--line); }
.scale-q { font-size: 15px; margin-bottom: 10px; }
.scale-q small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.dots { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.dots button, .yesno button {
  min-height: 36px;
  border-radius: 8px;
  background: var(--fill);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, color 0.15s;
}
.dots button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dots button.sel { background: var(--accent); color: #fff; font-weight: 600; }
.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.yesno button.sel { background: var(--accent); color: #fff; font-weight: 600; }

/* Sprint list inside goal */

.sprint-row { padding: 10px 16px; }
.sprint-row .num {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--g, var(--accent)) 16%, transparent);
  color: var(--g, var(--accent));
  font-weight: 700;
  font-size: 15px;
  display: grid;
  place-items: center;
}
.sprint-row .num.done { background: var(--g, var(--accent)); color: #fff; }
.sprint-row .info { flex: 1; min-width: 0; }
.sprint-row .info b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sprint-row .info small { color: var(--muted); font-size: 13px; }

/* Activities (Plan) */

.activity { padding: 10px 12px 10px 10px; display: flex; gap: 8px; align-items: flex-start; position: relative; }
.activity + .activity::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; border-top: 0.5px solid var(--line); }
.check { flex: none; width: 34px; height: 34px; display: grid; place-items: center; margin-top: 2px; }
.check span {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.check svg { width: 14px; height: 14px; stroke: #fff; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.activity.done .check span { background: var(--accent); border-color: var(--accent); }
.activity.done .check svg { opacity: 1; }
.activity .body { flex: 1; min-width: 0; }
.activity .act-text { padding: 7px 0 4px; min-height: 0; font-size: 16px; }
.activity.done .act-text { color: var(--muted); text-decoration: line-through; }
.activity .sub { display: flex; gap: 8px; flex-wrap: wrap; }
.activity .sub input {
  border: 0;
  background: var(--fill);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 14px;
  min-height: 30px;
  -webkit-appearance: none;
  appearance: none;
}
.activity .sub .owner { width: 110px; }
.activity .sub .date-wrap input { min-width: 120px; text-align: left; }
.activity .sub .date-wrap .clear { width: 24px; height: 24px; }
.activity .sub input.late { color: var(--danger); }
.activity .del { flex: none; width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); margin-top: 2px; }
.activity .del svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.add-row { color: var(--accent); font-weight: 500; }
.add-row svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }

.stat-line { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin: 0 4px; }

/* Calendar */

.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.cal-head h1 { font-size: 30px; font-weight: 700; margin: 0; }
.cal-head h1::first-letter { text-transform: uppercase; }
.cal-head h1 small { color: var(--muted); font-weight: 500; font-size: 22px; }
.cal-nav { display: flex; gap: 2px; align-items: center; }
.cal-nav button { color: var(--accent); min-width: 40px; min-height: 40px; display: grid; place-items: center; font-weight: 500; }
.cal-nav svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cal-nav .today-btn { padding: 0 8px; font-size: 16px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin: 0 4px 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--g); flex: none; }
.legend i.ring { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.legend i.big { width: 14px; height: 14px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--muted) 35%, transparent); background: var(--muted); }
.legend i.dot { background: var(--muted); }

.cal {
  background: var(--card);
  border-radius: 14px;
  padding: 8px 6px 6px;
  display: grid;
  grid-template-columns: 22px repeat(7, 1fr);
  row-gap: 2px;
}
.cal .wd { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 2px 0 6px; text-transform: uppercase; }
.cal .wk { font-size: 10px; color: var(--muted); opacity: 0.7; display: grid; place-items: center; padding-bottom: 12px; font-variant-numeric: tabular-nums; }
.day {
  position: relative;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  border-radius: 10px;
}
.day .n {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.day.other .n { color: var(--muted); opacity: 0.45; }
.day.today .n { color: var(--accent); font-weight: 700; }
.day.sel { background: var(--fill); }
.day.goal-day .n { background: var(--g); color: #fff; font-weight: 700; box-shadow: 0 0 0 3px color-mix(in srgb, var(--g) 30%, transparent); }
.day .marks { display: flex; gap: 3px; margin-top: 3px; height: 7px; }
.day .marks i { width: 7px; height: 7px; border-radius: 50%; background: var(--g); }
.day .marks i.act { width: 5px; height: 5px; margin-top: 1px; background: transparent; box-shadow: inset 0 0 0 1.5px var(--g); }
.day .marks i.done { opacity: 0.4; }

.ev {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 16px 10px 12px;
  position: relative;
}
.ev + .ev::before { content: ""; position: absolute; top: 0; left: 64px; right: 0; border-top: 0.5px solid var(--line); }
.ev .date { flex: none; width: 40px; text-align: center; line-height: 1.05; }
.ev .date b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.ev .date small { font-size: 11.5px; color: var(--muted); text-transform: uppercase; }
.ev .bar-c { flex: none; width: 4px; align-self: stretch; border-radius: 4px; background: var(--g); }
.ev .info { flex: 1; min-width: 0; }
.ev .info b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev .info small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.done .info b { color: var(--muted); text-decoration: line-through; }
.ev.goal { background: color-mix(in srgb, var(--g) 13%, transparent); }
.ev .kind { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--g); }
.ev-empty { padding: 18px 16px; color: var(--muted); font-size: 15px; text-align: center; }

/* Action sheet + overview panel */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 8px calc(8px + env(safe-area-inset-bottom));
  animation: fade 0.2s;
}
.sheet { width: 100%; max-width: 520px; animation: up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet .group { border-radius: 14px; }
.sheet .group + .group { margin-top: 8px; }
.sheet-btn { width: 100%; min-height: 56px; color: var(--accent); font-size: 19px; position: relative; }
.sheet-btn + .sheet-btn::before { content: ""; position: absolute; top: 0; left: 0; right: 0; border-top: 0.5px solid var(--line); }
.sheet-btn.danger { color: var(--danger); }
.sheet-btn.cancel { font-weight: 600; }
.sheet-note { font-size: 13px; color: var(--muted); text-align: center; padding: 14px 16px 12px; border-bottom: 0.5px solid var(--line); }

.backdrop.panel-wrap { padding: calc(env(safe-area-inset-top) + 40px) 0 0; }
.panel {
  width: 100%;
  max-width: 600px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  animation: up 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  overscroll-behavior: contain;
}
.panel .grab { width: 38px; height: 5px; border-radius: 99px; background: var(--muted); opacity: 0.4; margin: 0 auto 4px; }
.panel-top { display: flex; justify-content: flex-end; }
.panel-top button { color: var(--accent); font-weight: 600; min-height: 36px; }
.panel-goal {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--g);
  color: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  width: 100%;
  text-align: left;
}
.panel-goal svg { width: 34px; height: 34px; flex: none; stroke: #fff; fill: none; stroke-width: 1.8; }
.panel-goal small { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.panel-goal b { display: block; font-size: 19px; line-height: 1.2; overflow-wrap: anywhere; }
.panel-goal span { display: block; font-size: 13.5px; opacity: 0.9; margin-top: 2px; }
.panel h2 { font-size: 26px; margin: 0 0 4px; line-height: 1.15; overflow-wrap: anywhere; }
.panel .sub-meta { color: var(--muted); font-size: 15px; margin-bottom: 4px; }
.ov-act { display: flex; gap: 10px; align-items: flex-start; padding: 10px 16px; position: relative; }
.ov-act + .ov-act::before { content: ""; position: absolute; top: 0; left: 48px; right: 0; border-top: 0.5px solid var(--line); }
.ov-act .ring { margin-top: 1px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; }
.ov-act .ring svg { width: 12px; height: 12px; stroke: #fff; fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.ov-act.done .ring { background: var(--g); border-color: var(--g); }
.ov-act.done .ring svg { opacity: 1; }
.ov-act.done .t > span { color: var(--muted); text-decoration: line-through; }
.ov-act.hl { background: color-mix(in srgb, var(--g) 12%, transparent); }
.ov-act .t { flex: 1; }
.ov-act small { display: block; color: var(--muted); font-size: 13px; }
.panel .retro { white-space: pre-line; padding: 12px 16px; line-height: 1.45; }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(30, 30, 32, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
  max-width: calc(100% - 32px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.footer-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 28px; }
.steps { margin: 0; padding: 12px 16px 12px 36px; font-size: 14.5px; line-height: 1.45; }
.steps li + li { margin-top: 6px; }
.feed-url { font: 13px ui-monospace, Menlo, monospace; color: var(--muted); padding: 0 16px 12px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }

@media print {
  :root { --bg: #fff; --card: #fff; --fill: #fff; --text: #000; color-scheme: light; }
  .bar, .tabbar, .primary, .secondary, .add-row, .del, .clear, #toast, #sheet-root, .footer-note, .section-hint { display: none !important; }
  #view { padding-bottom: 0; }
  .group { border: 1px solid #ccc; break-inside: avoid; }
  .text::placeholder { color: transparent; }
}

/* Measurable target: slider on the home page */

.row input.wide {
  border: 0;
  background: var(--fill);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 34px;
  width: 150px;
  text-align: right;
  -webkit-appearance: none;
  appearance: none;
}
.row input.wide::placeholder { color: var(--muted); opacity: 0.75; }

.measure { background: var(--card); border-radius: 14px; padding: 14px 16px 12px; margin: 0 0 12px; }
.measure-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 8px; }
.measure-pct { font-size: 30px; font-weight: 800; line-height: 1; color: var(--g); font-variant-numeric: tabular-nums; white-space: nowrap; }
.measure-pct small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.measure-val { display: flex; align-items: center; gap: 6px; margin-left: auto; font-size: 14.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 16px so iOS doesn't zoom in when the field gets focus. */
.measure-input {
  border: 0;
  outline: 0;
  background: var(--fill);
  border-radius: 8px;
  padding: 5px 9px;
  min-height: 34px;
  min-width: 64px;
  max-width: 50vw;
  font-size: 16px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.measure-input:focus { box-shadow: 0 0 0 2px var(--g); }
.measure-hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; margin: 0; background: transparent; display: block; }
.slider:focus { outline: none; }
.slider::-webkit-slider-runnable-track { height: 10px; border-radius: 99px; background: linear-gradient(to right, var(--g) var(--p), var(--fill) var(--p)); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px; height: 30px;
  margin-top: -10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}
.slider::-moz-range-track { height: 10px; border-radius: 99px; background: var(--fill); }
.slider::-moz-range-progress { height: 10px; border-radius: 99px; background: var(--g); }
.slider::-moz-range-thumb { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3); }


/* Widget preview in Settings (roughly a medium iOS widget) */

.wprev {
  max-width: 360px;
  aspect-ratio: 2.13;
  margin: 0 auto;
  border-radius: 22px;
  padding: 14px 16px;
  color: #fff;
  background: linear-gradient(180deg, var(--g), color-mix(in srgb, var(--g) 62%, #000));
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.wprev small { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.75; }
.wprev b { font-size: 17px; line-height: 1.2; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wprev p { font-size: 12px; line-height: 1.3; opacity: 0.85; margin: 4px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wrow { display: flex; justify-content: space-between; align-items: flex-end; margin-top: auto; }
.wrow strong { display: block; font: 700 26px/1 ui-rounded, -apple-system, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.wrow span { font-size: 11px; font-weight: 500; opacity: 0.8; }
.wrow div:last-child { text-align: right; }
.wbar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.28); margin-top: 6px; overflow: hidden; flex: none; }
.wbar i { display: block; height: 100%; border-radius: 99px; background: #fff; }

/* Opened from the widget in Safari */

.tabbar[hidden] { display: none; }
.wv { padding-top: 4px; }
.wv + .wv, .notice + .wv { margin-top: 28px; padding-top: 22px; border-top: 0.5px solid var(--line); }
.wv .hero-title { margin-top: 6px; }
.wv .measure .progress { margin-top: 4px; height: 10px; }
.notice { margin: 18px 0 0; }
.notice p { margin: 0; line-height: 1.45; color: var(--muted); font-size: 15px; }

/* Buttons at the bottom of each goal page */

.page-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.page-actions button { margin: 0; }
.page .page-actions .secondary { color: var(--g); }
.page .page-actions .primary { background: var(--g); }

.side-brand { display: none; }

/* ---------- Computer: sidebar instead of the tab bar, goals side by side ---------- */

@media (min-width: 900px) {
  :root { --side-w: 232px; }
  body { font-size: 16px; }

  .tabbar {
    top: 0; right: auto; bottom: 0; left: 0;
    width: var(--side-w);
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    padding: 20px 12px;
    border-top: 0;
    border-right: 0.5px solid var(--line);
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-weight: 700; font-size: 18px; color: var(--text); }
  .side-brand img { width: 30px; height: 30px; border-radius: 8px; }
  .tabbar button {
    flex: none;
    height: 42px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 15px;
  }
  .tabbar button:hover { background: var(--fill); }
  .tabbar button.on { background: var(--accent-soft); }
  .tabbar svg { width: 22px; height: 22px; }

  #view { margin-left: var(--side-w); max-width: none; padding: 0 40px 48px; }
  #view > * { max-width: 860px; margin-left: auto; margin-right: auto; }
  #view > .bar { max-width: none; margin: 0 -40px; padding-left: 40px; padding-right: 40px; }
  #toast { left: calc(50% + var(--side-w) / 2); bottom: 32px; }

  /* Home: goals next to each other instead of swiping */
  #view > .pager { max-width: 1400px; }
  .pager {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: 24px;
    overflow: visible;
    padding: 32px 0 0;
  }
  .page {
    height: auto;
    overflow: visible;
    border-radius: 24px;
    padding: 24px 24px 28px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--g) 22%, var(--card)) 0, var(--bg) 380px);
    border: 0.5px solid var(--line);
  }
  .page.plain { grid-column: 1 / -1; border: 0; background: transparent; padding: 8px 0 0; }
  .page.plain .page-inner { max-width: 640px; margin: 0; }

  /* With goals: "Nytt mål" (and achieved goals) as a column to the right of them. */
  .pager.cols-1 { grid-template-columns: minmax(380px, 1fr) 300px; }
  .pager.cols-2 { grid-template-columns: repeat(2, minmax(360px, 1fr)) 300px; }
  .pager.cols-1 .page:not(.plain),
  .pager.cols-2 .page:not(.plain):nth-child(odd) { grid-column: 1; }
  .pager.cols-2 .page:not(.plain):nth-child(even) { grid-column: 2; }
  .pager[class*="cols-"] .page.plain {
    grid-column: -2;
    grid-row: 1;
    align-self: start;
    position: sticky;
    top: 24px;
    padding: 20px;
    border-radius: 24px;
    border: 1.5px dashed var(--line);
  }
  .pager[class*="cols-"] .page.plain .large-title { font-size: 24px; margin-top: 0; }
  .pager[class*="cols-"] .page.plain .section-label { margin-left: 4px; }
  .pager[class*="cols-"] .page.plain .footer-note { text-align: left; }
  .page-dots { display: none; }
  .phone-only { display: none; }
  .hero-title { font-size: 32px; }

  /* Calendar: month and list side by side */
  #view > .cal-layout { max-width: 1200px; }
  .cal-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 32px; align-items: start; }
  .cal-side .section-label:first-child { margin-top: 0; }
  #view > .cal-head { max-width: 1200px; }
  .day { min-height: 64px; }
  .day:hover { background: var(--fill); }

  /* Overview opens as a centred dialog rather than a bottom sheet */
  .backdrop.panel-wrap { align-items: center; padding: 40px; }
  .panel { border-radius: 16px; max-height: 85vh; }
  .backdrop { padding-bottom: 40px; align-items: center; }

  button, .row, .ev, .goal-card { cursor: pointer; }
  .ev:hover, .row.link-row:hover, .sprint-row:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }
}

/* Device sync pairing code */

.pair-code { display: block; width: 100%; text-align: center; padding: 16px 16px 18px; position: relative; }
.pair-code small { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.pair-code b {
  font: 600 28px/1.1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.08em;
  color: var(--text);
  user-select: all;
  -webkit-user-select: all;
}
.pair-code + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--line); }

/* ---------- New activity form ---------- */

.act-form h2, .pdf-form h2 { margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; margin-top: 18px; border-radius: 10px; background: var(--fill); }
.seg button { min-height: 34px; border-radius: 8px; font-size: 15px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekdays button {
  min-height: 42px;
  border-radius: 10px;
  background: var(--card);
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
}
.weekdays button.on { background: var(--g, var(--accent)); color: #fff; }
.act-form .mode-once, .act-form .mode-repeat { margin-top: 14px; }
.act-form .group .text + .text { border-top: 0.5px solid var(--line); }
.act-form .row input[type="date"], .act-form .row input[type="time"] {
  border: 0; background: var(--fill); border-radius: 8px; padding: 6px 10px; min-height: 34px; min-width: 130px; text-align: right;
  -webkit-appearance: none; appearance: none;
}
.af-preview { min-height: 1.4em; }
[hidden] { display: none !important; }

/* Activity row: time field and repeat marker */
.activity .sub input.time { width: 116px; }
.activity .sub .repeat { display: grid; place-items: center; color: var(--muted); }
.activity .sub .repeat svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* PDF export dialog */
.check-row { cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.check-row .label small { display: block; color: var(--muted); font-size: 13px; }
.check-row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--g); flex: none; }

.desktop-only { display: none; }
@media (min-width: 900px) {
  .desktop-only { display: block; }
}

/* ---------- Print layout for PDF export ---------- */

#print-root { display: none; }

@media print {
  @page { size: A4; margin: 14mm 14mm 16mm; }
  body.printing { background: #fff !important; color: #111 !important; min-height: 0; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }

  .pg { font: 10.5pt/1.4 -apple-system, "Segoe UI", system-ui, sans-serif; color: #111; break-after: page; }
  .pg:last-child { break-after: auto; }
  .pg-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; border-bottom: 3px solid var(--g); padding-bottom: 8px; margin-bottom: 12px; }
  .pg-head small { font-size: 9pt; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--g); }
  .pg-head h1 { font-size: 20pt; line-height: 1.15; margin: 2px 0 0; }
  .pg-head img { height: 16pt; width: auto; }
  .pg dl { margin: 0; }
  .pg dt { font-size: 7.5pt; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #666; }
  .pg dd { margin: 1px 0 0; font-weight: 600; }
  .pg-dates { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-bottom: 10px; }
  .pg-box { border: 1px solid #c9c9cf; border-radius: 6px; padding: 7px 10px 9px; margin-bottom: 8px; break-inside: avoid; }
  .pg-box h3 { margin: 0 0 3px; font-size: 7.5pt; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #555; }
  .pg-text { white-space: pre-line; min-height: 2.6em; }
  .pg-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .pg-assess div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
  .pg-assess b { white-space: nowrap; }
  .pg-sprint { margin-top: 16px; break-inside: avoid-page; }
  .pg-sprint-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; border-bottom: 1.5px solid var(--g); padding-bottom: 5px; margin-bottom: 8px; }
  .pg-sprint-head small { font-size: 7.5pt; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--g); }
  .pg-sprint-head h2 { font-size: 13pt; margin: 1px 0 0; }
  .pg-sprint-head dl { display: flex; gap: 18px; }
  .pg-plan { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 9.5pt; }
  .pg-plan th { text-align: left; font-size: 7.5pt; letter-spacing: 0.06em; text-transform: uppercase; color: #555; border-bottom: 1px solid #999; padding: 3px 6px; }
  .pg-plan td { border-bottom: 1px solid #ddd; padding: 4px 6px; vertical-align: top; }
  .pg-plan tr { break-inside: avoid; }
  .pg-plan td.c { text-align: center; font-weight: 700; color: var(--g); width: 3.5em; }
  .pg-plan th:nth-child(2), .pg-plan td:nth-child(2) { width: 18%; }
  .pg-plan th:nth-child(3), .pg-plan td:nth-child(3) { width: 20%; }
  .pg-plan td.empty { color: #888; font-style: italic; }
  .pg-foot { margin-top: 14px; font-size: 7.5pt; color: #888; }
  .pg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
