:root {
  --navy-900: #071226;
  --navy-800: #0b1a36;
  --navy-700: #12284f;
  --navy-600: #1b3a6b;
  --blue-500: #2f5ea8;
  --blue-400: #4f7fcf;
  --blue-300: #7fa6e3;
  --blue-200: #b9cff2;
  --blue-100: #e3ecfa;
  --blue-50: #f3f7fd;
  --white: #ffffff;
  --gold: #c9a24a;
  --gold-soft: #e8d39b;
  --ink: #0f1d38;
  --muted: #6b7a96;
  --line: #dfe7f4;
  --red: #e05a5a;
  --yellow: #e9b730;
  --green: #2e9d5f;
  --pale: #9fe0b3;
  --me: #1b3a6b;
  --other: #7fa6e3;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(11, 26, 54, .06), 0 6px 24px rgba(11, 26, 54, .07);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--blue-50);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.serif { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif; }

/* ---------- układ ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--safe-t) + 14px) 18px 14px;
  background: linear-gradient(160deg, var(--navy-800), var(--navy-700));
  color: var(--white);
  display: flex; align-items: center; gap: 12px;
}
.top .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.top .brand b { font-weight: 600; letter-spacing: .02em; }
.top .brand small { display: block; color: var(--blue-200); font-size: 12px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: url(icons/icon-192.png) center/cover;
  box-shadow: 0 0 0 1px rgba(201, 162, 74, .5);
}
.icon-btn {
  border: 0; background: rgba(255, 255, 255, .1); color: var(--white);
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
}
.icon-btn svg { width: 20px; height: 20px; }

main {
  max-width: 760px; margin: 0 auto;
  padding: 18px 16px calc(96px + var(--safe-b));
}
.view-title { font-size: 22px; margin: 6px 2px 14px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 4px 10px; font-weight: 600; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-b));
}
.tabs button {
  border: 0; background: none; padding: 6px 2px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); min-width: 0;
}
.tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--navy-600); font-weight: 600; }
.tabs button.on svg { color: var(--gold); }

/* ---------- karty ---------- */
.card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; border: 1px solid rgba(223, 231, 244, .7);
}
.card + .card { margin-top: 12px; }

.hero {
  position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, var(--blue-500) 0%, var(--navy-700) 45%, var(--navy-800) 100%);
  color: var(--white); border: 0;
  display: flex; align-items: center; gap: 18px;
}
.hero::after {
  content: ""; position: absolute; inset: auto -40px -60px auto; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 162, 74, .22), transparent 70%);
}
.hero .label { color: var(--blue-200); font-size: 14px; }
.hero .big { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.hero .big small { font-size: 18px; font-weight: 500; color: var(--blue-200); margin-left: 4px; }
.ring { width: 92px; height: 92px; flex: none; position: relative; z-index: 1; }
.ring .em { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: rgba(255, 255, 255, .12); color: var(--white); margin-top: 8px;
}
.pill.light { background: var(--blue-100); color: var(--navy-600); }

/* ---------- kafelki ---------- */
.tiles { display: grid; gap: 12px; margin-top: 14px; }
@media (min-width: 620px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile { display: flex; flex-direction: column; gap: 14px; }
.tile-head { display: flex; align-items: center; gap: 12px; }
.tile-icon {
  width: 42px; height: 42px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--navy-700), var(--blue-500)); color: var(--gold-soft);
}
.tile-icon svg { width: 22px; height: 22px; }
.tile-name { font-weight: 600; flex: 1; }
.tile.done { background: linear-gradient(180deg, var(--white), var(--blue-50)); }
.tile .value { font-size: 30px; font-weight: 700; color: var(--navy-600); line-height: 1; }
.tile .value small { font-size: 15px; font-weight: 500; color: var(--muted); }
.ok-badge { color: var(--gold); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.ok-badge svg { width: 16px; height: 16px; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--blue-50);
  font-size: 22px; color: var(--navy-600); flex: none;
}
.stepper input {
  width: 100%; min-width: 0; height: 44px; text-align: center; font-size: 22px; font-weight: 700;
  border: 1px solid var(--line); border-radius: 14px; background: var(--white); color: var(--navy-600);
}
.stepper .unit { color: var(--muted); font-size: 14px; }

/* ---------- przyciski i pola ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 600; text-decoration: none;
  background: var(--navy-600); color: var(--white);
  box-shadow: 0 2px 0 rgba(201, 162, 74, .0), inset 0 -2px 0 rgba(0, 0, 0, .15);
}
.btn:active { transform: translateY(1px); }
.btn.gold { background: linear-gradient(180deg, #d6b25c, var(--gold)); color: var(--navy-900); }
.btn.ghost { background: var(--blue-100); color: var(--navy-600); box-shadow: none; }
.btn.danger { background: #fde8e8; color: #b23b3b; box-shadow: none; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; }
.link { border: 0; background: none; color: var(--blue-500); font-weight: 600; padding: 4px 0; }

label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 0; }
input[type=text], input[type=password], input:not([type]), textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--white); color: var(--ink); font-size: 16px; outline: none;
}
input:focus, textarea:focus { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(79, 127, 207, .18); }
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }

.seg { display: flex; background: var(--blue-100); border-radius: 13px; padding: 3px; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 10px; font-size: 14px;
  color: var(--navy-600); white-space: nowrap; font-weight: 500;
}
.seg button.on { background: var(--white); box-shadow: 0 1px 3px rgba(11, 26, 54, .12); font-weight: 600; }

/* ---------- werset ---------- */
.verse { background: linear-gradient(170deg, var(--navy-800), var(--navy-700)); color: var(--white); border: 0; padding: 26px 22px; position: relative; }
.verse .quote { font-size: 21px; line-height: 1.55; }
.verse .quote::before { content: "„"; color: var(--gold); }
.verse .quote::after { content: "”"; color: var(--gold); }
.verse .ref { margin-top: 14px; color: var(--gold-soft); font-weight: 600; letter-spacing: .02em; }
.verse .src { margin-top: 12px; font-size: 13px; }
.verse a { color: var(--blue-200); }
.verse .tag { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--blue-300); margin-bottom: 12px; }

.reflection { white-space: pre-wrap; }
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none;
  background: var(--navy-600); color: var(--gold-soft);
}
.avatar.other { background: var(--blue-200); color: var(--navy-700); }

/* ---------- notatki ---------- */
.note .meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.note .meta .avatar { width: 24px; height: 24px; font-size: 11px; }
.note .body { white-space: pre-wrap; word-wrap: break-word; }
.note .actions { display: flex; gap: 14px; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.lock-note { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin: 10px 4px; }

/* ---------- statystyki ---------- */
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin: 6px 2px 0; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .caption { font-size: 14px; text-align: center; color: var(--navy-600); min-height: 21px; margin-top: 6px; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.duo .card { margin-top: 0; }
.stat .n { font-size: 26px; font-weight: 700; color: var(--navy-600); line-height: 1.15; }
.stat .n small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat .sub { font-size: 13px; color: var(--muted); }
.stat .dots { font-size: 13px; margin-top: 6px; }
.catbar { margin: 12px 0; }
.catbar .t { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.bar { height: 8px; border-radius: 6px; background: var(--blue-100); overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; border-radius: 6px; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.cal .dow { font-size: 11px; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal button {
  aspect-ratio: 1; border: 0; border-radius: 11px; font-size: 13px; font-weight: 600; background: var(--blue-50); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0;
}
.cal button.r { background: #fbe1e1; color: #a83c3c; }
.cal button.y { background: #fbf0cc; color: #8a6a10; }
.cal button.g { background: #cfeeda; color: #1d6e41; }
.cal button.p { background: #e6f8ec; color: #1d6e41; box-shadow: inset 0 0 0 2px var(--pale); }
.cal button.today { outline: 2px solid var(--gold); outline-offset: 1px; }
.cal button.future { opacity: .35; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { text-transform: capitalize; }
.key { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 12px; }

/* ---------- lista dni ---------- */
.days { display: flex; flex-direction: column; }
.days button {
  display: flex; align-items: center; gap: 12px; border: 0; background: none; text-align: left;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.days button:last-child { border-bottom: 0; }
.days .d { flex: 1; }
.days .d::first-letter, .sheet-head h2::first-letter { text-transform: uppercase; }
.days .m { font-weight: 700; color: var(--navy-600); }

.rows .row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.rows .row:last-child { border-bottom: 0; }
.rows .row b { color: var(--navy-600); }

/* ---------- okna (modal) ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(7, 18, 38, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out;
}
.sheet {
  background: var(--blue-50); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(22px + var(--safe-b));
  animation: up .2s ease-out;
}
@media (min-width: 700px) { .backdrop { align-items: center; } .sheet { border-radius: 22px; } }
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--blue-200); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 19px; text-transform: none; }
.close { border: 0; background: var(--blue-100); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; color: var(--navy-600); flex: none; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

#toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--navy-800); color: var(--white); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 30; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: #a83c3c; }

/* ---------- logowanie / instalacja ---------- */
.login-wrap, body.install {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(120% 80% at 80% 0%, var(--blue-500), var(--navy-800) 55%, var(--navy-900));
}
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 30px 24px; }
.login-card .logo-mark { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 14px; }
.login-card h1 { font-size: 24px; }
.login-card p { margin: 4px 0 18px; }
.login-card form { text-align: left; }
.install-card { max-width: 520px; width: 100%; }
.install-card h1 { margin-bottom: 12px; }
.install-card h2 { font-size: 17px; margin-top: 20px; }
.install-card pre { background: var(--blue-50); padding: 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-all; font-size: 13px; }
.install-card fieldset { border: 1px solid var(--line); border-radius: 14px; margin: 14px 0; padding: 4px 14px 14px; }
.install-card legend { font-weight: 600; padding: 0 6px; }
.err { color: #b23b3b; font-weight: 600; }
.splash { min-height: 100vh; display: grid; place-items: center; background: var(--navy-800); }
.splash .logo-mark { width: 64px; height: 64px; border-radius: 18px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.steps { padding-left: 20px; margin: 8px 0; }
.steps li { margin: 6px 0; }
.share-ico { display: inline-block; vertical-align: -3px; width: 18px; height: 18px; color: var(--blue-500); }
.card > p:first-child { margin-top: 0; } .card > p:last-child { margin-bottom: 0; }
