/* ===================== Планёрка — закрытое врачебное сообщество =====================
   Раньше жило внутри index.html (общие правила .team-* среди сотен других
   экранов); здесь — тот же визуальный язык (переменные из tokens.css),
   но в своём файле, который подключает только planerka.html.
*/

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; padding-bottom: 24px; }
[hidden] { display: none !important; }
a { color: inherit; }

.pl-top {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 10px;
}
.pl-back {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.pl-back svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pl-title { font-size: 18px; font-weight: 800; flex: 1; letter-spacing: -.01em; }
.pl-tabs { display: flex; gap: 4px; padding: 0 16px 10px; position: sticky; top: 58px; z-index: 19; background: var(--bg); }
.pl-tab {
  flex: 1; min-height: 38px; border-radius: 999px; border: 1px solid var(--border); background: var(--card);
  color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; position: relative;
}
.pl-tab.on { background: var(--sage); color: #fff; border-color: var(--sage); }
.pl-tab-badge {
  min-width: 16px; height: 16px; border-radius: 999px; background: var(--flag); color: #fff;
  font-size: 10px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.pl-wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 100px; }
.pl-fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 25;
  width: 58px; height: 58px; border-radius: 50%; border: none; background: var(--sage); color: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.22); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.pl-fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.empty-note { padding: 20px 16px; color: var(--muted); font-size: 13.5px; text-align: center; }

/* ---------- Composer ---------- */
.pl-category-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.pl-category-chip {
  font-size: 12px; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  background: var(--subtle); color: var(--muted); border: 1px solid var(--border); font: inherit;
}
.pl-category-chip.active { background: var(--sage); color: var(--card); border-color: var(--sage); }
.pl-input {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 14px; font-family: inherit;
  background: var(--card); color: var(--ink); margin-top: 12px;
}
.pl-compose-wrap { position: relative; margin-top: 10px; }
.pl-compose-wrap textarea { resize: vertical; padding-right: 46px; display: block; }
.pl-photo-btn, .pl-send-btn {
  position: absolute; right: 8px; bottom: 8px; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer; border: none;
}
.pl-photo-btn { background: var(--subtle); color: var(--muted); border: 1px solid var(--border); width: 30px; height: 30px; }
.pl-photo-btn:hover { color: var(--sage-dark); border-color: var(--sage); }
.pl-send-btn { background: var(--sage); color: #fff; }
.pl-send-btn:hover, .pl-send-btn:active { background: var(--sage-dark); }
.pl-photo-btn svg, .pl-send-btn svg { width: 15px; height: 15px; }
.pl-form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.pl-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; }
.pl-card h3 { margin: 0 0 12px; font-size: 16px; }
.pl-photo-preview-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pl-photo-preview-item { position: relative; width: 64px; height: 64px; border-radius: var(--radius-sm); overflow: hidden; }
.pl-photo-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-photo-preview-remove {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: none; font-size: 11px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Composer teaser (Facebook-style "What's on your mind") ---------- */
.pl-composer-teaser {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.pl-composer-teaser-text {
  flex: 1; background: var(--subtle); border-radius: 999px; padding: 10px 16px; color: var(--muted); font-size: 14px;
}

/* ---------- Feed ---------- */
.pl-post-row {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px 6px; margin-bottom: 14px; cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,.06); transition: transform .1s ease, box-shadow .15s ease;
  border-top: 3px solid var(--cat-accent, var(--line));
}
.pl-post-row:active { transform: scale(0.99); box-shadow: none; }
.pl-post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.pl-post-head-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pl-author-link { font-size: 13.5px; font-weight: 700; color: var(--ink); cursor: pointer; }
.pl-author-link:hover { text-decoration: underline; color: var(--sage-dark); }
.pl-post-subtime { font-size: 11px; color: var(--muted); }
.pl-avatar {
  border-radius: 50%; color: #fff; font-weight: 800; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; letter-spacing: -.02em;
  background-size: cover; background-position: center;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--line);
}
.pl-post-title { font-size: 15.5px; font-weight: 700; color: var(--ink); line-height: 1.35; }
.pl-post-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.pl-category-tag {
  font-size: 10.5px; padding: 3px 9px; border-radius: 999px; background: var(--info-bg); color: var(--info-ink);
  white-space: nowrap; flex-shrink: 0; font-weight: 700;
}
.pl-category-tag.pinned { background: var(--clay-soft); color: var(--clay-dark); }
.pl-unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--flag); display: inline-block; margin-right: 5px; }
/* Сетка фото постов в стиле Facebook — во всю ширину карточки (минус
   отступы карточки компенсируются отрицательным margin), без скруглений
   у отдельных плиток, только у общего блока. См. photoGridHtml() в JS. */
.pl-photo-grid { display: grid; gap: 2px; margin: 10px -16px; overflow: hidden; }
.pl-photo-grid img { width: 100%; object-fit: cover; cursor: pointer; display: block; }
.pl-photo-grid.n1 { grid-template-columns: 1fr; }
.pl-photo-grid.n1 img { height: auto; max-height: 420px; }
.pl-photo-grid.n2 { grid-template-columns: 1fr 1fr; }
.pl-photo-grid.n2 img { height: 230px; }
.pl-photo-grid.n3 { grid-template-columns: 1.3fr 1fr; grid-template-rows: 1fr 1fr; height: 280px; }
.pl-photo-grid.n3 img { height: 100%; }
.pl-photo-grid.n3 img:first-child { grid-row: 1 / 3; }
.pl-photo-grid.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; height: 280px; }
.pl-photo-grid.n4 img { height: 100%; }
.pl-photo-more-badge {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff;
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}

.pl-post-menu-btn {
  background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
  padding: 2px 6px; border-radius: 8px; flex-shrink: 0;
}
.pl-post-menu-btn:active { background: var(--subtle); }

/* ---------- Реакции — сводка + Like/Comment (как в Facebook) ---------- */
.pl-reaction-summary {
  display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted);
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.pl-reaction-summary-emoji { font-size: 13px; letter-spacing: -3px; padding-right: 3px; }
.pl-post-actions { display: flex; align-items: stretch; }
.pl-post-action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 4px;
  background: none; border: none; cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 700; color: var(--muted);
  border-radius: 8px;
}
.pl-post-action-btn:active { background: var(--subtle); }
.pl-post-action-btn.mine { color: var(--sage-dark); }
.pl-post-action-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pl-post-action-btn.mine svg { fill: var(--sage-dark); }
.pl-reaction-picker-toggle {
  width: 40px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background: none; border: none;
  cursor: pointer; color: var(--muted); border-radius: 8px;
}
.pl-reaction-picker-toggle:active { background: var(--subtle); }
.pl-reaction-picker-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.pl-reaction-bar { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; flex-wrap: wrap; }
.pl-reaction-btn {
  font-size: 13px; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  background: var(--subtle); border: 1px solid var(--border); color: var(--muted);
}
.pl-reaction-btn.mine { background: var(--sage-soft); border-color: var(--sage); color: var(--sage-dark); font-weight: 700; }
.pl-reaction-count { font-size: 11.5px; color: var(--muted); margin-left: 4px; }

/* ---------- Комментарии — "Нравится" ссылкой, как у Facebook ---------- */
.pl-comment-like-link { font-size: 12px; color: var(--muted); cursor: pointer; font-weight: 700; }
.pl-comment-like-link.mine { color: var(--sage-dark); }
.pl-comment-like-link:hover { text-decoration: underline; }

/* ---------- Case access ---------- */
.case-access-box { background: var(--subtle); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 12px 0; }
.case-access-h { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.case-access-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: 13px; }
.case-access-row + .case-access-row { border-top: 1px solid var(--line); }
.case-access-actions { display: flex; gap: 6px; }
.case-access-actions button { font-size: 11.5px; padding: 5px 10px; }
.case-access-status { font-size: 11.5px; color: var(--muted); }
.case-access-status.approved { color: var(--sage-dark); }
.case-access-status.denied { color: var(--flag); }
.case-access-study { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-top: 8px; font-size: 12.5px; }

/* ---------- Doctors / DM ---------- */
.pl-doctor-row {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 12px 14px; margin-bottom: 8px;
}
.pl-doctor-info { flex: 1; min-width: 0; }
.pl-doctor-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.pl-doctor-specialty { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pl-doctor-write-btn {
  flex-shrink: 0; font-size: 12px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--sage-soft); color: var(--sage-dark); border: 1px solid var(--sage); font: inherit; font-weight: 700;
}
.pl-specialty-select {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--ink); font: inherit; font-size: 13.5px; margin-bottom: 12px;
}
.pl-dm-thread-row {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.pl-dm-thread-info { flex: 1; min-width: 0; }
.pl-dm-thread-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.pl-dm-thread-preview { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-dm-thread-row.unread .pl-dm-thread-name { color: var(--sage-dark); }
.pl-dm-unread-badge {
  flex-shrink: 0; min-width: 18px; height: 18px; border-radius: 999px; background: var(--flag);
  color: #fff; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.pl-dm-thread-view { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; flex-direction: column; }
.pl-dm-thread-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  flex-shrink: 0; background: var(--bg);
}
.pl-dm-thread-header .name { font-size: 15px; font-weight: 700; color: var(--ink); flex: 1; }
.pl-dm-messages { flex: 1; overflow-y: auto; padding: 14px 16px; }
.pl-dm-thread-view .pl-compose-wrap { flex-shrink: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--bg); margin-top: 0; }
.pl-dm-message { max-width: 80%; margin-bottom: 8px; padding: 9px 13px; border-radius: var(--radius-md); font-size: 13.5px; line-height: 1.45; }
.pl-dm-message.mine { background: var(--sage); color: #fff; margin-left: auto; }
.pl-dm-message.theirs { background: var(--subtle); color: var(--ink); }
.pl-dm-message .pl-dm-time { font-size: 10px; opacity: 0.75; margin-top: 3px; display: block; }

/* ---------- Comments ---------- */
.pl-comment-row { padding: 12px 14px; margin-bottom: 8px; font-size: 13.5px; background: var(--subtle); border-radius: var(--radius-md); }
.pl-reply-row { margin: 8px 0 0 22px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--sage-soft); border-radius: var(--radius-sm); }
.pl-comment-head { display: flex; align-items: center; gap: 7px; }
.pl-comment-author { font-weight: 700; font-size: 12.5px; color: var(--ink); }
.pl-comment-time { font-size: 11px; color: var(--muted); margin-left: 6px; }
.pl-comment-body { margin-top: 4px; color: var(--ink); line-height: 1.5; }
.pl-reaction-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.pl-reply-link { font-size: 12px; color: var(--muted); cursor: pointer; font-weight: 700; }
.pl-reply-link:hover { color: var(--sage-dark); text-decoration: underline; }
.pl-reply-box { margin-top: 8px; display: flex; gap: 8px; align-items: flex-start; }
.pl-reply-box textarea {
  flex: 1; box-sizing: border-box; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 12.5px; font-family: inherit; resize: vertical;
  background: var(--card); color: var(--ink);
}
.pl-reply-box button { font-size: 12px; padding: 7px 12px; flex-shrink: 0; }

/* ---------- Истории ---------- */
.pl-stories-bar { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; -webkit-overflow-scrolling: touch; }
.pl-story-item { display: flex; flex-direction: column; align-items: center; gap: 5px; flex-shrink: 0; width: 64px; cursor: pointer; background: none; border: none; font: inherit; }
.pl-story-ring { width: 60px; height: 60px; border-radius: 50%; padding: 2.5px; background: linear-gradient(135deg, #E8A33D, #C25B5B, #8A6FBF); display: flex; align-items: center; justify-content: center; }
.pl-story-ring.seen { background: var(--border); }
.pl-story-ring.add { background: var(--subtle); }
.pl-story-ring-inner { width: 100%; height: 100%; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pl-story-add-plus {
  width: 22px; height: 22px; border-radius: 50%; background: var(--sage); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; line-height: 1;
}
.pl-story-item .pl-story-label { font-size: 11px; color: var(--muted); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-story-item .pl-avatar { width: 100%; height: 100%; font-size: 20px; border-radius: 50%; }

.pl-story-composer-overlay, .pl-story-viewer-overlay {
  position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center;
}
.pl-story-composer-overlay { background: rgba(0,0,0,.5); }
.pl-story-composer { background: var(--card); border-radius: 18px; padding: 18px; width: 92%; max-width: 420px; max-height: 86vh; overflow-y: auto; }
.pl-story-composer-head { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 700; }
#pl-story-photo-preview img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin-top: 10px; display: block; }

.pl-story-viewer-overlay { background: #000; flex-direction: column; }
.pl-story-progress { display: flex; gap: 4px; padding: 10px 12px 0; }
.pl-story-progress i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.3); display: block; overflow: hidden; }
.pl-story-progress i b { display: block; height: 100%; width: 0%; background: #fff; }
.pl-story-progress i.done b { width: 100%; }
.pl-story-viewer-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #fff; }
.pl-story-viewer-head .name { font-size: 14px; font-weight: 700; flex: 1; }
.pl-story-viewer-time { font-size: 12px; opacity: .75; }
.pl-story-viewer-head .pl-back { background: rgba(255,255,255,.15); border-color: transparent; color: #fff; }
.pl-story-viewer-body {
  flex: 1; display: flex; align-items: center; justify-content: center; position: relative;
  color: #fff; text-align: center; padding: 20px; font-size: 20px; line-height: 1.5; overflow: hidden;
}
.pl-story-viewer-body img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.pl-story-viewer-body .pl-story-text-only { position: relative; z-index: 1; max-width: 480px; font-weight: 600; }
.pl-story-viewer-body .pl-story-caption {
  position: absolute; left: 0; right: 0; bottom: 30px; z-index: 1; font-size: 15px;
  background: rgba(0,0,0,.45); padding: 10px 16px; margin: 0 16px; border-radius: 12px;
}

/* ---------- Рилс (на весь экран, поверх шапки и вкладок) ---------- */
.pl-reels-view { position: fixed; inset: 0; z-index: 400; background: #000; }
.pl-reels-view #pl-reels-list { height: 100%; overflow-y: scroll; scroll-snap-type: y mandatory; scroll-behavior: smooth; }
.pl-reel-item { position: relative; height: 100%; width: 100%; scroll-snap-align: start; scroll-snap-stop: always; background: #000; overflow: hidden; }
.pl-reel-item video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.pl-reel-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 16px 70px calc(20px + env(safe-area-inset-bottom, 0px)) 16px;
  background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff;
}
.pl-reel-overlay .pl-author-link { color: #fff; font-weight: 700; font-size: 14px; }
.pl-reel-caption { font-size: 13.5px; margin-top: 6px; line-height: 1.45; white-space: pre-wrap; }
.pl-reel-side-actions { position: absolute; right: 10px; bottom: 90px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.pl-reel-action {
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: #fff; background: none; border: none;
  cursor: pointer; font-size: 11px; font-weight: 700;
}
.pl-reel-action svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; filter: drop-shadow(0 1px 3px rgba(0,0,0,.5)); }
.pl-reel-action.reacted svg { fill: #E8536A; stroke: #E8536A; }
.pl-reel-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 24px;
  background: linear-gradient(rgba(0,0,0,.55), transparent);
}
.pl-reel-topbar-left { display: flex; align-items: center; gap: 8px; }
.pl-reel-topbar button {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.4); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.pl-reel-topbar svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pl-reel-mute {
  position: absolute; top: calc(58px + env(safe-area-inset-top, 0px)); right: 14px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,.4); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
}
.pl-reel-mute svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.pl-reels-empty { color: #fff; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; }
