:root {
  --bg: #eef1fb;
  --bg-tint: #e2e7ff;
  --bg-tint-2: #e9e3ff;
  --card: #ffffff;
  --brand-soft: #e6e9ff;
  --chrome-bg: rgba(255, 255, 255, 0.85);
  --ring-track: #dfe4f2;
  --heat-1: #c7d2fe;
  --heat-2: #818cf8;
  --heat-3: #4f46e5;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dce2f1;
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --brand-strong: #4f46e5;
  --brand-strong-2: #6d28d9;
  --good: #10b981;
  --danger: #f43f5e;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 30px -16px rgba(16, 24, 40, 0.25);
  --shadow-lift: 0 2px 6px rgba(16, 24, 40, 0.06), 0 22px 44px -18px rgba(16, 24, 40, 0.3);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(900px 520px at 12% -12%, var(--bg-tint) 0%, transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, var(--bg-tint-2) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  transition: background 0.5s ease;
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px calc(120px + env(safe-area-inset-bottom));
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-strong), var(--brand-strong-2));
  font-size: 22px;
  box-shadow: 0 10px 20px -8px rgba(99, 102, 241, 0.6);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8b93a7;
}

.pill-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: #334155;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.pill-btn:hover {
  transform: translateY(-1px);
  border-color: #c7d0e4;
}

/* ---------- Cards & buttons ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-strong), var(--brand-strong-2));
  color: #fff;
  box-shadow: 0 12px 22px -10px rgba(99, 102, 241, 0.7);
}

.btn-ghost {
  background: var(--card);
  color: #334155;
  border: 1px solid var(--line);
}

.btn-danger {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.btn-xl {
  width: 100%;
  padding: 18px;
  font-size: 17px;
  border-radius: 16px;
}

/* ---------- Today hero ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--brand-soft), var(--card));
  box-shadow: inset 0 4px 0 0 var(--brand), var(--shadow);
}

.hero-ring {
  position: relative;
  width: 88px;
  height: 88px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--brand) var(--p, 0%), var(--ring-track) 0);
  transition: background 0.4s ease;
}

.hero-ring::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--card);
}

.hero-ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
  line-height: 1.05;
}

.hero-ring-inner span {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-ring-inner small {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.hero-text {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.hero-text h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-text p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

/* ---------- Habit list ---------- */
.habit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.habit-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(180deg, var(--card), var(--brand-soft));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.habit-card.done {
  border-color: #d7f5e6;
  background: linear-gradient(180deg, var(--card), #f3fdf8);
}

.check {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid #dbe3f0;
  background: var(--card);
  color: transparent;
  font-size: 24px;
  font-weight: 800;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.check:hover {
  border-color: var(--c, #6366f1);
}

.check.on {
  background: var(--c, #10b981);
  border-color: var(--c, #10b981);
  color: #fff;
}

.check.pop {
  animation: pop 0.35s ease;
}

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

.habit-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.habit-top .emoji {
  font-size: 17px;
}

.habit-top .name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rem-chip {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: #4f46e5;
  background: #eef2ff;
  border: 1px solid #e0e7ff;
  padding: 2px 7px;
  border-radius: 999px;
}

.habit-card.done .habit-top .name {
  color: #0f766e;
  text-decoration: line-through;
  text-decoration-color: rgba(16, 185, 129, 0.5);
  text-decoration-thickness: 2px;
}

.streak {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  color: #b45309;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  padding: 2px 8px;
  border-radius: 999px;
}

.dots {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 22px;
  padding: 3px 1px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  appearance: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.day:hover {
  background: var(--brand-soft);
}

.day:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.day.is-future {
  opacity: 0.4;
  cursor: default;
}

.day.is-future:hover {
  background: transparent;
}

.dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--ring-track);
  transition: background 0.2s ease;
}

.dot.on {
  background: var(--dot, #10b981);
}

.dot.today {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.28);
}

.wd {
  font-size: 9px;
  font-weight: 700;
  color: #a3aec2;
}

.day.is-today .wd {
  color: var(--brand);
}

.more {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: #a3aec2;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.more:hover {
  background: #f1f5fb;
  color: #475569;
}

/* ---------- Empty ---------- */
.empty {
  text-align: center;
  padding: 38px 22px;
  background: var(--card);
  border: 1px dashed #d5deee;
  border-radius: var(--radius);
}

.empty .big {
  font-size: 34px;
}

.empty h3 {
  margin: 10px 0 4px;
  font-size: 17px;
}

.empty p {
  margin: 0 auto 16px;
  max-width: 320px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Stats ---------- */
.page-title {
  margin: 4px 2px 16px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.sub-title {
  margin: 26px 2px 10px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: linear-gradient(180deg, var(--brand-soft), var(--card));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: inset 0 4px 0 0 var(--brand), var(--shadow);
}

.stat-card .label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.stat-card .value {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.stat-card .hint {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.stats-habits {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-habit {
  background: linear-gradient(180deg, var(--brand-soft), var(--card));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-habit-head {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.stat-habit-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  min-width: 0;
}

.stat-habit-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-habit-meta {
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.mini-days {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.mini-day {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--ring-track);
}

.mini-day.on {
  background: var(--dot, #10b981);
}

/* ---------- Settings ---------- */
.settings-card {
  padding: 18px;
  margin-bottom: 14px;
}

.settings-card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 800;
}

.settings-card p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
}

.lang-select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.lang-select:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  accent-color: var(--brand);
  cursor: pointer;
}

.settings-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.status-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
}

.status-chip.ok {
  background: #ecfdf5;
  color: #047857;
  box-shadow: inset 0 0 0 1px #a7f3d0;
}

.status-chip.bad {
  background: #fff1f2;
  color: #be123c;
  box-shadow: inset 0 0 0 1px #fecdd3;
}

.row-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.file-label {
  cursor: pointer;
}

.danger-card {
  border-color: #fbd5db;
}

.version {
  text-align: center;
  margin-top: 8px;
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 680px;
  display: flex;
  justify-content: space-around;
  gap: 6px;
  background: var(--chrome-bg);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 4px;
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.tab-icon {
  font-size: 18px;
  filter: grayscale(0.4);
  transition: filter 0.15s ease, transform 0.15s ease;
}

.tab.active {
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.tab.active .tab-icon {
  filter: none;
  transform: translateY(-1px);
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: max(18px, calc(50% - 322px));
  bottom: calc(86px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--brand-strong), var(--brand-strong-2));
  color: #fff;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 16px 30px -10px rgba(99, 102, 241, 0.75);
  z-index: 31;
  transition: transform 0.15s ease;
}

.fab:hover {
  transform: translateY(-2px) rotate(90deg);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}

.sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 26px 26px 0 0;
  padding: 14px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 60px -20px rgba(15, 23, 42, 0.5);
  animation: slideUp 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet-grip {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: #e2e8f0;
  margin: 0 auto 12px;
}

.sheet h2 {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 800;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.field input::placeholder,
.rem-input::placeholder {
  color: var(--muted);
}

.field-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.emoji-opt {
  aspect-ratio: 1;
  border: 2px solid transparent;
  background: #f4f6fb;
  border-radius: 12px;
  font-size: 20px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.emoji-opt:hover {
  transform: scale(1.06);
}

.emoji-opt.selected {
  border-color: #6366f1;
  background: #eef2ff;
}

.color-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.color-opt {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.color-opt:hover {
  transform: scale(1.08);
}

.color-opt.selected {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #6366f1;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.confirm-modal {
  z-index: 90;
}

.confirm-sheet {
  max-width: 420px;
}

/* ---------- Focus ---------- */
.focus {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(800px 500px at 50% 0%, var(--bg-tint-2), transparent 65%),
    var(--bg);
  animation: fadeIn 0.2s ease;
}

.focus-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 30px 24px;
  text-align: center;
  box-shadow: var(--shadow-lift);
  animation: popIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.focus-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: #64748b;
  font-size: 15px;
  cursor: pointer;
}

.focus-emoji {
  font-size: 60px;
  line-height: 1;
  margin: 8px 0 10px;
}

.focus-card h2 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.focus-card .btn {
  margin-top: 10px;
}

.focus-card .btn-ghost {
  width: 100%;
}

/* ---------- Påminnelsebanner ---------- */
.reminder-banner {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lift);
  z-index: 80;
  animation: dropIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.reminder-bell {
  font-size: 22px;
  flex: 0 0 auto;
}

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

.reminder-title {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #818cf8;
}

.reminder-who {
  margin: 1px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reminder-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.mini-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.mini-btn:active {
  transform: scale(0.97);
}

.mini-btn.primary {
  background: linear-gradient(135deg, var(--brand-strong), var(--brand-strong-2));
  border-color: transparent;
  color: #fff;
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: translate(-50%, -16px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 70;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Ångra radering ---------- */
.undo-bar {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  background: var(--brand-strong);
  color: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-lift);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 90vw;
  z-index: 76;
}

.undo-bar .mini-btn {
  background: #fff;
  color: var(--brand-strong);
  border-color: transparent;
}

.undo-bar .mini-btn:hover {
  background: #f1f5f9;
}

/* ---------- Confetti ---------- */
.confetti {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 65;
  animation: confettiFall 0.85s ease-out forwards;
}

/* ---------- Animations ---------- */
@keyframes pop {
  0% {
    transform: scale(0.8);
  }
  55% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx, 0), var(--dy, 60px)) rotate(var(--rot, 180deg)) scale(0.6);
  }
}

/* ---------- Responsive ---------- */
@media (min-width: 560px) {
  .modal {
    align-items: center;
    padding: 20px;
  }
  .sheet {
    border-radius: 26px;
  }
  .sheet-grip {
    display: none;
  }
}

@media (max-width: 380px) {
  .hero {
    gap: 12px;
    padding: 14px;
  }
  .hero-ring {
    width: 74px;
    height: 74px;
  }
  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Teman ---------- */
html[data-theme='ocean'] {
  --brand: #0ea5e9;
  --brand-2: #14b8a6;
  --brand-strong: #0369a1;
  --brand-strong-2: #0f766e;
  --bg: #e2f5fd;
  --bg-tint: #bfeafb;
  --bg-tint-2: #c4f7ea;
  --brand-soft: #c9eeff;
  --card: #f2fbff;
  --line: #b3dff0;
  --ring-track: #c7e6f2;
  --chrome-bg: rgba(224, 246, 255, 0.92);
  --heat-1: #9fe0fb;
  --heat-2: #1fb6e9;
  --heat-3: #0369a1;
}
html[data-theme='sunset'] {
  --brand: #f97316;
  --brand-2: #ec4899;
  --brand-strong: #c2410c;
  --brand-strong-2: #9d174d;
  --bg: #ffefe4;
  --bg-tint: #ffcfb2;
  --bg-tint-2: #ffbfda;
  --brand-soft: #ffddc7;
  --card: #fff6f1;
  --line: #f2cbb9;
  --ring-track: #f1d6c7;
  --chrome-bg: rgba(255, 238, 229, 0.92);
  --heat-1: #fec99c;
  --heat-2: #f97316;
  --heat-3: #c2410c;
}
html[data-theme='forest'] {
  --brand: #10b981;
  --brand-2: #65a30d;
  --brand-strong: #047857;
  --brand-strong-2: #4d7c0f;
  --bg: #e4f8ed;
  --bg-tint: #bcefd0;
  --bg-tint-2: #cff0a9;
  --brand-soft: #c8f4da;
  --card: #f0fdf6;
  --line: #b8e4c9;
  --ring-track: #c2e7d1;
  --chrome-bg: rgba(227, 248, 237, 0.92);
  --heat-1: #a1edbe;
  --heat-2: #10b981;
  --heat-3: #047857;
}
html[data-theme='grape'] {
  --brand: #8b5cf6;
  --brand-2: #db2777;
  --brand-strong: #6d28d9;
  --brand-strong-2: #9d174d;
  --bg: #f5e8ff;
  --bg-tint: #e6c3ff;
  --bg-tint-2: #ffbfe4;
  --brand-soft: #e7ccff;
  --card: #fbf4ff;
  --line: #ddbdf4;
  --ring-track: #e1c9f2;
  --chrome-bg: rgba(245, 232, 255, 0.92);
  --heat-1: #cdb0ff;
  --heat-2: #8b5cf6;
  --heat-3: #6d28d9;
}
html[data-theme='aurora'] {
  --brand: #14b8a6;
  --brand-2: #8b5cf6;
  --brand-strong: #0f766e;
  --brand-strong-2: #6d28d9;
  --bg: #e7fbf5;
  --bg-tint: #c4f2e4;
  --bg-tint-2: #ded2ff;
  --brand-soft: #d3f7eb;
  --card: #f3fffb;
  --line: #bce6da;
  --ring-track: #c7e8df;
  --chrome-bg: rgba(231, 251, 245, 0.92);
  --heat-1: #a7f3d0;
  --heat-2: #14b8a6;
  --heat-3: #7c3aed;
}
html[data-theme='sand'] {
  --brand: #d97706;
  --brand-2: #b45309;
  --brand-strong: #92400e;
  --brand-strong-2: #7c2d12;
  --bg: #faf4e8;
  --bg-tint: #efe2c8;
  --bg-tint-2: #efe0c2;
  --brand-soft: #f4e6cd;
  --card: #fffbf3;
  --line: #e8d8bc;
  --ring-track: #ecdfc8;
  --chrome-bg: rgba(250, 244, 232, 0.92);
  --heat-1: #fde68a;
  --heat-2: #d97706;
  --heat-3: #92400e;
}
html[data-theme='oceandeep'] {
  --brand: #1d4ed8;
  --brand-2: #0e7490;
  --brand-strong: #1e40af;
  --brand-strong-2: #0f766e;
  --bg: #dbe7fb;
  --bg-tint: #a9c8f2;
  --bg-tint-2: #b6e2ee;
  --brand-soft: #c3d9fb;
  --card: #edf4ff;
  --line: #a6c3e6;
  --ring-track: #b9d0ea;
  --chrome-bg: rgba(219, 231, 251, 0.92);
  --heat-1: #93c5fd;
  --heat-2: #1d4ed8;
  --heat-3: #0e7490;
}
html[data-theme='midnight'] {
  --brand: #818cf8;
  --brand-2: #c084fc;
  --brand-strong: #4f46e5;
  --brand-strong-2: #7e22ce;
  --bg: #0b1020;
  --bg-tint: #16203c;
  --bg-tint-2: #2a1638;
  --brand-soft: #1c2647;
  --card: #141b2d;
  --line: #28324d;
  --ring-track: #232d47;
  --chrome-bg: rgba(13, 18, 32, 0.92);
  --heat-1: #33406b;
  --heat-2: #6366f1;
  --heat-3: #c084fc;
  --ink: #e8ecf7;
  --muted: #9aa6c2;
}

/* --- Midnight: ljusa textfärger/ytor som annars är hårdkodade --- */
html[data-theme='midnight'] .btn-ghost,
html[data-theme='midnight'] .pill-btn,
html[data-theme='midnight'] .mini-btn,
html[data-theme='midnight'] .range-btn,
html[data-theme='midnight'] .focus-close,
html[data-theme='midnight'] .rem-remove,
html[data-theme='midnight'] .more {
  color: var(--ink);
}
html[data-theme='midnight'] .more:hover,
html[data-theme='midnight'] .range-btn:hover {
  background: #202a44;
  color: #fff;
}
html[data-theme='midnight'] .btn-danger {
  background: #3a1622;
  color: #fda4af;
  border-color: #7f1d1d;
}
html[data-theme='midnight'] .status-chip {
  background: #202a44;
  color: #c7d2fe;
}
html[data-theme='midnight'] .status-chip.ok {
  background: #12352b;
  color: #6ee7b7;
  box-shadow: inset 0 0 0 1px #14532d;
}
html[data-theme='midnight'] .status-chip.bad {
  background: #3a1622;
  color: #fda4af;
  box-shadow: inset 0 0 0 1px #7f1d1d;
}
html[data-theme='midnight'] .streak {
  background: #3a2a12;
  color: #fcd34d;
  border-color: #7c4a12;
}
html[data-theme='midnight'] .rem-chip {
  background: #1e2a52;
  color: #c7d2fe;
  border-color: #2e3c6b;
}
html[data-theme='midnight'] .habit-card.done {
  background: linear-gradient(180deg, #14261f, #12211c);
  border-color: #1f4738;
}
html[data-theme='midnight'] .habit-card.done .habit-top .name {
  color: #6ee7b7;
}
html[data-theme='midnight'] .emoji-opt {
  background: #1c2540;
}
html[data-theme='midnight'] .emoji-opt.selected {
  background: #26325a;
  border-color: var(--brand);
}
html[data-theme='midnight'] .color-opt {
  border-color: #2a3550;
}
html[data-theme='midnight'] .empty {
  border-color: #2a3550;
}
html[data-theme='midnight'] .toast {
  background: #1c2540;
  border: 1px solid #2e3c6b;
  color: #e8ecf7;
}
html[data-theme='midnight'] .sheet-grip {
  background: #2a3550;
}
html[data-theme='midnight'] .check {
  border-color: #33406b;
}
html[data-theme='midnight'] .wd-bar-wrap {
  background: #1c2540;
}
html[data-theme='midnight'] .tab {
  color: #9aa6c2;
}
html[data-theme='midnight'] .tab.active {
  color: #c7d2fe;
}
html[data-theme='midnight'] .stat-card .label,
html[data-theme='midnight'] .sub-title,
html[data-theme='midnight'] .wd-label,
html[data-theme='midnight'] .brand-text span,
html[data-theme='midnight'] .hero-ring-inner small {
  color: #9aa6c2;
}
html[data-theme='midnight'] .plan-features li {
  color: #c7d2fe;
}
html[data-theme='midnight'] .plan-badge {
  background: #2e2250;
  color: #ddd6fe;
}
html[data-theme='midnight'] .plan-trial {
  color: #6ee7b7;
}
html[data-theme='midnight'] .plan-price {
  color: #c7d2fe;
}
html[data-theme='midnight'] .plan-card.is-lifetime {
  background: linear-gradient(180deg, #221a3a, #141b2d);
}

/* ---------- Planer & paywall ---------- */
.plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.plan-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--card);
  display: flex;
  flex-direction: column;
}

.plan-card.is-current {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.plan-card.is-lifetime {
  background: linear-gradient(180deg, var(--brand-soft), var(--card));
}

.plan-card-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-price {
  margin: 3px 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-strong);
}

.plan-trial {
  display: block;
  margin: -6px 0 10px;
  font-size: 11px;
  font-weight: 700;
  color: #059669;
}

.plan-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #ede9fe;
  color: #6d28d9;
  padding: 2px 7px;
  border-radius: 999px;
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.plan-features li {
  font-size: 12.5px;
  color: #475569;
  padding-left: 18px;
  position: relative;
  line-height: 1.35;
}

.plan-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #10b981;
  font-weight: 800;
}

.paywall-sheet {
  max-width: 720px;
}

.paywall-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.paywall-head h2 {
  margin: 0;
}

.paywall-currency {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
}

.currency-select {
  max-width: 150px;
  padding: 8px 10px;
}

/* ---------- Utseende ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.theme-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
}

.theme-opt.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.theme-opt.locked {
  opacity: 0.7;
}

.theme-swatch {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  flex: 0 0 auto;
}
.theme-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Avancerad statistik ---------- */
.stats-advanced {
  margin-top: 16px;
  padding: 16px;
  box-shadow: inset 0 4px 0 0 var(--brand), var(--shadow);
}

.stats-advanced-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stats-advanced-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.range-switch {
  display: flex;
  gap: 6px;
}

.range-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
}

.range-btn.active {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
}

.range-btn.locked {
  opacity: 0.7;
}

.consistency-big {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 8px;
}

.heatmap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 12px;
}

.heat {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--ring-track);
}
.heat.sq-1 {
  background: var(--heat-1);
}
.heat.sq-2 {
  background: var(--heat-2);
}
.heat.sq-3 {
  background: var(--heat-3);
}

.weekday-bars {
  display: flex;
  gap: 8px;
  align-items: stretch;
  height: 84px;
  margin-top: 8px;
}

.wd-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.wd-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: #f1f5fb;
  border-radius: 6px;
  overflow: hidden;
}

.wd-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
}

.wd-label {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
}

/* ---------- Påminnelselista (modal) ---------- */
.reminder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reminder-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rem-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
}

.rem-input:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.rem-remove {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: #94a3b8;
  font-weight: 700;
  cursor: pointer;
}

.rem-remove:hover {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}

#addReminderBtn {
  margin-top: 8px;
}

@media (min-width: 560px) {
  .plan-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Snabb tillägg ---------- */
.quick-add {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.quick-add-input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.quick-add-input::placeholder {
  color: var(--muted);
}

.quick-add-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.quick-add-btn {
  width: 50px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-strong), var(--brand-strong-2));
  color: #fff;
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 18px -10px rgba(99, 102, 241, 0.7);
}

.quick-add-btn:active {
  transform: scale(0.97);
}

/* ---------- Hopfällbar "Avancerat" ---------- */
.settings-more {
  margin-top: 14px;
}

.settings-more > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: inset 0 4px 0 0 var(--brand-soft), var(--shadow);
}

.settings-more > summary::-webkit-details-marker {
  display: none;
}

.settings-more > summary::after {
  content: '▾';
  color: var(--muted);
  transition: transform 0.2s ease;
}

.settings-more[open] > summary::after {
  transform: rotate(180deg);
}

.settings-more-body {
  margin-top: 12px;
}
