/* ===========================================================
   Project H.L.E.B. — dark wine theme
   =========================================================== */
:root {
  --bg:        #140a0e;   /* near-black with a wine undertone */
  --bg-soft:   #1d0f14;
  --surface:   #251218;
  --surface-2: #2f161e;
  --line:      #3d1d27;
  --wine:      #7b1e2b;   /* primary bordeaux */
  --wine-soft: #9c2b3b;
  --wine-glow: rgba(156, 43, 59, 0.35);
  --rose:      #c46b78;
  --gold:      #c9a36a;
  --text:      #f3e8ea;
  --muted:     #b08e96;
  --faint:     #7c6168;
  --good:      #5fa777;
  --warn:      #d98a3d;
  --bad:       #c0455a;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 8px 30px rgba(0,0,0,.45);
  --font:      "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: .1px;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  background: radial-gradient(120% 90% at 50% 0%, #2a1118 0%, var(--bg) 70%);
  z-index: 100;
}
.splash-logo { font-size: 64px; animation: float 3s ease-in-out infinite; }
.splash-title { font-family: var(--font-display); font-size: 44px; font-weight: 700; letter-spacing: 6px; color: var(--rose); }
.splash-sub { font-size: 12px; color: var(--faint); letter-spacing: 1px; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 18px 12px;
  background: linear-gradient(180deg, var(--bg-soft), rgba(20,10,14,.85));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.topbar-right { width: 12px; height: 12px; }
.presence-on  { background: var(--good); border-radius: 50%; box-shadow: 0 0 10px var(--good); }
.presence-off { background: var(--faint); border-radius: 50%; opacity: .5; }

.app {
  padding: 16px 16px calc(96px + var(--safe-bottom));
  max-width: 640px; margin: 0 auto;
  animation: fade .25s ease;
}
@keyframes fade { from{opacity:0; transform:translateY(6px)} to{opacity:1; transform:none} }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: linear-gradient(0deg, var(--bg-soft), rgba(29,15,20,.9));
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  background: none; border: none; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0; font-size: 10px; cursor: pointer;
  transition: color .2s, transform .15s;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--rose); }
.tab.active span { transform: scale(1.15); filter: drop-shadow(0 0 8px var(--wine-glow)); }
.tab:active { transform: scale(.92); }

/* ---------- Cards & sections ---------- */
.card {
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--faint); margin: 22px 4px 10px;
}
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: .3px; }
h3 { margin: 0; font-size: 15px; font-weight: 700; }
.topbar-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }

/* cover uploader */
.cover-pick { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.cover-preview { width: 60px; height: 82px; border-radius: 8px; object-fit: cover; background: var(--surface-2);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 24px; flex: 0 0 auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--wine); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .12s, background .2s, box-shadow .2s;
}
.btn:active { transform: scale(.96); }
.btn:hover { background: var(--wine-soft); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.gold { background: linear-gradient(135deg, var(--gold), #a9824f); color: #1a0e08; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
}
.pill.wine { background: var(--wine-glow); color: var(--rose); border-color: var(--wine); }

/* ---------- Forms ---------- */
input, select, textarea {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; font-size: 15px; font-family: inherit;
  margin-bottom: 10px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--wine-soft); box-shadow: 0 0 0 3px var(--wine-glow);
}
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }

/* ---------- Mood / resource ---------- */
.resource-bar { height: 12px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.resource-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }
.mood-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 8px; }
.mood-btn {
  font-size: 26px; padding: 10px 0; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: .15s;
}
.mood-btn.sel { border-color: var(--wine-soft); background: var(--wine-glow); transform: scale(1.05); }
.slider { -webkit-appearance: none; height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, var(--bad), var(--warn), var(--good)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; border: 3px solid var(--wine); cursor: pointer; }

/* ping buttons */
.ping-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.ping-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 14px; cursor: pointer; color: var(--text); font-size: 13px; transition:.15s;
}
.ping-btn span { font-size: 28px; }
.ping-btn:active { transform: scale(.95); border-color: var(--wine-soft); }

/* ---------- List items ---------- */
.item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item-cover { width: 52px; height: 70px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: 0 0 auto; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 600; margin-bottom: 3px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 18px; cursor: pointer; }

/* progress */
.mini-bar { height: 7px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.mini-bar > div { height: 100%; background: linear-gradient(90deg, var(--wine), var(--rose)); }

/* photos */
.photo-row { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0; }
.photo-row img { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; }

/* ---------- Map ---------- */
/* position+z-index makes #map its own stacking context, so Leaflet's high
   internal z-indexes can't paint over modals/toasts (which sit above). */
#map { height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); position: relative; z-index: 0; }
.leaflet-container { background: #e8e2dc; }
/* Кастомные цветные пины-капельки по категории места */
.hleb-pin-wrap { background: none; border: none; }
.hleb-pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.hleb-pin span { transform: rotate(45deg); font-size: 16px; line-height: 1; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.map-legend .pill { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Canvas ---------- */
.canvas-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-soft); }
#draw { display: block; width: 100%; touch-action: none; background: #faf3ec; }
.color-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #00000022; cursor: pointer; }
.swatch.sel { box-shadow: 0 0 0 3px var(--wine-glow); }

/* ---------- Radio ---------- */
.radio-card { display: flex; gap: 14px; align-items: center; }
.radio-art { width: 64px; height: 64px; border-radius: 12px; background: var(--surface-2); object-fit: cover; }
.equalizer { display: inline-flex; gap: 3px; align-items: flex-end; height: 16px; }
.equalizer i { width: 3px; background: var(--rose); animation: eq 1s ease-in-out infinite; }
.equalizer i:nth-child(2){animation-delay:.2s} .equalizer i:nth-child(3){animation-delay:.4s} .equalizer i:nth-child(4){animation-delay:.1s}
@keyframes eq { 0%,100%{height:4px} 50%{height:16px} }

/* ---------- Dice ---------- */
.dice { font-size: 80px; text-align: center; padding: 20px; animation: roll .6s ease; }
@keyframes roll { from{transform: rotate(-25deg) scale(.6); opacity:.2} to{transform:none; opacity:1} }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(110px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); color: var(--text);
  padding: 12px 18px; border-radius: 12px; border: 1px solid var(--wine);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 2100; max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,3,5,.7); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 2000;
  animation: fade .2s ease;
}
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; width: 100%; max-width: 640px;
  padding: 20px 18px calc(20px + var(--safe-bottom)); box-shadow: var(--shadow);
  animation: slideup .3s cubic-bezier(.2,.8,.2,1); max-height: 88vh; overflow-y: auto;
}
@keyframes slideup { from{transform:translateY(100%)} to{transform:none} }
.modal h3 { margin-bottom: 14px; font-size: 18px; }
.modal-handle { width: 40px; height: 4px; background: var(--line); border-radius: 999px; margin: 0 auto 14px; }

/* gallery */
.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.gallery-cell { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--surface-2); }
.gallery-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-tag { position: absolute; left: 4px; bottom: 4px; font-size: 9px; padding: 2px 6px; border-radius: 999px;
  background: rgba(8,3,5,.65); color: var(--text); backdrop-filter: blur(2px); }

/* loader — анимация загрузки разделов */
.loader { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 10px; }
.loader-glass { font-size: 38px; animation: swirl 1.1s ease-in-out infinite; filter: drop-shadow(0 0 12px var(--wine-glow)); }
@keyframes swirl { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-6px) rotate(6deg); } }

/* image uploader (желания/свидания) */
.up-pick { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.up-preview { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface-2);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 24px; flex: 0 0 auto; }
.plan-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; cursor: pointer; }

/* gallery fade-in (поэтапное появление) */
.fade-img { opacity: 0; transform: scale(.95); transition: opacity .45s ease, transform .45s ease; }
.fade-img.in { opacity: 1; transform: none; }

/* canvas fullscreen */
.canvas-wrap.fs { position: fixed; inset: 0; z-index: 2500; border-radius: 0; border: none;
  background: #120a0e;  /* тёмная подложка, чтобы белый холст имел видимые границы */
  display: flex; align-items: center; justify-content: center; padding: 12px; }
.canvas-wrap.fs #draw { width: auto; height: auto; max-width: 100%; max-height: 100%;
  border-radius: 8px; box-shadow: 0 0 0 1px var(--line), 0 10px 40px rgba(0,0,0,.6); }
.fs-exit { position: fixed; top: calc(12px + var(--safe-top)); right: 14px; z-index: 2600;
  width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--wine); color: #fff;
  font-size: 20px; cursor: pointer; box-shadow: var(--shadow); }
/* плавающая панель инструментов в полноэкранном режиме */
.fs-bar { position: fixed; left: 50%; bottom: calc(16px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 2600; background: rgba(20,10,14,.92); border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; backdrop-filter: blur(8px);
  max-width: 94vw; box-shadow: var(--shadow); }
.fs-colors { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.fs-bar-row { display: flex; gap: 10px; align-items: center; justify-content: center; }

.empty { text-align: center; color: var(--faint); padding: 30px 10px; }
.empty .e-emoji { font-size: 40px; display: block; margin-bottom: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.center { text-align: center; }
.mt { margin-top: 14px; }
a { color: var(--rose); }
