:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --grey-bg: #e2e8f0;
  --accent: #2563eb;
  --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 4px 16px rgb(15 23 42 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --card: #131c2e;
    --ink: #e5e9f0;
    --muted: #94a3b8;
    --line: #22304a;
    --green: #4ade80;
    --green-bg: #0f2e1d;
    --red: #f87171;
    --red-bg: #3a1414;
    --grey-bg: #1e293b;
    --accent: #60a5fa;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }

.top { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px 4px; }
.top h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.who { color: var(--muted); font-size: 14px; }

main { padding: 8px 16px 24px; max-width: 640px; margin: 0 auto; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; }
.empty { color: var(--muted); padding: 10px 4px; }

.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px; border: 1px solid var(--line); }

/* screen time */
.kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kid { text-align: left; padding: 14px; border-radius: 18px; border: 0; }
.kid.green { background: var(--green-bg); }
.kid.red { background: var(--red-bg); }
.kid.unknown { background: var(--grey-bg); }
.kid .name { font-weight: 700; font-size: 18px; }
.kid .lamp { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; letter-spacing: .05em; margin-top: 2px; }
.kid.green .lamp { color: var(--green); }
.kid.red .lamp { color: var(--red); }
.kid.unknown .lamp { color: var(--muted); }
.lamp i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; display: inline-block; }
.bar { height: 8px; background: rgb(0 0 0 / .08); border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; background: currentColor; border-radius: 4px; }
.kid.green .bar { color: var(--green); }
.kid.red .bar, .kid.unknown .bar { color: var(--red); }
.kid .meta { font-size: 13px; color: var(--muted); }
.week { display: flex; gap: 4px; margin-top: 8px; }
.week span { width: 14px; height: 14px; border-radius: 4px; background: var(--line); }
.week span.met { background: var(--green); }
.week span.part { background: var(--red); opacity: .6; }

/* chores */
.chore { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.chore .dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--green); }
.chore.red { border-color: var(--red); background: var(--red-bg); }
.chore.red .dot { background: var(--red); }
.chore .body { flex: 1; min-width: 0; }
.chore .t { font-weight: 600; }
.chore .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.chore img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; }
.owner { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; color: #fff; }

/* proposals */
.prop img.photo { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; margin-bottom: 10px; display: block; }
.compact .prop img.photo { max-height: 160px; }
.prop .t { font-weight: 600; font-size: 17px; }
.prop .s { font-size: 13px; color: var(--muted); margin: 2px 0 10px; }
.voters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.voter { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--grey-bg); }
.voter.yes { background: var(--green-bg); color: var(--green); font-weight: 600; }
.voter.no { background: var(--red-bg); color: var(--red); font-weight: 600; }
.stamp { font-weight: 800; font-size: 13px; letter-spacing: .05em; }
.stamp.passed { color: var(--green); }
.stamp.rejected { color: var(--red); }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.btn { border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 600; background: var(--grey-bg); cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.yes { background: var(--green); color: #fff; }
.btn.no { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sel { outline: 3px solid var(--ink); outline-offset: 2px; }
.btn:disabled { opacity: .5; }
.btn.wide { width: 100%; }
.fab { position: fixed; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); border-radius: 99px; padding: 14px 20px;
  box-shadow: 0 6px 20px rgb(0 0 0 / .2); z-index: 5; }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; font-size: 12px; color: var(--muted); position: relative; }
.tabs button span { display: block; font-size: 22px; line-height: 1.2; filter: grayscale(1); opacity: .7; }
.tabs button.on { color: var(--ink); font-weight: 600; }
.tabs button.on span { filter: none; opacity: 1; }
.tabs b { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--red); color: #fff; font-size: 11px;
  border-radius: 99px; min-width: 18px; padding: 1px 5px; }

/* sheet */
dialog { border: 0; border-radius: 20px 20px 0 0; padding: 0; width: 100%; max-width: 640px; margin: auto auto 0;
  background: var(--card); color: var(--ink); max-height: 90vh; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
dialog h3 { margin: 0; font-size: 20px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
input[type=text], input[type=number], select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px; font-size: 16px; }
.pick { display: flex; gap: 10px; align-items: center; }
.pick img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.hist { font-size: 14px; border-top: 1px solid var(--line); padding-top: 8px; max-height: 40vh; overflow: auto; }
.hist div { padding: 4px 0; }
.hist img { width: 100%; border-radius: 10px; margin-top: 4px; }
.big-photo { width: 100%; border-radius: 12px; }

#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0;
  transition: opacity .2s; pointer-events: none; z-index: 20; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; }
.note { font-size: 14px; color: var(--muted); }
.hint { background: var(--grey-bg); border-radius: 12px; padding: 12px; font-size: 14px; }
.kid .rank { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgb(127 127 127 / .2); font-size: 15px; }
.kid .stars { color: #f59e0b; letter-spacing: 1px; }
.prop .del { margin-top: 10px; color: var(--red); font-weight: 500; }

/* ---- faces ---------------------------------------------------------------- */
.face { border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex: none; vertical-align: middle; }
.facepicks { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-around; }
.facepick { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; padding: 6px; }
.facepick small { color: var(--accent); font-size: 12px; }

/* ---- padaryta ------------------------------------------------------------- */
.tallies { display: flex; justify-content: space-around; }
.tally { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tally b { font-size: 20px; }
.tally small { color: var(--muted); font-size: 12px; }
.donerow { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.donerow .body { flex: 1; min-width: 0; font-size: 15px; }
.donerow .s { font-size: 13px; color: var(--muted); }
.donerow img:not(.face) { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }

/* ---- pokalbis ------------------------------------------------------------- */
body.chatting { padding-bottom: 0; }
body.chatting .top { display: none; }
/* Pinned between the top of the screen and the measured tab bar (--tabs-h is
   set from JS), so the composer can never slide under the tabs whatever the
   phone's safe areas are. */
body.chatting main { position: fixed; left: 0; right: 0; top: env(safe-area-inset-top); bottom: var(--tabs-h, 64px);
  padding: 0; max-width: none; display: flex; flex-direction: column; }
.faces { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 10px 8px 8px; background: var(--card);
  border-bottom: 1px solid var(--line); flex: none; }
.facecard { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 0; }
.facecard b { font-size: 13px; }
.facecard small { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facecard i { font-size: 10px; color: var(--muted); font-style: normal; }
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.older { text-align: center; margin: 4px 0 8px; }
.day { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; text-transform: capitalize; }
.evt { text-align: center; font-size: 13px; color: var(--muted); margin: 6px 16px; user-select: none; -webkit-user-select: none; }
.evt span { font-size: 11px; opacity: .7; }
.msg { display: flex; gap: 8px; margin-top: 2px; align-items: flex-end; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; }
.msg.first { margin-top: 12px; }
.msg .av { width: 44px; flex: none; align-self: flex-start; }
.msg .col { display: flex; flex-direction: column; max-width: 78%; min-width: 0; }
.msg.mine { justify-content: flex-end; }
.msg.mine .col { align-items: flex-end; }
.msg .nm { font-size: 13px; font-weight: 700; margin: 0 0 2px 4px; }
.bub { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 8px 12px; font-size: 16px;
  line-height: 1.35; overflow-wrap: anywhere; box-shadow: var(--shadow); }
.msg.mine .bub { background: var(--accent); color: #fff; border-color: transparent; }
.msg.mine .bub a { color: #fff; }
.bub:has(img.ph) { padding: 4px; }
.bub img.ph { display: block; width: 240px; max-width: 100%; height: 240px; border-radius: 14px; object-fit: cover; }
.bub img.ph + div { padding: 6px 8px 4px; }
.msg.shout .bub { font-size: 22px; font-weight: 800; padding: 12px 16px; background: #f59e0b; color: #111; border: 0; }
.msg .tm { font-size: 11px; color: var(--muted); margin: 2px 6px 0; display: flex; gap: 6px; align-items: center; }
.seen { display: inline-flex; gap: 2px; }
.reacts { display: flex; gap: 4px; margin-top: -6px; z-index: 1; flex-wrap: wrap; }
.reacts span { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 1px 6px 1px 4px; font-size: 14px;
  display: inline-flex; gap: 3px; align-items: center; }
.ask { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; margin-top: 4px; color: var(--muted); }
.ask .face { margin-left: -2px; }
.gavau { padding: 6px 12px; font-size: 14px; }
.voice { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: inherit; padding: 2px 0; min-width: 180px; }
.voice .pp { width: 34px; height: 34px; border-radius: 50%; background: rgb(127 127 127 / .2); display: grid; place-items: center; font-size: 14px; }
.voice .wave { flex: 1; height: 4px; border-radius: 2px; background: rgb(127 127 127 / .3); overflow: hidden; }
.voice .wave i { display: block; height: 100%; width: 0; background: currentColor; }
.voice .dur { font-size: 13px; font-variant-numeric: tabular-nums; }
.composer { flex: none; background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px 8px; }
.shouts { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.shouts::-webkit-scrollbar { display: none; }
.shouts button { flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 6px 12px; font-size: 14px; }
.cbar { display: flex; gap: 6px; align-items: flex-end; }
.cbar textarea { flex: 1; resize: none; border-radius: 20px; padding: 9px 14px; max-height: 120px; line-height: 1.3; }
.ic { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--bg); font-size: 20px;
  display: grid; place-items: center; cursor: pointer; }
.ic.on { background: var(--red); }
.ic.send { background: var(--accent); color: #fff; }
.recording { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; height: 42px; }
.recording i { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.pickreact { display: flex; justify-content: space-between; }
.pickreact button { font-size: 30px; background: none; border: 0; border-radius: 12px; padding: 6px; }
.pickreact button.sel { background: var(--grey-bg); }
.tabs b#chatBadge { background: var(--accent); }
