/* DiCards PWA — тёмная премиальная тема (перенос палитры из Android-версии) */
:root {
  --bg: #0A0C10;
  --surface: #141822;
  --surface-elevated: #1E2433;
  --primary: #2F80ED;
  --accent: #8A46FF;
  --pink: #FF2E93;
  --text: #F2F5FA;
  --muted: #8E9AA8;
  --glass: rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.14);
  --danger: #FF5858;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  padding-bottom: 96px;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: var(--primary); }

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 10px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg) 75%, transparent);
  z-index: 5;
}
.topbar h1 { font-size: 28px; font-weight: 800; }
.topbar__title-small { font-size: 20px !important; font-weight: 700 !important; flex: 1; }
.topbar__actions { display: flex; gap: 8px; align-items: center; }
.topbar__spacer { width: 40px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  font-size: 19px;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(242, 245, 250, 0.75);
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon-btn--accent { background: rgba(47, 128, 237, 0.15); color: var(--primary); font-size: 24px; }
.icon-btn--danger { color: var(--danger); }
.icon-btn.is-fav { color: #FFD600; }
.icon-btn.is-signed-in { color: var(--primary); }

.avatar { width: 28px; height: 28px; border-radius: 50%; display: block; }
.avatar--big { width: 64px; height: 64px; border-radius: 50%; margin-bottom: 6px; }

/* ---------- Поиск ---------- */
.search-wrap { position: relative; padding: 4px 16px 8px; }
.search-icon {
  position: absolute; left: 30px; top: 50%;
  transform: translateY(-54%);
  color: var(--muted); font-size: 18px; pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 13px 42px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: rgba(20, 24, 34, 0.6);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.18);
  background: var(--surface);
}
.search-wrap input::placeholder { color: var(--muted); }
.search-clear {
  position: absolute; right: 26px; top: 50%;
  transform: translateY(-54%);
  color: var(--muted); font-size: 14px; padding: 6px;
}

/* ---------- Чипы категорий ---------- */
.chips {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 8px 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips--wrapless { padding: 8px 0; }
.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.chip--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

/* ---------- Контент ---------- */
.content { padding: 8px 16px 24px; }
.section-title { font-size: 18px; font-weight: 700; margin: 14px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; padding: 16px 0; }

/* ---------- Карта ---------- */
.card {
  position: relative;
  aspect-ratio: 1.58;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}
.card:active { transform: scale(0.98); }
.card__shine {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 55%);
  pointer-events: none;
}
.card__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; z-index: 1; }
.card__titles { min-width: 0; }
.card__name {
  font-size: 20px; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.card__category { font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, 0.75); margin-top: 2px; }
.card__fav {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 18px; line-height: 1;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.card__fav.is-fav { color: #FFD600; }
.card__number {
  align-self: flex-end;
  font-size: 18px; font-weight: 700;
  letter-spacing: 1px;
  z-index: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.card--small .card__name { font-size: 17px; }
.card--small .card__number { font-size: 15px; }

.cards-list { display: flex; flex-direction: column; gap: 16px; }
.fav-row {
  display: flex; gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin: 0 -16px;
  padding-left: 16px; padding-right: 16px;
  scrollbar-width: none;
}
.fav-row::-webkit-scrollbar { display: none; }
.fav-row .card { flex: 0 0 260px; }

/* ---------- Пустое состояние ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 64px 24px;
  gap: 10px;
}
.empty__icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(47, 128, 237, 0.15);
  color: var(--primary);
  font-size: 36px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.empty h2 { font-size: 20px; }
.empty p { color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 280px; }
.empty .btn { margin-top: 12px; }

/* ---------- Кнопки ---------- */
.btn {
  padding: 13px 22px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-weight: 600;
  font-size: 15px;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.15); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--big { width: 100%; padding: 16px; font-size: 16px; font-weight: 700; margin-top: 8px; }
.btn--square { width: 50px; height: 50px; padding: 0; font-size: 20px; flex-shrink: 0; }
.link-btn { color: var(--primary); font-size: 13px; font-weight: 700; }

.fab {
  position: fixed;
  bottom: 22px; right: 50%;
  transform: translateX(calc(min(520px, 100vw) / 2 - 22px - 100%));
  padding: 15px 22px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(47, 128, 237, 0.45);
  z-index: 6;
}
@media (max-width: 560px) {
  .fab { right: 22px; transform: none; }
}

/* ---------- Форма ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field__row { display: flex; gap: 8px; align-items: center; }
.field__row--between { justify-content: space-between; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.18);
}
.field textarea { resize: vertical; font-family: inherit; }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238E9AA8' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.palette { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.swatch:hover { transform: scale(1.1); }
.swatch--active { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2); }

/* ---------- Просмотр карты ---------- */
.barcode-box {
  margin-top: 22px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  cursor: pointer;
}
.barcode-box__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.barcode-box__canvas-wrap {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  display: flex; align-items: center; justify-content: center;
}
.barcode-box__canvas-wrap.is-qr { width: 70%; }
.barcode-box canvas { width: 100%; height: auto; display: block; image-rendering: pixelated; }
.barcode-error { color: #C62828; font-size: 14px; font-weight: 600; text-align: center; padding: 20px 8px; }
.barcode-box__number {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 21px; font-weight: 700; letter-spacing: 2px;
}
.barcode-box__hint { font-size: 11px; color: var(--muted); }

.notes-box {
  margin-top: 22px;
  border-radius: 16px;
  background: rgba(30, 36, 51, 0.5);
  border: 1px solid var(--glass-border);
  padding: 16px;
}
.notes-box__label { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.notes-box__text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }

/* ---------- Полноэкранный код ---------- */
.fullscreen-barcode {
  position: fixed; inset: 0;
  background: #fff;
  color: #0A0C10;
  z-index: 50;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  padding: 24px;
  cursor: pointer;
}
.fullscreen-barcode canvas { max-width: 92vw; max-height: 60vh; width: auto; image-rendering: pixelated; }
.fullscreen-barcode__name { font-size: 22px; font-weight: 800; }
.fullscreen-barcode__number {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 24px; font-weight: 700; letter-spacing: 2px;
}
.fullscreen-barcode__hint { font-size: 13px; color: #667; }

/* ---------- Сканер ---------- */
.scanner {
  position: fixed; inset: 0;
  background: #000;
  z-index: 60;
  display: flex; flex-direction: column;
}
.scanner__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px;
  color: #fff; font-weight: 600;
  z-index: 2;
}
.scanner__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner__frame {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(78vw, 340px);
  height: min(50vw, 220px);
  border: 3px solid var(--primary);
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
}

/* ---------- Модальные окна ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 { font-size: 20px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal__actions--column { flex-direction: column; }
.modal__actions--column .btn { width: 100%; }

.about { text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.about__logo {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff; font-size: 30px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
}
.about__desc { font-size: 13px; line-height: 1.5; margin: 6px 0; }
.about__strong { font-weight: 700; }
.about .modal__actions { width: 100%; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface-elevated);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 70;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
