/* HouseholdKings – style 1 "Clean Light" */
:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --text: #111827;
  --muted: #5B6472;
  --line: #E5E7EB;
  --accent: #2563EB;
  --accent-dark: #1D4ED8;
  --accent-soft: #EEF2FF;
  --accent-soft-text: #1E3A8A;
  --danger: #DC2626;
  --radius: 14px;
  --btn-radius: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06);
  --shadow-lift: 0 8px 24px rgba(17, 24, 39, .10);
  /* level chips: background / text */
  --lv-basic-bg: #DCFCE7;      --lv-basic: #14532D;
  --lv-medium-bg: #FEF3C7;     --lv-medium: #78350F;
  --lv-heavy-bg: #FFEDD5;      --lv-heavy: #7C2D12;
  --lv-legendaddy-bg: #EDE9FE; --lv-legendaddy: #4C1D95;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
body.has-nav { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1 { font-size: 24px; font-weight: 700; margin: 8px 0 16px; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
p { margin: 0 0 10px; }
.container { max-width: 640px; margin: 0 auto; padding: 16px 16px 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 19px; }
.brand svg { color: var(--accent); }
.brand:hover { color: var(--text); }
.points-pill {
  font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none; white-space: nowrap;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.points-pill b { color: var(--accent); }
.points-pill.bump b { display: inline-block; animation: bump .6s ease; }
@keyframes bump { 40% { transform: scale(1.35); } }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 68px; min-height: 48px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.bottomnav a[aria-current="page"] { color: var(--accent); }
.bottomnav a:hover { color: var(--text); background: var(--bg); }

/* ---------- sections, panels ---------- */
.section { margin-bottom: 22px; }
.count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px; background: var(--line); color: var(--muted); font-size: 12px; font-weight: 600;
}
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.empty { color: var(--muted); font-size: 14px; padding: 6px 2px 10px; }
.meta, .sub, .hint { color: var(--muted); font-size: 13px; }
.sub { display: block; font-weight: 400; }
.hint { font-weight: 400; margin-left: 4px; }
.lead { color: var(--muted); }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 8px; }

/* ---------- flash ---------- */
.flash {
  padding: 10px 14px; margin-bottom: 14px; border-radius: 10px; font-size: 14px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line); animation: flash-in .35s ease;
}
.flash.ok { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.flash.error { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border: none; border-radius: var(--btn-radius);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.ghost { background: var(--accent-soft); color: var(--accent-soft-text); }
.btn.ghost:hover { background: #E0E7FF; color: var(--accent-soft-text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.link { background: none; color: var(--accent); padding: 0 4px; min-height: 36px; }
.btn.wide { width: 100%; margin-top: 4px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.actions form { margin: 0; }

/* ---------- level chips ---------- */
.chip { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.lv-basic      { --c-bg: var(--lv-basic-bg);      --c: var(--lv-basic); }
.lv-medium     { --c-bg: var(--lv-medium-bg);     --c: var(--lv-medium); }
.lv-heavy      { --c-bg: var(--lv-heavy-bg);      --c: var(--lv-heavy); }
.lv-legendaddy { --c-bg: var(--lv-legendaddy-bg); --c: var(--lv-legendaddy); }
.chip { background: var(--c-bg); color: var(--c); }

/* ---------- task cards (collapsible) ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 10px;
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s;
}
.card.open { box-shadow: var(--shadow-lift); border-color: #D6DBE3; }
.card-toggle {
  width: 100%; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 4px 10px;
  padding: 14px 14px 14px 16px; min-height: 56px;
  background: none; border: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
  border-radius: var(--radius);
}
.card-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.chevron { color: var(--muted); display: inline-flex; transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
.card.open .chevron { transform: rotate(180deg); color: var(--accent); }
.card-sub { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.card-sub:empty { display: none; }
.sub-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }

.card-body {
  display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows .35s cubic-bezier(.2, .8, .2, 1), opacity .25s ease;
}
.card.open .card-body { grid-template-rows: 1fr; opacity: 1; }
.card-inner { overflow: hidden; min-height: 0; padding: 0 16px; }
.card.open .card-inner { padding-bottom: 8px; }
.card-inner > * { transform: translateY(-6px); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.card.open .card-inner > * { transform: none; }
.card .desc { font-size: 14px; color: #374151; margin: 0 0 10px; white-space: pre-line; }
.thumb { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; margin: 0 0 10px; object-fit: cover; }
.card .meta { margin: 0 0 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.card.completing { animation: complete-out 1.4s ease forwards; }
@keyframes complete-out {
  0% { transform: scale(1); }
  12% { transform: scale(1.025); border-color: #86EFAC; box-shadow: 0 0 0 4px #DCFCE7; }
  70% { opacity: 1; }
  100% { opacity: .35; transform: scale(.98); }
}

/* ---------- folds ---------- */
.fold { margin: 0 0 16px; }
.fold summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 15px; padding: 10px 2px; min-height: 44px;
}
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-left: auto; transition: transform .25s; }
.fold[open] summary::after { transform: rotate(-135deg); }

/* ---------- leaderboards ---------- */
.mini-board, .board, .feed { list-style: none; margin: 0 0 6px; padding: 0; }
.mini-board li, .board li { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.mini-board li + li, .board li + li { border-top: 1px solid var(--line); }
.mini-board .name, .board .name { flex: 1; font-weight: 600; }
.mini-board .pts, .board .pts { font-weight: 700; }
.board { padding: 4px 16px; }
.board li { padding: 12px 0; }
.board li.me .name { color: var(--accent); }
.board .pts { font-size: 18px; }
.board .pts small { font-size: 12px; color: var(--muted); font-weight: 500; }
.rank {
  width: 28px; height: 28px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; background: var(--bg); color: var(--muted);
}
.rank.r1 { background: #FEF3C7; color: #78350F; }
.rank.r2 { background: #E5E7EB; color: #374151; }
.rank.r3 { background: #FFEDD5; color: #7C2D12; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-soft-text); vertical-align: middle; }
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--line); border-radius: 12px; margin-bottom: 14px; }
.segmented a { flex: 1; text-align: center; padding: 9px 0; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.feed li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; font-size: 14px; }
.feed li + li { border-top: 1px solid var(--line); }
.feed-pts { flex: none; min-width: 48px; text-align: center; padding: 3px 0; border-radius: 8px; background: #DCFCE7; color: #14532D; font-weight: 700; font-size: 13px; }

/* ---------- forms ---------- */
.form label { display: block; font-size: 14px; font-weight: 600; margin: 0 0 14px; }
.form input:not([type=radio]):not([type=checkbox]), .form textarea, .form select, .inline-form input {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; min-height: 44px;
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid #D1D5DB; border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .form textarea:focus, .form select:focus, .inline-form input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
.form input[type=file] { padding: 9px; }
.form h2 { margin-top: 8px; }
.form .hint { display: inline; }
.form label > .hint:last-child { display: block; margin: 6px 0 0; }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.levels { border: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.levels legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.level-option {
  position: relative; display: flex !important; flex-direction: column; gap: 2px; margin: 0 !important;
  padding: 12px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.level-option input { position: absolute; opacity: 0; pointer-events: none; }
.level-option .lv-name { font-weight: 600; font-size: 14px; }
.level-option .lv-pts { font-size: 12px; color: var(--muted); font-weight: 500; }
.level-option:has(input:checked) { border-color: var(--c); background: var(--c-bg); }
.level-option:has(input:checked) .lv-name, .level-option:has(input:checked) .lv-pts { color: var(--c); }
.level-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.level-option:active { transform: scale(.98); }
.inline-form { display: flex; gap: 8px; flex: 1 1 260px; }
.inline-form input { margin-top: 0; }

/* ---------- auth ---------- */
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px; color: var(--accent); }
.auth-brand h1 { color: var(--text); margin: 0; text-align: center; }
.auth .lead { text-align: center; }

/* ---------- account / users ---------- */
.profile { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.big-pts { font-size: 28px; font-weight: 700; color: var(--accent); }
.big-pts small { font-size: 13px; color: var(--muted); font-weight: 500; }
.linklist { padding: 4px 16px; }
.linklist a { display: flex; align-items: center; gap: 12px; padding: 14px 0; min-height: 48px; color: var(--text); text-decoration: none; font-weight: 600; }
.linklist a + a { border-top: 1px solid var(--line); }
.linklist svg { color: var(--accent); }
.user-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.user-head .pts { font-weight: 700; }

/* ---------- maintenance ---------- */
.table-wrap { overflow-x: auto; margin-bottom: 16px; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; font-size: 14px; }
pre.log { background: #0F172A; color: #E2E8F0; padding: 12px; border-radius: 10px; overflow-x: auto; font-size: 12px; max-height: 320px; }
.err { color: var(--danger); }

/* ---------- completion effects ---------- */
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }
.points-bubble {
  position: fixed; z-index: 101; pointer-events: none; width: 0; height: 0;
  animation: pb-rise 1.9s cubic-bezier(.32, .72, 0, 1) .45s forwards;
}
.pb-circle {
  position: absolute; left: -44px; top: -44px; width: 88px; height: 88px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(37, 99, 235, .92);
  -webkit-backdrop-filter: blur(12px) saturate(1.6); backdrop-filter: blur(12px) saturate(1.6);
  box-shadow: 0 10px 30px rgba(37, 99, 235, .35), 0 2px 6px rgba(17, 24, 39, .18), inset 0 1px 0 rgba(255, 255, 255, .35);
  color: #fff; font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', 'Inter', system-ui, sans-serif;
  animation: pb-pop .55s cubic-bezier(.34, 1.56, .64, 1) both;
}
.pb-num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.pb-label { font-size: 11px; font-weight: 600; opacity: .85; margin-top: 3px; text-transform: uppercase; letter-spacing: .06em; }
.pb-ring {
  position: absolute; left: -44px; top: -44px; width: 88px; height: 88px; border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, .55);
  animation: pb-ring .9s cubic-bezier(.2, .8, .2, 1) .08s both;
}
.pb-ring2 { animation-delay: .22s; border-color: rgba(37, 99, 235, .35); }
@keyframes pb-pop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pb-ring {
  0%   { transform: scale(.6); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: scale(2.1); opacity: 0; }
}
@keyframes pb-rise {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-150px) scale(.82); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .points-bubble { animation: splat-fade 1.2s linear forwards !important; }
  @keyframes splat-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}

@media (min-width: 700px) {
  .container { padding-top: 24px; }
  .levels { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- v1.4: avatars ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; vertical-align: middle; background: var(--line); }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 700; }
.points-pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; }
.profile { justify-content: flex-start; }
.profile .profile-name { flex: 1; min-width: 0; }
.user-head { gap: 12px; }
.user-head .profile-name { flex: 1; min-width: 0; }
.mini-board .avatar, .board .avatar { margin-left: -2px; }
.feed li { align-items: center; }
.feed-pts.neg { background: #FEE2E2; color: #991B1B; }
.avatar-current { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar-choices { border: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.avatar-choices legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.avatar-option { position: relative; display: flex !important; flex-direction: column; align-items: center; gap: 4px; margin: 0 !important;
  padding: 10px 4px 8px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; font-size: 12px !important; font-weight: 600;
  transition: border-color .15s, background .15s, transform .15s cubic-bezier(.34, 1.56, .64, 1); }
.avatar-option input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-option img { width: 56px; height: 56px; border-radius: 50%; }
.avatar-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-text); transform: scale(1.04); }
.avatar-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.last-done { color: var(--muted); }
.last-done b { color: var(--text); font-weight: 600; }
.last-done .avatar { margin-right: 2px; }

/* ---------- v1.4: admin ---------- */
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.rollback-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.snap-list, .comp-list { list-style: none; margin: 0; padding: 0; }
.snap-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; }
.snap-list li + li, .comp-list li + li { border-top: 1px solid var(--line); }
.snap-list form { margin: 0; }
.comp-list { padding: 4px 14px; }
.comp-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px; padding: 12px 0; font-size: 14px; }
.comp-main { min-width: 0; overflow-wrap: anywhere; }
.comp-actions { grid-column: 2 / -1; display: flex; gap: 8px; }
.comp-actions form { margin: 0; }
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-row select { flex: 1; min-height: 44px; padding: 0 12px; font: inherit; border: 1px solid #D1D5DB; border-radius: 10px; background: var(--surface); }
.pager { justify-content: space-between; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ---------- v1.5: Kings / Queens ---------- */
.gender-form { flex: 1 1 100%; }
.gender-form select { margin-top: 0; min-height: 44px; padding: 0 12px; font: inherit; border: 1px solid #D1D5DB; border-radius: 10px; background: var(--surface); width: 100%; }
