:root {
  color-scheme: light;
  --page: #e9e7df;
  --bg: #f6f5f0;
  --card: #ffffff;
  --soft: #eceae2;
  --line: #dcdad1;
  --ink: #181816;
  --muted: #62625b;
  --accent: #5d6b12;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecc2;
  --blue: #3556c9;
  --m1: #d9534f;
  --m2: #e4894a;
  --m3: #d9b03a;
  --m4: #3fa86f;
  --m5: #6b7fe0;
  --shadow: 0 18px 50px rgba(24, 24, 22, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #050506;
  --bg: #0c0d0e;
  --card: #151719;
  --soft: #1d2023;
  --line: #292d31;
  --ink: #f2f1ec;
  --muted: #9a9b94;
  --accent: #c6d84a;
  --accent-ink: #12150a;
  --accent-soft: #272d12;
  --blue: #8aa2ff;
  --m1: #ef6b66;
  --m2: #f0a062;
  --m3: #e8c453;
  --m4: #55c88a;
  --m5: #8c9dff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #050506;
    --bg: #0c0d0e;
    --card: #151719;
    --soft: #1d2023;
    --line: #292d31;
    --ink: #f2f1ec;
    --muted: #9a9b94;
    --accent: #c6d84a;
    --accent-ink: #12150a;
    --accent-soft: #272d12;
    --blue: #8aa2ff;
    --m1: #ef6b66;
    --m2: #f0a062;
    --m3: #e8c453;
    --m4: #55c88a;
    --m5: #8c9dff;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell {
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}
main { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
@media (min-width: 520px) { .shell { box-shadow: var(--shadow); } }

h1 { font-size: 28px; line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 17px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.top .date { color: var(--muted); font-size: 14px; margin-top: 4px; }
.top .date::first-letter, .sheet-head h3::first-letter, .cap::first-letter { text-transform: uppercase; }

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

/* przyciski */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; font-weight: 600;
  background: var(--soft); border: 1px solid var(--line);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.block { width: 100%; }
.btn.danger { color: var(--m1); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.link { color: var(--accent); font-weight: 600; font-size: 14px; }
:root[data-theme="light"] .link { color: var(--accent); }

/* hero */
.hero { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center; }
.hero .face { width: 96px; height: 96px; }
.hero h3 { font-size: 22px; letter-spacing: -0.01em; }
.hero .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.energy { display: flex; gap: 4px; margin-top: 12px; }
.energy i { flex: 1; height: 8px; border-radius: 4px; background: var(--soft); }
.energy i.on { background: var(--accent); }
.hero-foot { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px;
  border-radius: 999px; background: var(--soft); font-size: 13px; border: 1px solid transparent;
}
.things { margin: 14px 0 0; padding: 0; list-style: none; }
.things li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }

/* tydzień */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 118px; }
.week button { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.week .bar { width: 100%; max-width: 30px; border-radius: 8px; background: var(--soft); min-height: 8px; }
.week .lbl { font-size: 12px; color: var(--muted); }
.week .today .lbl { color: var(--ink); font-weight: 700; }
.legend { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; background: var(--c, var(--soft)); vertical-align: -1px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--soft); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 24px; letter-spacing: -0.02em; margin-top: 2px; }
.stat small { color: var(--muted); font-size: 12px; }
.delta-up { color: var(--m4); } .delta-down { color: var(--m1); }

.progress { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; margin: 12px 0 8px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* tab bar */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: min(480px, 100%);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px; justify-content: center; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 12px; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--ink); }
.tabbar button[aria-current="page"] svg { color: var(--accent); }

/* kalendarz */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h3 { text-transform: capitalize; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 2px; }
.cal button { aspect-ratio: 1; border-radius: 12px; background: var(--soft); font-size: 13px; font-weight: 600; position: relative; }
.cal button.has { color: #10110a; }
.cal button.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.cal button:disabled { opacity: 0.3; cursor: default; }
.cal .pad { visibility: hidden; }
.year { display: grid; grid-auto-flow: column; grid-template-columns: repeat(53, 1fr); grid-template-rows: repeat(7, auto); gap: 2px; margin-top: 4px; }
.year i { aspect-ratio: 1; border-radius: 2px; background: var(--soft); display: block; }
.list-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 12px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .face { width: 44px; height: 44px; }
.list-item b { display: block; }
.list-item > span:nth-child(2) { min-width: 0; }
.list-item .num { white-space: nowrap; }
.list-item .sub { font-size: 13px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* wpływy */
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.seg button { min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--soft); font-size: 14px; font-weight: 600; border: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.impact { padding: 14px 0; border-top: 1px solid var(--line); }
.impact:first-of-type { border-top: 0; }
.impact-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.impact-head b { font-size: 16px; }
.impact-head .d { font-weight: 700; font-size: 18px; white-space: nowrap; }
.dbar { position: relative; height: 8px; border-radius: 4px; background: var(--soft); margin: 10px 0 8px; }
.dbar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--line); }
.dbar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.badge.medium { background: var(--accent-soft); color: var(--accent); }
.badge.high { background: var(--accent); color: var(--accent-ink); }
.chart text { fill: var(--muted); font-size: 10px; }
details { margin-top: 6px; }
summary { cursor: pointer; font-weight: 600; padding: 10px 0; }

/* ustawienia */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-height: 52px; }
.setting:first-of-type { border-top: 0; }
.switch { width: 52px; height: 32px; border-radius: 16px; background: var(--soft); border: 1px solid var(--line); position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--accent-ink); }
.notice { background: var(--accent-soft); color: var(--ink); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.notice.err { background: color-mix(in srgb, var(--m1) 18%, var(--card)); }

/* arkusze */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 30; display: flex; justify-content: center; align-items: flex-end; }
.sheet {
  width: min(480px, 100%); max-height: 94dvh; background: var(--bg); border-radius: 24px 24px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 10px; }
.sheet-head h3 { text-align: center; flex: 1; font-size: 17px; }
.sheet-body { overflow-y: auto; padding: 4px 16px 16px; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
.field { margin-bottom: 16px; }
.field > label, .field > .lab { display: block; font-weight: 600; margin-bottom: 4px; }
.field .hint { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button { min-height: 60px; border-radius: 14px; background: var(--soft); border: 2px solid transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 700; }
.scale button[aria-pressed="true"] { border-color: var(--ink); background: var(--card); }
.scale .face { width: 34px; height: 34px; }
.scale .bars { display: flex; align-items: flex-end; gap: 2px; height: 22px; }
.scale .bars i { width: 4px; background: var(--muted); border-radius: 2px; display: block; }
.scale[data-kind="mood"] button[aria-pressed="true"] { border-color: var(--c); }
.scale-label { text-align: center; font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 18px; }
input[type="text"], input[type="password"], input[type="time"], textarea {
  width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  padding: 10px 14px; font-size: 16px;
}
textarea { min-height: 88px; resize: vertical; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags button { min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); font-size: 14px; text-align: left; }
.tags button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.moment-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.moment-row:first-child { border-top: 0; }
.moment-row .face { width: 40px; height: 40px; }
.welcome { text-align: left; }
.welcome ol { padding-left: 20px; margin: 10px 0 14px; color: var(--muted); font-size: 14px; }
.welcome li { margin-bottom: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
