/* Веб-версия Inventory — оформление. Светлая и тёмная темы по настройке системы. */

:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --pane: #ffffff;
  --pane-2: #f9fafb;
  --line: #e3e5e8;
  --text: #1c1e21;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --pane: #1a1d21;
    --pane-2: #202428;
    --line: #2c3137;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --accent: #60a5fa;
    --accent-soft: #1e3a5f;
    --danger: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

/* Заслонка до заставки «Контур»: закрывает страницу, пока не начнётся анимация */
.splash-cover { position: fixed; inset: 0; z-index: 2147482000; background: var(--bg); }
html[data-splash="off"] .splash-cover, .splash-cover.gone { display: none; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
[hidden] { display: none !important; }

/* ---------- Раскладка: три колонки ---------- */
.app {
  display: grid;
  grid-template-columns: 300px minmax(280px, 420px) minmax(0, 1fr);
  height: 100dvh;
  gap: 1px;
  background: var(--line);
}
.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--pane);
}
.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
  flex: none;
}

/* ---------- Кнопки ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--pane-2);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-small { padding: 3px 9px; font-size: 13px; }
.btn-icon {
  width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px;
}
/* Кнопки «назад» — только на узком экране (правило после .btn-icon, чтобы победить его display) */
.btn.only-narrow { display: none; }

/* ---------- Левая колонка ---------- */
.brand { display: flex; align-items: center; gap: 8px; flex: 1; font-weight: 600; font-size: 17px; }
.brand-icon {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  display: inline-block;
}
.storages { flex: none; max-height: 40%; overflow: auto; border-bottom: 1px solid var(--line); }
.storage {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; cursor: pointer;
  border-left: 3px solid transparent;
}
.storage:hover { background: var(--pane-2); }
.storage.active { background: var(--accent-soft); border-left-color: var(--accent); }
.storage-icon { font-size: 18px; width: 22px; text-align: center; flex: none; }
.storage-main { flex: 1; min-width: 0; }
.storage-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.storage-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.storage-sub.err { color: var(--danger); }
.storage-actions { display: flex; gap: 4px; flex: none; }
.storage-actions .btn-icon { width: 28px; height: 28px; font-size: 15px; }
.storage-actions .btn-icon.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.storages-empty { padding: 20px 14px; color: var(--muted); font-size: 14px; }
.storages-empty .btn { margin-top: 10px; }

.tags-block { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tags-head { display: flex; align-items: center; padding: 8px 12px 4px; }
.tags-title { flex: 1; font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tags-tree { flex: 1; overflow: auto; padding: 0 6px 12px; }
.tag-row {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 4px; border-radius: 6px; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.tag-row:hover { background: var(--pane-2); }
.tag-row.selected { background: var(--accent-soft); }
.tag-toggle {
  width: 20px; height: 20px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px; border: 0; background: none; padding: 0; cursor: pointer;
}
.tag-toggle.leaf { visibility: hidden; }
.tag-toggle.open { transform: rotate(90deg); }
.tag-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.15); }
.tag-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-check { flex: none; width: 18px; height: 18px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.tag-children { margin-left: 18px; }
.tag-children[hidden] { display: none; }

.pane-foot { flex: none; padding: 6px 12px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- Средняя колонка ---------- */
.search-box { flex: 1; min-width: 0; }
.search-box input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--pane-2);
}
.sort-box select {
  padding: 6px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--pane-2);
}
.items-summary { padding: 6px 12px 0; font-size: 12px; color: var(--muted); }
.selected-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px; }
.selected-tags:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 6px; border-radius: 999px;
  font-size: 12px; background: var(--pane-2); border: 1px solid var(--line);
  cursor: pointer;
}
.chip .tag-dot { width: 10px; height: 10px; }
.items-list { flex: 1; overflow: auto; }
.item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.item-row:hover { background: var(--pane-2); }
.item-row.active { background: var(--accent-soft); }
.item-mark { width: 18px; flex: none; text-align: center; font-size: 15px; }
.mark-1 { color: var(--danger); }
.mark-2 { color: var(--warn); }
.mark-3 { color: var(--ok); }
.item-photo {
  width: 48px; height: 48px; flex: none; border-radius: 8px;
  background: var(--pane-2); border: 1px solid var(--line);
  object-fit: cover; display: block;
}
.item-photo.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px; }
.item-main { flex: 1; min-width: 0; }
.item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-id { font-size: 11px; color: var(--muted); }
.items-empty { padding: 30px 16px; color: var(--muted); text-align: center; }
.items-sentinel { height: 1px; }

/* ---------- Карточка ---------- */
.card-head-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; gap: 6px; }
.card { flex: 1; overflow: auto; padding: 16px 20px 40px; }
.card-empty { color: var(--muted); text-align: center; padding: 60px 0; }
.card-title { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 4px; font-size: 22px; font-weight: 600; line-height: 1.25; }
.card-title .item-mark { font-size: 20px; margin-top: 3px; }
.card-id { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.card-tags .chip { cursor: default; }
.field {
  display: grid; grid-template-columns: minmax(120px, 30%) 1fr; gap: 6px 14px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.field-name { color: var(--muted); font-size: 13px; padding-top: 2px; }
.field-value { white-space: pre-wrap; word-break: break-word; }
.field-value.num { font-variant-numeric: tabular-nums; }
.field-photos { grid-column: 1 / -1; }
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.photos-grid img, .photos-grid .photo-placeholder {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
  background: var(--pane-2); border: 1px solid var(--line); cursor: zoom-in; display: block;
}
.photo-placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; cursor: default; }

/* ---------- Диалоги ---------- */
.dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px;
  background: var(--pane); color: var(--text); width: min(520px, 92vw);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog h2 { margin: 0 0 8px; font-size: 18px; }
.dialog .hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.dialog textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--pane-2); resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
}
.dialog-error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- Фото на весь экран ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; }
.lightbox-close, .lightbox-nav {
  position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0;
  border-radius: 50%; width: 44px; height: 44px; font-size: 26px; cursor: pointer;
}
.lightbox-close { top: 12px; right: 12px; }
.lightbox-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lightbox-caption { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: #ddd; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 60; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}

/* ---------- Кружок синхронизации ---------- */
.sync-slot { display: inline-flex; flex: none; }
.sync-slot.only-narrow-slot { display: none; }
.sync-btn {
  width: 34px; height: 34px; padding: 0; border: 0; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 50%;
}
.sync-btn:hover { background: var(--pane-2); }
.sync-btn svg { width: 32px; height: 32px; display: block; }
.sync-track { fill: none; stroke: var(--line); stroke-width: 2.5; opacity: 0; }
.sync-prog { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; opacity: 0;
  transform: rotate(-90deg); transform-origin: 18px 18px; transition: stroke-dasharray .3s; }
.sync-cloud { fill: currentColor; }
.sync-slash { stroke: var(--pane); stroke-width: 4; stroke-linecap: round; display: none; }
.sync-slash2 { stroke: currentColor; stroke-width: 2; stroke-linecap: round; display: none; }
.sync-bang { fill: #fff; font: bold 9px/1 var(--font); display: none; }
.sync-btn[data-state="running"] { color: var(--accent); }
.sync-btn[data-state="running"] .sync-track, .sync-btn[data-state="running"] .sync-prog { opacity: 1; }
.sync-btn[data-state="error"] { color: var(--danger); }
.sync-btn[data-state="error"] .sync-bang { display: block; }
.sync-btn[data-state="offline"] .sync-slash, .sync-btn[data-state="offline"] .sync-slash2 { display: block; }
.sync-pop {
  position: fixed; top: 56px; left: 12px; z-index: 40; width: min(340px, calc(100vw - 24px));
  background: var(--pane); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 14px;
}
.sync-pop.err { border-color: var(--danger); }
.sync-pop-text { white-space: pre-wrap; word-break: break-word; }
.sync-pop-buttons { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }

/* ---------- Инструменты над списком: вид, размер, отметки, умный поиск ---------- */
.items-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { border: 0; background: var(--pane-2); padding: 4px 10px; font-size: 13px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { background: var(--accent); color: #fff; }
#tile-size { width: 110px; accent-color: var(--accent); }
#mark-filter { padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--pane-2); font-size: 13px; }
#mark-filter.on { border-color: var(--accent); color: var(--accent); }
.btn-smart { margin-left: auto; color: var(--accent); border-color: var(--accent); }
.fast-status { margin: 6px 12px 0; padding: 4px 10px; border-radius: 8px; font-size: 12px; background: var(--accent-soft); color: var(--text); display: flex; align-items: center; gap: 6px; }
.fast-status.err { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.fast-status.running::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }

/* Значок ИИ и процент у записей, найденных Jev */
.ai-badge {
  display: inline-flex; align-items: center; gap: 3px; flex: none;
  font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(135deg, #8b5cf6, #2563eb);
  border-radius: 999px; padding: 1px 7px; white-space: nowrap;
}

/* Личные отметки (как SF-символы приложения: кружок с галочкой, паузой, вопросом) */
.pmark { display: inline-flex; width: 18px; height: 18px; flex: none; }
.pmark svg { width: 100%; height: 100%; display: block; }
.mark-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.mark-btn { display: inline-flex; align-items: center; gap: 6px; }
.mark-btn .pmark { width: 16px; height: 16px; }
.mark-btn.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.mark-menu {
  position: fixed; z-index: 45; min-width: 180px; padding: 4px;
  background: var(--pane); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.mark-menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer; text-align: left; }
.mark-menu button:hover { background: var(--pane-2); }
.mark-menu button.on { font-weight: 600; }

/* Список: размер фото — ползунок */
.items-list { --photo: 48px; --tile: 96px; }
.item-row .item-photo { width: var(--photo); height: var(--photo); }
.item-row .ai-badge { margin-left: 4px; }

/* ---------- Значки ---------- */
.items-list.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
  gap: 14px 12px; padding: 12px; align-content: start;
}
.items-list.grid .items-empty, .items-list.grid .items-sentinel { grid-column: 1 / -1; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; min-width: 0; }
.tile-photo { position: relative; width: var(--tile); max-width: 100%; aspect-ratio: 1; }
.tile-photo img, .tile-photo .tile-empty {
  width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block;
  background: var(--pane-2); border: 1px solid var(--line);
}
.tile-empty { display: flex !important; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; }
.tile .pmark { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.tile .ai-badge { position: absolute; left: 4px; bottom: 4px; }
.tile-name {
  width: 100%; font-size: 12px; text-align: center; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.tile.active .tile-photo img, .tile.active .tile-photo .tile-empty { outline: 3px solid var(--accent); outline-offset: 1px; }

/* ---------- Настройки в окне хранилища ---------- */
.st-settings { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 12px; font-size: 14px; }
.st-thr { display: grid; gap: 6px; }
.st-thr input { width: 100%; accent-color: var(--accent); }
.st-marks { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* ---------- Умный поиск ---------- */
.dialog-chat { width: min(760px, 96vw); height: min(80vh, 760px); padding: 0; }
.dialog-chat[open] { display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 17px; }
.chat-model { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; white-space: normal; word-break: break-word; line-height: 1.45; }
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; white-space: pre-wrap; }
.msg-ai { align-self: flex-start; background: var(--pane-2); border: 1px solid var(--line); }
.msg-err { align-self: flex-start; color: var(--danger); border: 1px solid var(--danger); background: transparent; }
.msg-wait { align-self: flex-start; color: var(--muted); font-style: italic; }
.msg-ai p { margin: 0 0 6px; }
.msg-ai p:last-child { margin-bottom: 0; }
.msg-ai .li { padding-left: 14px; text-indent: -10px; }
.msg-ai code { background: var(--pane); padding: 0 3px; border-radius: 4px; }
.id-link { color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }
.chat-form { display: flex; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; resize: none; font-family: inherit; font-size: 14px; }

/* ---------- Узкий экран: одна колонка ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .app .pane { display: none; }
  .app[data-pane="tags"] .pane-tags { display: flex; }
  .app[data-pane="items"] .pane-items { display: flex; }
  .app[data-pane="card"] .pane-card { display: flex; }
  .btn.only-narrow { display: inline-flex; }
  .sync-slot.only-narrow-slot { display: inline-flex; }
  .btn-smart { margin-left: 0; }
  .storages { max-height: 45%; }
  .card { padding: 14px 14px 40px; }
  .field { grid-template-columns: 1fr; gap: 2px; }
}
.card-title .pmark { width: 22px; height: 22px; margin-top: 4px; }

/* ---------- Правка (веб 1.3.0): карточка-форма, дерево тегов, диалоги ---------- */
.card-actions .btn { white-space: nowrap; }
.offline-note { color: var(--muted); font-weight: 400; }
.btn-primary .offline-note { color: inherit; opacity: .85; }
.card.editing { background: var(--pane); }
.card.saving, .tags-tree.saving { opacity: .6; pointer-events: none; }
.card.drop-files { outline: 3px dashed var(--accent); outline-offset: -6px; }
.edit-name {
  width: 100%; font-size: 20px; font-weight: 600; line-height: 1.3; padding: 6px 10px; margin: 0 0 4px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--pane-2); resize: none; overflow: hidden; font-family: inherit;
}
.edit-name:focus, .edit-field input:focus, .edit-field textarea:focus, .edit-tag-search:focus, .tag-rename:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
.edit-tags { margin-bottom: 12px; display: grid; gap: 8px; }
.edit-chips { margin-bottom: 0; }
.edit-chips .hint { color: var(--muted); font-size: 13px; }
.chip-x {
  border: 0; background: none; padding: 0 2px; margin-left: 2px; cursor: pointer; color: var(--muted);
  font-size: 15px; line-height: 1;
}
.chip-x:hover { color: var(--danger); }
.edit-tags-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-search { position: relative; flex: 1; min-width: 180px; }
.edit-tag-search { width: 100%; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--pane-2); font-size: 14px; }
.tag-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30; max-height: 260px; overflow: auto;
  background: var(--pane); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px;
}
.tag-suggest .hint { padding: 6px 8px; color: var(--muted); font-size: 13px; }
.tag-sug {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.tag-sug:hover, .tag-sug.on { background: var(--accent-soft); }
.edit-fields { display: grid; gap: 8px; }
.edit-field { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--pane-2); display: grid; gap: 6px; }
.edit-field.dragging { opacity: .75; box-shadow: 0 8px 24px rgba(0,0,0,.2); border-color: var(--accent); }
.edit-field-head { display: flex; align-items: center; gap: 6px; }
.drag-handle {
  flex: none; width: 24px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; font-size: 16px;
}
.drag-handle:active { cursor: grabbing; }
.edit-field-kind {
  flex: none; width: 24px; height: 24px; border-radius: 6px; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.edit-field-name, .edit-field-value {
  width: 100%; min-width: 0; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--pane);
}
.edit-field-name { flex: 1; font-size: 13px; color: var(--muted); }
.edit-field-value { font-family: inherit; resize: none; overflow: hidden; }
.edit-field-value.num { max-width: 200px; font-variant-numeric: tabular-nums; }
.edit-field-del { width: 30px; height: 30px; font-size: 18px; color: var(--danger); flex: none; }
.edit-date { display: flex; gap: 6px; align-items: center; }
.edit-date .edit-field-value { max-width: 200px; }
.edit-date-pick { padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--pane); max-width: 160px; }
.edit-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.edit-photo { position: relative; aspect-ratio: 1; }
.edit-photo img, .edit-photo .photo-placeholder {
  width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; background: var(--pane); border: 1px solid var(--line);
}
.photo-star, .photo-del {
  position: absolute; top: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0,0,0,.55); color: #fff; font-size: 16px; line-height: 28px; padding: 0;
}
.photo-star { left: 4px; }
.photo-star.on { color: #ffcc00; }
.photo-del { right: 4px; }
.edit-photo-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  border: 1px dashed var(--line); border-radius: 8px; padding: 8px; min-height: 110px;
}
.edit-photo-add .hint { font-size: 11px; color: var(--muted); }
.edit-photo-add input[type=file] { display: none; }
.edit-photo-add label.btn { cursor: pointer; }
.edit-add-field { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.add-field-menu { display: flex; flex-wrap: wrap; gap: 6px; }
.edit-delete { display: block; margin: 24px 0 0; }

/* Дерево тегов в правке */
.tags-edit-actions { display: inline-flex; gap: 6px; }
.tags-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag-row.edit { cursor: default; padding: 2px 4px; }
.tag-row.edit:hover { background: var(--pane-2); }
.tag-row.edit .tag-name { cursor: text; }
.tag-handle { width: 20px; height: 26px; }
.tag-color { flex: none; width: 22px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: none; cursor: pointer; overflow: hidden; }
.tag-color::-webkit-color-swatch-wrapper { padding: 0; }
.tag-color::-webkit-color-swatch { border: 0; border-radius: 50%; }
.tag-color::-moz-color-swatch { border: 0; border-radius: 50%; }
.tag-rename { flex: 1; min-width: 0; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 6px; background: var(--pane); }
.tag-edit-actions { display: inline-flex; gap: 2px; flex: none; opacity: .35; }
.tag-row.edit:hover .tag-edit-actions, .tag-row.edit:focus-within .tag-edit-actions { opacity: 1; }
.tag-act { width: 26px; height: 26px; font-size: 14px; border-radius: 6px; }
.tag-act-del { color: var(--danger); }
.tag-row.dragging { opacity: .4; }
.tag-row.drop-into { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.tag-row.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.tag-row.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.tag-ghost {
  position: fixed; z-index: 70; pointer-events: none; background: var(--pane); border: 1px solid var(--accent);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: .9;
}
.tag-root-drop {
  margin: 8px 4px 4px; padding: 8px; border: 1px dashed var(--line); border-radius: 8px;
  color: var(--muted); font-size: 12px; text-align: center; display: none;
}
.tree-dragging .tag-root-drop { display: block; }
.tag-root-drop.drop-root { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.tree-hint { padding: 8px 6px; font-size: 12px; color: var(--muted); }

/* Диалог спора «у вас / в облаке» */
.dialog-conflict { width: min(760px, 96vw); max-height: 90vh; }
.conflict-list { display: grid; gap: 12px; max-height: 60vh; overflow: auto; }
.cf-entry { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.cf-title { font-weight: 600; margin-bottom: 8px; }
.cf-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cf-col { background: var(--pane-2); border-radius: 8px; padding: 8px 10px; font-size: 13px; min-width: 0; }
.cf-head { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.cf-line { word-break: break-word; white-space: pre-wrap; }
.cf-line.diff { color: var(--accent); font-weight: 600; }
.cf-choice { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 14px; }
.cf-opt { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.conflict-all { display: flex; gap: 6px; margin-top: 10px; }

/* Телефон: длинное нажатие на строке не вызывает системное меню */
.item-row, .tile { -webkit-touch-callout: none; }
@media (max-width: 900px) {
  .tag-edit-actions { opacity: 1; }
  .cf-cols { grid-template-columns: 1fr; }
  .card-actions { flex-wrap: wrap; justify-content: flex-end; }
  .card-actions .btn { padding: 4px 8px; }
  .edit-date { flex-wrap: wrap; }
}
@media (pointer: coarse) {
  .tag-edit-actions { opacity: 1; }
  .drag-handle { width: 32px; height: 36px; }
}
body.no-select, body.no-select * { user-select: none; -webkit-user-select: none; cursor: grabbing; }
