/* ---------- Шапки ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: var(--appbar-h);
  padding: 4px 8px;
  background: var(--bg);
}
.appbar__title { flex: 1; min-width: 0; padding: 0 4px; }
.appbar__title h1 {
  font-size: var(--fs-title);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__subtitle { color: var(--text-2); font-size: var(--fs-caption); }

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px var(--gutter) 12px;
}
.page-header__text { flex: 1; min-width: 0; }
.page-header h1 { font-size: var(--fs-display); font-weight: 700; line-height: 1.15; }
.page-header p { margin-top: 6px; color: var(--text-2); font-size: 15px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text);
  flex: none;
  transition: background 120ms;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn--muted { color: var(--text-2); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 20px 0 10px;
  font-size: var(--fs-section);
  font-weight: 600;
}
.section-title small { color: var(--text-2); font-size: var(--fs-caption); font-weight: 400; }

/* ---------- Поиск ---------- */
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: var(--field-h);
  padding: 0 14px;
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text-2);
  text-align: left;
}
.search-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  font-size: var(--fs-body);
  color: var(--text);
}
.search-field input::placeholder { color: var(--text-2); }
.search-field input:focus-visible { outline: none; }
.search-field:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-field .icon-btn { width: 32px; height: 32px; margin-right: -6px; }

/* ---------- Чипсы ---------- */
.chips {
  display: flex;
  gap: 8px;
  margin: 12px calc(-1 * var(--gutter)) 0;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: none;
  min-width: 64px;
  height: 64px;
  padding: 6px 8px;
  border-radius: var(--r-chip);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-tiny);
  font-weight: 500;
  transition: transform 120ms, background 120ms;
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.chip--inline {
  flex-direction: row;
  height: 36px;
  min-width: 0;
  padding: 0 14px;
  border-radius: 18px;
  font-size: 14px;
}

/* ---------- Карточки и списки ---------- */
.card-list { display: flex; flex-direction: column; gap: 8px; }

.container-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px 10px 10px;
  border-radius: var(--r-card);
  background: var(--surface);
  text-align: left;
  overflow: hidden;
  transition: transform 120ms;
}
.container-card:active { transform: scale(0.98); }
.container-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--tag, transparent);
}
.container-card__text { flex: 1; min-width: 0; }
.container-card__title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.container-card__meta { margin-top: 2px; color: var(--text-2); font-size: var(--fs-caption); }
.container-card > .icon { color: var(--text-3); }

.thumb {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb__number {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 22px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-caption);
  font-weight: 700;
  text-align: center;
}

.list-group {
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  text-align: left;
}
.list-row + .list-row { border-top: 1px solid var(--border); }
button.list-row:active { background: var(--surface-2); }
.list-row__text { flex: 1; min-width: 0; }
.list-row__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row__meta { color: var(--text-2); font-size: var(--fs-caption); }
.list-row > .icon:first-child { color: var(--text-2); }
.list-row--danger { color: var(--danger); }
.list-row--danger > .icon:first-child { color: var(--danger); }

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-tiny);
  font-weight: 700;
  text-align: center;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: var(--btn-h);
  padding: 0 20px;
  border-radius: var(--r-card);
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-body);
  font-weight: 600;
  transition: background 120ms, transform 120ms, opacity 120ms;
}
.btn:active { background: var(--accent-press); transform: scale(0.98); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn--secondary { background: var(--surface-2); color: var(--text); }
.btn--secondary:active { background: var(--surface-3); }
.btn--danger { background: var(--danger); }
.btn--text { background: none; color: var(--accent); height: 44px; font-weight: 500; }
.btn--text:active { background: var(--accent-soft); }
.btn.is-loading { pointer-events: none; opacity: 0.7; }
.btn.is-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fab {
  /* fixed, а не absolute: экран прокручивается, кнопка — нет.
     right учитывает колонку 430px по центру на широком экране */
  position: fixed;
  right: max(var(--gutter), calc((100vw - var(--app-width)) / 2 + var(--gutter)));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  z-index: 20;
  display: grid;
  place-items: center;
  width: var(--fab);
  height: var(--fab);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 24px rgba(47, 140, 255, 0.35);
  transition: transform 120ms;
}
.fab:active { transform: scale(0.92); }
.fab .icon { width: 28px; height: 28px; }

/* ---------- Поля ---------- */
.field { display: block; margin-top: 18px; }
.field__label { display: block; margin-bottom: 8px; font-size: 15px; font-weight: 500; }
.field__label small { color: var(--text-2); font-weight: 400; }
.input {
  display: block;
  width: 100%;
  height: var(--field-h);
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-card);
  background: var(--surface);
  font-size: var(--fs-body); /* не меньше 16px — иначе iOS зумит */
  transition: border-color 120ms;
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field__error { margin-top: 6px; color: var(--danger); font-size: var(--fs-caption); }
.field__hint { margin-top: 6px; color: var(--text-2); font-size: var(--fs-caption); }

.form-error {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--r-card);
  background: var(--danger-soft);
  color: #FF8A8C;
  font-size: 14px;
}

/* ---------- Переключатель ---------- */
.toggle {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: var(--surface-3);
  transition: background 160ms;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 160ms var(--ease-out);
}
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Таб-бар ---------- */
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform var(--dur) var(--ease-out);
}
.tabbar.is-hidden { transform: translateY(110%); visibility: hidden; transition: transform var(--dur) var(--ease-out), visibility 0s var(--dur); }
.no-tabbar .toast-stack { bottom: calc(var(--safe-bottom) + 88px); }
.tabbar__tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-2);
  font-size: var(--fs-tiny);
  font-weight: 500;
}
.tabbar__tab[aria-current="page"] { color: var(--accent); }
.tabbar__tab .badge { position: absolute; top: 6px; left: calc(50% + 6px); }

/* ---------- Индикатор синхронизации ---------- */
.sync-indicator { color: var(--text-2); }
.sync-indicator[data-state="pending"] { color: var(--accent); }
.sync-indicator[data-state="offline"] { color: var(--warning); }
.sync-indicator[data-state="error"] { color: var(--danger); }

/* ---------- Пустые состояния ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  text-align: center;
}
.empty__art {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin-bottom: 16px;
  border-radius: 24px;
  background: var(--surface);
  color: var(--accent);
}
.empty__art .icon { width: 44px; height: 44px; stroke-width: 1.5; }
.empty h2 { font-size: var(--fs-section); font-weight: 600; }
.empty p { margin-top: 6px; color: var(--text-2); font-size: 15px; }
.empty .btn { margin-top: 20px; width: auto; }

/* ---------- Оверлеи: bottom sheet, диалог, toast ---------- */
.overlay-root { position: absolute; inset: 0; z-index: 100; pointer-events: none; }
.overlay-root > * { pointer-events: auto; }

.backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  animation: screen-fade var(--dur) ease both;
}
.backdrop.is-closing { animation: fade-out var(--dur) ease both; }
@keyframes fade-out { to { opacity: 0; } }

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: 92%;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--surface);
  padding-bottom: var(--safe-bottom);
  animation: sheet-in var(--dur) var(--ease-out) both;
  will-change: transform;
}
.sheet.is-closing { animation: sheet-out var(--dur) var(--ease-out) both; }
.sheet.is-dragging { animation: none; transition: none; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-out { from { transform: translateY(var(--drag, 0)); } to { transform: translateY(100%); } }
.sheet__grabber {
  flex: none;
  display: grid;
  place-items: center;
  height: 22px;
  touch-action: none;
}
.sheet__grabber::before { content: ""; width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); }
.sheet__header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 4px var(--gutter);
  touch-action: none;
}
.sheet__header h2 { font-size: var(--fs-title); font-weight: 600; }
.sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px var(--gutter) 16px; }
.sheet__footer { flex: none; padding: 8px var(--gutter) 12px; border-top: 1px solid var(--border); }
.sheet__footer .btn--text { width: 100%; margin-top: 4px; }
.sheet .list-group { background: var(--surface-2); }
.sheet .list-row + .list-row { border-top-color: var(--surface-3); }
.sheet-section { margin: 14px 0 8px; font-size: var(--fs-section); font-weight: 600; }

.dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(320px, calc(100% - 48px));
  padding: 22px 20px 16px;
  border-radius: var(--r-sheet);
  background: var(--surface);
  transform: translate(-50%, -50%);
  animation: dialog-in var(--dur) var(--ease-out) both;
}
.dialog.is-closing { animation: fade-out 150ms ease both; }
@keyframes dialog-in { from { opacity: 0; transform: translate(-50%, -50%) scale(0.94); } }
.dialog h2 { font-size: var(--fs-section); font-weight: 600; text-align: center; }
.dialog p { margin-top: 8px; color: var(--text-2); font-size: 15px; text-align: center; }
.dialog__actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.dialog__actions .btn { height: 46px; }
.dialog .code {
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--r-card);
  background: var(--surface-2);
  font: 600 20px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 1px;
  text-align: center;
  user-select: all;
}

.toast-stack {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 8px 10px 16px;
  border-radius: var(--r-card);
  background: #2B3547;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 15px;
  pointer-events: auto;
  animation: toast-in 200ms var(--ease-out) both;
}
.toast.is-closing { animation: fade-out 160ms ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
.toast__text { flex: 1; }
.toast__action { padding: 8px 10px; border-radius: 8px; color: var(--accent); font-weight: 600; }
.toast__action:active { background: var(--accent-soft); }

.keyboard-open .tabbar { transform: translateY(110%); }
.keyboard-open .fab { display: none; }

/* ---------- Формы: сегменты, цвета, степпер, селектор, теги ---------- */
.form { padding-bottom: 8px; }
.field--row { display: flex; align-items: center; justify-content: space-between; }
.field--row .field__label { margin: 0; }
.input--number { height: 56px; font-size: 24px; font-weight: 700; letter-spacing: 1px; }
.input--multiline { height: auto; min-height: var(--field-h); padding: 12px 14px; resize: none; line-height: 1.4; }

.segments { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.segment {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 72px;
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-caption);
  transition: background 120ms, transform 120ms;
}
.segment:active { transform: scale(0.96); }
.segment[aria-checked="true"] { background: var(--accent); color: #fff; }

.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 0 var(--bg), 0 0 0 0 var(--swatch);
  transition: box-shadow 120ms;
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--swatch); }

.stepper { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: var(--r-card); background: var(--surface); }
.stepper__btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 22px;
  line-height: 1;
}
.stepper__btn:disabled { opacity: 0.35; }
.stepper__value { min-width: 36px; font-size: 17px; font-weight: 600; text-align: center; }

.select-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-card);
  background: var(--surface);
  text-align: left;
}
.select-row:active { background: var(--surface-2); }
.select-row.is-invalid { border-color: var(--danger); }
.select-row__icon { display: grid; color: var(--text-2); }
.select-row__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-row__text.is-placeholder { color: var(--text-3); }
.select-row > .icon:last-child { color: var(--text-3); }

.disclosure summary { display: flex; align-items: center; gap: 4px; list-style: none; cursor: pointer; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: "›"; margin-left: auto; color: var(--text-3); font-size: 22px; transition: transform 160ms; }
.disclosure[open] summary::after { transform: rotate(90deg); }
.disclosure .field__hint { margin: 0 0 10px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border-radius: var(--r-card); background: var(--surface); }
.tags--static { padding: 0; background: none; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 6px 0 12px;
  border-radius: 16px;
  background: var(--surface-2);
  font-size: 14px;
}
.tags--static .tag { padding-right: 12px; }
.tag button { display: grid; place-items: center; width: 24px; height: 24px; color: var(--text-2); }
.tags__input { flex: 1; min-width: 120px; height: 32px; border: 0; background: none; font-size: 16px; }
.tags__input::placeholder { color: var(--text-3); }

.form-footer {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin: 24px calc(-1 * var(--gutter)) 0;
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom));
  background: linear-gradient(to bottom, rgba(11, 17, 32, 0), var(--bg) 30%);
}
.btn--danger-text { margin-top: 16px; color: var(--danger); }
.btn--danger-text:active { background: var(--danger-soft); }

/* ---------- Фото ---------- */
.photo-pick-wrap { display: flex; justify-content: center; margin-top: 8px; }
.photo-pick { position: relative; width: 104px; height: 104px; }
.photo-pick__img {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 22px;
  background: var(--surface);
  color: var(--text-2);
  overflow: hidden;
}
.photo-pick__img img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick__badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

.photo-main {
  position: relative;
  aspect-ratio: 4 / 3;
  margin-top: 4px;
  border-radius: 18px;
  background: var(--surface);
  overflow: hidden;
}
.photo-main > img { width: 100%; height: 100%; object-fit: cover; }
.photo-main__frame {
  position: absolute;
  inset: 12px;
  pointer-events: none;
  background:
    linear-gradient(#fff, #fff) top left / 22px 2px, linear-gradient(#fff, #fff) top left / 2px 22px,
    linear-gradient(#fff, #fff) top right / 22px 2px, linear-gradient(#fff, #fff) top right / 2px 22px,
    linear-gradient(#fff, #fff) bottom left / 22px 2px, linear-gradient(#fff, #fff) bottom left / 2px 22px,
    linear-gradient(#fff, #fff) bottom right / 22px 2px, linear-gradient(#fff, #fff) bottom right / 2px 22px;
  background-repeat: no-repeat;
  opacity: 0.8;
}
.photo-main__remove { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; background: rgba(0, 0, 0, 0.55); color: #fff; }
.photo-main__cover {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: var(--fs-caption);
}
.photo-main--empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1.5px dashed var(--surface-3); background: none; }
.photo-main__shoot { display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 600; }
.photo-main__icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 24px rgba(47, 140, 255, 0.35);
}
.photo-main--empty .btn--text { width: auto; }

.photo-strip { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.photo-strip:empty { display: none; }
.photo-strip__item, .photo-strip__add {
  flex: none;
  width: 60px;
  height: 60px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.photo-strip__item img { width: 100%; height: 100%; object-fit: cover; }
.photo-strip__item[aria-pressed="true"] { border-color: var(--accent); }
.photo-strip__add { display: grid; place-items: center; color: var(--text-2); }

img.is-broken { visibility: hidden; }

/* ---------- Миниатюры, строки, плитки ---------- */
.thumb--sm { width: 44px; height: 44px; border-radius: 9px; }
.thumb--sm .thumb__number { font-size: var(--fs-tiny); min-width: 18px; padding: 0 4px; }
.thumb--md { width: 48px; height: 48px; }
.thumb--tile { width: 100%; height: auto; aspect-ratio: 1; border-radius: var(--r-thumb); }
.thumb--tile .icon { width: 32px; height: 32px; }

.container-card.is-conflict { box-shadow: inset 0 0 0 1px var(--danger); }
.text-danger { color: var(--danger); }

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px 8px 8px;
  border-radius: var(--r-card);
  background: var(--surface);
  text-align: left;
  transition: transform 120ms;
  -webkit-user-select: none;
  user-select: none;
}
.item-row:active { transform: scale(0.98); }
.item-row__text { flex: 1; min-width: 0; }
.item-row__title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row__meta { margin-top: 2px; color: var(--text-2); font-size: var(--fs-caption); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row > .icon { color: var(--text-3); }

.item-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 8px; margin-top: 14px; }
.item-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  text-align: left;
  transition: transform 120ms;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.item-tile:active { transform: scale(0.96); }
.item-tile__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: var(--fs-caption);
  line-height: 1.25;
}
.item-tile__qty {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: var(--fs-tiny);
  font-weight: 700;
}

.chips--compact .chip--icon { min-width: 52px; height: 40px; flex-direction: row; border-radius: 20px; font-size: 14px; }

.list-row__check { color: var(--accent); }
.list-row[aria-pressed="true"] .list-row__title,
.list-row[aria-pressed="true"] .list-row__text { color: var(--accent); }
.sheet-search { position: sticky; top: 0; z-index: 1; padding-bottom: 10px; background: var(--surface); }
.sheet-search .input { background: var(--surface-2); }

.banner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  padding: 14px;
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
}
.banner--danger { background: var(--danger-soft); color: #FF9C9E; }
.banner .btn { height: 42px; }

/* ---------- Просмотр фото ---------- */
.viewer {
  position: absolute;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, var(--fade, 1));
  animation: screen-fade 200ms ease both;
  touch-action: pan-x;
}
.viewer.is-closing { animation: fade-out 200ms ease both; }
.viewer__track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.viewer__track::-webkit-scrollbar { display: none; }
.viewer__slide { flex: none; display: grid; place-items: center; width: 100%; height: 100%; scroll-snap-align: center; }
.viewer__slide img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 8px 8px 20px;
  background: linear-gradient(rgba(0, 0, 0, 0.5), transparent);
  color: #fff;
}
.viewer__bar .icon-btn { color: #fff; }

/* ---------- Распознавание ---------- */
.recognize-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--text-2);
  font-size: 14px;
}
.recognize-status .icon { color: var(--accent); }
.recognize-status.is-working { color: var(--accent); }
.recognize-status.is-working .icon { animation: pulse 1.2s ease-in-out infinite; }
.recognize-status.is-done { color: var(--text); }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.85); } }

.auto-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  padding: 1px 8px 1px 6px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-tiny);
  font-weight: 600;
  vertical-align: middle;
}
.auto-badge .icon { width: 12px; height: 12px; }

.is-recognizing .input,
.is-recognizing .select-row {
  color: transparent;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.is-recognizing .input::placeholder { color: transparent; }
.is-recognizing .select-row * { visibility: hidden; }
@keyframes shimmer { to { background-position: -200% 0; } }

.suggestions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.suggestions .field__hint { margin: 0; }
.suggestions .chip--inline { height: 32px; padding: 0 12px; gap: 6px; background: var(--surface-2); font-size: 14px; }

.item-tile__pending {
  position: absolute;
  top: 6px;
  left: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- Поиск ---------- */
mark { padding: 0; border-radius: 3px; background: var(--accent-soft); color: var(--accent); }
.item-row__reason { margin-top: 2px; color: var(--accent); font-size: var(--fs-caption); }
.search-toolbar { display: flex; align-items: center; gap: 8px; }
.search-toolbar .section-title { flex: 1; }
.search-toolbar .icon-btn { margin-top: 10px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  margin-top: 10px;
  padding: 0 8px 0 12px;
  border-radius: 15px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}
.search-partial { margin: -4px 0 10px; }
.recent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-chip { display: inline-flex; align-items: center; height: 36px; border-radius: 18px; background: var(--surface); overflow: hidden; }
.recent-chip button:first-child { height: 100%; padding: 0 4px 0 14px; font-size: 15px; }
.recent-chip button:last-child { display: grid; place-items: center; width: 34px; height: 100%; color: var(--text-3); }
.sheet-details summary { list-style: none; cursor: pointer; }
.sheet-details summary::-webkit-details-marker { display: none; }
.sheet-details summary::after { content: " ›"; color: var(--text-3); }
.sheet-details[open] summary::after { content: " ⌄"; }
.avatar--sm { width: 26px; height: 26px; font-size: 12px; }

/* ---------- Свайп по строке ---------- */
.swipe { position: relative; border-radius: var(--r-card); overflow: hidden; }
.swipe__row { position: relative; z-index: 1; touch-action: pan-y; }
.swipe__under { position: absolute; inset: 0; display: flex; justify-content: space-between; }
.swipe__action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 88px;
  color: #fff;
  font-size: var(--fs-caption);
  font-weight: 500;
  visibility: hidden;
}
.swipe__action--danger { margin-left: auto; background: var(--danger); }
.swipe__action--edit { background: var(--surface-3); }
.swipe[data-side="end"] .swipe__action--end,
.swipe[data-side="start"] .swipe__action--start { visibility: visible; }
/* Полоса цвета коробки — по краю обёртки, а не уезжающей строки */
.swipe .container-card { border-radius: 0; }

/* ---------- Потяните вниз ---------- */
.ptr {
  position: absolute;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.ptr__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-2);
  border-right-color: transparent;
  border-radius: 50%;
}
.ptr.is-ready .ptr__spinner { border-color: var(--accent); border-right-color: transparent; }
.ptr.is-loading .ptr__spinner { animation: spin 700ms linear infinite; }

.fab.is-swiped { transform: translateY(-12px) scale(1.05); }

/* ---------- Быстрое добавление ---------- */
.quick-add__counter { color: var(--text-2); font-size: 14px; }
.quick-add__strip { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.quick-add__strip:empty { display: none; }
.quick-add__strip img { flex: none; width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.quick-add__photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 190px;
  margin-top: 10px;
  border: 1.5px dashed var(--surface-3);
  border-radius: 16px;
  font-weight: 600;
  overflow: hidden;
}
.quick-add__photo img { width: 100%; height: 100%; object-fit: cover; }
.quick-add__photo:has(img) { border: 0; }
.quick-add .field { margin-top: 12px; }
.quick-add .input, .quick-add .select-row { background: var(--surface-2); }
.chips--inline-scroll { margin-top: 12px; }
.chips--inline-scroll .chip--inline { height: 34px; gap: 6px; padding: 0 12px; background: var(--surface-2); }
.chips--inline-scroll .chip--inline[aria-pressed="true"] { background: var(--accent); }

/* ---------- Увеличение в просмотре фото ---------- */
.viewer.is-zoomed .viewer__track { overflow: hidden; touch-action: none; }
.viewer__slide img { will-change: transform; }

.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.icon-grid__item {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
}
.icon-grid__item[aria-checked="true"] { background: var(--accent); color: #fff; }
