:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --text: #1f1b16;
  --muted: #6f665c;
  --line: #e7e0d6;
  --accent: #b23a2b;
  --accent-ink: #ffffff;
  --done: #2f7d4f;
  --warn: #c27a12;
  --off: #9a9187;
  --shadow: 0 8px 28px rgba(40, 25, 10, .18);
  --radius: 14px;
  --panel-w: 380px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f; --surface: #221e18; --text: #f1ebe2; --muted: #a89e92; --line: #39322a;
    --accent: #e0644f; --done: #4fb07a; --warn: #e3a240; --off: #7b7268;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17140f; --surface: #221e18; --text: #f1ebe2; --muted: #a89e92; --line: #39322a;
  --accent: #e0644f; --done: #4fb07a; --warn: #e3a240; --off: #7b7268;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow: hidden;
}
#map { position: fixed; inset: 0; background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- панель ---------- */
.panel {
  position: fixed; z-index: 1000; background: var(--surface);
  display: flex; flex-direction: column; box-shadow: var(--shadow);
  left: 12px; top: 12px; bottom: 12px; width: var(--panel-w); border-radius: var(--radius);
}
.grip { display: none; }
.head { padding: 14px 16px 8px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-size: 19px; margin: 0; letter-spacing: -.01em; }
.icon-btn {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%;
  font-size: 20px; line-height: 1; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--line); }
.progress { margin-top: 10px; }
.progress-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--done); border-radius: 99px; transition: width .4s; }
.progress-text { margin-top: 6px; font-size: 13px; color: var(--muted); }
.progress-text b { color: var(--text); }

.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tab {
  border: 0; background: none; padding: 10px 12px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--text); border-color: var(--accent); }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 12px;
  background: var(--accent); color: var(--accent-ink); text-align: center;
}
.badge:empty { display: none; }

.view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.controls { padding: 10px 16px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
input[type="search"] {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: 99px;
  padding: 4px 11px; font-size: 13px; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; padding-top: 4px; }
.toggles label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.link-btn.danger { color: var(--muted); }

.list { list-style: none; margin: 0; padding: 4px 8px 16px; }
.item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 8px; border-radius: 10px; cursor: pointer;
}
.item:hover, .item:focus-visible { background: var(--bg); outline: none; }
.item .dot { margin-top: 3px; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 600; }
.item-sub { font-size: 13px; color: var(--muted); }
.item-dist { font-size: 12px; color: var(--muted); white-space: nowrap; margin-top: 2px; }
.item.done .item-name { color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: 1px; font-weight: 600; }
.tag.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.off { background: color-mix(in srgb, var(--off) 20%, transparent); color: var(--off); }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }

.dot {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.dot.done { background: var(--done); }
.dot.moved { background: var(--warn); }
.dot.off { background: var(--off); }
.dot.extra { background: #6a5acd; }

.hint { padding: 14px 16px 0; color: var(--muted); font-size: 14px; margin: 0; }
.plan-list .item { cursor: default; align-items: center; }
.plan-list .num {
  flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--text); color: var(--surface);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.plan-list .row-btns { display: flex; gap: 2px; }
.plan-list .row-btns .icon-btn { width: 30px; height: 30px; font-size: 15px; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 20px; align-items: center; }

.btn {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 14px;
  font-weight: 600; text-align: center; display: inline-block; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.success { background: var(--done); border-color: var(--done); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- карточка точки ---------- */
.sheet {
  position: fixed; z-index: 1100; background: var(--surface); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 18px 18px 16px;
  left: calc(var(--panel-w) + 24px); top: 12px; width: 360px; max-height: calc(100% - 24px); overflow-y: auto;
}
.sheet .close { position: absolute; top: 10px; right: 10px; font-size: 16px; }
.sheet h2 { font-size: 18px; margin: 0 34px 4px 0; }
.sheet .addr { color: var(--muted); margin: 0 0 12px; }
.sheet dl { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 14px; }
.sheet dt { color: var(--muted); }
.sheet dd { margin: 0; }
.notice {
  font-size: 14px; padding: 8px 10px; border-radius: 10px; margin: 0 0 12px;
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .wide { grid-column: 1 / -1; }
.stamp-meta { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.stamp-meta input[type="date"] { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 2px 6px; }
.sources { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- маркеры ---------- */
.pin { background: none; border: 0; padding: 0; cursor: pointer; display: block; }
.pin .dot { width: 26px; height: 26px; font-size: 13px; transition: transform .15s; }
.pin.sel .dot { transform: scale(1.35); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2a7de1; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(42,125,225,.25); }
.maplibregl-map { font: inherit; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-group { background: var(--surface) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted); }
.maplibregl-ctrl-group button { filter: none; }
:root[data-theme="dark"] .maplibregl-ctrl-group button span { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .maplibregl-ctrl-group button span { filter: invert(1); } }
.maplibregl-ctrl-top-right { top: env(safe-area-inset-top); }


/* ---------- меню, тост ---------- */
dialog {
  border: 0; border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); width: min(420px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.35); }
.menu { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.menu h2 { font-size: 16px; margin: 6px 0 0; }
.menu p { margin: 0; }
.file-btn { cursor: pointer; }
.toast {
  position: fixed; z-index: 1300; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--surface); padding: 9px 16px; border-radius: 99px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  .panel {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 18px 18px 0 0;
    height: 46%; transition: height .25s ease; padding-bottom: env(safe-area-inset-bottom);
  }
  .panel[data-state="min"] { height: 132px; }
  .panel[data-state="full"] { height: calc(100% - 56px); }
  .grip {
    display: block; border: 0; background: none; height: 22px; width: 100%; flex: none; padding: 0;
    position: relative;
  }
  .grip::after {
    content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 5px; margin-left: -20px;
    border-radius: 3px; background: var(--line);
  }
  .head { padding-top: 0; }
  .sheet {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 18px 18px 0 0;
    max-height: 75%; padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* ---------- v2: коллекции, блокнот, аккаунт ---------- */
.head-btns { display: flex; align-items: center; gap: 4px; }
.account-btn {
  border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 4px 12px;
  font-size: 13px; font-weight: 600; min-width: 34px; height: 32px;
}
.account-btn.in { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 32px; padding: 0; }
.account-btn.busy { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.collection-row { display: flex; align-items: center; gap: 2px; margin-top: 8px; }
.collection-row .icon-btn { font-size: 16px; flex: none; }
.collection-select {
  flex: 1; min-width: 0; font: inherit; font-weight: 600; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px;
}
.dot.custom { background: #2b7a8c; }
.add-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 8px 10px; }
body.picking #map, body.picking .maplibregl-canvas-container { cursor: crosshair; }

.book { list-style: none; margin: 0; padding: 12px 12px 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { cursor: pointer; border-radius: 12px; outline: none; }
.card:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.thumb {
  aspect-ratio: 3 / 4; border-radius: 10px; background: var(--bg) center / cover no-repeat;
  border: 1px solid var(--line); display: grid; place-items: center;
}
.thumb .dot { width: 40px; height: 40px; font-size: 20px; }
.card-name { font-size: 13px; font-weight: 600; margin-top: 6px; line-height: 1.25; }
.card-date { font-size: 12px; color: var(--muted); }

.stamp-box { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.photo-slot img { width: 100%; max-height: 42vh; object-fit: contain; background: var(--bg); border-radius: 10px; display: block; margin-bottom: 4px; }
.photo-add { width: 100%; cursor: pointer; }
.stamp-box textarea, .point-form input, .point-form textarea, .point-form select, .report select, .report textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 8px;
}
.point-form { display: flex; flex-direction: column; gap: 10px; }
.point-form label { font-size: 13px; color: var(--muted); }
.point-form label input, .point-form label textarea, .point-form label select { margin-top: 4px; }
.point-form label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 14px; }
.point-form label.check input { width: auto; margin: 2px 0 0; }
.slug-row { display: flex; align-items: center; gap: 4px; }
.slug-row input { margin-top: 0 !important; }
.profile-link { font-size: 13px; word-break: break-all; }
.report { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.tg-box { min-height: 40px; }
#account .menu { gap: 8px; }
#account h2 { font-size: 18px; margin: 0 0 4px; }

/* ---------- часы работы ---------- */
.tag.ok { background: color-mix(in srgb, var(--done) 16%, transparent); color: var(--done); }
.open-now { color: var(--done); }
.closed-now { color: var(--accent); }
.hours summary { cursor: pointer; list-style: none; }
.hours summary::-webkit-details-marker { display: none; }
.hours summary::after { content: " ▾"; color: var(--muted); font-size: 12px; }
.hours[open] summary::after { content: " ▴"; }
.hours table { border-collapse: collapse; margin: 6px 0 4px; font-size: 13px; }
.hours td { padding: 2px 12px 2px 0; }
.hours tr.today td { font-weight: 700; }
.item-warn { font-size: 12px; color: var(--warn); margin-top: 2px; }
