:root {
  --green-50: #f1f8f3;
  --green-100: #dff1e4;
  --green-200: #bfe3c9;
  --green-500: #3cb55a;
  --green-600: #2e9e4f;
  --green-700: #26833f;
  --green-800: #1b6030;
  --green-900: #0f3d1e;
  --bg: #eef3ef;
  --card: #ffffff;
  --text: #14211a;
  --muted: #6a7a70;
  --line: #e3ebe5;
  --danger: #d6372f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 61, 30, .06), 0 4px 14px rgba(15, 61, 30, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- przyciski / pola ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  background: var(--green-600); color: #fff; font-weight: 600; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--green-700); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--green-50); color: var(--green-800); border: 1px solid var(--green-200); }
.btn.secondary:hover { background: var(--green-100); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--green-50); color: var(--text); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f1c9c6; }
.btn.danger:hover { background: #fdf0ef; }
.btn.block { width: 100%; padding: 11px 16px; }
.btn.sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn.following { background: #fff; color: var(--green-800); border: 1px solid var(--green-200); }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=url], input[type=search], textarea, select {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(60, 181, 90, .18); }
textarea { resize: vertical; min-height: 44px; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0 0; min-height: 1em; }

/* ---------- logowanie ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: center; gap: 22px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(255, 255, 255, .22), transparent 60%),
    linear-gradient(155deg, var(--green-500) 0%, var(--green-700) 55%, var(--green-900) 100%);
}
.auth-hero::after {
  content: ""; position: absolute; width: 520px; height: 520px; right: -200px; bottom: -220px; border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
.logo-card {
  align-self: flex-start; background: #fff; border-radius: 22px; padding: 14px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.logo-card img { display: block; height: 78px; width: auto; }
.auth-hero p { margin: 0; max-width: 430px; font-size: 18px; opacity: .95; }
.auth-hero ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; max-width: 430px; position: relative; z-index: 1; }
.auth-hero li { display: flex; gap: 10px; align-items: flex-start; opacity: .95; }
.auth-hero li svg { flex: none; margin-top: 2px; }
.auth-side { display: grid; place-items: center; padding: 28px 16px; background: #f3f7f4; }
.auth-box { width: min(400px, 100%); }
.auth-card { background: #fff; border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 22px; margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--green-50); border-radius: 12px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--green-700); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }
.steps { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 8px; }
.waiting { text-align: center; }
.code {
  font-size: 44px; letter-spacing: 10px; font-weight: 800; color: var(--green-700);
  background: var(--green-50); border: 2px dashed var(--green-200); border-radius: 14px; padding: 12px 0 12px 10px; margin: 14px 0;
}
.spinner { width: 26px; height: 26px; margin: 8px auto; border: 3px solid var(--green-100); border-top-color: var(--green-600); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ramka aplikacji ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(15, 61, 30, .03); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 58px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; }
.brand img { height: 36px; width: auto; display: block; }
.search { position: relative; width: 240px; flex: none; }
.search input { padding-left: 36px; border-radius: 999px; background: var(--green-50); border-color: transparent; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.nav { display: flex; flex: 1; justify-content: center; gap: 2px; height: 100%; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 0 14px; min-width: 66px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.nav a:hover { color: var(--green-700); background: var(--green-50); }
.nav a.active { color: var(--green-600); }
.nav a.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--green-600); }
.usermenu { display: flex; align-items: center; gap: 8px; flex: none; }
.usermenu .who { font-weight: 600; font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page { max-width: 1240px; margin: 0 auto; padding: 18px 16px 80px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; max-width: 1060px; margin: 0 auto; }
.col-main { min-width: 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.card-title { font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h1 { font-size: 22px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { color: var(--green-200); margin-bottom: 8px; }

/* ---------- avatar ---------- */
.avatar { flex: none; border-radius: 50%; background: var(--green-600); color: #fff; font-weight: 700; display: inline-grid; place-items: center; overflow: hidden; object-fit: cover; user-select: none; }
.avatar.s32 { width: 32px; height: 32px; font-size: 12px; }
.avatar.s40 { width: 40px; height: 40px; font-size: 14px; }
.avatar.s96 { width: 96px; height: 96px; font-size: 32px; border: 4px solid #fff; }
.badge { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--green-600); color: #fff; vertical-align: -2px; margin-left: 4px; }
.badge.business { background: #c9a227; }
.badge.government { background: #7a8a80; }
.badge svg { width: 10px; height: 10px; }

/* ---------- tablica ---------- */
.composer { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 14px 16px; }
.composer textarea { border: 0; padding: 8px 0; box-shadow: none !important; font-size: 16px; min-height: 52px; }
.composer-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.composer-bar .grow { flex: 1; }
.composer .imgurl { grid-column: 1 / -1; }
.feed-tabs { display: flex; gap: 6px; margin: 14px 0; }
.chip { border: 1px solid var(--line); background: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.chip.active { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.post { padding: 14px 16px 6px; }
.post-head { display: flex; gap: 10px; align-items: center; }
.post-head .meta { min-width: 0; flex: 1; line-height: 1.25; }
.post-head .name { font-weight: 700; color: var(--text); }
.post-head a.name:hover { text-decoration: underline; }
.post-text { margin: 10px 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; }
.post-img { display: block; width: calc(100% + 32px); max-height: 460px; object-fit: cover; margin: 6px -16px 0; background: var(--green-50); }
.actions { display: flex; border-top: 1px solid var(--line); margin: 10px -16px 0; }
.actions button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; background: transparent; padding: 10px 4px; color: var(--muted); font-weight: 600; cursor: pointer; font-size: 14px; }
.actions button:hover { background: var(--green-50); color: var(--green-700); }
.actions button.on { color: var(--green-600); }
.actions button.on svg { fill: currentColor; }
.actions button.like.on { color: #e0245e; }
.comments { border-top: 1px solid var(--line); margin: 0 -16px; padding: 12px 16px; background: #fafcfa; border-radius: 0 0 var(--radius) var(--radius); }
.comment { display: flex; gap: 10px; margin-bottom: 12px; }
.comment .bubble { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 7px 11px; flex: 1; min-width: 0; }
.comment .bubble p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.side-user .meta { flex: 1; min-width: 0; line-height: 1.25; }
.side-user .meta > b, .side-user .meta > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-listing { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 6px 0; color: inherit; }
.mini-listing:hover { text-decoration: none; }
.mini-listing .thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--green-100); }
.mini-listing b { display: block; line-height: 1.2; }
.price { color: var(--green-700); font-weight: 700; }
.foot { color: var(--muted); font-size: 12px; padding: 4px 6px; }

/* ---------- profil ---------- */
.profile-banner { height: 170px; background: linear-gradient(120deg, var(--green-500), var(--green-800)); background-size: cover; background-position: center; border-radius: var(--radius) var(--radius) 0 0; }
.profile-top { padding: 0 20px 16px; }
.profile-top .row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: -48px; }
.profile-top h1 { margin-top: 10px; font-size: 22px; }
.profile-top .bio { margin: 10px 0; white-space: pre-wrap; }
.counts { display: flex; gap: 18px; color: var(--muted); }
.counts b { color: var(--text); }

/* ---------- uklady dwukolumnowe (wiadomosci, poczta, notatki) ---------- */
.split { display: grid; grid-template-columns: 330px 1fr; height: calc(100vh - 58px - 36px - 18px); min-height: 460px; overflow: hidden; }
.split .list { border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.split .detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.list-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.item { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; background: #fff; border-left: 0; border-right: 0; border-top: 0; width: 100%; }
.item:hover { background: var(--green-50); }
.item.active { background: var(--green-100); }
.item .meta { flex: 1; min-width: 0; line-height: 1.3; }
.item .meta > b, .item .meta > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .when { font-size: 12px; color: var(--muted); align-self: flex-start; }
.unread { background: var(--green-600); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.detail-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.detail-head .grow { flex: 1; min-width: 0; }
.thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: #f6faf7; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 16px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; align-self: flex-start; }
.msg.self { background: var(--green-600); color: #fff; border-color: var(--green-600); align-self: flex-end; }
.msg time { display: block; font-size: 10.5px; opacity: .7; margin-top: 2px; }
.sendbar { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.mail-body { padding: 18px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; flex: 1; }
.note-editor { display: flex; flex-direction: column; flex: 1; padding: 14px; gap: 10px; min-height: 0; }
.note-editor input { font-size: 20px; font-weight: 700; border: 0; padding: 4px 0; box-shadow: none !important; }
.note-editor textarea { flex: 1; border: 0; box-shadow: none !important; resize: none; padding: 4px 0; }
.back { display: none; }

/* ---------- siatki ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tile { overflow: hidden; position: relative; }
.tile img, .tile video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; background: var(--green-50); }
.tile .del { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .92); border: 0; border-radius: 8px; padding: 6px; cursor: pointer; color: var(--danger); display: none; }
.tile:hover .del { display: block; }
.listing img { display: block; width: 100%; height: 150px; object-fit: cover; background: var(--green-100); }
.listing .body { padding: 12px 14px 14px; }
.listing h3 { font-size: 16px; margin-bottom: 2px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; background: var(--green-100); color: var(--green-800); padding: 2px 8px; border-radius: 999px; }
.contact-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.contact-row:last-child { border-bottom: 0; }
.contact-row .meta { flex: 1; min-width: 0; line-height: 1.3; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(15, 40, 24, .5); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; padding: 20px; width: min(480px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal h2 { font-size: 18px; margin-bottom: 14px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.lightbox { background: rgba(0, 0, 0, .88); cursor: zoom-out; }
.lightbox img, .lightbox video { max-width: 96vw; max-height: 92vh; border-radius: 8px; }
#toasts { position: fixed; z-index: 60; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--green-900); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); animation: pop .2s ease-out; }
.toast.err { background: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.sessions .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sessions .row:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* ---------- responsywnosc ---------- */
@media (max-width: 1080px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .col-side { display: none; }
  .search { width: 170px; }
  .usermenu .who { display: none; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { padding: 28px 22px 34px; min-height: 0; gap: 14px; }
  .auth-hero ul { display: none; }
  .logo-card img { height: 56px; }
  .search { display: none; }
  .split { grid-template-columns: 1fr; height: calc(100vh - 58px - 74px); }
  .split .detail { display: none; }
  .split.open .list { display: none; }
  .split.open .detail { display: flex; }
  .back { display: inline-flex; }
}
@media (max-width: 720px) {
  .topbar-in { gap: 8px; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: 58px; background: #fff; border-top: 1px solid var(--line); justify-content: flex-start; z-index: 30; }
  .nav a { min-width: 72px; padding: 0 8px; }
  .nav a.active::after { top: 0; bottom: auto; border-radius: 0 0 3px 3px; }
  .page { padding: 12px 10px 80px; }
  .msg { max-width: 86%; }
}

.profile-banner img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* ---------- tryb wbudowany (aplikacja Bleeter w telefonie) ---------- */
html.embedded body { overscroll-behavior: none; }
html.embedded .topbar-in { height: 48px; padding: 0 12px; }
html.embedded .brand img { height: 30px; }
html.embedded .usermenu .who { display: none; }
html.embedded .page { padding: 10px 10px 76px; }
html.embedded .split { height: calc(100vh - 48px - 58px - 20px); }
html.embedded .nav { height: 56px; }
@media (max-width: 480px) {
  .actions button { font-size: 13px; gap: 5px; padding: 10px 2px; white-space: nowrap; }
}
