/* Family Hub UI. Uses tokens.css only; no raw colors except white on member fills. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body); font-size: var(--t-base); line-height: var(--lh); color: var(--ink);
  background: var(--bg); background-image: var(--bg-art); background-attachment: fixed;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
.display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em;
  font-variation-settings: 'SOFT' 50, 'opsz' 72; margin: 0; line-height: var(--lh-tight); }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); }
.icon { flex: none; display: block; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.board :focus:not(:focus-visible) { outline: none; }
.board { user-select: none; -webkit-user-select: none; }

/* ------------------------------------------------------------ shell */
.app { display: flex; height: 100dvh; overflow: hidden; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.screen { flex: 1; min-height: 0; overflow: auto; padding: var(--s5) var(--s6) var(--s6); }
.screen-flush { padding: 0; display: flex; flex-direction: column; }

.rail { width: var(--rail-w); flex: none; display: flex; flex-direction: column; align-items: center;
  gap: var(--s1); padding: var(--s4) 0 var(--s3); background: var(--bg); border-right: 1px solid var(--line); }
.rail-logo { width: 48px; height: 48px; border-radius: 15px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font: 600 24px var(--font-display); margin-bottom: var(--s3);
  box-shadow: var(--shadow-1); }
.rail-item { width: 76px; padding: 10px 0 8px; border: 0; background: none; border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--ink-2);
  font-size: var(--t-xs); font-weight: 600; letter-spacing: .01em; transition: background var(--dur-1), color var(--dur-1); }
.rail-item:hover { background: color-mix(in oklab, var(--ink) 5%, transparent); }
.rail-item.on { background: color-mix(in oklab, var(--accent) 16%, var(--bg)); color: color-mix(in oklab, var(--accent) 80%, var(--ink)); }
.rail-spacer { flex: 1; }

.tabbar { display: none; }
@media (max-width: 760px), (orientation: portrait) and (max-width: 900px) {
  .rail { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in oklab, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); }
  .tabbar .rail-item { flex: 1; width: auto; border-radius: 0; padding-top: 9px; }
  .tabbar .rail-item.on { background: none; }
  .main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .screen { padding: var(--s4); }
}

/* ------------------------------------------------------------ top bar (board header) */
.topbar { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--s6) var(--s3); flex-wrap: wrap; }
.topbar-title { display: flex; align-items: baseline; gap: var(--s4); min-width: 0; }
.topbar-title h1 { font-size: var(--t-2xl); white-space: nowrap; }
.clock { font-size: var(--t-lg); font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wx { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: var(--t-md); white-space: nowrap; }
.wx .icon { color: var(--ink-2); }
.topbar-grow { flex: 1; }
.chips { display: flex; gap: var(--s2); padding: 0 var(--s6) var(--s3); overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 6px;
  border-radius: var(--r-full); font-weight: 600; font-size: var(--t-sm); white-space: nowrap; border: 0; }
.pill.m-tint { color: var(--ink); }
.pill-outline { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); padding-left: 12px; }
.pill .sub { color: var(--ink-2); font-weight: 600; }
.pill.dim { opacity: .45; }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0;
  border-radius: var(--r-full); font-weight: 600; white-space: nowrap;
  transition: transform var(--dur-1) var(--ease), background var(--dur-1), box-shadow var(--dur-1); }
.btn:active { transform: scale(.97); }
.btn-md { height: 40px; padding: 0 18px; font-size: var(--t-sm); }
.btn-sm { height: 32px; padding: 0 13px; font-size: var(--t-xs); }
.btn-lg { height: 52px; padding: 0 24px; font-size: var(--t-base); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px color-mix(in oklab, var(--accent) 40%, transparent); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 90%, var(--ink)); }
.btn-secondary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: color-mix(in oklab, var(--ink) 6%, transparent); color: var(--ink); }
.btn-danger { background: color-mix(in oklab, var(--danger) 14%, var(--surface)); color: var(--danger); }
.btn:disabled { opacity: .5; pointer-events: none; }
.iconbtn { display: inline-grid; place-items: center; border: 0; border-radius: var(--r-full); color: var(--ink-2);
  transition: background var(--dur-1), color var(--dur-1), transform var(--dur-1); }
.iconbtn:active { transform: scale(.94); }
.iconbtn-md { width: 40px; height: 40px; } .iconbtn-sm { width: 32px; height: 32px; } .iconbtn-lg { width: 52px; height: 52px; }
.iconbtn-ghost { background: transparent; } .iconbtn-ghost:hover { background: color-mix(in oklab, var(--ink) 7%, transparent); color: var(--ink); }
.iconbtn-soft { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.iconbtn-primary { background: var(--accent); color: var(--accent-ink); }
.fab { position: fixed; right: var(--s6); bottom: var(--s6); width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; z-index: 15;
  box-shadow: 0 8px 24px color-mix(in oklab, var(--accent) 45%, transparent); transition: transform var(--dur-2) var(--ease-spring); }
.fab:active { transform: scale(.92); }
@media (max-width: 760px) { .fab { bottom: calc(var(--tabbar-h) + var(--s4) + env(safe-area-inset-bottom)); right: var(--s4); } }

/* segmented */
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--r-full);
  background: color-mix(in oklab, var(--ink) 6%, var(--bg)); }
.seg-item { border: 0; background: none; height: 34px; padding: 0 16px; border-radius: var(--r-full);
  font-weight: 600; font-size: var(--t-sm); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur-2) var(--ease), color var(--dur-2); }
.seg-item.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg-sm .seg-item { height: 28px; padding: 0 12px; font-size: var(--t-xs); }

/* avatars */
.avatar { position: relative; display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  background: var(--m); color: #fff; font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-ring { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack { display: inline-flex; } .avatar-stack > * + * { margin-left: -7px; }
.avatar-more { background: var(--surface-2); color: var(--ink-2); font-size: 10px; box-shadow: 0 0 0 2px var(--surface); }

/* check */
.check { width: var(--size); height: var(--size); flex: none; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: transparent; box-shadow: inset 0 0 0 2.5px color-mix(in oklab, var(--m) 45%, var(--line-strong)); color: transparent;
  transition: background var(--dur-2) var(--ease), box-shadow var(--dur-2), transform var(--dur-2) var(--ease-spring); }
.check:active { transform: scale(.88); }
.check.done { background: var(--m); box-shadow: none; color: #fff; }
.check.done .icon { animation: pop var(--dur-3) var(--ease-spring); }
@keyframes pop { from { transform: scale(.3); } to { transform: scale(1); } }

.progress { height: 8px; border-radius: var(--r-full); background: color-mix(in oklab, var(--surface) 70%, transparent); overflow: hidden; }
.progress > div { height: 100%; background: var(--m); border-radius: inherit; transition: width var(--dur-3) var(--ease); }

/* cards + generic */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.page-head { display: flex; align-items: flex-end; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head h1 { font-size: var(--t-2xl); }
.page-sub { color: var(--ink-2); font-weight: 600; margin-top: 4px; }
.page-titles { flex: 1; min-width: 0; }
.page-actions { display: flex; gap: var(--s2); align-items: center; }
.section-title { font: 500 var(--t-lg)/1.2 var(--font-display); margin: var(--s5) 0 var(--s3); }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: var(--s10) var(--s6); color: var(--ink-2); }
.empty-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px;
  background: color-mix(in oklab, var(--accent) 14%, var(--surface)); color: var(--accent); }
.empty-title { font: 500 var(--t-lg) var(--font-display); color: var(--ink); }
.empty-hint { max-width: 360px; font-size: var(--t-sm); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.field-label { font-size: var(--t-xs); font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.field-hint { font-size: var(--t-xs); color: var(--ink-3); }
.input, .field input, .field select, .field textarea { width: 100%; height: 46px; padding: 0 14px; border-radius: var(--r-md);
  border: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); outline: none; font-size: var(--t-base); }
.field textarea { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface); }
.member-picker { display: flex; flex-wrap: wrap; gap: var(--s2); }
.mchip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 6px; border-radius: var(--r-full); border: 0;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; font-size: var(--t-sm); }
.mchip.on { background: color-mix(in oklab, var(--m) var(--tint-strong), var(--surface)); box-shadow: inset 0 0 0 2px var(--m); }

/* sheet */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: grid; place-items: center;
  animation: fade var(--dur-2) var(--ease); }
.sheet { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); animation: rise var(--dur-3) var(--ease); }
.sheet-wide { width: min(860px, calc(100vw - 32px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s5) var(--s5) var(--s2) var(--s6); }
.sheet-head h2 { font-size: var(--t-xl); }
.sheet-body { padding: var(--s2) var(--s6) var(--s4); overflow: auto; }
.sheet-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s6) var(--s5); border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .scrim { place-items: end center; }
  .sheet { width: 100vw; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* toasts + confetti */
.toasts { position: fixed; left: 50%; top: var(--s5); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: var(--s2); pointer-events: none; }
.toast { padding: 12px 18px; border-radius: var(--r-full); background: var(--ink); color: var(--bg); font-weight: 600; font-size: var(--t-sm);
  box-shadow: var(--shadow-2); opacity: 0; transform: translateY(-8px); transition: all var(--dur-2) var(--ease); }
.toast.in { opacity: 1; transform: none; }
.toast-error { background: var(--danger); color: #fff; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }
.cf { position: absolute; width: 9px; height: 13px; border-radius: 2px; animation: burst 1.2s var(--ease) forwards; }
.cf-emoji { width: auto; height: auto; font-size: 22px; }
@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(.4) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 160px)) rotate(var(--rot)); opacity: 0; }
}
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.offline { display: inline-flex; align-items: center; gap: 6px; color: var(--danger); font-weight: 600; font-size: var(--t-xs); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; } }
