/* ═══════════════════════════════════════════════════════════
   homey — calm nautical: soft blues, rounded, airy
   Design system adapted from tidy ✦ / leafy 🌿 → blått tema
   ═══════════════════════════════════════════════════════════ */

:root {
  --cream:      #FAF7F0;
  --cream-deep: #F2EDE2;
  --ink:        #36404C;
  --ink-soft:   #6B7684;
  --ink-faint:  #A3ABB5;

  --leaf:       #6B93B8;
  --leaf-deep:  #4A7296;
  --leaf-soft:  #D4E2ED;
  --leaf-tint:  #EDF3F8;

  /* Semantik — positiva belopp & bra betyg (grönt, oberoende av branding) */
  --good:      #3F9160;
  --good-deep: #2E7D4F;
  --good-tint: #E6F2EA;
  --terracotta: #CE8B72;
  --terra-tint: #F8E9E2;
  --butter:     #E7D5A2;
  --butter-tint:#FAF3DD;
  --sky:        #9FBECB;
  --sky-tint:   #E6EFF3;
  --lilac:      #B3A9C6;
  --lilac-tint: #EDE9F2;

  --card:       #FFFFFF;
  --line:       #E9E3D4;
  --danger:     #C47A70;

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-soft: 0 1px 2px rgba(57,65,58,.04), 0 8px 24px rgba(57,65,58,.06);
  --shadow-lift: 0 2px 4px rgba(57,65,58,.05), 0 14px 34px rgba(57,65,58,.10);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Karla", -apple-system, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  scrollbar-gutter: stable; height: 100%; }

body {
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* subtle atmosphere: two soft botanical washes */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(60% 40% at 85% -5%, var(--leaf-tint) 0%, transparent 70%),
    radial-gradient(70% 45% at 5% 100%, var(--butter-tint) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 100px);
}

.hidden { display: none !important; }
.sheet.hidden, .sheet-backdrop.hidden { display: block !important; }

/* ── type ─────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
h2 { font-size: 28px; }
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--leaf-deep);
  margin-bottom: 2px;
}

/* ── auth ─────────────────────────────────────────────────── */
.auth-card {
  margin-top: 8vh;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 36px 26px 30px;
  text-align: center;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; color: var(--leaf); }
.brand h1 { font-size: 40px; font-weight: 600; }
.tagline { color: var(--ink-soft); margin: 14px 0 28px; font-size: 15px; }

#auth-form { text-align: left; }
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 12px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 7px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="url"],
.field input[type="date"],
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--leaf); background: #fff; }

/* Global date-input (date-sheet) */
input[type="date"] {
  width: 100%; padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font: 500 15px var(--font-body);
  background: var(--cream);
  color: var(--ink);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
input[type="date"]:focus {
  outline: none;
  border-color: var(--leaf);
  background: var(--card);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }
.field-opt { font-style: normal; font-weight: 500; color: var(--ink-faint); font-size: 12px; text-transform: none; letter-spacing: 0; }

.form-error { color: var(--danger); font-size: 13.5px; min-height: 18px; margin: -6px 0 8px; }

.link-btn {
  background: none; border: none; font: inherit;
  color: var(--ink-soft); cursor: pointer; margin-top: 18px;
}
.link-btn strong { color: var(--leaf-deep); }

/* ── buttons ──────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 700;
  border: none; border-radius: 999px;
  padding: 14px 22px; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  width: 100%;
  background: var(--leaf); color: #fff;
  box-shadow: 0 6px 16px rgba(122,158,126,.35);
}
.btn-primary:disabled { opacity: .6; }
.btn-ghost { background: var(--cream-deep); color: var(--ink-soft); }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 50%; cursor: pointer; color: var(--ink);
  box-shadow: var(--shadow-soft);
  transition: transform .12s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* ── topbar ───────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px;
}
.topbar-actions { display: flex; gap: 10px; }

/* ── today: task cards ────────────────────────────────────── */
.cards { display: flex; flex-direction: column; gap: 10px; }

.task-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: var(--radius-lg);
  padding: 14px 18px 14px 14px;
  box-shadow: 0 1px 3px rgba(61,79,61,.06); cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* visuell feedback under långtryck — skala ner gradvis tills menyn öppnas */
.task-card.pressing {
  transform: scale(.965);
  box-shadow: 0 1px 2px rgba(61,79,61,.1);
  transition: transform .22s ease, box-shadow .22s ease;
}
.task-card:nth-child(2) { animation-delay: .04s; }
.task-card:nth-child(3) { animation-delay: .08s; }
.task-card:nth-child(4) { animation-delay: .12s; }
.task-card:nth-child(5) { animation-delay: .16s; }

.plant-thumb {
  width: 72px; height: 88px; flex: none;
  border-radius: var(--radius-sm);
  overflow: hidden; background: var(--cream-deep);
  display: grid; place-items: center;
}
.plant-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
}

.task-info { flex: 1; min-width: 0; }
.task-info strong { display: block; font-size: 15.5px; line-height: 1.3; }
.task-info small { color: var(--ink-faint); font-size: 12.5px; display: block; margin-top: 1px; }

.row-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.care-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--ink-soft); background: var(--cream-deep);
  padding: 3px 9px; border-radius: 999px; flex: none;
}
.care-tag.info { background: var(--cream-deep); color: var(--ink-soft); }
.care-tag.action { background: var(--leaf-tint); color: var(--leaf-deep); }
.care-tag.danger { background: var(--terra-tint); color: var(--terracotta); }
.care-tag.done { background: var(--leaf-tint); color: var(--leaf-deep); }
.care-tag.done svg { color: var(--leaf); }

.pest-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--ink-soft); background: var(--cream-deep);
  padding: 3px 9px; border-radius: 999px; flex: none;
}

.done-check { width: 24px; height: 24px; color: var(--leaf); flex: none; }

.do-btn { 
  width: 52px; height: 52px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid var(--leaf);
  background: transparent; color: var(--leaf);
  cursor: pointer; padding: 0;
  font-size: 21px;
  transition: background .15s, color .15s, transform .12s;
}
.do-btn:active { transform: scale(.9); background: var(--leaf); color: #fff; }
.do-btn.treat { border-color: var(--butter); color: #B99A45; }
.do-btn.treat:active { background: var(--butter); color: #fff; }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-spark { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--leaf); }
.empty-spark svg { width: 100%; height: 100%; }
.empty-spark.muted { color: var(--ink-faint); }

.done-section { margin-top: 28px; }
.done-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  font: inherit; background: none; border: none; padding: 0;
  cursor: pointer; margin-bottom: 10px;
}
.done-toggle svg { width: 14px; height: 14px; color: var(--ink-faint); transition: transform .22s ease; }
.done-toggle.collapsed svg { transform: rotate(-90deg); }
.done-count {
  font-size: 11px; font-weight: 700; color: var(--leaf-deep);
  background: var(--leaf-tint); border-radius: 999px; padding: 2px 8px;
}
.done-heading {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint);
}
#today-done-list { display: flex; flex-direction: column; gap: 10px; }
#today-done-list .task-card { cursor: default; opacity: .6; }
#today-done-list .task-card strong { text-decoration: line-through; }
#today-done-list .done-check { width: 24px; height: 24px; color: var(--leaf); flex: none; }

.do-btn { background: var(--leaf); color: #fff; }

.offline-pill {
  margin: 22px auto 0; width: fit-content;
  font-size: 12.5px; font-weight: 700;
  color: var(--ink-soft);
  background: var(--butter-tint);
  border: 1.5px dashed var(--butter);
  padding: 8px 16px; border-radius: 999px;
}

/* ── plants grid ──────────────────────────────────────────── */
.search-field {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 11px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
}
.search-field svg { width: 17px; height: 17px; color: var(--ink-faint); flex: none; }
.search-field input {
  flex: 1; font: inherit; border: none; outline: none;
  background: transparent; color: var(--ink);
  -webkit-appearance: none;
}
.search-field input::placeholder { color: var(--ink-faint); }
.search-field input::-webkit-search-cancel-button { -webkit-appearance: none; }

.chip-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  font: inherit; font-size: 12.5px; font-weight: 700;
  padding: 7px 14px; border-radius: 999px; flex: none;
  border: 1.5px solid var(--line); background: var(--card);
  color: var(--ink-soft); cursor: pointer;
  transition: all .15s;
}
.chip.on { background: var(--leaf-tint); color: var(--leaf-deep); border-color: var(--leaf); }
.chip-sep { width: 1px; height: 18px; background: var(--line); flex: none; align-self: center; margin: 0 2px; }
.sort-chip { font-weight: 600; color: var(--ink-soft); }

.plant-grid { display: flex; flex-direction: column; gap: 10px; }
.plant-card {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  cursor: pointer;
  transition: transform .12s;
}
.plant-card:active { transform: scale(.97); }
.plant-card .photo {
  aspect-ratio: 4/5; background: var(--cream-deep);
  display: grid; place-items: center; font-size: 40px;
  overflow: hidden;
}
.plant-card .photo img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
}
.plant-card .meta { padding: 10px 13px 12px; }
.plant-card .meta strong { display: block; font-size: 14px; line-height: 1.25; }
.plant-card .meta small { color: var(--ink-faint); font-size: 12px; display: block; margin-top: 1px; }
.plant-card .status-dot {
  position: absolute; top: 10px; right: 10px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff;
}
.plant-card { position: relative; }
.status-dot.overdue { background: var(--terracotta); }
.status-dot.today { background: var(--butter); }
.status-dot.ok { background: var(--leaf); }

/* ── plant detail ─────────────────────────────────────────── */
.hero {
  position: relative;
  margin: 0; padding: 0;
  height: auto; background: none;
  display: block; overflow: visible;
}
.hero-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.hero-back {
  position: static; margin-bottom: 0;
}
.hero-edit svg { fill: none; }

/* anteckningar på detaljsidan */
.detail-notes {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--cream-deep);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* sektionshuvud med åtgärd (Historik + kommentarsknapp) */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 26px; margin-bottom: 12px;
}
.section-head .section-title { margin: 0; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--cream-deep); color: var(--ink-soft);
  border: none; border-radius: 999px;
  padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: transform .12s;
}
.chip-btn:active { transform: scale(.95); }
.detail-header img {
  width: 72px; height: 96px;
  border-radius: var(--radius-sm);
  object-fit: cover; object-position: center;
}

.detail-header {
  display: flex; align-items: center; gap: 16px;
  min-height: 84px;
}
.detail-thumb {
  width: 72px; height: 88px; flex: none;
  border-radius: var(--radius-sm);
  background: var(--cream-deep);
  display: grid; place-items: center;
  overflow: hidden;
}
.detail-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
}
.detail-meta { flex: 1; min-width: 0; }
.detail-meta h2 { font-size: 26px; line-height: 1.2; }
.detail-meta .eyebrow { margin-bottom: 0; }
.detail-body { padding-top: 14px; }
.detail-body h2 { font-size: 30px; }
.detail-sub { color: var(--ink-soft); font-size: 14.5px; margin-top: 2px; }
.family-row { margin-top: 4px; }
.family-link { color: var(--leaf-deep); cursor: pointer; font-weight: 600; }
.family-link:active { opacity: .7; }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 6px; }
.action-btn {
  flex: 1 1 calc(50% - 5px); min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 700; font-size: 14.5px;
  padding: 13px 14px; border-radius: 999px; cursor: pointer;
  border: none; white-space: nowrap;
  background: var(--leaf); color: #fff;
  box-shadow: 0 6px 16px rgba(122,158,126,.3);
  transition: transform .12s, background .15s;
}
.action-btn > span { width: 17px; height: 17px; flex: none; display: inline-block; vertical-align: 0; }
.action-btn:active { transform: scale(.96); }
.action-btn.treat { background: var(--butter); color: #6B5A22; box-shadow: 0 6px 16px rgba(231,213,162,.4); }
.action-btn.secondary {
  background: var(--card); color: var(--leaf-deep);
  border: 1.5px solid var(--leaf-soft);
  box-shadow: var(--shadow-soft);
}

.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint);
  margin: 26px 0 10px;
}
.log-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.log-filter {
  font: inherit; font-size: 12px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card);
  color: var(--ink-soft); cursor: pointer;
}
.log-filter.on { background: var(--leaf-tint); color: var(--leaf-deep); border-color: var(--leaf); }

.log-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  padding: 11px 14px; font-size: 14px;
  cursor: pointer;
}
.log-row + .log-row { margin-top: 8px; }
.log-row .log-icon { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--cream-deep); }
.log-row .log-icon svg { width: 16px; height: 16px; stroke-width: 1.5; }
.log-row .log-what { flex: 1; min-width: 0; }
.log-row .log-when { color: var(--ink-faint); font-size: 12.5px; flex: none; }

.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.photo-strip::-webkit-scrollbar { display: none; }
.photo-strip img, .photo-strip .photo-item {
  position: relative; flex: none;
  width: 100px; height: 125px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--cream-deep);
}
.photo-item img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
}
.photo-meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.35));
}
.photo-meta small {
  color: #fff; font-size: 9px; font-weight: 600;
}
.photo-delete {
  width: 20px; height: 20px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.9); color: var(--danger);
  font-size: 14px; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
}

.add-photo {
  width: 100px; height: 125px; flex: none;
  border: 2px dashed var(--line); border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--ink-faint); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.add-photo:hover { border-color: var(--leaf); color: var(--leaf); }

.show-more-tile {
  width: 100px; height: 125px; flex: none;
  border: 2px dashed var(--line); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: none; font: inherit; font-size: 13px; font-weight: 700;
  color: var(--ink-soft); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.show-more-tile small { font-size: 11px; font-weight: 600; color: var(--ink-faint); }
.show-more-tile:hover { border-color: var(--leaf); color: var(--leaf); }
.show-more-tile:active { transform: scale(.96); }

.show-more { width: 100%; margin-top: 12px; padding: 12px; border-radius: 999px; font-weight: 700; }

/* fullscreen gallery */
#gallery-viewer {
  position: fixed; inset: 0; z-index: 1000;
}
.gallery-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.92);
}
.gallery-content {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.gallery-img {
  max-width: 90%; max-height: 85%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.gallery-close {
  position: absolute; top: 20px; right: 20px;
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  font-size: 28px; line-height: 1;
  cursor: pointer; z-index: 10;
}
.gallery-prev, .gallery-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  font-size: 32px; line-height: 1;
  cursor: pointer; z-index: 10;
}
.gallery-prev { left: 20px; }
.gallery-next { right: 20px; }
.gallery-counter {
  position: absolute; bottom: 30px; left: 50%;
  transform: translateX(-50%);
  color: #fff; font-size: 14px;
  background: rgba(0,0,0,.5); padding: 6px 14px;
  border-radius: 99px;
}



/* ── tab bar ──────────────────────────────────────────────── */
.tabbar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 14px);
  display: flex; gap: 4px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow-lift);
  z-index: 50;
}
.tabbar::before {
  content: '';
  position: absolute;
  top: 6px; bottom: 6px;
  left: var(--tab-left, 6px);
  width: var(--tab-width, 60px);
  border-radius: 999px;
  background: var(--leaf-tint);
  z-index: 0;
  transition: left .28s cubic-bezier(.32,.72,.28,1), width .28s cubic-bezier(.32,.72,.28,1);
  opacity: 0;
}
.tabbar[data-active]::before { opacity: 1; }
.tab {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font: inherit; font-size: 10.5px; font-weight: 700;
  color: var(--ink-faint);
  background: none; border: none; border-radius: 999px;
  padding: 8px 16px 6px; cursor: pointer;
  transition: color .15s;
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--leaf-deep); }

/* ── sheets ───────────────────────────────────────────────── */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(57,65,58,.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s ease, visibility 0s .28s;
}

.sheet-backdrop:not(.hidden) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .28s ease, visibility 0s;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  margin: 0 auto; max-width: 480px;
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none;
  background: var(--card);
  border-radius: 28px 28px 0 0;
  padding: 14px 24px calc(var(--safe-bottom) + 26px);
  box-shadow: 0 -12px 40px rgba(57,65,58,.16);
  z-index: 100;
  transform: translateY(105%);
  visibility: hidden;
  pointer-events: none;
  transition: transform .32s cubic-bezier(.32,.72,0,1), visibility 0s .32s;
}

.sheet:not(.hidden) {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition: transform .32s cubic-bezier(.32,.72,0,1), visibility 0s;
}

.sheet::-webkit-scrollbar { display: none; }
.sheet h3 { font-size: 24px; margin-bottom: 20px; }
.sheet-actions {
  display: flex; gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.sheet-actions .btn { flex: 1; }

/* delete-knapp i en sheet: ligga i flödet under actions, inte täckt */
.sheet .delete-plant { margin-top: 14px; width: 100%; }

/* segmented controls */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 14px;
  background: var(--cream); color: var(--ink-soft);
  border: 1.5px solid var(--line); border-radius: 999px;
  cursor: pointer; transition: all .15s;
}
.seg button.on { background: var(--leaf-tint); color: var(--leaf-deep); border-color: var(--leaf); }

.custom-interval { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.custom-interval input[type="number"] {
  width: 74px; flex: none;
  font: inherit; font-size: 16px; text-align: center;
  padding: 9px 8px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--cream); color: var(--ink); outline: none;
  -webkit-appearance: none;
}
.custom-interval input[type="number"]:focus { border-color: var(--leaf); background: #fff; }

/* popup menu */
.pop-menu {
  position: fixed; z-index: 120;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  padding: 6px;
  display: flex; flex-direction: column; min-width: 200px;
  animation: pop-in .18s ease both;
}
.pop-menu button {
  font: inherit; font-size: 14.5px; font-weight: 600;
  text-align: left; padding: 11px 14px;
  background: none; border: none; border-radius: 10px;
  color: var(--ink); cursor: pointer;
}
.pop-menu button:active { background: var(--cream-deep); }
.pop-menu button.danger { color: var(--danger); }

/* toast */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 92px);
  display: flex; align-items: center; gap: 16px;
  background: var(--ink); color: var(--cream);
  font-size: 14px; font-weight: 600;
  padding: 12px 22px; border-radius: 999px;
  box-shadow: var(--shadow-lift);
  z-index: 200;
  animation: toast-in .3s ease both;
  white-space: nowrap;
}
.toast-action {
  font: inherit; font-size: 13.5px; font-weight: 700;
  background: none; border: none; cursor: pointer;
  color: var(--butter); letter-spacing: .02em;
}

/* settings */
.notify-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.notify-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notify-label { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.notify-copy small { font-size: 13px; line-height: 1.4; color: var(--ink-faint); }
.switch {
  position: relative; flex: none;
  width: 52px; height: 32px;
  border: none; border-radius: 16px;
  background: var(--line);
  cursor: pointer; padding: 0;
  transition: background .2s ease;
}
.switch[aria-checked="true"] { background: var(--leaf); }
.switch:disabled { opacity: .5; cursor: default; }
.switch-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(57,65,58,.28);
  transition: transform .22s cubic-bezier(.32,.72,.25,1);
}
.switch[aria-checked="true"] .switch-thumb { transform: translateX(20px); }
.notify-hint {
  margin-top: 10px; font-size: 13px; line-height: 1.45;
  color: var(--ink-soft); background: var(--butter-tint);
  border-radius: var(--radius-sm); padding: 10px 12px;
}

.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0; border-bottom: 1.5px solid var(--line);
  font-weight: 600; font-size: 15px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row small { color: var(--ink-faint); font-weight: 500; font-size: 13px; display: block; margin-top: 2px; }

/* stats */
.stat-summary {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.stat-tile {
  background: var(--card); border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-tile-val {
  font-family: var(--font-display); font-size: 26px; font-weight: 600;
  color: var(--ink);
}
.stat-tile-label { font-size: 12.5px; color: var(--ink-soft); }

.stat-card {
  background: var(--card); border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px; margin-bottom: 12px;
}
.stat-card h4 { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.stat-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.stat-medal { width: 26px; flex: none; text-align: center; font-size: 15px; }
.stat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-val { color: var(--ink-soft); font-weight: 700; font-size: 13px; flex: none; }

/* wishlist */
.wish-card { position: relative; }
.wish-card .wish-actions { display: flex; gap: 6px; padding: 0 13px 12px; }
.wish-btn {
  flex: 1; font: inherit; font-size: 12px; font-weight: 700;
  padding: 8px 6px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--leaf-soft); background: var(--leaf-tint); color: var(--leaf-deep);
}
.wish-btn.remove { border-color: var(--line); background: var(--card); color: var(--ink-faint); }

/* image preview in forms — shrink-wraps the image, no full-width box */
.img-preview {
  display: block; width: fit-content; max-width: 100%;
  border-radius: var(--radius-sm);
  color: var(--ink-faint); font-size: 13px; font-weight: 600;
  cursor: pointer;
}
/* empty state: dashed placeholder box */
.img-preview:has(> span) {
  width: 100%; min-height: 56px;
  display: grid; place-items: center;
  background: var(--cream-deep);
  border: 1.5px dashed var(--line);
  padding: 22px 16px;
}
/* chosen image: the img carries its own border, no box around it */
.img-preview img { display: block; max-width: 100%; max-height: 220px; width: auto; height: auto; object-fit: contain; border-radius: var(--radius-sm); }

.delete-plant {
  width: 100%; margin-top: 16px;
  font: inherit; font-weight: 700; font-size: 15px;
  padding: 13px; border: none; border-radius: 999px;
  background: var(--terra-tint); color: var(--danger);
  cursor: pointer;
}

/* ── animations ───────────────────────────────────────────── */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── loading spinner ── */
.topbar-spinner {
  position: fixed;
  top: calc(var(--safe-top, 0px) + 10px);
  right: 14px;
  z-index: 999;
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.spinner {
  width: 16px; height: 16px;
  border: 2.5px solid var(--line);
  border-top-color: var(--leaf-deep);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-loading {
  opacity: .6;
  pointer-events: none;
}

/* ── homey ── */
.card {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

/* (okategoriserat sparande — nya diskreta regler finns längre ner) */

/* expense card */
.exp-name { display: block; font-size: 15.5px; line-height: 1.3; font-weight: 700; }
.exp-sub { color: var(--ink-faint); font-size: 12.5px; display: block; margin-top: 1px; }
.exp-amount {
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
  white-space: nowrap;
}

/* kompakt kort (utgifter & sparande) — lägre höjd */
.card-compact { padding: 11px 16px; }
.card-compact .exp-name { font-size: 15px; }
.card-compact .exp-sub { font-size: 12px; margin-top: 0; }
.card-compact .exp-amount { font-size: 17px; }

/* apartment card */
.apt-address { display: block; font-size: 15.5px; line-height: 1.3; font-weight: 700; }
.apt-meta { color: var(--ink-faint); font-size: 13px; margin-top: 2px; }
.apt-price {
  font-family: var(--font-display); font-size: 22px; font-weight: 600;
  white-space: nowrap;
}
.apt-price-sub { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }

/* danger button variant */
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 6px 16px rgba(196,122,112,.3); }

/* grön text för "Kvar / månad" */
.stat-tile-green { color: var(--leaf-deep); }

/* formulärsektion (t.ex. "Övrigt") */
.form-section {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 600;
  margin: 22px 0 12px;
  padding-top: 18px;
  border-top: 1.5px solid var(--line);
}

/* två fält sida vid sida */
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

/* sorteringsrad */
.sort-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.sort-row label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.sort-pill {
  position: relative; display: inline-flex; align-items: center;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
}
.sort-pill select {
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 8px 30px 8px 12px; border: none; border-radius: 999px;
  background: transparent; color: inherit;
  appearance: none; -webkit-appearance: none;
  cursor: pointer;
}
.sort-pill svg {
  position: absolute; right: 10px; width: 14px; height: 14px;
  pointer-events: none; color: var(--ink-faint);
}

/* checkbox-grid för egenskaper */
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-bottom: 14px; }
.check {
  display: flex; align-items: center; gap: 9px;
  font-size: 14.5px; font-weight: 500; color: var(--ink);
  padding: 8px 0; cursor: pointer; user-select: none;
}
.check input[type="checkbox"] {
  width: 19px; height: 19px; margin: 0; flex: none;
  accent-color: var(--leaf-deep); cursor: pointer;
}
.field select {
  font: inherit; width: 100%;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}

/* plain länk i detaljvyn (ingen bakgrundsplatta) */
.detail-link {
  display: inline-block;
  color: var(--leaf-deep); font-weight: 700; font-size: 14.5px;
  text-decoration: none;
  margin: 8px 0 16px;
}
.detail-link:active { opacity: .7; }

/* lab-fält i detaljvyn */
.lab-card {
  background: var(--cream);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px 6px;
  margin-bottom: 16px;
}
.lab-card .lab-title {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint);
  margin-bottom: 10px;
}
.lab-sub {
  font-size: 13px; font-weight: 700; color: var(--ink);
  margin-bottom: 8px;
}

/* expanderbar lab */
.lab-expander { padding: 0; }
.lab-expander > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
}
.lab-expander > summary::-webkit-details-marker { display: none; }
.lab-chev {
  width: 18px; height: 18px; color: var(--ink-faint);
  transition: transform .2s;
}
.lab-expander[open] .lab-chev { transform: rotate(180deg); }
.lab-body { padding: 0 16px 14px; border-top: 1px dashed var(--line); padding-top: 14px; }

/* diff-värde (+/-) bredvid siffror */
.diff { font-size: 13px; font-weight: 700; }

/* 30%-jämförelse-kort */
.cmp30 h4 { color: var(--leaf-deep); }

/* Sparande-rubrik — starkare hierarki */
.savings-head { margin-top: 34px; margin-bottom: 14px; }
.savings-title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink);
}

/* Okategoriserat sparande — diskretare (ingen stark bakgrund) */
.unallocated-card {
  margin-top: 22px;
  padding: 14px 18px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
}
.unallocated-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
}
.unallocated-label { font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.unallocated-val {
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
}
.unallocated-sub {
  margin-top: 4px; font-size: 12px; color: var(--ink-faint); line-height: 1.45;
}

/* ── samlat listkort: poster med skiljelinjer ─────────────── */
.line-card { padding: 4px 18px; }
.line-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.line-row:last-child { border-bottom: none; }
.line-row-link { cursor: pointer; }
.line-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.line-row-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-row-sub { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.line-row-amount {
  font-family: var(--font-display); font-size: 17px; font-weight: 600;
  white-space: nowrap; flex: none;
}

/* ── betyg-badge ──────────────────────────────────────────── */
.rating-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 22px; padding: 0 7px; margin-left: 8px;
  border-radius: 999px;
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  vertical-align: 2px;
}
.rating-good { background: var(--good-tint); color: var(--good-deep); }
.rating-mid  { background: #f3e9d2; color: #8a6d1c; }
.rating-low  { background: #f6e3e0; color: var(--danger); }

/* ── detaljvy: rubrikrad ──────────────────────────────────── */
.detail-headline { display: flex; align-items: center; gap: 10px; }
.detail-headline .rating-badge { margin-left: 0; min-width: 38px; height: 28px; font-size: 15px; }

/* hint-text i stat-rader (t.ex. "(inkl. amortering)") */
.row-hint { color: var(--ink-faint); font-weight: 500; font-size: 12px; }

/* totalt sparande — totalrad sist i sparandekortet */
.line-row-total {
  border-top: 1.5px solid var(--line);
  border-bottom: none;
  padding-top: 12px;
}
/* raden före totalen ska inte ha egen skiljelinje */
.line-card .line-row:has(+ .line-row-total) { border-bottom: none; }
.line-row-total .line-row-name { font-size: 15px; font-weight: 700; }
.line-row-total .line-row-amount { font-size: 19px; }

/* bostadskort: adress + betyg på samma rad */
.apt-titleline { display: flex; align-items: center; flex-wrap: wrap; }

/* tre tiles i detaljvyn */
.detail-tiles { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) {
  .detail-tiles { grid-template-columns: repeat(2, 1fr); }
  .detail-tiles .stat-tile-val { font-size: 21px; }
}

/* omräknat belopp (30 %-läge) i tile-etiketter */
.tile-diff { font-weight: 700; }

/* varningsbanner: utanför budget */
.afford-warning {
  background: #f6e3e0; color: var(--danger);
  border-radius: var(--radius-md);
  padding: 12px 16px; margin: 10px 0 14px;
  font-size: 13.5px; line-height: 1.5;
  display: flex; flex-direction: column; gap: 3px;
}
.afford-warning strong { font-weight: 700; }
/* ── jämför: välj-läge i listan ───────────────────────────── */
.card.selectable { cursor: pointer; }
.card.cmp-selected {
  box-shadow: var(--shadow-soft), 0 0 0 2.5px var(--leaf);
}
.compare-mode-active .sort-row { opacity: .4; pointer-events: none; }

/* skatteskillnad-chip: grön när skatten blir lägre */
.care-tag.good { background: var(--good-tint); color: var(--good-deep); }

/* flytande jämför-knapp längst ner */
.compare-bar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 84px);
  display: flex; gap: 8px; align-items: center;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow-lift);
  z-index: 60;
}
.compare-go { white-space: nowrap; }
.compare-go:disabled { opacity: .45; }
#compare-count { font-weight: 600; opacity: .85; margin-left: 2px; }

/* ── jämförelsevy ─────────────────────────────────────────── */
.compare-head {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px;
  margin: 4px 0 14px;
}
.compare-head .cmp-col-label {
  background: var(--card); border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 12px 14px; text-align: center;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.cmp-col-addr {
  font-family: var(--font-display); font-weight: 600; font-size: 16px;
  line-height: 1.25;
}
.cmp-col-mun { font-size: 12px; color: var(--ink-soft); }
.cmp-col-label .rating-badge { margin-left: 0; }

.cmp-verdict {
  text-align: center; margin: 0 0 16px;
  font-size: 15px; color: var(--ink-soft);
}
.cmp-verdict strong { color: var(--ink); }

.cmp-card {
  background: var(--card); border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px; margin-bottom: 12px;
}
.cmp-card h4 {
  font-family: var(--font-display); font-size: 17px; font-weight: 600;
  margin-bottom: 4px;
}

/* varje rad: etikett + två högerställda värdekolumner.
   skiljelinje ÖVANFÖR varje rad → inga dubletter runt totalrader */
.cmp-row {
  display: grid;
  grid-template-columns: minmax(0,1.05fr) minmax(0,1fr) minmax(0,1fr);
  gap: 8px; align-items: baseline;
  padding: 7px 0; font-size: 14px;
  border-top: 1px solid var(--cream-deep);
}
.cmp-card h4 + .cmp-row,
.cmp-card > div > .cmp-row:first-child { border-top: none; }
.cmp-row .cmp-label { color: var(--ink-soft); min-width: 0; }
.cmp-row .cmp-val {
  text-align: right; font-weight: 700; font-size: 13.5px; color: var(--ink);
}
.cmp-row .cmp-val.is-best { color: var(--good-deep); }
.cmp-row .cmp-val.is-worse { color: var(--ink-faint); font-weight: 500; }
.cmp-row .cmp-val .cmp-diff {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--good-deep); margin-top: 1px;
}
.cmp-row .cmp-na { color: var(--ink-faint); font-weight: 500; }
.cmp-row.cmp-total {
  border-top: 1.5px solid var(--line);
  margin-top: 4px; padding-top: 11px;
}
.cmp-row.cmp-total .cmp-label,
.cmp-row.cmp-total .cmp-val { font-weight: 700; }

/* smal skärm: samma tre kolumner, bara trängre — inget omstaplande */
@media (max-width: 640px) {
  .cmp-card { padding: 14px; }
  .cmp-row { gap: 6px; font-size: 13px; padding: 6px 0; }
  .cmp-row .cmp-val { font-size: 12.5px; }
  .cmp-row .cmp-val .cmp-diff { font-size: 10.5px; }
  .cmp-col-addr { font-size: 14.5px; }
  .cmp-verdict { font-size: 14px; }
}
