:root {
  --bg: #0a0b0f;
  --sidebar-bg: #0d0f15;
  --card: #13151c;
  --card-2: #171a23;
  --border: #22252f;
  --border-soft: #1a1c25;
  --text: #eef0f3;
  --muted: #8b8f9c;
  --muted-2: #5f6371;
  --accent: #9061F9;
  --accent-2: #6B77F5;
  --accent-soft: rgba(144, 97, 249, 0.14);
  --accent-text: #c3b3ff;
  --ok: #35d187;
  --ok-soft: rgba(53, 209, 135, 0.14);
  --warn: #f5b93d;
  --warn-soft: rgba(245, 185, 61, 0.14);
  --err: #ff6669;
  --err-soft: rgba(255, 102, 105, 0.14);
  --fail: #ff9142;
  --fail-soft: rgba(255, 145, 66, 0.16);
  --info: #4fb8f0;
  --info-soft: rgba(79, 184, 240, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 24px -8px rgba(0,0,0,.45);
  --shadow-sm: 0 2px 8px -2px rgba(0,0,0,.3);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8; --sidebar-bg: #ffffff; --card: #ffffff; --card-2: #f8f9fb;
    --border: #e6e8ee; --border-soft: #eef0f4; --text: #14161c; --muted: #6a6f7d; --muted-2: #9298a6;
    --accent-soft: rgba(144, 97, 249, 0.09); --accent-text: #7c4fe0;
    --ok-soft: rgba(20, 170, 100, 0.1); --warn-soft: rgba(200, 140, 0, 0.1);
    --err-soft: rgba(220, 50, 55, 0.1); --info-soft: rgba(20, 130, 200, 0.1);
    --fail: #c8720a; --fail-soft: rgba(200, 114, 10, 0.1);
    --shadow: 0 8px 24px -10px rgba(20,22,30,.15); --shadow-sm: 0 2px 10px -4px rgba(20,22,30,.1);
  }
}
* { box-sizing: border-box; }
/* clip zamiast hidden: "overflow: hidden" na html/body robi z nich pojemniki
   przewijania, przez co Safari na iOS przejmuje przewijanie i gubi natywny ped
   (a wraz z nim plynnosc 120 Hz). "clip" tylko przycina, nie tworzy scrollera. */
html, body { overflow-x: clip; max-width: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; font-feature-settings: 'ss01' 1;
}
h1, h2, h3 { margin: 0 0 .4em; letter-spacing: -0.01em; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.history-details { margin-top: 16px; }
.history-details summary {
  font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; user-select: none;
}
.history-details summary::-webkit-details-marker { display: none; }
.history-details summary::before { content: '▸'; font-size: 11px; transition: transform .15s ease; color: var(--muted-2); }
.history-details[open] summary::before { transform: rotate(90deg); }
.history-details[open] summary { margin-bottom: 8px; }
a { color: var(--accent-text); text-decoration: none; }
p { line-height: 1.55; }

/* ---------- Shell / nav ---------- */

.app-shell { display: flex; min-height: 100vh; }

.app-nav {
  position: fixed; top: 0; left: 0; bottom: 0; width: 232px;
  background: var(--sidebar-bg); border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; padding: 20px 14px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; display: block; }
.brand-name { font-weight: 800; font-size: 15px; line-height: 1.15; }
.brand-name span { display: block; font-weight: 500; font-size: 11px; color: var(--muted-2); letter-spacing: .03em; }

.nav-links { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--muted); font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-align: left; transition: background .15s ease, color .15s ease; position: relative;
  font-family: inherit;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-label-short { display: none; }
.nav-link:hover { background: var(--card-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-badge {
  position: absolute; top: 4px; right: 10px; background: var(--err); color: #fff; font-style: normal;
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; line-height: 1.5; min-width: 15px; text-align: center;
}
@media (max-width: 880px) {
  .nav-badge { top: 2px; right: 16px; }
}
.nav-footer { font-size: 11px; padding: 8px 12px 2px; color: var(--muted-2); }

.main-col { margin-left: 232px; flex: 1; min-width: 0; }
main#app { max-width: 1080px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) 28px 60px; }

@media (max-width: 880px) {
  .app-nav {
    top: auto; right: 0; flex-direction: row; align-items: center; width: auto;
    height: calc(62px + env(safe-area-inset-bottom));
    padding: 0 6px calc(env(safe-area-inset-bottom)) 6px; border-right: none; border-top: 1px solid var(--border-soft);
    box-shadow: 0 -4px 16px rgba(0,0,0,.25);
  }
  .brand, .nav-footer { display: none; }
  .nav-links { flex-direction: row; flex: 1; justify-content: space-around; align-items: stretch; }
  .nav-link {
    flex: 1; min-width: 0; max-width: 84px;
    flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 3px; font-size: 9.5px; padding: 7px 3px;
  }
  .nav-link svg { margin: 0 auto; }
  .nav-link span {
    display: block; width: 100%; text-align: center; white-space: normal;
    line-height: 1.2; overflow-wrap: normal; word-break: normal; hyphens: none;
  }
  .nav-link .nav-label-full { display: none; }
  .nav-link .nav-label-short { display: block; }
  .main-col { margin-left: 0; }
  main#app { padding: calc(16px + env(safe-area-inset-top)) 14px calc(78px + env(safe-area-inset-bottom)); }
  button.primary, button.secondary, button.danger, button.ok, button.revise { min-height: 44px; }
}

/* ---------- Skeleton loaders ---------- */

@keyframes skel-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skel {
  background: linear-gradient(90deg, var(--card-2) 25%, var(--border-soft) 37%, var(--card-2) 63%);
  background-size: 400% 100%; animation: skel-shimmer 1.4s ease infinite; border-radius: var(--radius-sm);
}
.skel-line { height: 14px; margin-bottom: 10px; }
.skel-card { height: 78px; margin-bottom: 12px; border-radius: var(--radius); }
.skel-tile { height: 74px; border-radius: var(--radius); }
.skel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 620px) { .skel-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Generic building blocks ---------- */

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow-sm); position: relative;
}
.overdue-card { border-color: var(--err); }
.overdue-tag { color: var(--err); font-weight: 700; }
/* Top-LEFT, with identical top/left insets so it reads as a deliberate corner
   mark rather than floating. The review card reserves a band for it (see
   .review-card below) so it never sits on top of the post thumbnail. */
.heart-like {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-size: 17px; line-height: 1;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  transition: border-color .2s ease, background-color .2s ease, transform .12s ease;
}
/* Both glyphs occupy the same cell; only opacity/scale animate, so the fill
   grows out of the outline instead of snapping between two characters. */
.heart-like .h-outline, .heart-like .h-fill {
  grid-area: 1 / 1; display: block; line-height: 1;
  transition: opacity .22s ease, transform .22s cubic-bezier(.34, 1.56, .64, 1);
}
.heart-like .h-fill { color: var(--accent); opacity: 0; transform: scale(.4); }
.heart-like.liked .h-fill { opacity: 1; transform: scale(1); }
.heart-like.liked .h-outline { opacity: 0; transform: scale(1.35); }
.heart-like:hover { border-color: var(--accent); color: var(--accent-text); }
.heart-like:active { transform: scale(0.92); }
.heart-like.liked { border-color: var(--accent); background: var(--accent-soft); }
.heart-like[disabled] { cursor: default; }
/* One short bounce on the button itself, only when switching ON. */
.heart-like.pop { animation: heart-pop .32s ease; }
@keyframes heart-pop {
  0% { transform: scale(1); } 45% { transform: scale(1.18); } 100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .heart-like, .heart-like .h-outline, .heart-like .h-fill { transition-duration: .01ms; }
  .heart-like.pop { animation: none; }
}
/* Reserve the corner band so the heart has its own space above the post row. */
.review-card { padding-top: 56px; }
.modal .heart-like { position: static; margin-left: 10px; }

/* Thumbs sit beside the heart but mean something different: the heart is
   aspirational ("more like this"), the thumbs are a verdict on THIS post and
   are deliberately independent of approve/reject - a post can ship and still
   be marked bad. Offset by the heart's 34px + a 10px gap. */
.signal-thumbs {
  position: absolute; top: 12px; left: 56px; z-index: 2;
  display: flex; gap: 6px;
}
.thumb-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-size: 15px; line-height: 1;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease, transform .12s ease;
}
.thumb-btn:active { transform: scale(0.92); }
.thumb-btn[disabled] { cursor: default; opacity: .6; }
/* Kolorowa obwodka wylacznie dla oceny wcisnietej - inaczej nie da sie jednym
   spojrzeniem odczytac stanu. Hover tylko rozjasnia tlo i tylko tam, gdzie
   kursor naprawde istnieje: na dotyku :hover zostaje przyklejony po tapnieciu
   i nieoceniony kciuk wygladalby jak wybrany. */
@media (hover: hover) {
  .thumb-btn:hover { background: var(--border-soft); color: var(--text); }
}
.thumb-btn.up.on { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.thumb-btn.down.on { border-color: var(--err); background: var(--err-soft); color: var(--err); }
.thumb-btn.on { animation: thumb-pop .3s ease; }
@keyframes thumb-pop {
  0% { transform: scale(1); } 45% { transform: scale(1.16); } 100% { transform: scale(1); }
}
/* W modalu serduszko i kciuki musza siedziec w jednym rzedzie flex.
   .heart-like ma display:grid, czyli jest blokiem - samo "position: static"
   dawalo mu wlasny wiersz, a kciuki spadaly obok. Rzad jest tez clearfixem dla
   .close (float: right), zeby przyciski nie oplywaly krzyzyka. */
.modal .signal-row {
  display: flex; align-items: center; gap: 8px;
  clear: both; padding-top: 4px; margin-bottom: 10px;
}
.modal .signal-row .heart-like { position: static; margin-left: 0; }
.modal .signal-thumbs { position: static; display: flex; margin-left: 0; }
@media (prefers-reduced-motion: reduce) {
  .thumb-btn { transition-duration: .01ms; }
  .thumb-btn.on { animation: none; }
}
.page-header {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.page-header h2 { margin: 0; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 14px 0 5px; }
input[type=text], input[type=url], input[type=number], input[type=time], input[type=date], input[type=search], input[type=password], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); font-size: 16px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
/* 16px is deliberate, not a design choice - iOS Safari auto-zooms the whole
   page on focus for any text input under 16px, which then leaves the page
   pannable/zoomed until the user manually pinches back out. Never go below
   16px on a focusable text field, on any screen size. */
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 76px; resize: vertical; }
select { cursor: pointer; }
.hint { font-size: 12px; color: var(--muted-2); margin-top: 5px; line-height: 1.5; }

button { font-family: inherit; }
button.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff; border: none;
  padding: 11px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer;
  margin-top: 18px; box-shadow: var(--shadow-sm); transition: transform .12s ease, box-shadow .12s ease;
}
button.primary:hover { box-shadow: 0 6px 18px -4px rgba(144,97,249,.5); transform: translateY(-1px); }
button.primary:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
button.secondary {
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .15s ease, border-color .15s ease;
}
button.secondary:hover { background: var(--border-soft); border-color: var(--muted-2); }
button.secondary.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
button.icon-btn {
  background: var(--card-2); border: 1px solid var(--border); color: var(--text); width: 34px; height: 34px;
  border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; transition: background .15s ease;
}
button.icon-btn:hover { background: var(--border-soft); }
button.danger, button.ok, button.revise {
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
button.danger { background: var(--err-soft); color: var(--err); }
button.danger:hover { background: var(--err); color: #fff; }
button.ok { background: var(--ok-soft); color: var(--ok); }
button.ok:hover { background: var(--ok); color: #06231a; }
button.revise { background: var(--accent-soft); color: var(--accent-text); }
button.revise:hover { background: var(--accent); color: #fff; }
button.danger:disabled, button.ok:disabled, button.revise:disabled { opacity: .5; cursor: default; }

.multi-row { display: flex; gap: 8px; margin-bottom: 6px; }
.multi-row input { flex: 1; }

/* ---------- Segmented control (view switcher) ---------- */

.segmented {
  display: flex; background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px; gap: 2px; max-width: 100%; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.segmented button {
  background: none; border: none; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 7px 13px;
  border-radius: 7px; cursor: pointer; transition: background .15s ease, color .15s ease; white-space: nowrap;
  flex-shrink: 0;
}
.segmented button.active { background: var(--accent); color: #fff; }
.segmented button:not(.active):hover { color: var(--text); }

/* ---------- Status badges ---------- */

.status-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-DRAFT { background: var(--border-soft); color: var(--muted); }
.status-REVIEW { background: var(--warn-soft); color: var(--warn); }
.status-APPROVED { background: var(--ok-soft); color: var(--ok); }
.status-SCHEDULED { background: var(--ok-soft); color: var(--ok); }
.status-PUBLISHED { background: var(--info-soft); color: var(--info); }
.status-REJECTED { background: var(--err-soft); color: var(--err); }
.status-ERROR { background: var(--fail-soft); color: var(--fail); }

.swatch.status-DRAFT { background: var(--muted); }
.swatch.status-REVIEW { background: var(--warn); }
.swatch.status-APPROVED, .swatch.status-SCHEDULED { background: var(--ok); }
.swatch.status-PUBLISHED { background: var(--info); }
.swatch.status-REJECTED { background: var(--err); }
.swatch.status-ERROR { background: var(--fail); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }
.legend span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* ---------- Stat tiles ---------- */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.stat-tile:hover { background: var(--card-2); transform: translateY(-1px); }
.stat-tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.stat-tile .num { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat-tile .lbl { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* ---------- Toolbar (brand select + date nav) ---------- */

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 160px; max-width: 100%; }
.date-nav { display: flex; align-items: center; gap: 4px; }
.date-nav strong { font-size: 14px; min-width: 148px; text-align: center; font-weight: 700; }

/* ---------- Month grid ---------- */

.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.grid .dow { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em; padding-bottom: 2px; }
.day-cell {
  border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 96px; padding: 7px;
  background: var(--card); transition: border-color .15s ease;
}
.day-cell.empty { border: none; background: none; }
.day-cell.today { border-color: var(--accent); }
.day-cell .daynum { color: var(--muted-2); font-size: 11px; font-weight: 700; margin-bottom: 5px; }
.day-cell.today .daynum { color: var(--accent-text); }
.post-chip {
  border-radius: 6px; padding: 4px 6px; margin-bottom: 4px; cursor: pointer; font-size: 10.5px;
  line-height: 1.35; font-weight: 600; border-left: 2.5px solid currentColor; transition: transform .1s ease;
}
.post-chip:hover { transform: translateX(1px); }
.post-chip.status-DRAFT { background: var(--border-soft); color: var(--muted); }
.post-chip.status-REVIEW { background: var(--warn-soft); color: var(--warn); }
.post-chip.status-APPROVED, .post-chip.status-SCHEDULED { background: var(--ok-soft); color: var(--ok); }
.post-chip.status-PUBLISHED { background: var(--info-soft); color: var(--info); }
.post-chip.status-REJECTED { background: var(--err-soft); color: var(--err); }
.post-chip.status-ERROR { background: var(--fail-soft); color: var(--fail); }
.more-chip { font-size: 10.5px; color: var(--muted-2); font-weight: 600; padding: 2px 6px; cursor: pointer; }

.month-fallback { display: none; }
@media (max-width: 780px) {
  .grid { display: none; }
  .month-fallback { display: block; }
}

/* ---------- Week view ---------- */

.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-col { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 10px; min-height: 220px; }
.week-col .wh { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.week-col.today { border-color: var(--accent); }
.week-col.today .wh { color: var(--accent-text); }
@media (max-width: 780px) {
  .week-grid { display: flex; flex-direction: column; }
}

/* ---------- Quarter view ---------- */

.quarter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mini-month { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 14px; }
.mini-month h3 { cursor: pointer; margin-bottom: 10px; }
.mini-month h3:hover { color: var(--accent-text); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mini-grid .mdow { font-size: 9px; text-align: center; color: var(--muted-2); font-weight: 700; }
.mini-day {
  aspect-ratio: 1; border-radius: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; color: var(--muted-2); cursor: pointer;
}
.mini-day:hover { background: var(--card-2); }
.mini-day .dots { display: flex; gap: 2px; height: 4px; }
.mini-day .mdot { width: 4px; height: 4px; border-radius: 50%; }

.mini-month.standalone { padding: 10px; }
.mini-month.standalone .mini-grid { gap: 5px; }
.mini-month.standalone .mini-grid .mdow { font-size: 11px; padding-bottom: 3px; }
.mini-month.standalone .mini-day { font-size: 14px; font-weight: 600; border-radius: 8px; }
.mini-month.standalone .mini-day .dots { height: 6px; gap: 3px; }
.mini-month.standalone .mini-day .mdot { width: 6px; height: 6px; }
@media (max-width: 780px) { .quarter-grid { grid-template-columns: 1fr; } }

/* ---------- List / row views ---------- */

.day-group { margin-bottom: 18px; }
.day-group h3 { font-size: 12.5px; border-bottom: 1px solid var(--border-soft); padding-bottom: 8px; margin-bottom: 4px; }
.post-row {
  display: flex; gap: 12px; padding: 11px 6px; border-radius: var(--radius-sm); cursor: pointer; align-items: center;
  transition: background .15s ease;
}
.post-row:hover { background: var(--card-2); }
.post-row img.thumb, .post-row .thumb {
  width: 48px; height: 48px; object-fit: cover; border-radius: 9px; background: var(--card-2); flex-shrink: 0;
  border: 1px solid var(--border-soft);
}
.post-row .meta { flex: 1; min-width: 0; }
.post-row .meta .title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-row .meta .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.rev-commentable {
  cursor: pointer; border-radius: 10px; padding: 8px 10px; margin: 0 -10px 4px;
  box-shadow: 0 0 0 2px var(--accent-soft); transition: box-shadow .15s ease, background .15s ease;
}
.rev-commentable:hover { box-shadow: 0 0 0 2px var(--accent); }
.rev-commentable.has-note { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.rev-commentable img { cursor: pointer; }
.rev-note-box { margin-top: 8px; cursor: default; }
.rev-note-box textarea { min-height: 52px; }

/* ---------- Modal ---------- */

.modal-backdrop {
  /* Bez backdrop-filter (usuniete 2026-08-05). Rozmycie 2px pod scrimem o
     kryciu 0.72 bylo praktycznie niewidoczne, a kosztowalo przerysowywanie
     calej warstwy przy kazdej klatce przewijania modala - tekst drzal. */
  position: fixed; inset: 0; background: rgba(6,7,10,.72); display: flex;
  align-items: flex-end; justify-content: center; z-index: 100; animation: fadein .15s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 720px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--card); border-radius: 18px 18px 0 0; max-width: 640px; width: 100%;
  /* dvh, nie vh: w PWA na iOS wysokosc widoku zmienia sie przy pojawianiu
     klawiatury i paskow systemowych, a 90vh liczone od statycznej wysokosci
     powoduje przeskok ukladu w trakcie przewijania. */
  max-height: 90dvh; overflow-y: auto; padding: 24px; border: 1px solid var(--border); box-shadow: var(--shadow);
  /* Swiadomie BEZ transform: translateZ(0) i contain: paint. Na iOS promowanie
     przewijanego pojemnika z tekstem do wlasnej warstwy daje efekt odwrotny do
     zamierzonego: tekst laduje w teksturze, a przy pedzie przewijania WebKit
     rasteryzuje go od nowa na ulamkowych pozycjach - i wlasnie to migocze.
     Na desktopie zysk byl niewielki, na iOS koszt duzy.
     -webkit-overflow-scrolling: touch tez usuniete - od iOS 13 nic nie robi. */
  /* Bez tego przewijanie na koncu listy przechodzi na strone pod spodem i
     cala zawartosc wizualnie skacze. */
  overscroll-behavior: contain;
}
/* Strona pod spodem nie moze sie przewijac, kiedy otwarta jest nakladka. */
body.modal-open { overflow: hidden; }
@media (min-width: 720px) { .modal { border-radius: 18px; } }
.modal img { max-width: 100%; border-radius: 12px; margin: 10px 0; border: 1px solid var(--border-soft); }
.modal .close {
  float: right; background: var(--card-2); border: 1px solid var(--border); color: var(--muted); font-size: 15px;
  cursor: pointer; width: 30px; height: 30px; border-radius: 50%;
}
/* Wyszukiwarka produktu w modalu posta. Domyslnie widac tylko jedna linie z
   aktualnym produktem (.prod-current wyglada jak dawny <select>); wyszukiwarka
   rozwija sie dopiero po kliknieciu. Panel wchodzi w uklad strony, a nie w
   pozycjonowanie absolutne - modal przewija sie i przycina wszystko, co
   wychodzi poza jego prostokat. */
.prod-current {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); font-size: 15px; font-family: inherit;
  text-align: left; cursor: pointer; line-height: 1.35;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.prod-current:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.prod-current[aria-expanded="true"] { border-color: var(--accent); }
.prod-current[aria-expanded="true"] .prod-caret { transform: rotate(180deg); }
.prod-caret { color: var(--muted); font-size: 12px; flex: none; transition: transform .15s ease; }
.prod-panel {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-2); padding: 8px; margin-top: 6px;
}
.prod-panel .prod-search { margin: 0 0 8px; background: var(--card); }
.prod-list { max-height: 190px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 3px; }
.prod-item {
  text-align: left; width: 100%; padding: 8px 10px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--text);
  font-size: 13.5px; cursor: pointer; line-height: 1.35;
  transition: background .12s ease, border-color .12s ease;
}
@media (hover: hover) { .prod-item:hover { background: var(--border-soft); } }
.prod-item.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.prod-note { padding: 8px 4px 2px; margin: 0; font-size: 12px; }

.meta-ok { color: var(--ok); }
.meta-warn { color: var(--warn); }

/* Wejscie do Dostepow: kafelek na samym dole strony glownej, nie zakladka w
   pasku. Rzecz administracyjna, uzywana rzadko - nie ma zajmowac miejsca w
   nawigacji, ktora na telefonie jest waska. */
.access-entry {
  display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 14px;
  text-align: left; cursor: pointer; font-family: inherit; color: var(--text);
  transition: border-color .15s ease, background .15s ease;
}
.access-entry svg { width: 26px; height: 26px; flex: none; color: var(--muted); }
.access-entry > span:nth-of-type(1) { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.access-entry strong { font-size: 15px; font-weight: 600; }
.access-entry .muted { font-size: 13px; }
.access-entry-arrow { font-size: 22px; color: var(--muted-2); flex: none; }
@media (hover: hover) { .access-entry:hover { border-color: var(--accent); } }

/* Przydzielanie marek kontom operatorskim. Zwykle checkboxy w siatce - lista
   marek jest krotka i ma byc czytelna na raz, bez rozwijania i szukania. */
.access-brands { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; margin: 6px 0 4px; }
.access-brand {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-2);
  font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; text-transform: none;
}
.access-brand input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; margin: 0; }
.access-brand:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.access-status { font-size: 13px; }

.switcher-modal input[type=text] { margin-top: 4px; }
.switcher-results { margin-top: 12px; max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.switcher-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left;
  background: none; border: none; border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer;
  color: var(--text); font-size: 14px; font-weight: 600; font-family: inherit; transition: background .12s ease;
}
.switcher-row:hover { background: var(--card-2); }

.fab {
  position: fixed; right: 20px; bottom: 24px; width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 30;
  box-shadow: 0 8px 22px -6px rgba(144,97,249,.55); transition: transform .12s ease, opacity .12s ease;
  opacity: .8;
}
.fab:hover, .fab:focus, .fab:active { transform: scale(1.06); opacity: 1; }
.fab svg { width: 22px; height: 22px; }
@media (max-width: 880px) {
  .fab { bottom: calc(74px + env(safe-area-inset-bottom)); right: 14px; width: 48px; height: 48px; }
}

.history-item { border-left: 2px solid var(--border); padding: 7px 0 7px 13px; margin-bottom: 3px; font-size: 12.5px; }
.history-item .agent { color: var(--accent-text); font-weight: 700; text-transform: capitalize; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border); padding: 11px 18px; border-radius: 11px;
  font-size: 13.5px; z-index: 200; box-shadow: var(--shadow);
  max-width: min(90vw, 420px); white-space: normal; text-align: center;
}
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 50px 0; font-size: 13.5px; }

/* ---------- Brand settings view ---------- */
.view-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.view-header h2 { font-size: 19px; font-weight: 700; }
.view-header select { width: auto; min-width: 260px; max-width: 100%; margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.settings-grid .card h3 { margin-bottom: 10px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.check-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card-2); font-size: 13px; font-weight: 500;
  color: var(--text); cursor: pointer; margin: 0; width: auto;
}
.check-pill input { width: auto; margin: 0; padding: 0; }
.check-pill.disabled { opacity: .55; cursor: default; }
.check-pill.danger-active { border-color: var(--err); background: var(--err-soft); color: var(--err); }
.tag {
  display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent-text); font-size: 12px; font-weight: 600; margin: 2px 4px 2px 0;
}
.product-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.product-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.product-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--card-2); border: 1px solid var(--border); flex-shrink: 0; }
.chat-box {
  max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border-radius: var(--radius-sm); background: var(--card-2); border: 1px solid var(--border); margin-top: 10px;
}
.chat-msg { font-size: 13.5px; line-height: 1.5; }
.chat-msg.chat-user { color: var(--text); }
.chat-msg.chat-assistant { color: var(--muted); }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row input { margin: 0; flex: 1; }

/* ---------- Home dashboard ---------- */
.mascot-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 26px 20px 22px; margin-bottom: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.mascot-card svg { display: block; cursor: pointer; transform-origin: 50% 100%; }
@keyframes mascot-bounce {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  20% { transform: translateY(-16px) rotate(-9deg) scale(1.04); }
  40% { transform: translateY(0) rotate(7deg) scale(0.98); }
  60% { transform: translateY(-7px) rotate(-4deg) scale(1.02); }
  80% { transform: translateY(0) rotate(2deg) scale(1); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}
.mascot-card svg.bounce { animation: mascot-bounce 0.6s ease; }
.mascot-label { font-weight: 700; font-size: 15px; margin-top: 6px; }
.mascot-caption { color: var(--muted); font-size: 13.5px; max-width: 360px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.dash-tile { text-align: center; padding: 18px 12px; cursor: pointer; transition: transform .12s ease, background .12s ease; }
.dash-tile:hover { background: var(--card-2); transform: translateY(-2px); }
.dash-tile:active { transform: translateY(0); }
.dash-tile.err { border-color: var(--err); box-shadow: 0 0 0 1px var(--err), 0 0 26px -6px var(--err); }
.dash-tile.ok-glow { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok), 0 0 26px -6px var(--ok); }
.dash-num { font-size: 26px; font-weight: 800; margin-bottom: 3px; }
.mini-list { display: flex; flex-direction: column; gap: 6px; }
.mini-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
.mini-row:last-child { border-bottom: none; }

/* Health tile - deliberately the SAME shape as every other dash tile: one
   glyph + one short label. The summary and the rescan button live in the
   details modal (openHealthModal), not here. */
.tile-note { font-size: 11.5px; color: var(--muted); display: block; margin-top: 3px; line-height: 1.35; }
.dash-tile.ok { border-color: var(--ok); }
.dash-tile.warn { border-color: var(--warn); }
