/* ==========================================================================
   CozyKeep — warm & cozy
   Mobile-first. All colour via custom properties so the theme is one edit.
   ========================================================================== */

:root {
  /* ── Moominhouse daylight ──────────────────────────────────────────────
     The 1990s house: a tall round blue tower under a deep navy roof, cream
     plaster walls, honey lamplight in the round windows, a timber door.     */
  --bg:            #dceaf2;
  --bg-2:          #cfe0ea;
  --surface:       #fdfaf2;
  --surface-2:     #f6f1e4;
  --surface-3:     #e9e2d2;

  --text:          #1f3340;
  --text-2:        #4c6473;
  --muted:         #7d95a3;

  --border:        #d6e2ea;
  --border-strong: #b9ccd8;

  --primary:       #2f6f95;
  --primary-dark:  #1f5273;
  --primary-soft:  #cfe4ef;
  --on-primary:    #ffffff;

  --roof:          #173a52;
  --roof-2:        #275a78;
  --wall:          #3c7fa3;
  --wall-2:        #2f6f95;
  --trim:          #f4efe1;

  --accent:        #c88f4f;
  --accent-soft:   #f3e3cc;

  --rose:          #c98a80;
  --rose-soft:     #f6e6e2;

  --success:       #5f8f6a;
  --success-soft:  #dcecdf;

  --danger:        #a85a48;
  --danger-soft:   #f4ded7;

  --ring:          rgba(47, 111, 149, .35);
  --shadow-sm:     0 1px 2px rgba(27, 66, 88, .07), 0 1px 3px rgba(27, 66, 88, .05);
  --shadow-md:     0 6px 18px rgba(27, 66, 88, .11);
  --shadow-lg:     0 22px 52px rgba(27, 66, 88, .20);

  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  28px;
  --r-pill: 999px;

  --sp:    14px;
  --header-h: 58px;
  --bottom-nav-h: 66px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --font: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-display: 'Baloo 2', 'Nunito', -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

html[data-theme="dark"] {
  /* ── Moominvalley after dark: the house at night, windows lit ─────────── */
  --bg:            #101f28;
  --bg-2:          #152630;
  --surface:       #1a2d38;
  --surface-2:     #203540;
  --surface-3:     #27404d;

  --text:          #eaf2f7;
  --text-2:        #b0c6d3;
  --muted:         #7e97a6;

  --border:        #294350;
  --border-strong: #385666;

  --primary:       #7cb9d6;
  --primary-dark:  #a3cfe4;
  --primary-soft:  #1c3a49;
  --on-primary:    #0d1d25;

  --roof:          #0b1820;
  --roof-2:        #132833;
  --wall:          #2b6a8c;
  --wall-2:        #235a78;
  --trim:          #e7e0cf;

  --accent:        #d8ab74;
  --accent-soft:   #33291d;

  --rose:          #d69b91;
  --rose-soft:     #34231f;

  --success:       #8fb98f;
  --success-soft:  #1f3226;

  --danger:        #d18a76;
  --danger-soft:   #33211c;

  --ring:          rgba(124, 185, 214, .40);
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md:     0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg:     0 22px 52px rgba(0, 0, 0, .60);
}

/* ─────────────────────────── reset ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

[hidden] { display: none !important; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 100%; height: 100%; fill: currentColor; display: block; }

.muted { color: var(--muted); font-size: 13px; }
.hint  { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ─────────────────────────── screens ─────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

#mainScreen.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ─────────────────────────── boot ─────────────────────────── */
.boot-screen {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
  padding: 24px;
  z-index: 500;
}
.boot-screen.active { display: flex; }
.boot-inner { text-align: center; max-width: 320px; width: 100%; }
.boot-logo { font-size: 56px; line-height: 1; margin-bottom: 10px; }
.boot-inner h1 { font-size: 30px; letter-spacing: -.02em; margin-bottom: 6px; }
.boot-msg { color: var(--text-2); font-size: 14px; min-height: 20px; margin-bottom: 18px; }
.boot-bar {
  height: 4px; width: 100%;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.boot-bar span {
  display: block; height: 100%; width: 12%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--r-pill);
  transition: width .35s var(--ease);
}

/* ─────────────────────────── login ─────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  display: none;
  overflow-y: auto;
  background:
    radial-gradient(circle at 15% 0%, var(--primary-soft) 0%, transparent 55%),
    radial-gradient(circle at 90% 100%, var(--accent-soft) 0%, transparent 50%),
    var(--bg);
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  z-index: 400;
}
.login-screen.active { display: block; }
.login-card {
  width: 100%; max-width: 420px;
  margin: max(6vh, 30px) auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 28px 22px 22px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo { font-size: 46px; line-height: 1; }
.login-card h1 { font-size: 27px; margin-top: 8px; letter-spacing: -.02em; }
.login-tag { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.link-btn {
  display: block; margin: 16px auto 0;
  background: none; border: 0; padding: 8px;
  color: var(--text-2); font-size: 13px;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--primary); }

/* ─────────────────────────── header ─────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: calc(var(--header-h) + var(--safe-t));
  padding: var(--safe-t) calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 30;
}
.brand-btn { flex: 0 0 auto; }
.brand-mark { font-size: 24px; line-height: 1; }
.app-title {
  flex: 1 1 auto;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  width: 40px; height: 40px;
  min-width: 40px;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 9px;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover  { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn-primary { color: var(--primary); background: var(--primary-soft); }
.icon-btn-primary:hover { background: var(--primary); color: var(--on-primary); }
.icon-btn-spacer { width: 40px; height: 40px; display: inline-block; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  font-size: 13px; font-weight: 700;
  text-transform: uppercase;
}

.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
  flex: 0 0 auto;
  transition: background .2s var(--ease);
}
.sync-dot.is-online  { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.sync-dot.is-offline { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-soft); }
.sync-dot.is-syncing { background: var(--accent);  animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .32; } }

/* desktop nav lives in the header; bottom nav hides */
.nav-tabs { display: none; }

/* ─────────────────────────── main ─────────────────────────── */
.app-main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 8px);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.tab-head {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 16px calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
}
.tab-head-text { flex: 1 1 auto; min-width: 0; }
.tab-head h2 {
  font-size: 22px; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.tab-head-actions { display: flex; gap: 4px; flex: 0 0 auto; padding-bottom: 2px; }

/* ─────────────────────────── buttons ─────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 11px 16px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              color .16s var(--ease), transform .1s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); }
.btn-soft:hover { background: var(--primary); color: var(--on-primary); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 12px; min-height: 38px; font-size: 13.5px; }
.btn-wide { flex: 1 1 0; min-width: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn-row-2 > .btn { flex: 1 1 0; }

/* critical action — slow pulsing red glow */
.btn-critical {
  animation: criticalGlow 3.4s ease-in-out infinite;
  border-color: var(--danger);
}
@keyframes criticalGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 73, 47, 0); }
  50%      { box-shadow: 0 0 0 7px rgba(192, 73, 47, .16); }
}

/* ─────────────────────────── forms ─────────────────────────── */
.field { display: block; margin-bottom: 13px; }
.field-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .04em;
}
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1 1 0; min-width: 0; }

.input {
  width: 100%;
  padding: 11px 13px;
  min-height: 44px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 16px; /* ≥16px stops iOS zoom-on-focus */
  outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
textarea.input { min-height: 60px; resize: vertical; line-height: 1.4; }
select.input {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 20px;
  padding-right: 34px;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder { color: var(--muted); }

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 11px 0; min-height: 44px;
  font-size: 15px; cursor: pointer;
}
.switch {
  appearance: none;
  width: 48px; height: 28px; flex: 0 0 auto;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  position: relative; cursor: pointer;
  transition: background .2s var(--ease);
  -webkit-appearance: none;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease);
}
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }

.form-error {
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px;
}

/* ─────────────────────────── modal ─────────────────────────── */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(40, 30, 24, .55);
  z-index: 300;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal.active { display: flex; align-items: flex-end; justify-content: center; }

/* mobile: modal fills the screen, actions pinned to the bottom */
.modal-content {
  background: var(--surface);
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: sheetUp .26s var(--ease);
}
@keyframes sheetUp {
  from { transform: translateY(28px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-head {
  display: flex; align-items: center; gap: 6px;
  flex: 0 0 auto;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 10px calc(12px + var(--safe-l));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.modal-head h2 { flex: 1 1 auto; font-size: 17.5px; }
.modal-x { font-size: 26px; line-height: 1; font-weight: 300; }
.modal-back { color: var(--text); }

.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px calc(16px + var(--safe-r)) 16px calc(16px + var(--safe-l));
}

.modal-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 12px calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.modal-actions > .btn { flex: 1 1 0; min-width: 0; }
/* 3-button rows: DELETE left | primary centre | CANCEL right */
.modal-actions > .btn-danger { flex: 0 0 auto; }
.modal-dialog { height: auto; max-height: 86dvh; border-radius: var(--r-lg); }
.modal.active .modal-dialog { animation: popIn .2s var(--ease); }
@keyframes popIn {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-camera { background: #000; height: 100%; }

/* ─────────────────────────── photo field ─────────────────────────── */
.photo-field { margin-bottom: 16px; }
.photo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 260px;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); font-size: 13px;
}
.photo-placeholder span { font-size: 34px; }
.photo-btns { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }

/* ─────────────────────────── shop tab ─────────────────────────── */
.quick-add {
  display: flex; gap: 8px;
  padding: 4px calc(14px + var(--safe-r)) 12px calc(14px + var(--safe-l));
}
.quick-add-input { flex: 1 1 auto; min-width: 0; }
.quick-add .btn { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; }

.progress-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 0 calc(14px + var(--safe-r)) 12px calc(14px + var(--safe-l));
}
.progress-track {
  flex: 1 1 auto; height: 7px;
  background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden;
}
.progress-track span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--r-pill);
  transition: width .3s var(--ease);
}
.progress-label { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px calc(14px + var(--safe-r)) 6px calc(14px + var(--safe-l));
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 5;
}
.group-head .group-count { font-weight: 500; }

.line-list { list-style: none; margin: 0; padding: 0 0 6px; }

.line-item {
  display: flex; align-items: center; gap: 12px;
  margin: 0 calc(10px + var(--safe-r)) 6px calc(10px + var(--safe-l));
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: opacity .2s var(--ease), transform .12s var(--ease);
}
.line-item:active { transform: scale(.99); }
.line-item.is-checked { opacity: .74; }
.line-item.is-checked .line-name { text-decoration: line-through; text-decoration-thickness: 1.5px; }

.line-check {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.line-check svg { width: 16px; height: 16px; color: #fff; opacity: 0; transition: opacity .16s var(--ease); }
.line-item.is-checked .line-check { background: var(--success); border-color: var(--success); }
.line-item.is-checked .line-check svg { opacity: 1; }

.line-main { flex: 1 1 auto; min-width: 0; }
.line-name { font-size: 15.5px; font-weight: 550; word-break: break-word; }
.line-meta { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.line-note { font-size: 12.5px; color: var(--text-2); margin-top: 2px; font-style: italic; }

.line-qty {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 2px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 2px;
}
.qty-btn {
  width: 28px; height: 28px; border: 0; background: transparent;
  color: var(--text-2); border-radius: 50%; cursor: pointer;
  font-size: 17px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { background: var(--surface-3); color: var(--text); }
.qty-val { min-width: 26px; text-align: center; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }

.line-photo {
  flex: 0 0 auto; width: 40px; height: 40px;
  border-radius: var(--r-sm); object-fit: cover;
  background: var(--surface-3);
}

/* ─────────────────────────── cards / lists ─────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin: 0 calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
  padding: 14px;
  cursor: pointer;
  transition: transform .12s var(--ease), box-shadow .16s var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }
.card:active { transform: scale(.99); }
.card.is-active-list { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-title { flex: 1 1 auto; font-size: 16px; font-weight: 650; min-width: 0; word-break: break-word; }
.card-sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.card-notes { color: var(--muted); font-size: 12.5px; margin-top: 6px; font-style: italic; }
.card-foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.card-foot .spacer { flex: 1 1 auto; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 650;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.badge-primary { background: var(--primary-soft);  color: var(--primary-dark); }
.badge-accent  { background: var(--accent-soft);   color: #8a5f16; }
.badge-success { background: var(--success-soft);  color: var(--success); }
html[data-theme="dark"] .badge-accent { color: var(--accent); }

/* ─────────────────────────── catalog ─────────────────────────── */
.catalog-toolbar {
  display: flex; gap: 8px; align-items: center;
  padding: 0 calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
}
.search-wrap { flex: 1 1 auto; min-width: 0; }
.search-wrap .input { border-radius: var(--r-pill); }

.chip-row {
  display: flex; gap: 7px;
  overflow-x: auto;
  padding: 0 calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: var(--r-pill);
  padding: 7px 13px;
  font-size: 13.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
  min-height: 36px;
}
.chip:hover { background: var(--surface-3); }
.chip.is-on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 calc(14px + var(--safe-r)) 16px calc(14px + var(--safe-l));
}
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform .12s var(--ease), box-shadow .16s var(--ease);
}
.item-card:hover { box-shadow: var(--shadow-md); }
.item-card:active { transform: scale(.985); }
.item-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.item-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface-3);
}
.item-photo-empty {
  width: 100%; aspect-ratio: 1 / 1;
  background: linear-gradient(150deg, var(--surface-2), var(--surface-3));
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: var(--muted);
}
.item-card-body { padding: 9px 11px 11px; flex: 1 1 auto; display: flex; flex-direction: column; }
.item-card-name { font-size: 14.5px; font-weight: 650; line-height: 1.25; word-break: break-word; }
.item-card-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.item-card-add {
  margin-top: 9px;
  width: 100%;
  padding: 7px; min-height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px; font-weight: 650;
  cursor: pointer;
}
.item-card-add:hover { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ─────────────────────────── picker ─────────────────────────── */
.picker-list { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; }
.picker-row {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.picker-row.is-selected { border-color: var(--primary); background: var(--primary-soft); }
.picker-thumb {
  width: 42px; height: 42px; flex: 0 0 auto;
  border-radius: var(--r-sm); object-fit: cover; background: var(--surface-3);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.picker-name { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 550; word-break: break-word; }
.picker-sub  { font-size: 12px; color: var(--muted); }
.picker-tick {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px;
}
.picker-row.is-selected .picker-tick { background: var(--primary); border-color: var(--primary); }

/* ─────────────────────────── calendar ─────────────────────────── */
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0 calc(10px + var(--safe-r)) 4px calc(10px + var(--safe-l));
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); text-align: center;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  padding: 0 calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l));
}
.cal-cell {
  aspect-ratio: 1 / 1;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 2px;
  transition: background .16s var(--ease), border-color .16s var(--ease);
  position: relative;
}
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.is-blank { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.is-today { border-color: var(--primary); border-width: 2px; }
.cal-cell.is-selected { background: var(--primary-soft); border-color: var(--primary); }
.cal-day { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-cell.is-today .cal-day { color: var(--primary); font-weight: 750; }
.cal-dots { display: flex; gap: 2px; height: 6px; align-items: center; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.cal-dot.kind-shopping  { background: var(--accent); }
.cal-dot.kind-occasion  { background: var(--success); }
.cal-dot.kind-list      { background: var(--primary); }
.cal-more { font-size: 9px; color: var(--muted); line-height: 1; }

.cal-upcoming { padding: 6px 0 16px; }
.cal-upcoming h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700;
  padding: 0 calc(14px + var(--safe-r)) 8px calc(14px + var(--safe-l));
}
.event-row {
  display: flex; align-items: center; gap: 11px;
  margin: 0 calc(14px + var(--safe-r)) 7px calc(14px + var(--safe-l));
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.event-row.kind-shopping { border-left-color: var(--accent); }
.event-row.kind-occasion { border-left-color: var(--success); }
.event-row.is-done { opacity: .5; }
.event-when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.event-title { flex: 1 1 auto; font-size: 15px; font-weight: 600; min-width: 0; word-break: break-word; }
.event-row.is-done .event-title { text-decoration: line-through; }

/* ─────────────────────────── settings ─────────────────────────── */
.settings-section { margin-bottom: 22px; }
.settings-section h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700; margin-bottom: 8px;
  padding-left: 2px;
}
.row-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%;
  padding: 13px 14px;
  min-height: 48px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 7px;
  font-size: 15px; font-weight: 550;
  text-align: left; cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.row-btn:hover { background: var(--surface-3); }
.row-btn-static { cursor: default; }
.row-btn-static:hover { background: var(--surface-2); }
.row-btn-meta { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.row-btn-danger { color: var(--danger); }
.row-btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.settings-about { text-align: center; }

.cat-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.cat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.cat-row-name { flex: 1 1 auto; font-size: 15px; }
.cat-row-icon { font-size: 18px; }
.inline-add { display: flex; gap: 8px; }
.inline-add .input { flex: 1 1 auto; }

/* ─────────────────────────── users ─────────────────────────── */
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  cursor: pointer;
}
.user-row:hover { background: var(--surface-3); }
.user-row.is-me { border-color: var(--primary); }
.user-avatar {
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; text-transform: uppercase;
}
.user-info { flex: 1 1 auto; min-width: 0; }
.user-name { font-size: 15px; font-weight: 650; }
.user-sub { font-size: 12.5px; color: var(--muted); }

/* ─────────────────────────── empty states ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 54px 26px;
  color: var(--text-2);
}
.empty-icon { font-size: 48px; line-height: 1; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 14px; color: var(--text-2); margin-bottom: 18px; }
.empty-state .btn-row { justify-content: center; max-width: 340px; margin: 0 auto; }
.empty-mini {
  text-align: center; padding: 26px 20px; color: var(--muted); font-size: 14px;
}

/* ─────────────────────────── camera ─────────────────────────── */
.camera-stage {
  flex: 1 1 auto;
  position: relative;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.camera-stage video { width: 100%; height: 100%; object-fit: cover; }
.camera-hint {
  position: absolute; bottom: 14px; left: 0; right: 0;
  text-align: center; color: #fff; font-size: 13px;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  padding: 0 16px;
}
.camera-actions {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 20px calc(20px + var(--safe-b));
  background: #000;
}
.camera-actions .btn-ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.camera-shutter {
  width: 68px; height: 68px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.85);
  background: rgba(255,255,255,.22);
  cursor: pointer;
  transition: transform .1s var(--ease), background .16s var(--ease);
  flex: 0 0 auto;
}
.camera-shutter:active { transform: scale(.9); background: rgba(255,255,255,.5); }

/* ─────────────────────────── toast ─────────────────────────── */
.toast-wrap {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 12px);
  z-index: 600;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: var(--text);
  color: var(--bg);
  border-radius: var(--r-pill);
  padding: 10px 18px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-md);
  max-width: 100%;
  animation: toastIn .22s var(--ease);
  text-align: center;
}
.toast.is-error   { background: var(--danger); color: #fff; }
.toast.is-success { background: var(--success); color: #fff; }
@keyframes toastIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ─────────────────────────── bottom nav ─────────────────────────── */
.bottom-nav {
  flex: 0 0 auto;
  display: flex;
  height: calc(var(--bottom-nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 30;
}
.bottom-tab {
  flex: 1 1 0;
  border: 0; background: transparent;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
  transition: color .16s var(--ease);
}
.bottom-tab svg { width: 22px; height: 22px; }
.bottom-tab.active { color: var(--primary); }

/* ══════════════════════════════════════════════════════════════════════
   DESKTOP
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 860px) {

  .app-header {
    height: calc(64px + var(--safe-t));
    padding: var(--safe-t) 24px 0;
    gap: 14px;
  }
  .app-title { flex: 0 0 auto; font-size: 19px; }

  .nav-tabs {
    display: flex;
    flex: 0 1 auto;
    gap: 2px;
    margin-left: 8px;
  }
  .nav-tab {
    border: 0; background: transparent;
    color: var(--text-2);
    padding: 9px 15px;
    border-radius: var(--r-pill);
    font-size: 14.5px; font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .16s var(--ease), color .16s var(--ease);
  }
  .nav-tab:hover { background: var(--surface-3); color: var(--text); }
  .nav-tab.active { background: var(--primary-soft); color: var(--primary-dark); }

  .header-actions { margin-left: auto; }

  .bottom-nav { display: none; }

  .app-main { padding-bottom: 32px; }

  .tab-head h2 { font-size: 26px; }
  .quick-add, .progress-strip, .group-head, .catalog-toolbar, .chip-row,
  .item-grid, .card, .line-list, .cal-weekdays, .cal-grid, .events-wrap {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
  }
  .line-item {
    margin-left: auto; margin-right: auto;
    max-width: 1040px;
  }
  .event-row { max-width: 1040px; margin-left: auto; margin-right: auto; }

  .item-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

  .cal-cell { min-height: 74px; aspect-ratio: auto; border-radius: var(--r-md); }
  .cal-day { font-size: 15px; }

  /* modals become centred cards with rounded corners */
  .modal.active { align-items: center; padding: 24px; }
  .modal-content {
    height: auto;
    max-height: 88dvh;
    width: 100%;
    max-width: 620px;
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    animation: popIn .2s var(--ease);
  }
  .modal-head { padding: 16px 20px 14px; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .modal-head h2 { font-size: 19px; }
  .modal-body { padding: 20px; }
  .modal-actions { padding: 14px 20px 18px; border-radius: 0 0 var(--r-xl) var(--r-xl); }
  .modal-content.modal-dialog { max-width: 440px; }
  .modal-camera { max-width: 700px; border-radius: var(--r-xl); overflow: hidden; height: 80dvh; }
  .photo-frame { max-height: 300px; }

  .toast-wrap { bottom: 24px; }
}

/* wide desktop: give the shop tab a comfortable measure */
@media (min-width: 1200px) {
  .line-item { max-width: 900px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ─────────────────────────── banner ─────────────────────────── */
.app-banner {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 9px calc(14px + var(--safe-r)) 9px calc(14px + var(--safe-l));
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}
.app-banner span { flex: 1 1 auto; }
.app-banner.is-warn { background: var(--accent-soft); color: #8a5f16; }
html[data-theme="dark"] .app-banner.is-warn { color: var(--accent); }
.banner-btn {
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  background: rgba(0, 0, 0, .045);
  color: inherit;
  border-radius: var(--r-pill);
  padding: 5px 12px;
  font-size: 12.5px; font-weight: 650;
  cursor: pointer; white-space: nowrap;
}
.banner-btn:hover { background: rgba(0, 0, 0, .07); }

.card-foot-actions {
  display: flex; justify-content: center;
  padding: 10px calc(14px + var(--safe-r)) 22px calc(14px + var(--safe-l));
}
.card-foot-actions .btn { max-width: 320px; width: 100%; }

.chip-n { font-weight: 500; font-size: 12px; opacity: .75; }

/* print — a plain paper list */
@media print {
  .app-header, .bottom-nav, .modal-actions, .quick-add,
  .tab-head-actions, .toast-wrap, .catalog-toolbar, .chip-row { display: none !important; }
  .app-main { overflow: visible; padding: 0; }
  .tab-content { display: none !important; }
  .tab-content.active { display: block !important; }
  .line-item { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}

/* ==========================================================================
   Moominhouse theme layer
   The 1990s house, carried into the interface: a deep navy shingled roof for
   the header, cream plaster walls for the cards, round lit windows for the
   icons, an arched timber door for the sign-in card, a railed veranda for the
   bottom bar. Colours come from the tokens at the top of this file.
   ========================================================================== */

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../vendor/fonts/nunito-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../vendor/fonts/baloo2-500.woff2') format('woff2');
}

/* ── the house itself ───────────────────────────────────────────────────── */
.mh-roof       { fill: var(--roof); }
.mh-roof-lit   { fill: var(--roof-2); opacity: .8; }
.mh-eave       { fill: var(--roof); }
.mh-finial     { fill: none; stroke: var(--trim); stroke-width: 3; stroke-linecap: round; }
.mh-wall       { fill: var(--wall); }
.mh-wall-shade { fill: rgba(9, 26, 36, .16); }
.mh-band       { fill: none; stroke: var(--trim); stroke-width: 1.8; opacity: .30; }
.mh-frame      { fill: var(--trim); }
.mh-lit        { fill: #f7d79b; }
.mh-mullion    { fill: none; stroke: var(--wall-2); stroke-width: 1.7; opacity: .5; }
.mh-ledge      { fill: var(--trim); }
.mh-rail       { fill: none; stroke: var(--trim); stroke-width: 2; opacity: .92; }
.mh-door-frame { fill: var(--trim); }
.mh-door       { fill: var(--accent); }
.mh-knob       { fill: var(--roof); }
.mh-ledge-shadow { fill: none; stroke: rgba(9, 26, 36, .25); stroke-width: 2; }
.mh-chimney    { fill: var(--wall-2); }
.mh-smoke      { fill: none; stroke: rgba(244, 239, 225, .5); stroke-width: 2.4; stroke-linecap: round; }

html[data-theme="dark"] .mh-lit        { fill: #ffd79a; }
html[data-theme="dark"] .mh-wall-shade { fill: rgba(0, 0, 0, .28); }

/* ── sky, plaster, paper grain ──────────────────────────────────────────── */
body {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.05'/></svg>"),
    radial-gradient(760px 460px at 50% -12%, #ffffff 0%, rgba(255, 255, 255, 0) 62%),
    radial-gradient(1100px 700px at 8% 4%, rgba(60, 127, 163, .22), transparent 62%),
    radial-gradient(900px 620px at 96% 100%, rgba(31, 82, 115, .18), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .app-title, .login-brand h1, .home-title, .modal-head h2, .tab-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .1px;
}

/* ── header: the roof ───────────────────────────────────────────────────── */
.app-header {
  background-color: var(--roof);
  background-image:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .045) 0 2px, transparent 2px 8px),
    linear-gradient(180deg, var(--roof-2) 0%, var(--roof) 70%);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 3px 16px rgba(11, 24, 32, .32);
  color: var(--trim);
}
.app-title {
  color: var(--trim);
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: .35px;
}
.brand-btn { color: var(--trim); }
.brand-mark { display: block; width: 25px; height: 25px; color: currentColor; }
.brand-mark svg { width: 100%; height: 100%; display: block; }

.header-actions { gap: 4px; }
.header-actions .icon-btn {
  color: rgba(244, 239, 225, .88);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px rgba(244, 239, 225, .28);
}
.header-actions .icon-btn:hover {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(244, 239, 225, .55);
}
.avatar {
  background: var(--trim);
  color: var(--roof);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .5), 0 2px 6px rgba(0, 0, 0, .25);
}
.sync-dot.is-online  { background: #8fd39a; box-shadow: 0 0 0 3px rgba(143, 211, 154, .18); }
.sync-dot.is-offline { background: #e08b76; box-shadow: 0 0 0 3px rgba(224, 139, 118, .18); }
.sync-dot.is-syncing { background: var(--accent); box-shadow: 0 0 0 3px rgba(200, 143, 79, .2); }

/* desktop nav sits on the roof */
.nav-tab {
  font-family: var(--font-display);
  font-size: 14px;
  color: rgba(244, 239, 225, .78);
  border-radius: var(--r-pill);
  padding: 6px 12px;
}
.nav-tab:hover  { background: rgba(255, 255, 255, .10); color: var(--trim); }
.nav-tab.active { background: var(--trim); color: var(--roof); }

/* ── veranda: the bottom bar ────────────────────────────────────────────── */
.bottom-nav {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-3) 100%);
  border-top: 3px solid var(--accent);
  box-shadow: 0 -8px 22px rgba(27, 66, 88, .13);
}
.bottom-tab { position: relative; color: var(--text-2); }
.bottom-tab span { font-family: var(--font-display); }
.bottom-tab.active { color: var(--primary-dark); }
/* the active tab is a lit round window */
.bottom-tab.active::before {
  content: '';
  position: absolute;
  top: 5px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 143, 79, .32) 0%, rgba(200, 143, 79, 0) 72%);
  pointer-events: none;
}
.bottom-tab.active svg { filter: drop-shadow(0 1px 3px rgba(200, 143, 79, .55)); }

/* ── login: standing at the door ────────────────────────────────────────── */
.login-screen {
  background:
    radial-gradient(700px 420px at 50% -10%, rgba(255, 255, 255, .85), transparent 62%),
    radial-gradient(900px 600px at 50% 112%, rgba(60, 127, 163, .20), transparent 62%),
    linear-gradient(180deg, #e6f2f8 0%, var(--bg) 58%, var(--bg-2) 100%);
}

.login-card {
  position: relative;
  z-index: 1;
  border-radius: 44px 44px 22px 22px;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .9);
  background: var(--surface);
  padding-top: 26px;
}

/* the house, standing on its own hill inside the card */
.login-diorama {
  position: relative;
  height: 186px;
  margin: 0 0 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 74% at 50% 4%, #ffffff 0%, rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, #dcecf6 0%, #c6dfee 100%);
}
.ld-hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 58px; }
.ld-far  { fill: rgba(47, 111, 149, .17); }
.ld-near { fill: rgba(47, 111, 149, .27); }
.ld-tree { position: absolute; left: 18px; bottom: 10px; width: 46px; height: 67px; }
.ld-tree path   { stroke: rgba(31, 82, 115, .40); stroke-width: 3; fill: none; stroke-linecap: round; }
.ld-tree circle { fill: rgba(47, 111, 149, .26); }
.ld-house {
  position: absolute;
  left: 52%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 118px; height: 177px;
}

.login-brand h1 {
  font-family: var(--font-display);
  font-size: 29px;
  letter-spacing: .3px;
  color: var(--primary-dark);
}
.login-tag {
  font-family: var(--font-display);
  font-size: 14.5px;
  letter-spacing: .4px;
  color: var(--accent);
}

/* valley under the door (screen is position:fixed inset:0 — do not touch it) */
.login-scene {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 0;
  pointer-events: none;
  line-height: 0;
}
.login-scene svg { width: 100%; height: auto; display: block; }
.ls-far  { fill: rgba(47, 111, 149, .16); }
.ls-near { fill: rgba(47, 111, 149, .28); }
.ls-tree { stroke: rgba(31, 82, 115, .40); stroke-width: 2.6; fill: none; stroke-linecap: round; }
.ls-leaf { fill: rgba(47, 111, 149, .30); }

/* ── boot ───────────────────────────────────────────────────────────────── */
.boot-logo { width: 74px; height: 111px; margin: 0 auto 14px; }
.boot-logo svg { width: 100%; height: 100%; display: block; }
.boot-screen h1 { font-family: var(--font-display); color: var(--primary-dark); letter-spacing: .4px; }

/* ── home ───────────────────────────────────────────────────────────────── */
/* .tab-content carries no padding of its own; Home has no .tab-head, so it
   needs its own inset or the cards run to the screen edges. */
#tab-home { padding: 14px calc(14px + var(--safe-r)) 6px calc(14px + var(--safe-l)); }
#tab-home.active { display: flex; flex-direction: column; min-height: 100%; }

.home-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 176px;
  background:
    radial-gradient(120% 90% at 84% 106%, rgba(60, 127, 163, .26), transparent 64%),
    linear-gradient(172deg, var(--surface) 0%, var(--primary-soft) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 46px 46px 18px 18px;
  padding: 18px 8px 0 18px;
  margin-bottom: 14px;
  overflow: hidden;
}

.home-greet { flex: 1 1 auto; min-width: 0; padding-bottom: 20px; }
.home-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: .95px;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}
.home-title {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.25;
  margin: 0 0 5px;
  color: var(--text);
}
.home-sub { margin: 0; font-size: 13.5px; color: var(--text-2); max-width: 30ch; }

/* the house stands on the bottom edge of the hero */
.home-scene {
  position: relative;
  flex: 0 0 132px;
  width: 132px;
  height: 158px;
  align-self: flex-end;
}
.hs-hills {
  position: absolute;
  left: -22px; right: -10px; bottom: -2px;
  width: auto; height: 48px;
}
.hs-far  { fill: rgba(47, 111, 149, .15); }
.hs-near { fill: rgba(47, 111, 149, .25); }
.hs-house { position: absolute; right: 2px; bottom: 4px; width: 98px; height: 147px; }

.home-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.home-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon big" "label label" "sub sub";
  align-items: center;
  gap: 3px 8px;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s;
  font: inherit;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.home-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.home-tile:active { transform: scale(.985); }
.home-tile:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* each tile icon is a little round window */
.home-tile-icon {
  grid-area: icon;
  width: 29px; height: 29px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
}
.home-tile-icon svg {
  width: 15px; height: 15px;
  display: block;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.home-tile-big {
  grid-area: big;
  justify-self: end;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
  color: var(--primary);
}
.home-tile-label { grid-area: label; font-family: var(--font-display); font-size: 14px; margin-top: 5px; }
.home-tile-sub {
  grid-area: sub;
  font-size: 11.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* section heading with a balcony railing running off to the right */
.home-section h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 8px;
  color: var(--text-2);
}
.home-section h3::after {
  content: '';
  flex: 1 1 auto;
  height: 7px;
  border-radius: 2px;
  background-image: repeating-linear-gradient(90deg, var(--border-strong) 0 1.5px, transparent 1.5px 8px);
  opacity: .75;
}

.home-upcoming { display: grid; gap: 7px; }
.home-event {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.home-event:hover { border-color: var(--border-strong); }
.home-event-date { flex: 0 0 auto; font-size: 11.5px; font-weight: 700; color: var(--primary); min-width: 70px; }
.home-event-title { flex: 1 1 auto; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-event-kind { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.home-event-kind.kind-shopping { background: var(--rose); }
.home-event-kind.kind-occasion { background: var(--success); }
.home-quiet {
  margin: 0;
  padding: 16px;
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}

.home-foot { margin: auto 0 6px; padding-top: 26px; text-align: center; }
.home-foot svg { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 auto 4px; }
.hf-far  { fill: rgba(47, 111, 149, .12); }
.hf-near { fill: rgba(47, 111, 149, .20); }
.hf-tree { stroke: rgba(31, 82, 115, .35); stroke-width: 2.4; stroke-linecap: round; fill: none; }
.hf-leaf { fill: rgba(47, 111, 149, .22); }
html[data-theme="dark"] .hf-far  { fill: rgba(124, 185, 214, .14); }
html[data-theme="dark"] .hf-near { fill: rgba(124, 185, 214, .22); }
html[data-theme="dark"] .hf-leaf { fill: rgba(124, 185, 214, .26); }
html[data-theme="dark"] .hf-tree { stroke: rgba(124, 185, 214, .40); }
html[data-theme="dark"] .home-foot-line { color: var(--text-2); }
.home-foot-line {
  margin: 0;
  font-family: var(--font-display);
  font-size: 12.5px;
  letter-spacing: .7px;
  color: var(--muted);
}

/* ── plaster walls for everything else ──────────────────────────────────── */
.btn {
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  letter-spacing: .25px;
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .14), 0 2px 6px rgba(47, 111, 149, .22);
}
.btn-primary:hover { background: var(--primary-dark); }
.input {
  border-radius: var(--r-md);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.card, .list-card, .catalog-card, .settings-card {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.modal-head { border-top: 3px solid var(--accent); }
.modal-content { border-radius: 18px 18px 0 0; }

@media (prefers-reduced-motion: reduce) {
  .home-tile, .home-event, .bottom-tab svg { transition: none; }
}
