:root {
  --bg: #0a1820;
  --surface: #10232d;
  --surface-2: #163140;
  --line: #21414f;
  --text: #eef3ef;
  --muted: #8ea7ab;
  --accent: #ff7a3d;
  --accent-ink: #1c0d04;
  --mint: #7fd1b9;
  --danger: #ff6b6b;
  --radius: 18px;
  --tabbar: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 500px at 80% -10%, #12313d 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }

/* Viršutinė juosta */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 10px) 18px 10px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 19px; letter-spacing: -0.01em; color: var(--text); }
.brand svg { width: 28px; height: 28px; color: var(--muted); }
.brand b { color: var(--accent); font-weight: 800; }

main { max-width: 560px; margin: 0 auto; padding: 0 14px calc(var(--tabbar) + var(--safe-b) + 24px); }
.view { display: none; }
.view.active { display: block; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* Apatinis meniu */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b)); z-index: 1000;
  display: flex; align-items: center; gap: 4px;
  padding: 6px; border-radius: 26px;
  background: rgba(16, 35, 45, .92); backdrop-filter: blur(14px);
  border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(0,0,0,.45);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 74px; padding: 7px 8px; border-radius: 20px;
  color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--text); background: var(--surface-2); }
.tabbar .tab-add {
  min-width: 56px; height: 56px; margin: 0 4px; justify-content: center;
  background: var(--accent); color: var(--accent-ink); border-radius: 50%;
  box-shadow: 0 6px 18px rgba(255, 122, 61, .4);
}
.tabbar .tab-add svg { width: 28px; height: 28px; stroke-width: 2.6; }
.tabbar .tab-add.active { background: var(--accent); color: var(--accent-ink); }

/* Kortelės */
.list { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
  background: linear-gradient(140deg, var(--mint), #3c8e8a); color: #062019;
}
.who { font-weight: 700; }
.where { color: var(--muted); font-size: 13.5px; }
.card-head .grow { flex: 1; min-width: 0; }
.card-head .where { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 6px 8px; border-radius: 10px; cursor: pointer; font-size: 20px; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); }
.photo { aspect-ratio: 4 / 5; background: #0d1d25; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 12px 14px 14px; }
.title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.title-row h3 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.tag.release { background: rgba(127, 209, 185, .14); color: var(--mint); }
.measures { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.measure { background: var(--surface-2); border-radius: 12px; padding: 6px 12px; color: var(--muted); font-size: 14px; }
.measure b { color: var(--text); font-size: 18px; font-weight: 800; margin-right: 2px; }
.meta { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.note { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 99px;
  padding: 7px 13px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text);
}
.chip svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.chip.on { color: var(--accent); border-color: rgba(255,122,61,.4); }
.chip.on svg { fill: currentColor; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 20px; margin: 0 0 14px; }
.more { display: block; margin: 4px auto 0; }
.loader { text-align: center; color: var(--muted); padding: 30px; }

/* Mygtukai */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 14px; padding: 11px 18px; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 11px; }
.btn.big { width: 100%; padding: 15px; font-size: 17px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.danger { color: var(--danger); }

/* Forma */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-title { margin: 4px 0 0; font-size: 26px; letter-spacing: -0.02em; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; border: 0; margin: 0; padding: 0; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field.narrow { flex: 0 0 150px; }
.row { display: flex; gap: 12px; }
input:not([type=radio]):not([type=checkbox]), select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 12px 13px; outline: none; font-size: 16px;
}
input:focus, select:focus, textarea:focus { border-color: var(--mint); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
input[type=date] { color-scheme: dark; }
textarea { resize: vertical; }
.help { color: var(--muted); font-size: 13px; }

.photo-pick {
  position: relative; display: grid; place-items: center; cursor: pointer;
  aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden;
  border: 2px dashed var(--line); background: var(--surface);
}
.photo-pick.has { border-style: solid; aspect-ratio: 4 / 5; }
.photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-hint { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.photo-hint svg { width: 44px; height: 44px; color: var(--accent); }
.photo-hint b { color: var(--text); font-size: 17px; }

.pick-map { height: 220px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.pick-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick-actions small { color: var(--muted); }

.segmented { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 4px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 8px 4px; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; text-transform: none; letter-spacing: 0; font-size: 15px; }
.segmented input:checked + span { background: var(--surface-2); color: var(--text); }
.segmented input:focus-visible + span { outline: 2px solid var(--mint); }

.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.toggle input { position: absolute; opacity: 0; }
.switch { width: 46px; height: 28px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text); transition: transform .2s; }
.toggle input:checked + .switch { background: var(--mint); }
.toggle input:checked + .switch::after { transform: translateX(18px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--mint); outline-offset: 2px; }

/* Prisijungimas */
.auth { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 18px; margin-top: 10px; }
.auth h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.auth p { margin: 0 0 18px; color: var(--muted); }
.auth .form { gap: 12px; }
.auth .switch-link { background: none; border: 0; color: var(--mint); font-weight: 600; cursor: pointer; padding: 6px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1em; margin: 0; }

/* Profilis */
.profile-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.profile-head .avatar { width: 62px; height: 62px; font-size: 26px; }
.profile-head h2 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.profile-head .where { margin-top: 2px; }
.profile-head .grow { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.best { display: flex; align-items: center; gap: 12px; background: linear-gradient(120deg, rgba(255,122,61,.16), rgba(255,122,61,.04)); border: 1px solid rgba(255,122,61,.35); border-radius: 14px; padding: 12px 14px; margin-bottom: 18px; }
.best img { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; }
.best small { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: 11.5px; }
.best div b { display: block; font-size: 17px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 10px; }

/* Žemėlapis */
.view-map.active { position: fixed; inset: 0; z-index: 10; animation: none; }
#map { position: absolute; inset: 0; background: #0d1d25; }
.map-legend {
  position: absolute; z-index: 500; top: calc(var(--safe-t) + 62px); right: 12px;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(16,35,45,.9); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 11px; font-size: 12.5px; color: var(--muted);
}
.map-legend span { display: flex; align-items: center; gap: 7px; }
.map-legend .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.map-legend .ring { width: 13px; height: 13px; border-radius: 50%; background: rgba(255,122,61,.3); border: 1px solid var(--accent); }
body.on-map .topbar { position: fixed; left: 0; right: 0; z-index: 600; background: linear-gradient(rgba(10,24,32,.96) 55%, transparent); padding-bottom: 22px; pointer-events: none; }
body.on-map .topbar a { pointer-events: auto; }
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.leaflet-popup-content { margin: 10px; width: 200px !important; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.pop img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; display: block; }
.pop b { display: block; font-size: 16px; margin-top: 8px; }
.pop span { color: var(--muted); font-size: 13px; }
.pop a { color: var(--mint); font-weight: 600; }
.leaflet-control-attribution { background: rgba(10,24,32,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--mint) !important; }
#map .leaflet-bottom { bottom: calc(var(--tabbar) + var(--safe-b) + 14px); }

/* Pranešimas */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-b) + 28px); z-index: 2000;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 600;
  padding: 11px 18px; border-radius: 14px; max-width: calc(100% - 40px); text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .tabbar a { min-width: 62px; }
  .row { flex-direction: column; }
  .field.narrow { flex: 1; }
}
