/* Общая база всех сервисов сайта: шрифт, токены темы и компоненты shadcn/ui.
   Подключается первой, своим styles.css сервис только дополняет её.

   Компоненты повторяют shadcn/ui (стиль new-york, тема dark, base neutral);
   рядом с каждым в комментарии записаны исходные классы Tailwind. --primary
   заменён на Tailwind violet-500. */

/* Inter Variable — локальные субсеты (см. update-vendor.sh) */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("vendor/inter/inter-cyrillic-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("vendor/inter/inter-cyrillic-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("vendor/inter/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --radius: 0.625rem;
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.269 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.606 0.25 292.717);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.371 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --success: oklch(0.696 0.17 162.48);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  /* высота шапки — от неё считаются sticky-отступы внутри страниц */
  --header-h: 52px;
  /* ширина колонки с содержимым: по ней же выравнивается шапка, иначе на
     широком экране её текст уезжает к самому краю окна. Страница с колонкой
     пошире переопределяет это у себя. */
  --content-w: 440px;
  /* tailwind shadow-xs / shadow-sm / shadow-md на тёмном фоне */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.35), 0 1px 2px -1px rgb(0 0 0 / 0.35);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

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

/* Собственный display у .alert и .field перебивает hidden — возвращаем его силу */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--foreground);
  font-family: "Inter Variable", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}

/* Иконка: размер и цвет наследует от родителя */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Шапка сайта ───────────────────────────────────────────────────────── */
/* Одна на все сервисы: слева возврат на главную, дальше название сервиса.
   Прижата к верху, чтобы уйти с неё можно было с любого места страницы. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  flex: none;
  /* прижимаемся к левой границе содержимого, а на узком экране — к краю */
  padding-inline: max(6px, calc((100% - var(--content-w)) / 2));
  background: color-mix(in oklch, var(--background) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .site-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-header .site-ver { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--muted-foreground); }
.site-header .site-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: calc(var(--radius) - 4px);
  background: color-mix(in oklch, var(--primary) 15%, transparent);
  color: var(--primary);
  font-size: 18px;
}

/* Контент страницы: узкая колонка по центру — так открываются все сервисы,
   кроме tag2ean, который занимает экран целиком (см. .fill). */
.main { flex: 1; display: flex; justify-content: center; padding: 16px; }
.wrap {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: env(safe-area-inset-bottom);
}
/* Короткая страница вешается по центру экрана: прижатая к шапке карточка
   оставляет снизу пустое поле и выглядит обрезком. safe center — чтобы на
   низком экране контент не уехал под шапку, а прокрутился. */
.main.center { align-items: center; align-items: safe center; }

.main.fill { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); min-height: 0; }
.main.fill .wrap { max-width: 480px; gap: 12px; flex: 1; min-height: 0; }

/* ── Card (shadcn: rounded-xl border py-6 shadow-sm, gap-6) ────────────── */
.card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-sm);
}

.card-header { display: flex; align-items: center; gap: 12px; }
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted-foreground);
}
.card-title .icon { font-size: 16px; }
.card-desc { font-size: 13px; line-height: 18px; color: var(--muted-foreground); }

.icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in oklch, var(--primary) 15%, transparent);
  color: var(--primary);
  font-size: 20px;
}

/* ── Field / Label / Hint ──────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.label { font-size: 14px; line-height: 1; font-weight: 500; }
.label.muted { color: var(--muted-foreground); font-weight: 400; }
.hint { margin: 0; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.hint b { font-weight: 600; color: var(--foreground); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ── Input (shadcn: h-9 rounded-md border px-3 py-1 shadow-xs) ─────────── */
.input-wrap { position: relative; display: flex; }
.input {
  height: 36px;
  width: 100%;
  min-width: 0;
  padding: 4px 12px;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  /* 16px — иначе iOS зумит страницу при фокусе */
  font-size: 16px;
  line-height: 24px;
  box-shadow: var(--shadow-xs);
  outline: none;
  transition: color .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.input::placeholder { color: var(--muted-foreground); }
.input:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 50%, transparent);
}
.input[aria-invalid="true"] {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--destructive) 40%, transparent);
}
/* стрелки у number ни на телефоне, ни на десктопе не нужны */
.input::-webkit-outer-spin-button,
.input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.input-wrap .suffix {
  position: absolute;
  top: 0;
  right: 12px;
  height: 36px;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: var(--muted-foreground);
  pointer-events: none;
}
.input-wrap.has-suffix .input { padding-right: 40px; }

/* Поле с приклеенным хвостом (домен почты) — рамка общая, суффикс внутри */
.input-group {
  display: flex;
  align-items: center;
  height: 36px;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 50%, transparent);
}
.input-group .input { height: 34px; border: none; border-radius: 0; box-shadow: none; }
.input-group .input:focus-visible { box-shadow: none; }
.input-group .suffix {
  flex: none;
  padding-right: 12px;
  font-size: 14px;
  color: var(--muted-foreground);
  white-space: nowrap;
}

/* ── Select (shadcn) ───────────────────────────────────────────────────── */
.select { position: relative; }
.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.select-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 50%, transparent);
}
.select-trigger .icon { font-size: 16px; opacity: .5; transition: transform .15s ease; }
.select-trigger[aria-expanded="true"] .icon { transform: rotate(180deg); }

.select-content {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);
  animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-2px); } }

.select-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 32px 6px 8px;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  cursor: pointer;
}
.select-item:hover,
.select-item:focus-visible { background: var(--accent); color: var(--accent-foreground); outline: none; }
.select-item .check { position: absolute; right: 8px; font-size: 14px; display: none; }
.select-item[aria-selected="true"] .check { display: block; }
.select-item .rate { margin-left: auto; font-size: 12px; color: var(--muted-foreground); }
.select-item[aria-selected="true"] .rate,
.select-item:hover .rate { color: inherit; opacity: .7; }

/* ── ToggleGroup, variant outline (shadcn) ─────────────────────────────── */
.toggle-group { display: flex; width: 100%; }
.toggle {
  flex: 1;
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  margin-left: -1px;
  border: 1px solid var(--input);
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  outline: none;
  transition: background-color .15s ease, color .15s ease;
}
.toggle:first-child { margin-left: 0; border-radius: calc(var(--radius) - 2px) 0 0 calc(var(--radius) - 2px); }
.toggle:last-child { border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0; }
.toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-foreground); }
.toggle:focus-visible { z-index: 1; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 50%, transparent); }
@media (hover: hover) { .toggle:hover { background: color-mix(in oklch, var(--accent) 60%, transparent); } }

/* ── Tabs (shadcn: TabsList h-9 rounded-lg bg-muted p-[3px]) ───────────── */
.tabs {
  display: flex;
  align-items: center;
  height: 36px;
  flex: none;
  padding: 3px;
  border-radius: calc(var(--radius) - 2px);
  background: var(--muted);
  color: var(--muted-foreground);
}
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  height: 100%;
  padding: 0 8px;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  transition: background-color .15s ease, color .15s ease;
}
.tab .icon { font-size: 16px; }
.tab[aria-selected="true"] { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-xs); }
.tab:focus-visible { box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 50%, transparent); }

/* ── Switch (shadcn) ───────────────────────────────────────────────────── */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row .label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.switch-row .label .icon { font-size: 16px; color: var(--muted-foreground); }
.switch {
  position: relative;
  flex: none;
  width: 32px;
  height: 18px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--input);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  outline: none;
  transition: background-color .15s ease;
}
.switch[aria-checked="true"] { background: var(--primary); }
.switch:focus-visible { box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 50%, transparent); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.switch .thumb {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--foreground);
  transform: translateX(1px);
  transition: transform .15s ease;
}
.switch[aria-checked="true"] .thumb { background: var(--primary-foreground); transform: translateX(15px); }

/* ── Alert, variant destructive (shadcn) ───────────────────────────────── */
.alert {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid color-mix(in oklch, var(--destructive) 50%, transparent);
  border-radius: calc(var(--radius) - 2px);
  color: var(--destructive);
  font-size: 13px;
  line-height: 18px;
}
.alert .icon { font-size: 16px; margin-top: 1px; }
/* без иконки — одной колонкой, текст не уезжает вправо */
.alert.text-only { display: block; text-align: center; font-weight: 500; }

/* ── Badge, variant secondary (shadcn: rounded-md border px-2 py-0.5 text-xs) ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: calc(var(--radius) - 4px);
  background: var(--secondary);
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.separator { height: 1px; flex: none; background: var(--border); }

/* ── Button (shadcn) ───────────────────────────────────────────────────── */
/* base: inline-flex h-9 rounded-md px-4 text-sm font-medium; варианты ниже */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: none;
  height: 36px;
  padding: 8px 16px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn .icon { font-size: 16px; }
.btn:focus-visible { box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 50%, transparent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* variant default */
.btn-primary { background: var(--primary); color: var(--primary-foreground); box-shadow: var(--shadow-xs); }
.btn-primary:active:not(:disabled) { background: color-mix(in oklch, var(--primary) 90%, black); }
@media (hover: hover) { .btn-primary:hover:not(:disabled) { background: color-mix(in oklch, var(--primary) 90%, black); } }

/* variant secondary */
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); box-shadow: var(--shadow-xs); }
.btn-secondary:active:not(:disabled) { background: color-mix(in oklch, var(--secondary) 80%, transparent); }
@media (hover: hover) { .btn-secondary:hover:not(:disabled) { background: color-mix(in oklch, var(--secondary) 80%, transparent); } }

/* variant outline */
.btn-outline { border: 1px solid var(--input); background: var(--background); box-shadow: var(--shadow-xs); }
.btn-outline:active:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }
@media (hover: hover) { .btn-outline:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); } }

/* variant ghost */
.btn-ghost { color: var(--muted-foreground); }
.btn-ghost:active:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }
@media (hover: hover) { .btn-ghost:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); } }
.btn-ghost.text-destructive:active { color: var(--destructive); }
@media (hover: hover) { .btn-ghost.text-destructive:hover { color: var(--destructive); } }

/* размеры: lg — основное действие на телефоне, icon — только иконка */
.btn-lg { height: 44px; padding: 0 24px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; height: 32px; }
.btn-block { width: 100%; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sonner (тосты) ────────────────────────────────────────────────────── */
.toaster {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  padding: 12px 14px;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 18px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast .icon { font-size: 16px; }
.toast.ok .icon { color: var(--success); }
.toast.err .icon { color: var(--destructive); }
.toast.wait .icon { color: var(--primary); }

/* прогресс загрузки — тонкой полосой по нижнему краю тоста */
.toast-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--primary);
  transition: width .2s ease, background-color .2s ease;
}
.toast.ok .toast-bar { background: var(--success); }

/* ── Dialog (shadcn) ───────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  background: rgb(0 0 0 / 0.5);
  opacity: 0;
  transition: opacity .2s ease;
}
.dialog-overlay.show { display: block; opacity: 1; }
.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 50;
  display: none;
  grid-template-columns: 1fr;
  gap: 16px;
  width: 100%;
  max-width: calc(100% - 2rem);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background: var(--background);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, -50%) scale(.95);
  transition: opacity .2s ease, transform .2s ease;
}
.dialog.show { display: grid; opacity: 1; transform: translate(-50%, -50%) scale(1); }
@media (min-width: 640px) { .dialog { max-width: 32rem; } }
.dialog img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: calc(var(--radius) - 2px); }
.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  padding: 6px;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: none;
  color: var(--foreground);
  font-size: 16px;
  opacity: .7;
  cursor: pointer;
  transition: opacity .15s ease;
}
.dialog-close:hover { opacity: 1; }
