/* icons.css */
@font-face{
  font-family: "Material Symbols Rounded";
  src: url("./assets/fonts/material-symbols/material-symbols-rounded.woff2") format("woff2");
  font-weight: 100 700; /* variable font */
  font-style: normal;
  font-display: swap;
}

.ms{
  font-family: "Material Symbols Rounded";
  font-weight: 400; font-style: normal; line-height: 1;
  display: inline-block; font-size: 24px;
  /* оси variable-шрифта: FILL, wght, GRAD, opsz */
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* тёмная тема — залитые иконки */
:root[data-theme="dark"] .ms{
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}


.fab .btn{
  width: var(--fab-size, 52px);
  height: var(--fab-size, 52px);
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Размер иконки (Material Symbols) */
.fab .btn .ms{ font-size: 24px; line-height: 1; }
@media (max-width: 390px){ .fab .btn .ms{ font-size: 22px; } }

/* Если где-то оставались правила, скрывающие все span в FAB — отключаем их */
.fab .btn span{ display: inline-block !important; }


/* Применяем переменные */
.fab .btn{
  width: var(--fab-size);
  height: var(--fab-size);
  padding: 0;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.fab .btn .ms{
  font-size: var(--fab-icon);
  line-height: 1;
}

/* (необязательно) разные размеры по устройствам */
@media (max-width: 430px){           /* телефоны 390px (iPhone 12/14/15/16 base/pro) */
  :root{ --fab-size: 54px; --fab-icon: 46px; }
}
@media (min-width: 768px){           /* планшеты */
  :root{ --fab-size: 60px; --fab-icon: 46px; }
}
@media (min-width: 1200px){          /* десктоп */
  :root{ --fab-size: 64px; --fab-icon: 46px; }
}

.fab .btn .ms{ font-size: var(--fab-icon); line-height: 1; }



/* На всякий случай: скрыть, если где-то остался */
.navbar{ display: none !important; }

/* Контент: раньше нижний отступ учитывал высоту навбара — теперь только safe-area */
main{
  margin-bottom: calc(env(safe-area-inset-bottom) + 16px) !important;
}

/* FAB: держим над нижним краем экрана/safe-area */
.fab{
  bottom: calc(env(safe-area-inset-bottom) + 16px) !important;
}

/* Панель выбора (в режиме массового выбора) крепим к низу экрана */
.selectbar{
  bottom: calc(env(safe-area-inset-bottom) + 8px) !important;
}

/* курсор-указатель для кликабельных карточек */
#locations-grid .card,
#items-grid .card { cursor: pointer; }

/* Кнопка "ещё" (три точки) справа в крошках */
.breadcrumb .more-btn{ margin-left:auto; padding:6px 8px; border-radius:8px }
.breadcrumb .more-btn .ms{ font-size:20px; line-height:1 }


/* ===== Показывать/прятать код и чипсы ===== */
/* когда выключено — ничего лишнего */
body.no-meta #locations-grid .card .muted,
body.no-meta #locations-grid .card .chips,
body.no-meta #items-grid .card .muted,
body.no-meta #items-grid .card .chips{ display:none !important; }

/* когда включено — принудительно показываем даже на узких экранах */
body:not(.no-meta) #locations-grid .card .muted,
body:not(.no-meta) #items-grid .card .muted{ display:block !important; }
body:not(.no-meta) #locations-grid .card .chips,
body:not(.no-meta) #items-grid .card .chips{ display:flex !important; }

/* ===== Супер-компактные карточки ===== */
body.compact .grid{ gap:10px !important; }
body.compact #locations-grid{ --card-min: 140px; }
body.compact #items-grid{ --card-min: 140px; }
@media (min-width:1200px){
  body.compact #locations-grid,
  body.compact #items-grid{ --card-min: 180px; }
}
body.compact .thumb{ aspect-ratio: 16/9; }          /* ниже превью */
body.compact .card .body{ padding:8px 10px; }
body.compact .card .title{ font-size: .95rem; }
body.compact .actions .btn{ padding:6px 8px; font-size:12px; }


/* Картинка внутри превью */
.thumb{ position:relative; overflow:hidden; border-radius:12px }
.thumb img{ width:100%; height:100%; object-fit:cover; display:block }

/* Скелет-заглушка до загрузки */
.thumb.skeleton::before{
  content:""; position:absolute; inset:0;
  background: linear-gradient(90deg, rgba(0,0,0,.06), rgba(0,0,0,.12), rgba(0,0,0,.06));
  animation: thumb-shimmer 1.1s linear infinite;
}
@keyframes thumb-shimmer{ 0%{ transform:translateX(-100%) } 100%{ transform:translateX(100%) } }

/* заглушка «Нет фото» (если без картинки) */
.thumb .no-photo{
  width:100%; height:100%; display:flex; align-items:center; justify-content:center;
  opacity:.6; font-size:.9rem;
}

/* маленькие иконки в блоке действий карточек */
.actions.actions-icons{ display:flex; gap:8px; flex-wrap:wrap }
.actions.actions-icons .btn.icon{
  width:36px; height:36px; padding:0; border-radius:10px;
  display:inline-flex; align-items:center; justify-content:center;
}
.actions.actions-icons .btn.icon .ms{ font-size:20px; line-height:1 }
@media (max-width:390px){
  .actions.actions-icons .btn.icon{ width:34px; height:34px }
  .actions.actions-icons .btn.icon .ms{ font-size:18px }
}

/* Фото-карточки: без .body, всё поверх превью */
.card.photo{ position: relative; }
.card.photo .thumb{
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 3 / 4;                 /* основной формат для телефона */
}

/* Скролл/скелет у вас уже есть — оставляем .thumb.skeleton как раньше */

/* Выбор (массовая печать) — чекбокс в левом верхнем углу */
.card.photo .select-badge{
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(0,0,0,.35); border-radius: 8px; padding: 4px;
}
.card.photo .select-badge input{ width:18px; height:18px }

/* Кнопки действий поверх фото (справа сверху) */
.card.photo .actions.actions-icons{
  position: absolute; top: 8px; right: 8px; z-index: 2;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.card.photo .actions.actions-icons .btn.icon{
  width: 36px; height: 36px; padding: 0; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35); backdrop-filter: blur(2px);
  border: 1px solid rgba(255,255,255,.2);
}
.card.photo .actions.actions-icons .btn.icon .ms{ font-size: 20px; color: #fff; line-height: 1 }
@media (max-width: 390px){
  .card.photo .actions.actions-icons .btn.icon{ width: 34px; height: 34px }
  .card.photo .actions.actions-icons .btn.icon .ms{ font-size: 18px }
}

/* Заголовок/мета — нижняя плашка поверх фото с градиентом */
.card.photo .titlebar{
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  padding: 10px; display: flex; flex-direction: column; gap: 4px;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6);
  background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0) 60%);
}
.card.photo .titlebar .title{ font-weight: 600; font-size: 0.98rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.card.photo .titlebar .meta{ font-size: 12px; opacity: .85 }

/* Учитываем ваш тумблер "Показывать код и чипсы" */
body.no-meta .card.photo .titlebar .meta{ display: none !important; }

/* «Кликабельно»: курсор */
#locations-grid .card.photo, #items-grid .card.photo{ cursor: pointer; }

/* Сетка фиксированной ширины колонки = 200px */
#locations-grid, #items-grid{
  display: grid !important;
  grid-template-columns: repeat(auto-fill, 100px) !important;
  justify-content: center;      /* центрируем ряды */
  gap: 10px;
}

/* Карточка и превью строго 100×125 */
#locations-grid .card.photo,
#items-grid .card.photo{ width: 100px; }

#locations-grid .card.photo .thumb,
#items-grid .card.photo .thumb{
  width: 100px; height: 125px;
  aspect-ratio: auto !important; /* отключаем прежнее 16:9 */
}

/* Карточки фиксированной ширины 100px и высоты превью 125px */
#locations-grid, #items-grid{
  display: grid !important;
  grid-template-columns: repeat(auto-fill, 100px) !important; /* фикс-ширина */
  gap: 8px !important;
  justify-content: center; /* или start/end по вкусу */
}

#locations-grid .card.photo,
#items-grid .card.photo{ width: 100px !important; }

#locations-grid .card.photo .thumb,
#items-grid .card.photo .thumb{
  width: 100px; height: 125px;       /* фикс высота вместо aspect-ratio */
  aspect-ratio: auto !important;      /* перекрываем прежние 16:9 / 2:3 */
}

/* чекбокс (select-mode) */
.card.photo .select-badge{
  top: 4px; left: 4px; padding: 3px; border-radius: 6px;
  background: rgba(0,0,0,.35);
}
.card.photo .select-badge input{ width: 16px; height: 16px }

/* иконки-действия */
.card.photo .actions.actions-icons{
  top: 4px; right: 4px; gap: 6px;
}
.card.photo .actions.actions-icons .btn.icon{
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.36);
}
.card.photo .actions.actions-icons .btn.icon .ms{ font-size: 18px; color:#fff }

/* нижняя плашка */
.card.photo .titlebar{
  padding: 6px 6px 5px;
  background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0) 60%);
}
.card.photo .titlebar .title{
  font-size: 12px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.card.photo .titlebar .meta{ display:none } /* на таких маленьких тайлах мету скрываем */

/* ====================== МОБИЛА ≤480px: фикс 100×125 ====================== */
@media (max-width: 480px){
  /* сетка ровно по 100px */
  #locations-grid, #items-grid{
    display: grid !important;
    grid-template-columns: repeat(auto-fill, 100px) !important;
    gap: 8px !important;
    justify-content: center; /* можно start/end */
  }
  /* сама карточка и превью */
  #locations-grid .card.photo,
  #items-grid .card.photo{ width: 100px !important; }

  #locations-grid .card.photo .thumb,
  #items-grid .card.photo .thumb{
    width: 100px; height: 125px;
    aspect-ratio: auto !important;  /* отключаем любые прежние 16:9/2:3 */
  }

  /* уменьшенные оверлеи под маленький тайл */
  .card.photo .select-badge{ top:4px; left:4px; padding:3px; border-radius:6px; }
  .card.photo .select-badge input{ width:16px; height:16px; }

  .card.photo .actions.actions-icons{ top:4px; right:4px; gap:6px; }
  .card.photo .actions.actions-icons .btn.icon{
    width:28px; height:28px; border-radius:8px;
    background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.2);
  }
  .card.photo .actions.actions-icons .btn.icon .ms{ font-size:18px; color:#fff }

  .card.photo .titlebar{ padding:6px 6px 5px; }
  .card.photo .titlebar .title{
    font-size:12px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  .card.photo .titlebar .meta{ display:none } /* на крошечном тайле мета не нужна */
}

/* ============== ПЛАНШЕТ/ПК ≥481px: адаптив, портрет 2:3 ============== */
@media (min-width: 481px){
  /* возвращаем адаптивную сетку с min шириной плитки */
  #locations-grid, #items-grid{
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-min, 160px), 1fr)) !important;
    gap: 12px !important;
    justify-content: start;
  }
  /* задаём минимальную ширину плитки и делаем превью портретным */
  #locations-grid, #items-grid{ --card-min: 160px; }   /* базово на планшете */
  #locations-grid .card.photo, #items-grid .card.photo{ width: auto !important; }

  #locations-grid .card.photo .thumb,
  #items-grid .card.photo .thumb{
    width: auto; height: auto;
    aspect-ratio: 2 / 3 !important;  /* высокая карточка ~портрет */
  }

  /* немного крупнее оверлеи и заголовок */
  .card.photo .actions.actions-icons .btn.icon{ width:32px; height:32px; }
  .card.photo .actions.actions-icons .btn.icon .ms{ font-size:20px; }
  .card.photo .titlebar .title{ font-size: .95rem; }
  .card.photo .titlebar .meta{ display: inline; } /* если не отключено body.no-meta */
}

/* На десктопе можно ещё увеличить «минималку» */
@media (min-width: 768px){
  #locations-grid, #items-grid{ --card-min: 180px; }
}

/* ====== Карточки-фото: titlebar сверху, кнопки снизу слева ====== */

/* Заголовок теперь наверху с градиентом сверху вниз */
.card.photo .titlebar{
  position: absolute;
  left: 0; right: 0; top: 0; bottom: auto; z-index: 1;
  padding: 8px 10px 14px;                 /* чуточку воздуха вниз */
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6);
  background: linear-gradient(to bottom, rgba(0,0,0,.58), rgba(0,0,0,0) 65%);
}
.card.photo .titlebar .title{
  font-weight: 600; font-size: .95rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.card.photo .titlebar .meta{ font-size: 12px; opacity: .85 }
body.no-meta .card.photo .titlebar .meta{ display: none !important; }

/* Кнопки действий — вниз слева */
.card.photo .actions.actions-icons{
  position: absolute; bottom: 8px; left: 8px; right: auto; top: auto; z-index: 2;
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start;
}
.card.photo .actions.actions-icons .btn.icon{
  width: 40px; height: 40px; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35); backdrop-filter: blur(0.8px);
  border: 1px solid rgba(255,255,255,.2);
}
.card.photo .actions.actions-icons .btn.icon .ms{ font-size: 27px; color: #fff; line-height: 1 }

/* Чекбокс выбора перенесём вправо, чтобы не перекрывал заголовок */
.card.photo .select-badge{
  position: absolute; top: 8px; right: 8px; left: auto; z-index: 2;
  background: rgba(0,0,0,.35); border-radius: 8px; padding: 4px;
}
.card.photo .select-badge input{ width:18px; height:18px }

/* Мобильный тайл 100×125 — компактнее шрифты/иконки */
@media (max-width: 480px){
  .card.photo .titlebar{ padding: 6px 6px 10px; }
  .card.photo .titlebar .title{ font-size: 12px; }
  .card.photo .titlebar .meta{ display: none; }   /* очень маленький тайл — мета не нужна */
  .card.photo .actions.actions-icons{ bottom: 4px; left: 4px; gap: 6px; }
  .card.photo .actions.actions-icons .btn.icon{ width: 32px; height: 32px; border-radius: 8px; }
  .card.photo .actions.actions-icons .btn.icon .ms{ font-size: 22px; }
  .card.photo .select-badge{ top: 4px; right: 4px; padding: 3px; }
  .card.photo .select-badge input{ width:16px; height:16px }
}

/* мини-таббар */
.tabbar.small .tab{
  padding:6px 10px; border-radius:8px;
  border:1px solid var(--border);
  background: var(--muted);
  color: var(--text);
  font-size:13px; pointer-events:auto; cursor:pointer;
}
.tabbar.small .tab.active{ 
  background: var(--accent);
  border-color: color-mix(in oklab, var(--accent), black 18%);
  color:#fff; 
}

/* сетка миниатюр */
.thumb-grid{
  display:grid; grid-template-columns:repeat(auto-fill, minmax(64px,1fr));
  gap:8px;
}
.thumb-option{
  position:relative; border-radius:10px; overflow:hidden; cursor:pointer;
  border:1px solid rgba(0,0,0,.15);
}
.thumb-option img{ width:100%; height:100%; object-fit:cover; display:block; aspect-ratio: 2 / 3; }
.thumb-option.active{ outline:2px solid var(--accent, #4f8cff); }
.thumb-option::after{
  content:""; position:absolute; inset:0; background:linear-gradient(to top, rgba(0,0,0,.25), rgba(0,0,0,0));
  opacity:.8; transition:.2s;
}
.thumb-option.active::after{ opacity:.2; }

/* превью выбранной */
.thumb-preview img{ width:120px; height:160px; object-fit:cover; }

/* скелет не должен перехватывать клики */
.thumb.skeleton::before{
  pointer-events: none;
  z-index: 0; /* ниже любого контента */
}

/* контент поверх скелета */
.card.photo .titlebar{ z-index: 2; }
.card.photo .actions.actions-icons{ z-index: 3; }
.card.photo .select-badge{ z-index: 3; }

/* Ничто под кнопками не перехватывает клики */
.card.photo .thumb img{ pointer-events: none; }
.thumb.skeleton::before{ pointer-events: none; z-index: 0; }

/* Верхние слои и кликабельность */
.card.photo .titlebar{ z-index: 2; pointer-events: none; } /* заголовок не нужен кликабельный */
.card.photo .select-badge{ z-index: 3; pointer-events: auto; }
.card.photo .actions.actions-icons{
  position: absolute; bottom: 8px; left: 8px;
  z-index: 4; pointer-events: auto;
}

/* Сами кнопки точно принимают клики */
.card.photo .actions.actions-icons .btn{ pointer-events: auto; }

/* (по вкусу) сделаем их светлее в светлой теме и заметнее в тёмной */
:root[data-theme="light"] .card.photo .actions.actions-icons .btn.icon{
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.08);
}
:root[data-theme="dark"] .card.photo .actions.actions-icons .btn.icon{
  background: rgba(0,0,0,.29);
  border: 1px solid rgba(255,255,255,.33);
}

/* ========= Skin: Graphite / минимализм ========= */
/* включение: <html data-skin="graphite"> */

html[data-skin="graphite"]{
  /* Light */
  --r-card: 14px; --r-btn: 10px;
}

html[data-skin="graphite"][data-theme="dark"]{
  /* Dark */
  --bg:        #0F1317;
  --surface:   #141A20;
  --surface-2: #192029;
  --text:      #E8ECF1;
  --text-weak: #A7B0BA;
  --accent:    #69B1FF;
  --accent-2:  #3C8BE6;
  --br:        #202833;
  --shadow:    0 12px 24px rgba(0,0,0,.45);
}

/* Фон страницы — лёгкая «пелена» */
html[data-skin="graphite"] body{
  background:
    radial-gradient(900px 600px at 110% -10%, rgba(78,159,255,.08), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(60,139,230,.06), transparent 60%),
    var(--bg);
  color: var(--text);
}

/* Карточки/модалки/кнопки */
html[data-skin="graphite"] .card{ background: var(--surface); border:1px solid var(--br); border-radius: var(--r-card); box-shadow: var(--shadow); }
html[data-skin="graphite"] dialog{ background: var(--surface); border:1px solid var(--br); border-radius: 16px; box-shadow: var(--shadow); }
html[data-skin="graphite"] .btn{
  background: var(--surface-2); border:1px solid var(--br); color:var(--text); border-radius: var(--r-btn);
}
html[data-skin="graphite"] .btn.primary,
html[data-skin="graphite"] .btn.accent{
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent), white 8%), var(--accent));
  border-color: color-mix(in oklab, var(--accent), black 14%); color:#fff;
}
html[data-skin="graphite"] .chip{ background: var(--surface-2); border:1px solid var(--br); color:var(--text-weak); }

/* FAB */
html[data-skin="graphite"] .fab .btn{ width: var(--fab-size,56px); height: var(--fab-size,56px); border-radius:999px; }
html[data-skin="graphite"] .fab .btn.accent{
  background: var(--accent-2); border-color: color-mix(in oklab, var(--accent-2), black 12%); color:#fff;
}

/* Фото-карточки */
html[data-skin="graphite"] .card.photo{ background: transparent; border:none; box-shadow:none; }
html[data-skin="graphite"] .card.photo .thumb{ border-radius: var(--r-card); box-shadow: var(--shadow); }
html[data-skin="graphite"] .card.photo .titlebar{
  color:#fff; text-shadow: 0 1px 2px rgba(0,0,0,.55);
  background: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,0) 65%);
}
html[data-skin="graphite"] .card.photo .actions.actions-icons .btn.icon{
  background: rgba(15,19,23,.45); border:1px solid rgba(255,255,255,.18);
}
html[data-skin="graphite"][data-theme="light"] .card.photo .actions.actions-icons .btn.icon{
  background: rgba(31,36,43,.35);
}

/* Скелет под палитру и не блокирует клики */
html[data-skin="graphite"] .thumb.skeleton::before{
  content:""; position:absolute; inset:0;
  background: linear-gradient(90deg, rgba(78,159,255,.10), rgba(60,139,230,.18), rgba(78,159,255,.10));
  animation: thumb-shimmer 1.1s linear infinite;
  pointer-events:none; z-index:0;
}

/* Поля/плейсхолдеры */
html[data-skin="graphite"] input[type="text"],
html[data-skin="graphite"] textarea,
html[data-skin="graphite"] select{
  background: var(--surface); border:1px solid var(--br); color:var(--text); border-radius: var(--r-btn);
}
html[data-skin="graphite"] input::placeholder,
html[data-skin="graphite"] textarea::placeholder{ color: color-mix(in oklab, var(--text), transparent 45%); }

/* Иконки-шрифт наследуют цвет */
html[data-skin="graphite"] .ms{ color: currentColor; }
