/* Rodzinka – ciepły, nowoczesny styl */
:root {
  --bg: #fbf3e7;
  --bg2: #f4e6d3;
  --card: #fffaf3;
  --card2: #fff4e3;
  --text: #3b2418;
  --muted: #8a6a55;
  --line: #ead9c2;
  --accent: #d9742b;
  --accent2: #e9a23b;
  --accent-soft: #fbe3cf;
  --accent-text: #fff;
  --ok: #4f9a5a;
  --danger: #c84b3c;
  --shadow: 0 10px 30px rgba(120, 70, 30, .12);
  --radius: 18px;
  --nav-h: 66px;
}
[data-theme="terracotta"] { --accent: #c2410c; --accent2: #e07a3b; --accent-soft: #f9dccb; --bg: #fbefe6; --bg2: #f4ddcb; }
[data-theme="olive"] { --accent: #8a7a2b; --accent2: #c9a43c; --accent-soft: #f1ead0; --bg: #f8f4e5; --bg2: #efe7cd; }
[data-theme="rose"] { --accent: #c04d6a; --accent2: #e58a9b; --accent-soft: #fbdde5; --bg: #fcf0f0; --bg2: #f6dede; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .9em; }
.small { font-size: .82em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }
.center { text-align: center; }

/* ---------- logowanie ---------- */
#login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(1200px 600px at 20% -10%, #ffd9a8 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #f6b58a 0%, transparent 60%),
    linear-gradient(170deg, #fff2df, #f8d9b8 60%, #efc39a);
}
.login-card {
  width: 100%; max-width: 420px;
  background: rgba(255, 250, 243, .92);
  border-radius: 28px;
  box-shadow: 0 25px 60px rgba(120, 60, 20, .22);
  overflow: hidden;
  backdrop-filter: blur(6px);
  animation: pop .5s ease;
}
@keyframes pop { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.login-art { background: linear-gradient(180deg, #ffd59c, #f7b474); line-height: 0; }
.login-art svg { width: 100%; height: auto; }
.login-body { padding: 22px 26px 28px; }
.login-body h1 { font-size: 1.6rem; margin-bottom: 2px; }
.login-body .muted { margin-bottom: 18px; display: block; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .85rem; font-weight: 700; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=color], select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { min-height: 90px; resize: vertical; }
input[type=color] { padding: 4px; height: 44px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 14px; border: 0; cursor: pointer; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--accent-text);
  box-shadow: 0 8px 20px rgba(217, 116, 43, .28); transition: transform .1s, box-shadow .15s, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn.wide { width: 100%; }
.btn.ghost { background: var(--card2); color: var(--accent); box-shadow: none; border: 1.5px solid var(--line); }
.btn.danger { background: var(--danger); box-shadow: none; }
.btn.sm { padding: 7px 12px; border-radius: 11px; font-size: .88rem; }
.btn.icon { padding: 8px 10px; }
.btn:disabled { opacity: .55; cursor: wait; }
.iconbtn { background: transparent; border: 0; cursor: pointer; padding: 6px; border-radius: 10px; color: var(--muted); font-size: 1rem; line-height: 1; }
.iconbtn:hover { background: var(--accent-soft); color: var(--accent); }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 4px 0 8px; }

/* ---------- układ aplikacji ---------- */
#app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--card); border-right: 1px solid var(--line); padding: 22px 16px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 900; font-size: 1.15rem; }
.brand .logo { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: grid; place-items: center; color: #fff; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 13px; color: var(--text); text-decoration: none; font-weight: 700;
  transition: background .15s;
}
.nav a:hover { background: var(--card2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .ico { font-size: 1.15rem; width: 24px; text-align: center; }
.nav .badge { margin-left: auto; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: .72rem; padding: 2px 7px; font-weight: 800; min-width: 20px; text-align: center; }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--card2); text-decoration: none; color: inherit; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 1.1rem; color: #fff; flex: none;
  background: var(--accent); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}
.avatar.sm { width: 26px; height: 26px; font-size: .85rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.6rem; }

.main { padding: 22px 26px 100px; max-width: 1100px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h2 { margin: 0; }
.topbar .sub { color: var(--muted); font-size: .9rem; }

.bottomnav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h);
  background: rgba(255, 250, 243, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 50;
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .68rem; font-weight: 800; color: var(--muted); text-decoration: none; position: relative; border-radius: 12px; }
.bottomnav a .ico { font-size: 1.35rem; }
.bottomnav a.active { color: var(--accent); }
.bottomnav a .badge { position: absolute; top: 2px; right: calc(50% - 22px); }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .bottomnav { display: flex; }
  .main { padding: 16px 14px 100px; }
}

/* ---------- karty ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; border: 1px solid rgba(234, 217, 194, .6); }
.card h3 { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.tile { background: var(--card2); border-radius: 16px; padding: 14px; display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; transition: transform .15s; }
.tile:hover { transform: translateY(-2px); }
.tile .big { font-size: 1.7rem; font-weight: 900; color: var(--accent); line-height: 1; }
.tile .ico { font-size: 1.6rem; }
.hero { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero h2 { color: #fff; font-size: 1.5rem; }
.hero .muted { color: rgba(255, 255, 255, .85); }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .15); }
.quote { font-style: italic; font-size: 1.05rem; padding: 10px 14px; border-left: 4px solid var(--accent2); background: var(--card2); border-radius: 0 14px 14px 0; }
.date-item { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.date-item:last-child { border-bottom: 0; }
.date-item .when { margin-left: auto; font-weight: 800; color: var(--accent); white-space: nowrap; }
.date-item.today { background: var(--accent-soft); border-radius: 12px; padding: 9px 10px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 800; }
.pill.gray { background: var(--bg2); color: var(--muted); }
.pill.ok { background: #dff1e1; color: var(--ok); }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; margin-right: 4px; }

/* ---------- zakładki ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); cursor: pointer; font-weight: 800; color: var(--muted); }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- listy ---------- */
.addbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.addbar input[type=text] { flex: 1 1 220px; }
.addbar select, .addbar input[type=date] { flex: 0 1 170px; width: auto; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item.done .txt { text-decoration: line-through; color: var(--muted); }
.item .txt { white-space: pre-wrap; word-break: break-word; }
.item .meta { font-size: .78rem; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item .actions { margin-left: auto; display: flex; gap: 2px; flex: none; }
.check { width: 26px; height: 26px; border-radius: 9px; border: 2px solid var(--accent2); background: #fff; cursor: pointer; flex: none; display: grid; place-items: center; color: #fff; font-weight: 900; margin-top: 1px; }
.check.on { background: var(--ok); border-color: var(--ok); }
.like { border: 0; background: transparent; cursor: pointer; font-weight: 800; color: var(--muted); padding: 4px 8px; border-radius: 10px; }
.like.on { color: var(--danger); background: #fde3df; }
.due.late { color: var(--danger); font-weight: 800; }

/* ---------- galeria ---------- */
.albums { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.album { border-radius: 16px; overflow: hidden; background: var(--card2); cursor: pointer; box-shadow: var(--shadow); transition: transform .15s; }
.album:hover { transform: translateY(-3px); }
.album .cov { aspect-ratio: 4/3; background: linear-gradient(135deg, var(--accent-soft), var(--bg2)); display: grid; place-items: center; font-size: 2.5rem; }
.album .cov img { width: 100%; height: 100%; object-fit: cover; }
.album .inf { padding: 10px 12px; }
.album .inf b { display: block; }
.media-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.media-grid .m { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bg2); position: relative; cursor: pointer; }
.media-grid .m img { width: 100%; height: 100%; object-fit: cover; }
.media-grid .m .vid { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.media-grid .m .novid { width: 100%; height: 100%; display: grid; place-items: center; font-size: 2.2rem; background: #3b2418; color: #fff; }
.progress { height: 10px; border-radius: 999px; background: var(--bg2); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0; transition: width .2s; }
.lightbox { position: fixed; inset: 0; background: rgba(20, 10, 5, .94); z-index: 200; display: flex; flex-direction: column; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox .lb-top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #fff; }
.lightbox .lb-top .iconbtn { color: #fff; font-size: 1.2rem; }
.lightbox .lb-body { flex: 1; display: grid; place-items: center; min-height: 0; padding: 0 10px; position: relative; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .15); color: #fff; border: 0; font-size: 1.6rem; width: 46px; height: 46px; border-radius: 50%; cursor: pointer; }
.lightbox .lb-nav.prev { left: 10px; } .lightbox .lb-nav.next { right: 10px; }
.lightbox .lb-cap { color: #fff; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); text-align: center; font-size: .95rem; }

/* ---------- czat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
@media (max-width: 900px) { .chat { height: calc(100vh - var(--nav-h) - 110px); } }
.chat .online { display: flex; gap: 6px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); padding-bottom: 8px; align-items: center; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 6px 4px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 78%; align-self: flex-start; display: flex; gap: 8px; align-items: flex-end; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--card); border: 1px solid var(--line); border-radius: 18px 18px 18px 6px; padding: 9px 13px; box-shadow: 0 3px 10px rgba(120, 70, 30, .08); position: relative; }
.msg.mine .bubble { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0; border-radius: 18px 18px 6px 18px; }
.bubble .who { font-size: .75rem; font-weight: 800; color: var(--accent); margin-bottom: 2px; }
.bubble .t { white-space: pre-wrap; word-break: break-word; }
.bubble .tm { font-size: .68rem; opacity: .7; margin-top: 3px; text-align: right; }
.bubble img { border-radius: 10px; max-height: 260px; margin-top: 4px; cursor: pointer; }
.bubble video { border-radius: 10px; max-height: 260px; max-width: 100%; margin-top: 4px; }
.reads { font-size: .7rem; color: var(--muted); text-align: right; margin-top: 2px; display: flex; gap: 4px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.reads .tilek { display: inline-flex; align-items: center; gap: 3px; background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px 1px 2px; }
.reads .avatar { width: 16px; height: 16px; font-size: .6rem; }
.msg .mtools { opacity: 0; transition: opacity .15s; }
.msg:hover .mtools, .msg.touch .mtools { opacity: 1; }
.chat .compose { display: flex; gap: 8px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.chat .compose textarea { min-height: 44px; max-height: 140px; border-radius: 22px; padding: 11px 16px; }
.daysep { align-self: center; font-size: .72rem; color: var(--muted); background: var(--bg2); padding: 2px 10px; border-radius: 999px; margin: 4px 0; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(50, 25, 10, .45); z-index: 150; display: grid; place-items: end center; animation: fade .15s; }
@media (min-width: 700px) { .modal-bg { place-items: center; } }
.modal { background: var(--card); width: 100%; max-width: 520px; border-radius: 24px 24px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); animation: up .2s; }
@media (min-width: 700px) { .modal { border-radius: 24px; } }
@keyframes up { from { transform: translateY(30px); } to { transform: none; } }
.modal h3 { font-size: 1.2rem; margin-bottom: 14px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%); background: #3b2418; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 300; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }
@media (min-width: 900px) { #toast { bottom: 24px; } }

/* ---------- kalendarz ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dn { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 800; padding: 4px 0; }
.cal .d { aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .85rem; background: var(--card2); position: relative; cursor: default; }
.cal .d.off { opacity: .3; }
.cal .d.today { outline: 2px solid var(--accent); font-weight: 900; }
.cal .d .dots { display: flex; gap: 2px; margin-top: 2px; }
.cal .d .dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.cal .d.has { cursor: pointer; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); margin-top: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; }

/* ---------- tabele panelu ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tablewrap { overflow-x: auto; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.switch:last-child { border-bottom: 0; }
.switch input[type=checkbox] { width: 44px; height: 24px; appearance: none; background: var(--bg2); border-radius: 999px; position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input[type=checkbox]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input[type=checkbox]:checked { background: var(--ok); }
.switch input[type=checkbox]:checked::after { left: 23px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-size: .9rem; }
.kv b { color: var(--accent); }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-pick button { border: 1.5px solid var(--line); background: #fff; border-radius: 10px; font-size: 1.3rem; width: 42px; height: 42px; cursor: pointer; }
.emoji-pick button.on { border-color: var(--accent); background: var(--accent-soft); }
.empty { text-align: center; color: var(--muted); padding: 24px 10px; }
.empty .ico { font-size: 2.4rem; }
.media-grid .empty, .albums .empty { grid-column: 1 / -1; }
