/* Family Hub — large, high-contrast, easy-to-tap design.
   Colors come from CSS variables set by js/core.js (light/dark + 8 color pairs).
   All sizes are in rem so "Text size" in Look & colors scales everything. */
:root {
  --bg: #FBF8F3; --card: #FFFFFF; --line: #D9D2C5; --ink: #1C2430; --quiet: #4A5563;
  --accent: #1F5FA8; --on-accent: #FFFFFF; --soft: #E8F0FA; --second: #B4501A; --on-second: #FFFFFF;
  --alert-bg: #FFF3E8; --alert-line: #F0CDAE; --good: #2E7D4F; --good-soft: #E5F2EA; --good-ink: #1F5E3A;
  --bad: #A3321A; --field: #9AA3AF;
  font-size: 18px;
  color-scheme: light;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem; line-height: 1.45; -webkit-text-size-adjust: 100%; overflow-x: hidden;
}
#app { height: 100dvh; display: flex; flex-direction: column; max-width: 680px; margin: 0 auto; background: var(--bg); }
@media (min-width: 700px) { body { background: color-mix(in srgb, var(--bg) 88%, var(--ink)); } #app { border-inline: 1px solid var(--line); } }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* boot */
.boot { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--quiet); font-size: 1.1rem; }
.boot-logo { width: 72px; height: 72px; border-radius: 20px; background: url(icons/icon.svg) center / cover; }

/* screen layout */
.top { display: flex; align-items: center; gap: 8px; padding: calc(14px + env(safe-area-inset-top)) 14px 8px; }
.top h1 { margin: 0; font-size: 1.55rem; line-height: 1.15; flex: 1; }
.back { min-height: 48px; padding: 0 12px 0 2px; display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 1rem; text-decoration: none; color: var(--accent); border-radius: 12px; }
.content { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 18px 24px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.content > * { flex-shrink: 0; }

/* bottom navigation */
.nav { display: flex; background: var(--card); border-top: 2px solid var(--line); padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); }
.nav a { position: relative; flex: 1; min-height: 64px; border-radius: 14px; color: var(--quiet); text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 15px; font-weight: 700; white-space: nowrap; }
.nav a[aria-current="page"] { background: var(--soft); color: var(--accent); }
.nav .dot { position: absolute; top: 8px; right: calc(50% - 22px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--second); color: var(--on-second); font-size: 0.72rem; line-height: 20px; text-align: center; }

/* text */
.greet-date { font-size: 1.1rem; color: var(--quiet); }
.greet { margin: 0; font-size: 1.75rem; line-height: 1.15; }
.label { font-size: 0.86rem; font-weight: 700; letter-spacing: 0.07em; color: var(--quiet); text-transform: uppercase; margin: 4px 0 -4px; }
.muted { color: var(--quiet); }
.small { font-size: 0.89rem; }
.big-num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
h2 { font-size: 1.25rem; margin: 0; }

/* cards & rows */
.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card.accent { border: 3px solid var(--accent); }
.card.soft { background: var(--soft); border-color: transparent; }
.card.alert { background: var(--alert-bg); border-color: var(--alert-line); }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.title { font-size: 1.15rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.sub { color: var(--quiet); font-size: 0.95rem; overflow-wrap: anywhere; }
.time { flex: none; width: 4.4rem; font-size: 1.05rem; font-weight: 700; color: var(--quiet); line-height: 1.2; }
.linkcard { text-decoration: none; color: var(--ink); }
.empty { text-align: center; color: var(--quiet); padding: 22px 12px; border: 2px dashed var(--line); border-radius: 18px; font-size: 1rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 0 18px; border-radius: 14px; border: 2px solid var(--accent); background: var(--card); color: var(--accent); font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer; text-align: center; line-height: 1.2; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.go { background: var(--good); border-color: var(--good); color: #FFFFFF; }
.btn.plain { border-color: var(--line); color: var(--ink); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.dashed { border-style: dashed; }
.btn.big { min-height: 72px; font-size: 1.2rem; border-radius: 18px; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 0.89rem; border-radius: 12px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btns > .btn { flex: 1 1 140px; }
.iconbtn { flex: none; width: 54px; height: 54px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; }
.iconbtn.fill { background: var(--good); border-color: var(--good); color: #FFFFFF; }

/* home tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { position: relative; min-height: 6rem; background: var(--card); border: 2px solid var(--line); border-radius: 18px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 700; font-size: 1.05rem; text-align: center; padding: 10px; }
.tile svg { color: var(--accent); }
.badge { position: absolute; top: 8px; right: 8px; background: var(--second); color: var(--on-second); font-size: 0.8rem; border-radius: 999px; padding: 2px 9px; font-weight: 700; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label { font-weight: 700; font-size: 1rem; }
.input, select.input, textarea.input { width: 100%; min-height: 56px; border: 2px solid var(--field); border-radius: 14px; padding: 0 14px; background: var(--card); font-size: 1.05rem; }
textarea.input { padding: 12px 14px; min-height: 6rem; resize: vertical; line-height: 1.4; }
.input::placeholder { color: color-mix(in srgb, var(--quiet) 80%, transparent); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); font-weight: 700; cursor: pointer; }
.check input { width: 26px; height: 26px; accent-color: var(--accent); }
.err { color: var(--bad); font-weight: 700; }

/* pills / segmented */
.pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex: none; min-height: 46px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); color: var(--ink); font-weight: 700; font-size: 0.95rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.pill[aria-pressed="true"], .pill.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.seg .pill { justify-content: center; border-radius: 14px; min-height: 52px; }

/* list items */
.item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 68px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 16px; background: var(--card); text-align: left; cursor: pointer; color: var(--ink); }
.box { flex: none; width: 38px; height: 38px; border-radius: 10px; border: 3px solid var(--quiet); display: flex; align-items: center; justify-content: center; }
.item.done .box { background: var(--good); border-color: var(--good); color: #fff; }
.item.done .title { text-decoration: line-through; color: var(--quiet); font-weight: 400; }
.store-head { display: flex; align-items: center; gap: 10px; }
.store-head .title { flex: 1; }

/* chips */
.chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px; font-size: 0.86rem; font-weight: 700; background: var(--soft); color: var(--accent); }
.chip.good { background: var(--good-soft); color: var(--good-ink); }
.chip.bad { background: var(--bad); color: #fff; }

/* messages */
.threads .item { min-height: 76px; }
.avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; }
.unread { flex: none; min-width: 26px; height: 26px; border-radius: 13px; background: var(--second); color: var(--on-second); font-size: 0.8rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 7px; }
.chat { gap: 12px; }
.msg { display: flex; gap: 10px; align-items: flex-end; }
.msg.me { justify-content: flex-end; }
.bubble { max-width: 78%; background: var(--card); border: 2px solid var(--line); border-radius: 18px 18px 18px 6px; padding: 10px 14px; font-size: 1.05rem; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.me .bubble { background: var(--accent); color: var(--on-accent); border-color: var(--accent); border-radius: 18px 18px 6px 18px; }
.linkbtn { background: none; border: 0; padding: 6px 4px; min-height: 32px; color: var(--accent); font-weight: 700; font-size: inherit; text-decoration: underline; cursor: pointer; }
.who { font-size: 0.83rem; font-weight: 700; color: var(--quiet); margin-bottom: 2px; }
.bubble img, .post img, .scan img { display: block; max-width: 100%; border-radius: 12px; margin-top: 6px; background: var(--soft); }
.stamp { text-align: center; font-size: 0.8rem; font-weight: 700; color: var(--quiet); letter-spacing: 0.06em; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 2px solid var(--line); }
.composer textarea { flex: 1; min-height: 54px; max-height: 9rem; border: 2px solid var(--field); border-radius: 16px; padding: 12px 14px; resize: none; font-size: 1.05rem; background: var(--card); }

/* bulletin */
.note { position: relative; border-radius: 16px; padding: 22px 16px 14px; display: flex; flex-direction: column; gap: 6px; color: #1C2430; border: 2px solid rgba(28, 36, 48, 0.12); }
.note.important { border: 3px solid #A3321A; }
.note .pin { position: absolute; top: -8px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; border: 2px solid #fff; }
.note .meta { font-size: 0.86rem; color: #3D4652; }
.note .btn { color: #1C2430; border-color: #3D4652; background: transparent; }
.n-yellow { background: #FFF3BF; } .n-yellow .pin { background: #C99A06; }
.n-blue { background: #E1ECFA; } .n-blue .pin { background: #1F5FA8; }
.n-green { background: #E1F2E6; } .n-green .pin { background: #2E7D4F; }
.n-pink { background: #FBE3EA; } .n-pink .pin { background: #B03A5B; }
.auto { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 16px; background: var(--card); text-decoration: none; color: var(--ink); }
.auto .when { flex: none; width: 3.3rem; height: 3.3rem; border-radius: 12px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 0.75rem; font-weight: 700; line-height: 1.1; padding: 2px; }
.auto .src { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; }
.k-appt .when, .k-appt .src { color: #174A84; } .k-appt .when { background: #E1ECFA; }
.k-chore .when, .k-chore .src { color: #1F5E3A; } .k-chore .when { background: #E1F2E6; }
.k-shop .when, .k-shop .src { color: #6B4E00; } .k-shop .when { background: #FFF3BF; }
.k-news .when, .k-news .src { color: #8C2A47; } .k-news .when { background: #FBE3EA; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 54px; height: 54px; border-radius: 14px; border: 3px solid var(--line); cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px var(--card) inset; }

/* scanner / images */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.folder { min-height: 5.2rem; border-radius: 16px; border: 2px solid var(--line); background: var(--card); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 10px 14px; text-align: left; cursor: pointer; color: var(--ink); text-decoration: none; }
.folder svg { color: var(--accent); }
.scan { border: 2px solid var(--line); border-radius: 16px; background: var(--card); padding: 8px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; text-align: left; color: var(--ink); }
.scan img { margin: 0; aspect-ratio: 3 / 4; object-fit: cover; width: 100%; }
.preview { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 14px; background: var(--soft); display: block; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 200px; }
.sizeopt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 4.2rem; padding: 10px 14px; border-radius: 16px; border: 3px solid var(--line); background: var(--card); text-align: left; cursor: pointer; color: var(--ink); }
.sizeopt[aria-pressed="true"] { border-color: var(--accent); }
.sizeopt .radio { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--line); }
.sizeopt[aria-pressed="true"] .radio { border-color: var(--accent); background: var(--accent); }
.sizeopt .est { margin-left: auto; text-align: right; white-space: nowrap; }

/* sketchpad */
.pad { position: relative; background: #FFFFFF; border: 2px solid var(--line); border-radius: 18px; overflow: hidden; height: 52vh; min-height: 300px; }
.pad canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.pad textarea { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 16px; font-size: 1.3rem; line-height: 1.5; color: #1C2430; background: #FFFFFF; resize: none; }
.pen { width: 50px; height: 50px; border-radius: 50%; border: 4px solid var(--card); box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.pen[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--ink); }

/* tip */
.money { display: flex; align-items: center; background: var(--card); border: 3px solid var(--accent); border-radius: 16px; padding: 0 16px; min-height: 76px; }
.money span { font-size: 2rem; font-weight: 700; color: var(--quiet); }
.money input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 2.1rem; font-weight: 700; padding: 0 8px; min-height: 70px; }
.sumrow { display: flex; justify-content: space-between; font-size: 1.15rem; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .iconbtn { font-size: 1.8rem; font-weight: 700; color: var(--ink); }

/* settings */
.palettes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pal { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 0 12px; border-radius: 14px; border: 3px solid var(--line); background: var(--card); cursor: pointer; text-align: left; font-weight: 700; font-size: 0.95rem; color: var(--ink); }
.pal[aria-pressed="true"] { border-color: var(--accent); }
.pal i { flex: none; display: flex; } .pal i b { width: 22px; height: 32px; border-radius: 7px 0 0 7px; } .pal i b + b { width: 12px; border-radius: 0 7px 7px 0; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(92vw, 560px); background: var(--ink); color: var(--bg); padding: 14px 20px; border-radius: 14px; font-weight: 700; font-size: 1rem; z-index: 50; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); }

/* login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 28px 22px calc(28px + env(safe-area-inset-bottom)); }
.login h1 { font-size: 2.1rem; margin: 0; line-height: 1.1; }
.code { letter-spacing: 0.4em; font-size: 1.6rem !important; text-align: center; }

@media (prefers-reduced-motion: no-preference) {
  .content { scroll-behavior: smooth; }
  #toast { animation: rise 0.25s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
}
