:root {
  --bg: #faf8f5; --card: #fff; --text: #1c1c1e; --muted: #8a8580;
  --green: #2e7d4f; --orange: #c07a2c; --red: #e0a3a3; --red-text: #b5544f; --beige: #e8e1d6;
  --radius: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px; line-height: 1.35;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 16px)
           calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 16px);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
[hidden] { display: none !important; }
.screen { max-width: 520px; margin: 0 auto; }
button { font: inherit; color: inherit; cursor: pointer; }
h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; margin: 0; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.top { display: flex; align-items: flex-start; justify-content: space-between; margin: 8px 0 20px; }
.date { margin: 2px 0 0; color: var(--muted); font-size: 17px; }
.icon-btn { border: 0; background: var(--card); width: 44px; height: 44px; border-radius: 50%; font-size: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); display: grid; place-items: center; }
.back-btn { border: 0; background: none; color: var(--text); font-size: 17px; padding: 8px 0; width: 64px; text-align: left; }
.settings-title { font-size: 20px; padding-top: 6px; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.03); }

/* Karta dawki */
.dose-head { display: flex; justify-content: space-between; align-items: baseline; }
.dose-label { font-size: 13px; font-weight: 600; letter-spacing: .8px; color: var(--muted); }
.dose-time { font-size: 28px; font-weight: 700; margin-top: 2px; }
.dose-state { font-weight: 600; font-size: 15px; }
.dose-state.waiting { color: var(--orange); }
.dose-state.skipped { color: var(--red-text); }
.take-btn { display: block; width: 100%; height: 56px; margin-top: 14px; border: 0; border-radius: 14px;
  background: #1c1c1e; color: #fff; font-size: 19px; font-weight: 600; }
.take-btn:active { transform: scale(.985); opacity: .9; }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.dose.taken { cursor: pointer; }
.taken-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.check { width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 700; flex: none; }
.taken-text { font-size: 17px; font-weight: 600; color: var(--green); }
.taken-sub { font-size: 13px; color: var(--muted); }

/* Tydzień */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 4px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.week-day .wd { font-size: 13px; color: var(--muted); font-weight: 500; }
.week-day.today .wd { color: var(--text); font-weight: 700; }
.dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: var(--beige); }
.dot.taken { background: var(--green); }
.dot.skipped { background: var(--red); }
.dot.waiting { background: var(--beige); }
.dot.none { background: transparent; border: 1.5px solid #e3ddd3; }
.legend { display: flex; gap: 14px; justify-content: center; margin-top: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 11px; height: 11px; }
.week .small { text-align: center; margin: 8px 0 0; font-size: 12px; }

/* Logowanie */
.login-box { display: flex; flex-direction: column; align-items: center; padding-top: 6vh; }
.login-icon { width: 72px; height: 72px; border-radius: 16px; margin-bottom: 12px; }
.pin-dots { display: flex; gap: 14px; margin: 18px 0 6px; height: 16px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text); }
.pin-dots i.on { background: var(--text); }
.pin-error { min-height: 22px; color: var(--red-text); font-size: 15px; margin: 6px 0 10px; text-align: center; }
.keypad { display: grid; grid-template-columns: repeat(3, 78px); gap: 16px 24px; }
.keypad button { width: 78px; height: 78px; border-radius: 50%; border: 0; background: var(--card); font-size: 30px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.keypad button:active { background: var(--beige); }
.keypad button[data-k="del"] { background: transparent; box-shadow: none; font-size: 26px; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* Ustawienia */
.btn { display: block; width: 100%; min-height: 50px; border: 0; border-radius: 14px; background: #1c1c1e; color: #fff;
  font-size: 17px; font-weight: 600; margin-top: 10px; padding: 0 16px; }
.btn.secondary { background: #f1ede7; color: var(--text); }
.btn:disabled { opacity: .5; }
.link-btn { border: 0; background: none; color: var(--muted); font-size: 14px; text-decoration: underline; padding: 8px 0 0; }
.push-status { font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.push-status::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.push-status.on::before { background: var(--green); }
.install-tip { background: #f6f1e8; border-radius: 14px; padding: 12px 14px; margin-top: 12px; font-size: 15px; }
.name-form { display: flex; gap: 8px; }
.name-form input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 0 14px; height: 50px; border-radius: 14px;
  border: 1px solid #e3ddd3; background: var(--bg); color: var(--text); }
.small-btn { width: auto; margin-top: 0; }
.hist-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; padding: 9px 0; border-top: 1px solid #f0ebe4; font-size: 15px; }
.hist-row:first-child { border-top: 0; }
.hist-row.head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.hist-row .t { color: var(--green); font-weight: 600; }
.hist-row .s { color: var(--red-text); }
.hist-row .w { color: var(--muted); }
.log { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.log div { padding: 4px 0; border-top: 1px solid #f0ebe4; }
.log div:first-child { border-top: 0; }
