:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #f87171;
  --border: #334155;
  --tap: 52px;
  --radius: 16px;
  --nav-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  min-height: 100%;
}
a { color: var(--accent); text-decoration: none; }
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 1rem 1rem calc(var(--nav-h) + var(--safe-bottom) + 1rem);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.75rem;
}
.topbar h1 {
  font-size: 1.35rem;
  margin: 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.muted { color: var(--muted); }
.total {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.btn, button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.75rem 1.1rem;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
  text-align: center;
}
.btn.secondary { background: #334155; color: var(--text); }
.btn.success { background: var(--accent-2); color: #052e16; }
.btn.danger { background: var(--danger); color: #450a0a; }
.btn + .btn { margin-top: 0.6rem; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.grid-2 .btn { margin-top: 0; }
label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  padding: 0.75rem 0.9rem;
  font-size: 1.05rem;
}
textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.35;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}
.chip {
  position: relative;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}
.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chip:has(input:checked),
.chip.is-on {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.15);
}
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: none; }
.list.notes li { align-items: flex-start; }
.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 600;
}
.alert.error { background: rgba(248, 113, 113, 0.15); color: #fecaca; }
.alert.success { background: rgba(34, 197, 94, 0.15); color: #bbf7d0; }
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.96);
  border-top: 1px solid var(--border);
  padding: 0.35rem 0.35rem calc(0.35rem + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.15rem;
  max-width: 480px;
  margin: 0 auto;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 12px;
  gap: 0.15rem;
}
.bottom-nav a span.icon { font-size: 1.2rem; line-height: 1; }
.bottom-nav a.active {
  color: var(--text);
  background: rgba(56, 189, 248, 0.12);
}
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.small { font-size: 0.85rem; }
.row-actions { display: flex; gap: 0.5rem; align-items: center; }
.row-actions form { margin: 0; }
.row-actions .btn { width: auto; min-width: 96px; padding: 0.55rem 0.85rem; min-height: 44px; margin-top: 0; }
.row-actions input { flex: 1; }
.inline-filter label { margin-top: 0.25rem; }
.check-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  margin: 0;
}
.check-btn {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0b1220;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
}
.item-done strong { text-decoration: line-through; opacity: 0.65; }
.kind-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #0b1220;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-right: 0.35rem;
  vertical-align: middle;
}
.kind-badge.kind-bring { color: #93c5fd; border-color: #1d4ed8; }
.kind-badge.kind-buy { color: #fcd34d; border-color: #b45309; }
.kind-badge.kind-task { color: #86efac; border-color: #15803d; }

.btn-sm, a.btn-sm, button.btn-sm {
  width: auto;
  min-width: 72px;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  margin-top: 0;
}
.empty-state {
  text-align: center;
  padding: 1.25rem 0.5rem;
}
.empty-state .btn { margin-top: 0.75rem; }
.search-form .row-actions { margin-top: 0.35rem; }
.search-form input[type="search"] { flex: 1; }
.topbar .btn-sm { width: auto; }
.list a.btn-sm { flex-shrink: 0; }
.chip { min-height: var(--tap); padding: 0.65rem 1rem; }

.copy-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.copy-row input { flex: 1; min-width: 0; }
.copy-row .btn { width: auto; min-width: 96px; margin-top: 0; }
.member-row { align-items: flex-start; }
.member-row form { margin: 0; }
.member-row select { min-height: 44px; width: auto; }


/* P10: larger typography + guest read-only */
body.large-text {
  font-size: 20px;
}
body.large-text .topbar h1 { font-size: 1.7rem; }
body.large-text .total { font-size: 2.55rem; }
body.large-text .btn,
body.large-text button.btn,
body.large-text a.btn {
  font-size: 1.15rem;
  min-height: 56px;
}
body.large-text .muted.small,
body.large-text .small { font-size: 0.95rem; }
body.large-text input,
body.large-text select,
body.large-text textarea {
  font-size: 1.1rem;
}
body.large-text .kind-badge { font-size: 0.85rem; }
body.large-text .chip { min-height: 56px; padding: 0.75rem 1.1rem; }

body.role-guest form[method="post"]:not(.guest-ok) { display: none; }
body.role-guest .guest-hide { display: none !important; }

.guest-banner {
  background: #334155;
  color: #e2e8f0;
  text-align: center;
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
}
body.large-text .guest-banner { font-size: 1.05rem; }

/* Calendar (Naptár) — /events month grid */
.cal-card { padding-bottom: 0.75rem; }
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.cal-nav-btn {
  width: auto !important;
  min-width: 44px;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  margin-top: 0;
  font-size: 1.15rem;
}
.cal-nav-label {
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.cal-nav-label strong {
  font-size: 1.05rem;
  text-transform: capitalize;
}
.cal-today-link {
  font-size: 0.85rem;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--accent);
  background: #0b1220;
}
.cal-layers { margin-bottom: 0.75rem; }
.cal-layer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.cal-layer {
  cursor: pointer;
  user-select: none;
  margin: 0;
  gap: 0.35rem;
}
.cal-layer input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.cal-layer.is-on {
  border-color: var(--accent);
  color: var(--text);
  background: #0c4a6e;
}
.cal-grid { display: flex; flex-direction: column; gap: 0.25rem; }
.cal-weekdays,
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
}
.cal-weekday {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0;
}
.cal-day {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 64px;
  min-width: 0;
  padding: 0.25rem 0.2rem 0.35rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #0b1220;
  color: var(--text);
  text-decoration: none;
  gap: 0.15rem;
}
.cal-day:hover { border-color: var(--border); }
.cal-day.is-out {
  opacity: 0.35;
  background: transparent;
}
.cal-day.is-today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}
.cal-day.is-selected {
  background: #1e3a5f;
  border-color: var(--accent);
}
.cal-day-num {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 0 0.1rem;
}
.cal-day-chips {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}
.cal-chip {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.12rem 0.28rem;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  border: 1px solid transparent;
}
.cal-overflow {
  color: var(--muted);
  background: #1e293b;
  border-color: var(--border);
  text-align: center;
}
.cal-kind-event { background: #0c4a6e; color: #7dd3fc; border-color: #0284c7; }
.cal-kind-recorded { background: #312e81; color: #c4b5fd; border-color: #6366f1; }
.cal-kind-birthday { background: #831843; color: #f9a8d4; border-color: #db2777; }
.cal-kind-nameday { background: #78350f; color: #fcd34d; border-color: #d97706; }
.cal-kind-bill { background: #7c2d12; color: #fdba74; border-color: #ea580c; }
.cal-kind-asset { background: #134e4a; color: #5eead4; border-color: #0d9488; }
.cal-kind-chore { background: #14532d; color: #86efac; border-color: #16a34a; }

.cal-agenda .cal-chip {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.cal-agenda-list li { align-items: flex-start; }

body.large-text .cal-day { min-height: 72px; }
body.large-text .cal-chip { font-size: 0.72rem; }
body.large-text .cal-day-num { font-size: 0.95rem; }

@media (max-width: 380px) {
  .cal-day { min-height: 56px; padding: 0.2rem 0.1rem; }
  .cal-chip { font-size: 0.55rem; }
}
