/* Theme color tokens now live in tokens.css (generated from design tokens).   Legacy variable names are aliased there for compatibility. */

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--background);
  color: var(--foreground);
  line-height: 1.45;
  letter-spacing: 0;
}

::selection { background: color-mix(in oklch, var(--primary) 25%, transparent); }

button { font-family: inherit; touch-action: manipulation; }
button:active { transform: scale(0.96); }
button { transition: transform 0.12s ease; }

/* ---- sticky top: header + add bar, frosted ---- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--background);
  background: color-mix(in srgb, var(--background) 84%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.top-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 16px 12px;
  padding-top: max(14px, env(safe-area-inset-top));
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

header h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 10px;
}

header h1 .logo { width: 34px; height: 34px; border-radius: 10px; box-shadow: var(--shadow-sm); }

/* shadcn "outline" button */
#langToggle {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

#langToggle:hover { background: var(--accent); color: var(--accent-foreground); }

#addForm { display: flex; gap: 8px; position: relative; }

/* shadcn "input" */
#addInput {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#addInput::placeholder { color: var(--muted-foreground); }

#addInput:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 28%, transparent), var(--shadow-sm);
}

/* shadcn "primary" button */
#addForm button {
  border: none;
  border-radius: var(--radius-md);
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-foreground);
  background: var(--primary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

#addForm button:hover { filter: brightness(1.07); }

.hint {
  margin: 8px 4px 0;
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

/* ---- list ---- */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 6px 16px 40px;
}

.dept { margin: 24px 0; }

.dept h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

/* shadcn "badge / secondary" */
.dept h2 .count {
  font-weight: 600;
  letter-spacing: 0;
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.72rem;
}

.dept ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* shadcn "card" */
.dept li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
}

li.enter { animation: rise 0.28s ease-out; }

li.leaving {
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  transform: scale(0.96);
}

/* shadcn "checkbox" */
.check {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.22s ease, border-color 0.22s ease, color 0.22s ease, transform 0.12s ease;
}
.check svg { width: 20px; height: 20px; }
.check .ico-check { display: none; }
li.done .check .ico-cart { display: none; }
li.done .check .ico-check { display: block; }

li.done { opacity: 0.5; }
li.done .check { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
li.done .check:active { transform: scale(0.9); }
li.done .name { text-decoration: line-through; }

.name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }

/* shadcn "badge" on accent */
.qty {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-foreground);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-inline-start: 6px;
  white-space: nowrap;
}

/* ghost icon button */
.del {
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  font-size: 1.25rem;
  line-height: 1;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, transform 0.12s;
}

.del:hover { opacity: 1; background: var(--accent); color: var(--accent-foreground); }

li.pending { opacity: 0.55; }
li.pending .check { animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: 0.35; } }

.empty { text-align: center; color: var(--muted-foreground); margin: 64px 16px; }
.empty .big { font-size: 3.5rem; display: block; margin-bottom: 8px; }
.empty-title { font-size: 1.15rem; font-weight: 700; color: var(--foreground); margin: 0 0 4px; }
.empty-sub { font-size: 0.92rem; margin: 0; }

/* "Buy again" suggestions */
.dept.suggest h2 { color: var(--primary); }
.dept.suggest li { border-style: dashed; }
.addback {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, background-color 0.2s;
  will-change: transform; /* fix Safari not repainting bg in transformed drawer */
}
.addback:hover { background: var(--primary-hover); }
.addback:active { transform: scale(0.92); }
.addback:disabled { opacity: 0.6; }
.freq {
  margin-inline-start: auto;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip {
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s, color 0.2s, transform 0.12s;
}
.chip:hover { background: var(--accent); color: var(--accent-foreground); }
.chip::before { content: '+ '; font-weight: 700; }

.actions { margin: 28px 0 20px; }

/* shadcn "outline" button, full width */
.actions .ghost {
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.actions .ghost:hover { background: var(--accent); color: var(--accent-foreground); }

/* ---- login ---- */
#loginView {
  max-width: 400px;
  margin: 12vh auto;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 40px 32px 36px;
  box-shadow: 0 16px 40px var(--shadow);
  text-align: center;
}

#loginView .logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 6px 18px var(--shadow); }

#loginView h2 { margin: 20px 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }

#loginView p { color: var(--soft); font-size: 15px; margin: 0 0 4px; }

#loginView .oauth-buttons { max-width: none; margin-top: 28px; }

#loginForm { display: flex; flex-direction: column; gap: 10px; }

#loginForm input {
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  min-width: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#loginForm input::placeholder { color: var(--muted-foreground); }

#loginForm input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 28%, transparent);
}

#loginForm button {
  border: none;
  border-radius: var(--radius-md);
  padding: 15px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-foreground);
  background: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

#loginForm button:hover { filter: brightness(1.07); }

.msg { color: var(--destructive); min-height: 1.4em; font-size: 0.9rem; }

/* Buy-again bottom drawer */
#drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  background: var(--card);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.14);
  z-index: 50;
  max-height: 58vh;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% - 60px));
  transition: transform 0.25s ease;
}
#drawer.open {
  transform: translateY(0);
}
#drawer.open .teaser {
  display: none;
}
#drawer[hidden] {
  display: none;
}
.drawer-handle {
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  cursor: grab;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.drawer-handle .count {
  background: var(--accent);
  color: var(--accent-foreground);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.75rem;
  font-weight: 700;
}
.drawer-handle .teaser {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}
.drawer-body li .hide-sug {
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 1.1rem;
  line-height: 1;
  padding: 8px;
  cursor: pointer;
  opacity: 0.6;
}
.drawer-body li .hide-sug:hover {
  opacity: 1;
}
.drawer-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px calc(8px + env(safe-area-inset-bottom));
}
.drawer-body ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.drawer-body li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}
.drawer-body .freq {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  white-space: nowrap;
}
body.has-drawer #listView {
  padding-bottom: 62px;
}

/* ---- header menu ---- */
#menuBtn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  letter-spacing: 1px;
}
.top-inner { position: relative; }
#menu {
  position: absolute;
  top: 58px;
  inset-inline-end: 16px;
  width: 248px;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 60;
}
#menu[hidden] { display: none; }
.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.menu-label { font-size: 0.9rem; font-weight: 600; }
.seg {
  display: flex;
  background: var(--muted);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.seg button.on {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}
.theme-dots { display: flex; gap: 8px; padding: 2px 4px; }
.theme-dots button {
  border: 2px solid transparent;
  background: none;
  padding: 2px;
  border-radius: 50%;
  cursor: pointer;
}
.theme-dots button.on { border-color: var(--primary); }
.theme-dots .dot {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.theme-dots .dot.sage { background: #486f59; }
.theme-dots .dot.ocean { background: #3d6db5; }
.theme-dots .dot.clay { background: #b26a45; }
.theme-dots .dot.plum { background: #8e5aa8; }
.theme-dots .dot.midnight { background: #1c1c1e; }
.menu-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: none;
  color: var(--foreground);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 8px 6px;
  cursor: pointer;
  font-family: inherit;
}

/* Store tag: faint icon when unset, badge when set */

/* ---- stats view ---- */
.stats-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 16px;
}
.stats-head h2 { margin: 0; font-size: 1.3rem; }
#statsBack {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  cursor: pointer;
}
[dir="ltr"] #statsBack { transform: scaleX(-1); }
#adminBack {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  cursor: pointer;
}
[dir="ltr"] #adminBack { transform: scaleX(-1); }
.muted { color: var(--muted-foreground); font-size: 0.9rem; }

/* Autocomplete dropdown under the add input */
#suggestDrop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 70;
  overflow: hidden;
}
#suggestDrop[hidden] { display: none; }
#suggestDrop button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: none;
  color: inherit;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
#suggestDrop button:last-child { border-bottom: none; }
#suggestDrop button:active { background: var(--accent); }
#suggestDrop .sub {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  margin-inline-start: auto;
}

/* Stats/Activity tabs */
.seg.tabs {
  display: flex;
  gap: 4px;
  margin: 0 16px 16px;
  max-width: 600px;
}
.seg.tabs button {
  flex: 1;
  border: none;
  background: none;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted-foreground);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.seg.tabs button.on {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

/* Activity feed */
#activityList {
  list-style: none;
  margin: 0;
  padding: 0 16px;
  max-width: 632px;
}
#activityList li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
#activityList li:last-child { border-bottom: none; }
#activityList .ico {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
#activityList .txt { flex: 1; min-width: 0; }
#activityList .desc { font-size: 0.95rem; }
#activityList .desc b { font-weight: 700; }
#activityList .time {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  margin-top: 2px;
}
#activityMore {
  display: block;
  margin: 8px auto 24px;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ---- Stats redesign ---- */
.stat-hero {
  display: flex;
  gap: 12px;
  margin: 0 16px 16px;
  max-width: 600px;
}
.stat-hero > div {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 8px;
  text-align: center;
}
.stat-hero .stat-big {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}
.stat-hero .muted { font-size: 0.8rem; margin-top: 4px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin: 0 16px 16px;
  max-width: 600px;
}
.stat-card h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
}
.stat-card .bars { width: 100%; height: auto; display: block; }
.donut-wrap {
  display: flex;
  gap: 20px;
  align-items: center;
}
.donut { width: 130px; height: 130px; flex-shrink: 0; }
.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.legend-row .swatch {
  width: 12px; height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}
.legend-row span:nth-child(2) {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.legend-row b { font-weight: 700; }
.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}
.stat-row span {
  flex: 0 0 42%;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.92rem;
}
.stat-row .bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: var(--muted);
  overflow: hidden;
}
.stat-row .bar div {
  height: 100%;
  background: var(--primary);
  border-radius: 5px;
}
.stat-row b { min-width: 2ch; text-align: end; }
.pad { padding: 0 16px; }

/* ---- Popover triggers (replace native selects) ---- */
.qty-btn, .store-btn {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin-inline-start: 6px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  color: var(--muted-foreground);
  opacity: 0.75;
}
.qty-btn.unset, .store-btn:not(.set) {
  width: 30px;
  height: 30px;
}
.qty-btn.unset svg, .store-btn:not(.set) svg {
  width: 18px;
  height: 18px;
}
.qty-btn:not(.unset), .store-btn.set {
  background: var(--accent);
  color: var(--accent-foreground);
  border-radius: 999px;
  padding: 4px 8px;
  padding-inline-end: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 1;
  gap: 4px;
  white-space: nowrap;
}
.store-btn.set {
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.qty-btn .chev, .store-btn .chev {
  display: inline-flex;
  width: 10px;
  height: 10px;
  opacity: 0.7;
}
.qty-btn .chev svg, .store-btn .chev svg {
  width: 10px;
  height: 10px;
}

/* ---- Popover ---- */
#popBackdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 90;
}
#pop {
  position: fixed;
  z-index: 91;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 14px;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 32px));
  max-height: 70vh;
  overflow-y: auto;
}
.pop-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted-foreground);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pop-sec { margin-bottom: 14px; }
.pop-sec:last-child { margin-bottom: 0; }
.pop-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pop-chips button {
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.pop-chips button.on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.pop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.pop-grid button {
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  border-radius: 10px;
  padding: 10px 4px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.pop-grid button.on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.pop-custom {
  display: flex;
  gap: 6px;
}
input[type="text"], input[type="number"], input[type="password"], input[type="search"] {
  font-size: 16px;
}
.pop-custom input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 16px; /* iOS zooms the page if inputs are under 16px */
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--background);
  color: var(--foreground);
}
.pop-custom button {
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.pop-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: -4px -4px 8px;
}
.pop-list button {
  border: none;
  background: none;
  text-align: start;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--foreground);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pop-list button:hover { background: var(--muted); }
.pop-list button.on { font-weight: 700; }
.pop-list button .tick {
  color: var(--primary);
  font-weight: 700;
}
.pop-actions {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}
.pop-actions button {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  border-radius: 10px;
  padding: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

/* ---- Admin panel ---- */
#adminView, #settingsView {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}
#settingsBack {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  cursor: pointer;
}
[dir="ltr"] #settingsBack { transform: scaleX(-1); }
.admin-desc.warn { color: #c0392b; }
.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.admin-card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}
.admin-card h4 {
  margin: 16px 0 8px;
  font-size: 0.9rem;
  color: var(--muted-foreground);
}
.admin-card input[type="search"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  margin-bottom: 8px;
  background: var(--background);
  color: var(--foreground);
}
.admin-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}
.admin-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.admin-list li.is-deleted {
  opacity: 0.5;
}
.admin-list .pname {
  font-weight: 600;
  flex: 1;
}
.admin-list .psub {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}
.admin-list button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  cursor: pointer;
  font-size: 0.85rem;
}
.admin-list li.empty {
  justify-content: center;
  color: var(--muted-foreground);
}
.admin-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  margin: 8px 0;
  cursor: pointer;
}
.admin-row {
  display: flex;
  gap: 12px;
}
.admin-row label {
  flex: 1;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-row select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: var(--background);
  color: var(--foreground);
}
.admin-slider {
  margin-bottom: 14px;
}
.admin-slider label {
  font-size: 0.9rem;
  display: block;
  margin-bottom: 6px;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.slider-row input[type="range"] {
  flex: 1;
}
.slider-val {
  min-width: 48px;
  text-align: end;
  font-weight: 600;
  font-size: 0.9rem;
}
.edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.edit-field input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}
.pop-actions .danger {
  color: #c0392b;
}
.pop-actions .primary {
  font-weight: 700;
}

/* ---- Admin accordion ---- */
.admin-accordion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: start;
}
.admin-accordion-head h3 {
  margin: 0;
}
.admin-accordion-head .chev {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}
.admin-desc {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin: 8px 0;
}

/* ---- Admin refinements ---- */
.admin-title-row h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.count-badge {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted-foreground);
}
.admin-list .empty-state {
  justify-content: center;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  padding: 24px 16px;
  border-bottom: none;
}
.link-danger {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #c0392b;
  font-size: 0.9rem;
  padding: 12px;
  cursor: pointer;
  text-align: center;
}
.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
}
#adminProdTabs {
  margin: 8px 0;
}

/* ---- Cute tote empty state ---- */
.empty {
  text-align: center;
  padding: 48px 24px;
}
.tote-illo {
  width: 96px;
  height: 96px;
  margin-bottom: 8px;
  opacity: 0.7;
}
.empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 8px 0 4px;
}
.empty-sub {
  color: var(--muted-foreground);
  font-size: 0.95rem;
  margin: 0 0 16px;
}

.admin-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.danger-btn {
  color: #c0392b;
  border-color: #c0392b;
}

/* ---- Skeleton category header (pending items) ---- */
.skeleton-head {
  padding: 0 4px;
}
.skeleton-head .skel {
  display: inline-block;
  width: 90px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--border) 25%, var(--card) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============ Redesign: Plan view ============ */

.plan {
  padding-bottom: 120px;
}

.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 20px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
}

.plan-avatars {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.plan-hh {
  display: flex;
  align-items: center;
}

.plan-hh-stack {
  display: flex;
  align-items: center;
}

.plan-avatars .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--bg);
  overflow: hidden;
  flex: none;
}

.plan-avatars .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plan-avatars .avatar + .avatar {
  margin-inline-start: -8px;
}

.plan-hh-names {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plan-hh-chev {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink-soft, var(--ink));
  cursor: pointer;
  margin-inline-start: -8px;
}

.plan-hh .hh-popover {
  inset-inline-start: -8px;
}

.plan-chart {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--ink);
  cursor: pointer;
}

.plan-title {
  padding: 10px 20px 0;
}

.plan-title h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.04em;
}

[dir="rtl"] .plan-title h1 {
  letter-spacing: -0.015em;
}

.plan-new {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--soft);
}

.plan-new a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--mori);
  font-weight: 500;
  text-decoration: none;
}

.plan-new .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mori);
}

/* Next shop card */
.next-shop {
  margin: 18px 12px 0;
  border-radius: var(--r-card);
  background: var(--deep);
  color: var(--deep-ink);
  padding: 18px 18px 16px;
}

.next-shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.next-shop-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.6;
}

.next-shop-head span {
  font-size: 12.5px;
  opacity: 0.6;
}

.next-shop-count {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 6px;
}

.next-shop-count .mono {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.next-shop-count span:last-child {
  font-size: 14px;
  opacity: 0.6;
}

.aisle-bar {
  display: flex;
  gap: 3px;
  height: 6px;
  margin-top: 14px;
}

.aisle-bar span {
  border-radius: 3px;
  transition: flex-grow 0.5s var(--ease-out);
}

.next-shop-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12.5px;
  opacity: 0.6;
}

/* Department sections (SPEC Rev3 §5.1: no header counts; right edge is quantities only) */
.plan-dept {
  padding-top: 24px;
}

.plan-dept-head {
  display: flex;
  align-items: center;
  padding: 0 20px 2px;
}

.plan-dept-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--soft);
}

/* Plan rows (SPEC Rev3 §5.1) */
/* Row separator: full width, edge to edge (Yogev override of spec §5.1) */
.plan-row {
  position: relative;
  overflow: hidden;
  max-height: 88px;
  border-bottom: 1px solid var(--line);
}

.plan-row-tray {
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-end: 0;
  width: 156px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-inline-end: 10px;
  background: var(--bg);
  pointer-events: none;
}
.plan-row.tray-open .plan-row-tray {
  pointer-events: auto;
}

.tray-btn {
  width: 68px;
  height: 48px;
  border-radius: 16px;
  border: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0;
  transform: scale(0.6);
  -webkit-tap-highlight-color: transparent;
}

.tray-edit {
  background: var(--ink);
  color: var(--bg);
}

.tray-remove {
  background: color-mix(in srgb, var(--warm) 12%, var(--bg));
  color: color-mix(in srgb, var(--warm) 80%, black);
}

[data-theme="midnight"] .tray-remove {
  background: rgba(255,107,74,.16);
  color: #FF9C82;
}

.plan-row-slide {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding-inline: 8px 10px;
  background: var(--bg);
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.plan-row.has-meta .plan-row-slide {
  min-height: 64px;
}

.plan-row.is-new .plan-row-slide {
  background: color-mix(in srgb, var(--mori) 6%, var(--bg));
}

/* Check control: 44×52 hit area, 22px shape, 1.75 stroke */
.plan-check {
  flex: none;
  width: 44px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.plan-check:active svg {
  transform: scale(0.88);
}

.plan-check-pop {
  transform-box: fill-box;
  transform-origin: center;
  /* Pop animation now handled by Motion One (see plan.js checkOff) */
}

.plan-row-text {
  flex: 1;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 8px 0;
  margin-inline-end: 8px;
}

.plan-row-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.plan-row-name-t {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.plan-row.is-checking .plan-row-name-t {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  color: var(--soft);
}

.plan-row-name .new-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mori);
  flex: none;
}

.plan-row-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--soft);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.plan-row-meta svg {
  flex: none;
}

.plan-meta-note {
  overflow: hidden;
  text-overflow: ellipsis;
}

.plan-meta-sep {
  flex: none;
}

.plan-row.is-checking .plan-row-meta,
.plan-row.is-checking .plan-badges,
.plan-row.is-checking .note-btn {
  opacity: 0.4;
}

/* Badges: store and qty indicators, left of the note button.
   Tapping a badge opens the edit sheet. */
.plan-badges {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}
.badge {
  height: 28px;
  padding-inline: 8px;
  border-radius: 8px;
  background: var(--fill);
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.badge svg {
  flex: none;
}
.badge-qty-in {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.badge-qty-in .q-unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--soft);
}

/* Note button: always visible, rightmost. Opens the edit sheet. */
.note-btn {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--soft);
  -webkit-tap-highlight-color: transparent;
}
.note-btn:active {
  color: var(--ink);
}

/* Inline stepper: 36 tall, radius 12, ink bg */
.qty-stepper {
  display: flex;
  align-items: center;
  height: 36px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
}

.qty-stepper button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.qty-stepper .mono {
  font-family: var(--font-mono);
  min-width: 48px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Undo toast */
.plan-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(104px + env(safe-area-inset-bottom));
  height: 48px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline: 16px 8px;
  font-size: 14px;
  font-weight: 400;
  z-index: 90;
  /* Enter/exit animations handled by Motion One (see plan.js toast) */
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
}

.plan-toast-msg {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plan-toast-undo {
  flex: none;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent-soft);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Long-press context menu */
.plan-ctx {
  position: absolute;
  z-index: 95;
  min-width: 168px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(0,0,0,0.2);
  padding: 6px;
}

.plan-ctx button {
  display: block;
  width: 100%;
  text-align: start;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.plan-ctx button.danger {
  color: var(--warm);
}

/* Item sheet (Edit) */
#itemSheet:empty {
  display: none;
}

.is-backdrop {
  position: fixed;
  inset: 0;
  background: var(--ink);
  opacity: 0.32;
  z-index: 70;
}

.is-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 71;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 82vh;
  overflow-y: auto;
  transform: translateY(100%);
  /* Slide animation handled by Motion One (see plan.js openItemSheet/closeItemSheet) */
}

.is-grab {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin: 4px auto 12px;
}

.is-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.is-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-sec h3 {
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--soft);
}

.is-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 52px;
}

.is-stepper button {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--fill);
  border: 0;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.is-stepper .mono {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  min-width: 64px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.is-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.is-chip {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.is-chip.on {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.is-done {
  width: 100%;
  height: 52px;
  margin-top: 24px;
  border-radius: 16px;
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  opacity: 1;
}
.is-done:disabled {
  opacity: 1;
}

/* Global button reset: prevent iOS native styling from fading buttons */
button {
  -webkit-appearance: none;
  appearance: none;
}
/* Ensure primary accent buttons are never faded */
button[style*="--accent"] {
  opacity: 1 !important;
}

/* Dock */
.plan-dock {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  border-radius: var(--r-dock);
  background: var(--glass);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 0 0 0.5px var(--line), 0 1px 1px var(--shadow), 0 20px 40px var(--shadow);
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.dock-low {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 8px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: start;
  color: var(--ink);
  font-size: 14px;
}

.dock-low .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warm);
  flex: none;
}

.dock-low .text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-low .text strong {
  font-weight: 600;
}

.dock-low .text span:last-child {
  color: var(--soft);
}

.dock-add {
  height: 52px;
  border-radius: var(--r-dock-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  cursor: pointer;
  width: 100%;
}

/* Empty state */
.plan-empty {
  text-align: center;
  padding: 20px;
}

.plan-empty h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 12px 0 6px;
}

.plan-empty p {
  color: var(--soft);
  font-size: 15px;
  margin: 0 0 4px;
}

.plan-empty .meta {
  font-size: 12.5px;
  color: var(--soft);
  margin-bottom: 16px;
}

.sleeping-tote {
  animation: breathe 4.5s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes breathe {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.012); }
}

@media (prefers-reduced-motion: reduce) {
  .sleeping-tote { animation: none; }
  .plan-row-slide { transition: none; }
}

/* ============ Redesign: Add sheet ============ */
#addSheet .tile {
  transition: background-color .25s ease, color .25s ease, transform .15s ease;
}
#addSheet .tile:active {
  transform: scale(.96);
}
#addSheet .pop {
  animation: pop .4s cubic-bezier(.3,1.7,.5,1);
  transform-origin: center;
}
@keyframes pop {
  0% { transform: scale(.3); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #addSheet .pop { animation: none; }
}

/* ============ Redesign: Household view ============ */

.household {
  padding: 54px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
}

.hh-top { }

.hh-back {
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent-ink);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.hh-back .flip { transform: scaleX(-1); }

.hh-title {
  margin: 8px 4px 0;
  font-size: 40px;
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.035em;
}

[dir="rtl"] .hh-title { letter-spacing: -0.01em; }

.hh-card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 6px 16px;
  box-shadow: 0 1px 2px var(--shadow);
}

.hh-card.pad0 { padding: 0 16px; }

.hh-h2 {
  margin: 0 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--soft);
}

/* Members */
.hh-member {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
}

.hh-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex: none;
}

.hh-member-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hh-member-name { font-size: 16px; font-weight: 600; }
.hh-member-role { font-size: 13px; color: var(--soft); }

.hh-invite {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-ink);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  text-align: start;
}

.hh-invite-plus {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1.5px var(--line);
  color: var(--ink);
  flex: none;
}

/* Member management */
.hh-avatar { overflow: hidden; }
.hh-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hh-you { font-weight: 400; color: var(--soft); }
.hh-member-email { font-size: 13px; color: var(--soft); }
.hh-role-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--soft);
  vertical-align: 2px;
  margin-inline-start: 4px;
}
.hh-member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.hh-mini-btn {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.hh-mini-btn.danger { color: var(--destructive, #C81E1E); border-color: var(--destructive, #C81E1E); }
.hh-mini-btn:disabled { opacity: .5; }
.hh-invite-box {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.hh-invite-box-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--soft);
  margin-bottom: 8px;
}
.hh-invite-box-row { display: flex; gap: 8px; align-items: center; }
.hh-invite-box-row input {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--fill);
  color: var(--ink);
  direction: ltr;
}
.hh-invite-box-exp { display: block; font-size: 12px; color: var(--soft); margin-top: 6px; }
.hh-danger-btn {
  width: 100%;
  min-height: 52px;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--destructive, #C81E1E);
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
  text-align: start;
}

/* Segmented control */
.hh-seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
  background: var(--fill);
}

.hh-seg.sm { grid-template-columns: repeat(3, minmax(0, 1fr)); border-radius: 14px; padding: 3px; }

.hh-seg-btn {
  height: 48px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  background: transparent;
  color: var(--soft);
  border: 0;
  cursor: pointer;
}

.hh-seg-btn.sm { height: 40px; border-radius: 11px; font-size: 13.5px; }

.hh-seg-btn.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px var(--shadow);
}

/* Theme swatches */
.hh-themes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.hh-theme {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.hh-theme-prev {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 0.2s ease;
}

.hh-theme-prev.on { box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4.5px var(--ink); }

.hh-theme-prev svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hh-theme-name { font-size: 12px; font-weight: 500; color: var(--ink); }
.hh-theme-name.on { font-weight: 700; }

/* Notify toggles */
.hh-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}

.hh-toggle-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hh-toggle-name { font-size: 15.5px; font-weight: 500; }
.hh-toggle-sub { font-size: 12.5px; color: var(--soft); }

.hh-switch {
  width: 52px;
  height: 32px;
  border-radius: 16px;
  padding: 3px;
  display: flex;
  background: var(--line);
  flex: none;
  border: 0;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.hh-switch.on { background: var(--accent); }

.hh-knob {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: transform 0.25s cubic-bezier(.3,1.4,.5,1);
}

/* Catalog links */
.hh-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  width: 100%;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  text-align: start;
  color: var(--ink);
}

.hh-link-shapes { display: flex; gap: 2px; }
.hh-link-name { flex: 1; font-size: 15.5px; font-weight: 500; }
.hh-link-n {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}
.hh-chev { color: var(--soft); flex: none; }
.hh-chev.flip { transform: scaleX(-1); }

.hh-sense { padding: 14px 0 16px; border-top: 1px solid var(--line); }
.hh-sense-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.hh-sense-name { font-size: 15.5px; font-weight: 500; }
.hh-sense-hint { font-size: 12.5px; color: var(--soft); }

/* ============ Redesign: Us view ============ */

.us {
  padding: 16px 16px 40px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 480px;
  margin: 0 auto;
}

.us-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.us-back {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent-ink);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

[dir="rtl"] .us-back svg { transform: scaleX(-1); }

.us-gear {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--ink);
  cursor: pointer;
}

.us-head { padding: 6px 4px 0; }

.us-head h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.04em;
}

[dir="rtl"] .us-head h1 { letter-spacing: -0.015em; }

.us-head p {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--soft);
}

.us-card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 20px 16px 16px;
  box-shadow: 0 1px 2px var(--shadow);
}

.us-life { margin: 4px 0 0; }
.us-life figcaption { margin-top: 16px; }

.us-mix-row {
  display: grid;
  grid-template-columns: 16px 1fr 70px 42px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
}

.us-mix-row .mono {
  font-family: var(--font-mono);
  font-size: 14px;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.us-mix-row .mono:last-child { font-size: 12.5px; }

.us-soft { color: var(--soft); }

.us-note {
  margin: 0 4px;
  font-size: 13px;
  color: var(--soft);
  line-height: 1.45;
}

.us-section {
  margin: 10px 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--soft);
}

.us-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.us-tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.us-tile {
  border-radius: 20px;
  padding: 14px;
  background: var(--surface);
  box-shadow: 0 1px 2px var(--shadow);
}

.us-tile-accent {
  background: var(--accent);
  color: var(--on-accent);
}

.us-bignum {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.us-tile-sub {
  font-size: 12.5px;
  margin-top: 2px;
  line-height: 1.35;
}

.us-tile:not(.us-tile-accent) .us-tile-sub { color: var(--soft); }
.us-tile-accent .us-tile-sub { opacity: 0.85; }

.us-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--fill);
  margin-top: 8px;
  overflow: hidden;
}

.us-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.us-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.us-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--r-chip);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 500;
}

.us-dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 4px;
}

.us-dow span {
  text-align: center;
  font-size: 10.5px;
  color: var(--soft);
}

.us-cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.us-cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.us-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5px;
}

.us-ring-in {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}

.us-feed { padding-top: 6px; padding-bottom: 6px; }

/* Activity timeline */
.us-activity { padding: 4px 0; }
.us-act-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.us-act-row:first-child { border-top: 0; }
.us-act-icon {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}
.us-act-main {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.4;
}
.us-act-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--soft);
  font-size: 14px;
}
.us-act-more {
  display: block;
  margin: 12px auto 0;
  padding: 10px 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.us-act-more:disabled { opacity: 0.5; }

.us-feed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
}

.us-dots {
  display: flex;
  gap: 3px;
  flex: none;
}

.us-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.us-feed-main {
  flex: 1;
  font-size: 14.5px;
  min-width: 0;
}

.us-feed .mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Fix: ensure accent surfaces use solid accent (hardcoded per theme) */
html[data-theme="sage"] .dock-add, html[data-theme="sage"] .add-all-btn, html[data-theme="sage"] .us-tile-accent,
html[data-theme="sage"] .hh-switch.on {
  background: #1F6B45 !important;
  color: #FFFFFF !important;
  opacity: 1 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
html[data-theme="ocean"] .dock-add, html[data-theme="ocean"] .add-all-btn, html[data-theme="ocean"] .us-tile-accent,
html[data-theme="ocean"] .hh-switch.on {
  background: #1D5FBF !important;
  color: #FFFFFF !important;
  opacity: 1 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
html[data-theme="clay"] .dock-add, html[data-theme="clay"] .add-all-btn, html[data-theme="clay"] .us-tile-accent,
html[data-theme="clay"] .hh-switch.on {
  background: #B3421E !important;
  color: #FFFFFF !important;
  opacity: 1 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
html[data-theme="plum"] .dock-add, html[data-theme="plum"] .add-all-btn, html[data-theme="plum"] .us-tile-accent,
html[data-theme="plum"] .hh-switch.on {
  background: #7B2E9C !important;
  color: #FFFFFF !important;
  opacity: 1 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
html[data-theme="midnight"] .dock-add, html[data-theme="midnight"] .add-all-btn, html[data-theme="midnight"] .us-tile-accent,
html[data-theme="midnight"] .hh-switch.on {
  background: #FFC24B !important;
  color: #1A1B1E !important;
  opacity: 1 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}





/* ---- OAuth login ---- */
.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
  width: 100%;
  max-width: 320px;
}
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
  transition: transform 0.1s;
}
.oauth-btn:active { transform: scale(0.98); }
.oauth-apple {
  background: #000;
  color: #fff;
  border-color: #000;
}
.oauth-google {
  background: #fff;
  color: #1f1f1f;
  border-color: #dadce0;
}
[data-theme="midnight"] .oauth-google {
  background: #191B23;
  color: #F2EFE7;
  border-color: rgba(242,239,231,.2);
}

/* ---- Household switcher popover ---- */
.hh-switcher {
  position: relative;
}
.hh-popover {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 32px var(--shadow);
  padding: 8px;
  z-index: 50;
}
.hh-popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: none;
  border-radius: 10px;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  text-align: start;
}
.hh-popover button:hover { background: var(--fill); }
.hh-popover button.current { font-weight: 700; }
.hh-popover .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
  overflow: hidden;
}
.hh-popover .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
