:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f2f2f7);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0a0a0a);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent-2: #7c5cff;
  --accent-3: #ff5fa2;
  --success: #30d158;
  --danger: #e5484d;
  --danger-bg: rgba(229, 72, 77, .12);
  --success-bg: rgba(48, 209, 88, .14);
  --border: rgba(127, 127, 127, .14);
  --radius: 16px;
  --radius-sm: 13px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 14px 32px -16px rgba(0,0,0,.28);
  --ease: cubic-bezier(.22,1,.36,1);
  --glass: var(--bg-secondary);
  --card-blur: none;
  --icon-accent: var(--accent-2);
}

/* ---------- Тёмная тема ----------
   По умолчанию цвета берутся из --tg-theme-* (тема клиента Telegram).
   Когда клиент в тёмном режиме (applyColorScheme() в app.js), поверх
   накладывается своя фиксированная тёмная палитра - как в веб-панели
   настроек: тёмный градиентный фон, плоские карточки без блюра,
   фиолетовый акцент иконок. */
:root[data-theme="dark"] {
  --bg: #101014;
  --bg-secondary: #17141f;
  --text: #f2f2f2;
  --hint: #8e8e93;
  --border: rgba(255, 255, 255, .1);
  --glass: var(--bg-secondary);
  --card-blur: none;
}
:root[data-theme="dark"] html,
:root[data-theme="dark"] body {
  background: linear-gradient(160deg, #101014, #17141f);
}
:root[data-theme="dark"] .tile,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .stat-box {
  box-shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { min-height: 100%; background: var(--bg); }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  overscroll-behavior-y: none;
  padding-bottom: 24px;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
html.tg-fullscreen body {
  padding-bottom: calc(24px + var(--tg-safe-area-inset-bottom, 0px));
}

#app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#root { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#home { flex: 1; display: flex; flex-direction: column; }

::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--hint) 40%, transparent); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* ==================== Загрузочный экран ==================== */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  transition: opacity .4s var(--ease), visibility .4s var(--ease);
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }

/* Обёртка под лоадер «Волна точек». */
.loader-visual { position: relative; width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; }

.loader-dotwave { display: flex; align-items: center; justify-content: center; gap: 8px; }
.loader-dotwave span {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent-2);
  animation: dot-wave 1.2s ease-in-out infinite;
}
.loader-dotwave span:nth-child(odd) { background: var(--accent-3); }
.loader-dotwave span:nth-child(1) { animation-delay: 0s; }
.loader-dotwave span:nth-child(2) { animation-delay: .1s; }
.loader-dotwave span:nth-child(3) { animation-delay: .2s; }
.loader-dotwave span:nth-child(4) { animation-delay: .3s; }
.loader-dotwave span:nth-child(5) { animation-delay: .4s; }
@keyframes dot-wave {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-14px); }
}
.loader-text {
  display: flex;
  align-items: baseline;
  gap: 2px;
  color: var(--hint);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}
.dots i { font-style: normal; }
.dots i::before { content: "."; }
.dots i { animation: dot-blink 1.4s infinite; opacity: 0; }
.dots i:nth-child(1) { animation-delay: 0s; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot-blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* ==================== Отказ в доступе ==================== */

.denied {
  padding: 64px 24px;
  text-align: center;
  color: var(--hint);
  animation: pop-in .4s var(--ease) both;
  max-width: 420px;
  margin: 40px auto 0;
}
.denied-badge {
  width: 68px; height: 68px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  background: color-mix(in srgb, var(--danger) 14%, var(--glass));
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border));
  box-shadow: 0 10px 28px -14px color-mix(in srgb, var(--danger) 70%, transparent);
  animation: wobble 1.8s ease-in-out infinite;
}
@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

/* ==================== Домашний экран ==================== */

.home-header {
  padding: 22px 18px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fade-down .5s var(--ease) both;
}
html.tg-fullscreen .home-header {
  padding-top: calc(22px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
}
.home-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--accent) 65%, transparent);
  animation: icon-float 5s ease-in-out infinite;
}
@keyframes icon-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-4deg); }
}
.home-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
}
.home-subtitle {
  color: var(--hint);
  font-size: 12.5px;
  margin-top: 1px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px 14px 90px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  background: var(--glass);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border: .5px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 96px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  position: relative;
  opacity: 0;
  transform: translateY(10px);
  animation: card-in .5s var(--ease) forwards;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.tile:active {
  transform: scale(.97);
  box-shadow: none;
}
.tile .tile-icon {
  font-size: 20px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: color-mix(in srgb, var(--icon-accent) 18%, transparent);
}
.tile .tile-label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
}
.tile .tile-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.tile .tile-badge.on { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.tile .tile-badge.off { background: color-mix(in srgb, var(--hint) 18%, transparent); color: var(--hint); }

/* ==================== Экран раздела ==================== */

.section-header {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px 10px 2px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
html.tg-fullscreen .section-header {
  padding-top: calc(4px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
}
.back-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 25px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color .2s var(--ease), transform .12s var(--ease);
}
.back-btn:active { background: color-mix(in srgb, var(--accent) 12%, transparent); transform: scale(.92); }
.section-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.2px;
  padding: 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section { animation: detail-in .3s var(--ease) both; }
@keyframes detail-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.content { padding: 0 14px 90px; }

/* ==================== Карточки / списки ==================== */

.card {
  background: var(--glass);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border: .5px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card h3 { margin: 0 0 10px; font-size: 11px; color: var(--hint); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.card p.hint { margin: -4px 0 10px; font-size: 12.5px; color: var(--hint); line-height: 1.4; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: .5px solid var(--border);
  gap: 10px;
}
.row:last-child { border-bottom: none; }
.row .label { flex: 1; word-break: break-word; min-width: 0; }
.row .muted { color: var(--hint); font-size: 12px; margin-top: 2px; }
.row .actions { display: flex; gap: 6px; flex: 0 0 auto; }

.entity-name { font-weight: 600; }
.entity-username { color: var(--link); }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge.danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.badge.success { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge.neutral { background: color-mix(in srgb, var(--hint) 18%, transparent); color: var(--hint); }

.empty {
  text-align: center;
  color: var(--hint);
  padding: 28px 8px;
  font-size: 13px;
}

/* ==================== Вкладки (внутри раздела «Аналитика») ==================== */

.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 2px 12px;
}
.tab-btn {
  flex: 1 1 auto;
  min-width: 84px;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  color: var(--hint);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  text-align: center;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.tab-btn.active { background: linear-gradient(100deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-text); }
.tab-btn:active { transform: scale(.97); }

/* ==================== Статистика ==================== */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.stat-box {
  background: var(--glass);
  border: .5px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.stat-box .num { font-size: 22px; font-weight: 800; }
.stat-box .lbl { font-size: 11px; color: var(--hint); margin-top: 3px; text-transform: uppercase; letter-spacing: .03em; }

/* ==================== Формы ==================== */

label.field-label {
  display: block;
  font-size: 11px;
  color: var(--hint);
  margin: 10px 0 4px 2px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
label.field-label:first-child { margin-top: 0; }

input, textarea, select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease);
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--hint); }
textarea { min-height: 90px; resize: vertical; }

.field-group { position: relative; }

/* ==================== Кнопки ==================== */

button.btn {
  padding: 10px 16px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s var(--ease), opacity .15s var(--ease);
}
button.btn:active { transform: scale(.98); }
button.btn.block { width: 100%; }
button.btn.secondary {
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  color: var(--text);
  border: 1px solid var(--border);
}
button.btn.danger { background: var(--danger); color: #fff; }
button.btn.success { background: var(--success); color: #06280f; }
button.btn.small { padding: 6px 12px; min-height: 32px; font-size: 12.5px; border-radius: 10px; }
button.btn:disabled { opacity: .5; cursor: default; }

a.btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
  margin-bottom: 8px;
}

/* ==================== Переключатель ==================== */

.switch {
  width: 40px; height: 24px; border-radius: 12px;
  background: var(--border);
  position: relative; cursor: pointer; border: none; flex: 0 0 auto;
  transition: background .3s var(--ease);
}
.switch.on { background: linear-gradient(120deg, var(--success), #27c093); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent); }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .38s var(--ease);
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
}
.switch.on::after { transform: translateX(16px); }

/* ==================== Автодополнение поиска пользователя ==================== */

.suggest-list {
  background: var(--glass);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: -4px 0 10px;
  border: 1px solid var(--border);
}
.suggest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  gap: 8px;
  cursor: pointer;
  border-bottom: .5px solid var(--border);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.suggest-item .s-name { font-size: 13.5px; font-weight: 600; }
.suggest-item .s-sub { font-size: 11.5px; color: var(--hint); }

/* ==================== Гистограмма (активность по часам и т.п.) ==================== */

.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 70px;
  margin: 6px 0 4px;
}
.bar {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}
.bar-fill {
  width: 100%;
  min-height: 2px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-radius: 3px 3px 0 0;
}
.bar-lbl {
  font-size: 8px;
  color: var(--hint);
  margin-top: 3px;
  transform: rotate(0deg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ==================== Редактор БД ==================== */

.db-table-list { display: flex; flex-direction: column; gap: 6px; }
.db-table-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg) 45%, transparent);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background-color .2s var(--ease), transform .12s var(--ease);
}
.db-table-item:active { transform: scale(.99); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.db-table-item .db-table-names { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.db-table-item .db-table-name { font-weight: 700; font-size: 13.5px; }
.db-table-item .db-table-technical { color: var(--hint); font-size: 11.5px; font-family: monospace; }
.db-table-item .db-table-count { color: var(--hint); font-size: 12px; white-space: nowrap; }

.db-toolbar { display: flex; gap: 6px; margin-bottom: 10px; }
.db-toolbar input { flex: 1; margin: 0; }

.db-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table.db-grid { border-collapse: collapse; width: 100%; font-size: 12.5px; white-space: nowrap; }
table.db-grid th, table.db-grid td {
  padding: 7px 10px; border-bottom: .5px solid var(--border); text-align: left;
}
table.db-grid th { color: var(--hint); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; background: var(--bg); }
table.db-grid td { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.db-grid tr.db-row:active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
table.db-grid td.db-actions-cell { white-space: nowrap; }

.db-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 12.5px; color: var(--hint); }
.db-pager .btn { flex: 0 0 auto; }

.db-sql-textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; min-height: 120px; }
.db-sql-result { margin-top: 10px; }

/* Модалка добавления/редактирования строки */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 10, 14, .55); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px);
  animation: fade-down .25s var(--ease) both;
}
.modal-sheet {
  width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px;
  border: .5px solid var(--border);
  border-bottom: none;
  box-shadow: 0 -14px 40px -12px rgba(0,0,0,.35);
  animation: card-in .3s var(--ease) both;
}
.modal-sheet h3 { margin: 0 0 14px; font-size: 15px; font-weight: 800; }
.modal-field-label { font-size: 11px; color: var(--hint); margin: 8px 0 3px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

/* ==================== Тосты ==================== */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  color: var(--text); border: 1px solid var(--border);
  padding: 11px 20px 11px 34px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.32); z-index: 999; opacity: 0;
  animation: toast-in .35s var(--ease) forwards;
  max-width: calc(100% - 40px);
}
.toast::before {
  content: "";
  position: absolute;
  left: 18px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 18%, transparent);
}
.toast.err::before { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent); }
.toast.err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(.94); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- Custom icons (inline SVG, currentColor) ---------- */
.icon-svg { width: 1em; height: 1em; display: block; }
.home-icon .icon-svg { width: 19px; height: 19px; color: var(--accent-text); }
.tile .tile-icon .icon-svg { width: 19px; height: 19px; color: var(--icon-accent); }
.denied-badge .icon-svg { width: 30px; height: 30px; color: var(--danger); }
.section-title-icon {
  display: inline-flex;
  vertical-align: -3px;
  width: 20px; height: 20px;
  margin-right: 6px;
  color: var(--icon-accent);
}
.section-title-icon .icon-svg { width: 100%; height: 100%; }

/* ---------- Десктоп ----------
   Панель проектировалась под мобильный экран Telegram Mini App -
   на широком экране ПК она просто растягивается во всю ширину монитора.
   Никакого нового оформления не добавляем, только не даём контенту
   растягиваться шире разумного и центрируем по горизонтали. */
@media (min-width: 720px) {
  body { align-items: center; }
  #app { width: 100%; max-width: 480px; }
}

/* ==================== Подарки ==================== */

.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.gift-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 10px 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease), transform .15s var(--ease);
}
.gift-tile:active { transform: scale(.97); }
.gift-tile .gift-emoji { font-size: 30px; line-height: 1.15; }
.gift-tile .gift-price { font-size: 12.5px; font-weight: 700; }
.gift-tile .gift-title { font-size: 10.5px; color: var(--text, inherit); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gift-tile.limited:not(:disabled) { border-color: rgba(255, 140, 0, .45); }
.gift-tile .gift-tag { font-size: 11px; margin-left: 1px; }
.gift-filter { display: flex; gap: 6px; margin: 0 0 8px; flex-wrap: wrap; }
.gift-chip { border: 1px solid var(--border, rgba(128,128,128,.3)); background: transparent; color: inherit; border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.gift-chip.active { background: var(--accent, #2481cc); border-color: var(--accent, #2481cc); color: #fff; }
.gift-tile .gift-left { font-size: 10.5px; color: var(--hint); }
.gift-tile.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.gift-tile:disabled { opacity: .45; cursor: default; }
.gift-note { font-size: 12px; color: var(--hint); line-height: 1.4; margin: -4px 2px 10px; }
.gift-note.warn { color: var(--danger); }
.gift-counter { text-align: right; font-size: 11.5px; color: var(--hint); margin: -6px 2px 10px; }
.gift-summary { font-size: 12.5px; color: var(--hint); line-height: 1.45; margin: 0 2px 10px; }
.gift-summary.warn { color: var(--danger); }
.gift-link-btn {
  background: none; border: none; padding: 4px 2px; margin: 0 0 8px;
  color: var(--link); font-size: 12.5px; font-family: inherit; cursor: pointer;
}
