* { box-sizing: border-box; }

:root {
  --accent: #e8842c;
  --ink: #26221c;
  --muted: #8a8378;
  --panel-bg: #ffffff;
  --card-border: #eee7dc;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

#map {
  position: absolute;
  inset: 0;
}

#hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.8);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  pointer-events: none;
  z-index: 5;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* ---------- лента: базово мобильная шторка ---------- */

#panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  transition: height 0.25s ease;
}

#panel.peek { height: 64px; }
#panel.peek #feed { display: none; }
#panel.half { height: 50vh; }

#panel-handle {
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  flex-shrink: 0;
}

#panel-handle .grip {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #d8d2c8;
}

#feed-count {
  font-size: 14px;
  font-weight: 600;
}

#feed {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 12px 12px;
  flex: 1;
}

/* атрибуция и нижние контролы карты над peek-шторкой */
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right { bottom: 64px; }

.card {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
}

.card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.card-text {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-time {
  font-size: 12px;
  color: var(--muted);
}

.standby {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 4px 12px;
  cursor: pointer;
}

.standby:hover { border-color: var(--accent); }

.standby.stood {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}

/* ---------- пульс выбранной точки ---------- */

.pulse {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(232, 132, 44, 0.5);
  position: relative;
}

.pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* ---------- форма: базово над peek-шторкой ---------- */

#compose {
  position: absolute;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  padding: 12px;
  z-index: 20;
}

#compose.hidden { display: none; }

#compose-text {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 15px;
}

.compose-note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.compose-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#char-counter {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#char-counter.over {
  color: #d33;
  font-weight: 700;
}

.compose-actions {
  display: flex;
  gap: 8px;
}

.compose-actions button {
  font: inherit;
  font-size: 14px;
  border-radius: 18px;
  padding: 6px 16px;
  cursor: pointer;
  border: 1px solid #ccc;
  background: #fff;
}

#compose-submit {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#compose-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- десктоп: сайдбар слева ---------- */

@media (min-width: 769px) {
  #panel,
  #panel.peek,
  #panel.half {
    top: 0;
    left: 0;
    right: auto;
    bottom: 0;
    width: 380px;
    height: auto;
    border-radius: 0;
    border-right: 1px solid var(--card-border);
    box-shadow: none;
    transition: none;
  }
  #panel.peek #feed { display: block; }
  #panel-handle { cursor: default; pointer-events: none; }
  #panel-handle .grip { display: none; }

  #map { left: 380px; }
  #hint { left: calc(50% + 190px); }

  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right { bottom: 0; }

  #compose {
    bottom: 24px;
    left: calc(50% + 190px);
    width: min(440px, calc(100vw - 380px - 32px));
  }
}
