:root {
  --bg: #F3F5F8;
  --fg: #17202B;
  --muted: #5F6977;
  --faint: #9AA3AE;
  --card: #FFFFFF;
  --line: #E1E6EC;
  --stub: #D5DBE2;
  --danger: #B3261E;
  --nav-h: 76px;
  --tabs-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
body.has-tabs { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); }
.app {
  max-width: 480px;
  margin: 0 auto;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
h1, h2 { margin: 0; line-height: 1.1; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: flex-start;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
  padding: 8px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
  background: var(--card);
}
.tabs a {
  min-width: 72px; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none;
}
.tabs a[aria-current="page"] { color: var(--fg); }

/* stepper: ‹ label › */
.stepper { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; gap: 8px; }
.round {
  width: 48px; height: 48px; border-radius: 24px; background: var(--card); color: var(--fg);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.round.off { opacity: .3; }
.stepper-mid { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.stepper-label { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stepper-sub { font-size: 14px; color: var(--muted); }

/* Lisa */
.daynav { height: var(--nav-h); padding: 14px 16px; }
.daynav .stepper-label { font-weight: 600; }
.lisa {
  display: flex; flex-direction: column; gap: 24px;
  padding: 28px 0 24px;
  min-height: calc(100dvh - var(--tabs-h) - env(safe-area-inset-bottom, 0px));
}
.head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 0 20px; }
.head h1 { font-size: 32px; font-weight: 700; }
.head p { font-size: 16px; color: var(--muted); }
.textlink {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 12px;
  font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.textlink.center { align-self: center; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 16px; }
.tile {
  position: relative; height: 116px; border: 0; border-radius: 16px; background: var(--card); color: var(--fg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 8px 4px;
  text-decoration: none; transition: transform .08s ease; touch-action: manipulation; user-select: none;
}
.tile:active { transform: scale(.95); }
.tile-wrap { position: relative; min-width: 0; }
.tile-wrap .tile { width: 100%; }
.tile-minus {
  position: absolute; top: 2px; left: 2px; width: 44px; height: 44px; border: 0; border-radius: 14px;
  background: none; color: var(--muted); display: none; align-items: center; justify-content: center;
}
.tile-minus:active { color: var(--fg); }
.tile-wrap.has .tile-minus { display: flex; }
.tile-name { font-size: 15px; font-weight: 600; line-height: 1.1; text-align: center; overflow-wrap: anywhere; }
.tile-count { position: absolute; top: 10px; right: 12px; font-size: 15px; font-weight: 700; }
.daylist { list-style: none; margin: 0; padding: 0 20px; }
.daylist li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; align-items: center; gap: 12px;
  min-height: 48px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.daylist b { font-variant-numeric: tabular-nums; }
.minus { width: 44px; height: 44px; border: 0; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.toast {
  position: fixed; z-index: 20;
  left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 12px);
  max-width: 448px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 4px 8px 4px 18px; border-radius: 14px; background: var(--fg); color: var(--card); font-size: 15px;
}
.toast[hidden] { display: none; }
.toast #toast-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-actions { display: flex; flex-shrink: 0; }
.toast button { min-height: 44px; padding: 0 10px; border: 0; background: none; color: var(--card); font-weight: 700; }
.toast button[hidden] { display: none; }

/* terviseks */
.cheers-line { text-align: center; font-size: 15px; font-weight: 600; padding: 0 20px; margin-bottom: -10px; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30; background: rgba(23, 32, 43, .35);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 480px; max-height: 85dvh; overflow-y: auto;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 12px;
}
.sheet h2 { font-size: 24px; font-weight: 700; }
.sheet-friends { display: flex; flex-direction: column; }
.friend {
  display: flex; justify-content: space-between; align-items: center; min-height: 52px;
  border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 600;
}
.friend input { width: 22px; height: 22px; accent-color: var(--fg); }
.sheet-close { align-self: center; }
.sheet > div { display: flex; flex-direction: column; gap: 10px; }
.sheet > div[hidden] { display: none; }
.sheet p { font-size: 17px; line-height: 1.45; }
.sheet p.muted { font-size: 15px; }
.sheet h2 + .lead { margin-top: -4px; }
.sheet .lead { font-size: 18px; font-weight: 700; }
.share-icon { vertical-align: -3px; }
.url-field { width: 100%; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 0; background: var(--bg); font-size: 14px; }
.icon-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; }
.icon-steps li {
  counter-increment: step; display: grid; grid-template-columns: 22px 44px minmax(0, 1fr); align-items: center; gap: 10px;
  min-height: 52px; border-bottom: 1px solid var(--line); font-size: 16px;
}
.icon-steps li:last-child { border-bottom: 0; }
.icon-steps li::before { content: counter(step); font-weight: 800; color: var(--muted); text-align: center; grid-column: 1; grid-row: 1; }
.step-icon {
  grid-column: 2; grid-row: 1; width: 44px; height: 44px; border-radius: 12px; background: var(--bg); color: var(--fg);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.step-icon img { border-radius: 8px; }
.step-word { font-size: 14px; font-weight: 800; }
.icon-steps li > span:last-child { grid-column: 3; grid-row: 1; }
.steps-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-size: 17px; }

/* hangover */
.hang { margin: 0 16px; padding: 16px 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.hang-q { font-size: 18px; font-weight: 700; }
.faces { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; width: 100%; margin-top: 10px; }
.face {
  border: 0; background: none; color: var(--fg); min-height: 64px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; font-weight: 600;
}
.face:active { background: var(--bg); }
.row-face { display: inline-flex; margin-left: 2px; color: var(--muted); }
.hang-stats h2, .push-row h2 { font-size: 17px; font-weight: 700; }
.hang-rows { display: flex; flex-direction: column; }
.hang-row { display: flex; justify-content: space-between; min-height: 40px; align-items: center; border-bottom: 1px solid var(--line); }
.hang-row:last-child { border-bottom: 0; }
.hang-row b { font-variant-numeric: tabular-nums; }
.center-line { text-align: center; font-size: 15px; }

/* notifications */
.push-card { margin: 0 16px; padding: 14px 16px 4px; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.push-card[hidden], .push-row[hidden] { display: none; }
.push-card-actions { display: flex; gap: 12px; }
.push-row { align-items: flex-start; }

/* general pages */
.page { display: flex; flex-direction: column; gap: 18px; padding: 40px 16px 32px; }
.page-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.page-head h1 { font-size: 32px; font-weight: 700; }
.page-head p { color: var(--muted); }
.back {
  align-self: flex-start; margin-top: -28px; min-height: 44px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 16px; font-weight: 600; text-decoration: none;
}
.periods { display: flex; gap: 26px; }
.periods a {
  min-height: 44px; display: flex; align-items: center; padding: 0 2px;
  font-size: 16px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent;
}
.periods a[aria-current="page"] { color: var(--fg); font-weight: 700; border-bottom-color: var(--fg); }
.card { background: var(--card); border-radius: 16px; }
.card.pad { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.list { padding: 4px 6px; }
.row {
  display: grid; align-items: center; gap: 8px; min-height: 52px; padding: 6px 10px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--fg);
}
.list > .row:last-child { border-bottom: 0; }
.row-day { grid-template-columns: 84px minmax(0, 1fr) auto; min-height: 58px; }
.row-range { grid-template-columns: minmax(0, 1fr) 52px 64px 52px; }
.row-headings { min-height: 40px; font-size: 13px; color: var(--muted); }
.row-headings span { text-align: right; }
.who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who.is-me { font-weight: 800; }
.icons { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.more { font-size: 13px; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.num.muted { color: var(--muted); }
.sub-head { font-size: 17px; font-weight: 700; padding: 6px 4px 0; }

/* person */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--card); border-radius: 16px; padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.stat b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { font-size: 14px; color: var(--muted); }
.chart { padding: 18px 16px 14px; }
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; height: 150px; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bar-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { width: 100%; max-width: 30px; border-radius: 6px; background: var(--stub); }
.bar.drank { background: var(--fg); }
.bar-letters { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; padding-top: 8px; }
.bar-letters span { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.bar-letters .today { color: var(--fg); font-weight: 800; }
.bar-letters .future { color: var(--faint); }
.calendar { padding: 18px 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.calendar h2 { text-align: center; font-size: 17px; font-weight: 700; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 6px; justify-items: center; }
.cal-dow { font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.cal-day {
  width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.cal-day.drank { background: var(--fg); color: var(--card); }
.cal-day.muted { color: var(--faint); }
.cal-day.today { font-weight: 800; box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--fg); }
.cal-line { text-align: center; font-size: 15px; color: var(--muted); }
.links { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 8px; }
.links a, .links button {
  min-height: 44px; display: flex; align-items: center; padding: 0 12px;
  border: 0; background: none; font-size: 15px; font-weight: 600; text-decoration: none; color: var(--fg);
}
.links .danger, .textbutton.danger { color: var(--danger); }

/* forms */
.auth { display: flex; flex-direction: column; gap: 18px; padding: 72px 24px 32px; }
.auth h1 { font-size: 32px; font-weight: 700; text-align: center; }
.auth > p { text-align: center; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form.card { padding: 18px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.field span { font-size: 14px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 14px; color: var(--muted); }
.field input, .copy input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-size: 17px;
}
.form.card .field input { background: var(--bg); border-color: transparent; }
.field-row { display: flex; gap: 10px; }
.primary {
  min-height: 52px; border: 0; border-radius: 14px; background: var(--fg); color: var(--card);
  font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.danger-fill { background: var(--danger); }
.error { color: var(--danger); font-size: 15px; }
.glasses { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.glasses legend { font-size: 14px; font-weight: 600; color: var(--muted); padding: 0 0 6px; }
.glass-pick input { position: absolute; opacity: 0; pointer-events: none; }
.glass-pick > span {
  width: 52px; height: 56px; border-radius: 12px; background: var(--bg); color: var(--fg);
  display: flex; align-items: center; justify-content: center; border: 2px solid transparent;
}
.glass-pick input:checked + span { border-color: var(--fg); background: var(--card); }
.glass-pick input:focus-visible + span { outline: 2px solid var(--fg); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 20px; height: 20px; }
.textbutton.muted { color: var(--muted); }
.textbutton { border: 0; background: none; padding: 0 4px; min-height: 44px; font-weight: 600; color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.row-own { grid-template-columns: minmax(0, 1fr) auto auto; }
.row-own.is-off > span:first-child { color: var(--faint); text-decoration: line-through; }
.row-member { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.member-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.member-actions { display: flex; gap: 6px; }
.copy { display: flex; gap: 8px; align-items: center; }
.copy input { font-size: 14px; min-height: 44px; }
