:root {
  --border: #e5e5e5;
  --text: #0f1419;
  --muted: #8e8e8e;
  --accent: #0095f6;
  --liked: #ff3040;
  --bg: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* ── Шапка (как в Threads: логотип по центру, минимум хрома) ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.tabs { display: flex; gap: 4px; margin-left: auto; margin-right: auto; }
.tab {
  border: 0; background: none; padding: 16px 20px 12px;
  font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.iconbtn {
  border: 0; background: none; font-size: 20px; cursor: pointer;
  color: var(--text); padding: 6px; border-radius: 8px;
}
.iconbtn:hover { background: #f2f2f2; }
#refreshBtn { margin-left: auto; }
#refreshBtn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Плашка «N новых» (Т11): лента сама не обновляется ── */
.pill {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 60; background: var(--text); color: #fff;
  padding: 8px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.18);
}

/* ── Лента ── */
.view { max-width: 640px; margin: 0 auto; }
@media (min-width: 768px) {
  #view-feed { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

.geobar {
  display: block; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--border); background: none;
  padding: 10px 16px; font-size: 14px; color: var(--muted); cursor: pointer;
}
.geopanel {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fafafa;
}
.geopanel select, .composer select, .modal-card input {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 14px; background: #fff;
}

.btn {
  border: 0; border-radius: 999px; padding: 8px 18px;
  background: var(--text); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .35; cursor: default; }
.btn.light { background: #f2f2f2; color: var(--text); }
.btn.wide { width: 100%; margin-top: 12px; padding: 12px; }

/* ── Композер ── */
.composer { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: #efefef; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #666; text-transform: uppercase;
}
.composer-body { flex: 1; }
.composer textarea {
  width: 100%; border: 0; resize: none; outline: none;
  font: inherit; font-size: 15px; line-height: 1.4; padding: 8px 0;
}
.composer-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.media-preview { display: flex; gap: 8px; flex-wrap: wrap; }
.media-preview img, .media-preview video { height: 64px; max-width: 120px; object-fit: cover; border-radius: 8px; }

/* ── Пост ── */
.post { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.post-main { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: baseline; gap: 8px; }
.post-nick { font-weight: 700; font-size: 14px; }
.post-time { color: var(--muted); font-size: 13px; }
.post-geo { margin-left: auto; color: var(--muted); font-size: 12px; }
.post-tools { display: inline-flex; gap: 2px; margin-left: 6px; }
.tool {
  border: 0; background: none; cursor: pointer; font-size: 13px;
  color: var(--muted); padding: 2px 4px; border-radius: 6px;
}
.tool:hover { background: #f2f2f2; color: var(--text); }
.cmt-tools { margin-left: 8px; }
.editarea {
  width: 100%; min-height: 90px; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; font: inherit; font-size: 15px; margin-top: 6px;
}
.editrow { display: flex; gap: 8px; margin-top: 8px; }
.post-text { font-size: 15px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; margin: 4px 0 0; }
.post-media img, .post-media video { max-width: 100%; border-radius: 12px; margin-top: 10px; max-height: 420px; }

.actions { display: flex; gap: 20px; margin-top: 10px; }
.action {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--muted); font-size: 13px;
}
.action:hover { color: var(--text); }
.action svg { width: 19px; height: 19px; }
.action.liked { color: var(--liked); }

.comments { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.comment { font-size: 14px; margin: 6px 0; }
.comment b { margin-right: 6px; }
.comment-media img, .comment-media video {
  display: block; max-width: 100%; max-height: 320px;
  border-radius: 10px; margin-top: 8px;
}
.comment-form { margin-top: 8px; }
.comment-preview:not(:empty) { margin-bottom: 8px; }
.comment-input { display: flex; align-items: center; gap: 8px; }
.comment-input input[type="text"] {
  flex: 1; min-width: 0; border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; font-size: 14px;
}
.comment-attach { flex-shrink: 0; font-size: 17px; padding: 4px; }
.comment-attach:disabled { opacity: .35; cursor: default; }
.feedend { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── Карта (Т7/Т9): десктоп — карта + список, мобильный — вся карта ── */
#view-map { max-width: 1100px; }
.mapwrap { display: flex; height: calc(100dvh - 56px); }
#map { flex: 1; z-index: 1; }
.maplist {
  width: 340px; overflow-y: auto; border-left: 1px solid var(--border); display: none;
}
.maplist-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.maplist-item:hover { background: #fafafa; }
.maplist-item .n { font-weight: 600; font-size: 13px; }
.maplist-item .e { font-size: 14px; margin: 4px 0; }
.maplist-item .c { font-size: 12px; color: var(--muted); }
.maprefresh { position: absolute; right: 24px; bottom: 90px; z-index: 60; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.mk {
  background: var(--text); color: #fff; border-radius: 999px;
  min-width: 28px; height: 28px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

/* ── Нижняя навигация (мобильная) ── */
.bottomnav { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(255,255,255,.98); display: flex; align-items: center; justify-content: center;
}
.modal-card { width: 340px; max-width: 92vw; text-align: center; }
.modal-card h1 { margin-bottom: 4px; }
.modal-card input#nickInput { width: 100%; margin: 16px 0 8px; padding: 12px; }
.consent { display: block; text-align: left; font-size: 13px; color: #444; margin: 8px 0; }

/* ── Адаптивность: планшет и десктоп ── */
@media (min-width: 768px) {
  .maplist { display: block; }
  .maprefresh { bottom: 24px; }
}

/* ── Адаптивность: мобильный ── */
@media (max-width: 767px) {
  .tabs { display: none; }
  body { padding-bottom: 56px; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
    background: #fff; border-top: 1px solid var(--border);
  }
  .bottomnav button {
    flex: 1; border: 0; background: none; padding: 14px;
    font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  }
  .bottomnav button.active { color: var(--text); }
  .mapwrap { height: calc(100dvh - 112px); }
}
