/* ==========================================================================
   telefoanebeius UI foundation
   Calm, product-first components shared by cards, product page, cart and checkout.
   Every new component uses the --tb-* tokens below; the brand colour still comes
   from the admin design settings (--primary).
   Light mode is html.light-mode; dark mode is the absence of that class.
   ========================================================================== */

:root {
  --tb-brand: var(--primary, #6366f1);
  --tb-brand-ink: #fff;
  --tb-brand-soft: color-mix(in srgb, var(--tb-brand) 14%, transparent);
  /* Brand colour for small text/links (AA 4.5:1). --tb-brand stays the fill colour. */
  --tb-brand-text: color-mix(in srgb, var(--tb-brand) 55%, #fff);

  --tb-canvas: #0b1020;
  --tb-surface: #121831;
  --tb-surface-2: #182042;
  --tb-stage: #1a2142;
  --tb-ink: #f5f7fb;
  --tb-ink-2: #c3c9d9;
  --tb-ink-3: #8d95ab;
  --tb-line: rgba(255, 255, 255, 0.09);
  --tb-line-strong: rgba(255, 255, 255, 0.16);

  --tb-ok: #34d399;
  --tb-ok-soft: rgba(52, 211, 153, 0.14);
  --tb-warn: #fbbf24;
  --tb-warn-soft: rgba(251, 191, 36, 0.14);
  --tb-bad: #f87171;
  --tb-bad-soft: rgba(248, 113, 113, 0.14);
  --tb-info: #7dd3fc;
  --tb-info-soft: rgba(125, 211, 252, 0.14);
  --tb-new: #a5b4fc;
  --tb-new-soft: rgba(165, 180, 252, 0.16);
  /* "Economisești X Lei" and other savings text: 6:1 on the dark and Black Friday surfaces */
  --tb-save: #ff4d67;

  --tb-r-sm: 8px;
  --tb-r-md: 12px;
  --tb-r-lg: 18px;
  --tb-r-xl: 24px;
  --tb-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.2);
  --tb-shadow-2: 0 10px 30px -12px rgba(0, 0, 0, 0.55);

  --tb-s1: 4px; --tb-s2: 8px; --tb-s3: 12px; --tb-s4: 16px; --tb-s5: 24px; --tb-s6: 32px; --tb-s7: 48px; --tb-s8: 64px;

  --tb-fs-xs: 0.75rem;  /* 12 */
  --tb-fs-sm: 0.875rem; /* 14 */
  --tb-fs-md: 1rem;     /* 16 */
  --tb-fs-lg: 1.125rem; /* 18 */
  --tb-fs-xl: 1.375rem; /* 22 */
  --tb-fs-2xl: 1.75rem; /* 28 */
  --tb-fs-3xl: clamp(1.6rem, 1.15rem + 1.6vw, 2.25rem);

  --tb-font: var(--font-main, 'Inter'), ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* Display face: headings, hero, prices. Inter Tight is Inter drawn tighter for large sizes. */
  --tb-font-display: var(--font-heading, 'Inter Tight'), 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --tb-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

html.light-mode {
  --tb-brand-ink: #fff;
  --tb-brand-text: color-mix(in srgb, var(--tb-brand) 85%, #000);
  --tb-canvas: #f6f7fb;
  --tb-surface: #ffffff;
  --tb-surface-2: #f8f9fc;
  --tb-stage: #f1f3f8;
  --tb-ink: #0f172a;
  --tb-ink-2: #3b4559;
  --tb-ink-3: #64748b;
  --tb-line: #e6e8ef;
  --tb-line-strong: #d5d9e3;

  --tb-ok: #15803d;
  --tb-ok-soft: #e8f7ee;
  --tb-warn: #b45309;
  --tb-warn-soft: #fdf3e2;
  --tb-bad: #b91c1c;
  --tb-bad-soft: #fdecec;
  --tb-info: #0369a1;
  --tb-info-soft: #e6f3fb;
  --tb-new: #4338ca;
  --tb-new-soft: #eef0ff;
  --tb-save: #be123c; /* 6.2:1 on white */

  --tb-shadow-1: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.06);
  --tb-shadow-2: 0 12px 32px -14px rgba(15, 23, 42, 0.22);
}

/* ---------- Typography ---------- */
/* Inter for text and UI, Inter Tight for display sizes (h1/h2, hero, section titles, prices).
   Both are loaded with latin-ext, so ș ț ă î â come from the webfont. */
body {
  font-family: var(--tb-font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Inter's contextual alternates turn "A3x" into "A3×" and "->" into arrows: keep model names literal. */
  font-variant-ligatures: no-contextual;
}
h1, h2 { font-family: var(--tb-font-display); letter-spacing: -0.012em; }
h3, h4, h5, h6 { font-family: var(--tb-font); letter-spacing: -0.006em; }
/* Small labels that happen to be h2 (footer columns, filter panel) read better in the text face. */
.footer-title, .tb-filters__title { font-family: var(--tb-font); letter-spacing: 0; }
.tb-display { font-family: var(--tb-font-display); }
/* Equal-width digits only where numbers stack in columns (totals, tables, counters, pager, countdown). Display prices
   stay proportional: Inter's tabular "1" is a full digit wide and "1.990 Lei" reads "1 .990". */
.tb-num, [class*='total'], [class*='summary'] { font-variant-numeric: tabular-nums; }
.tb-price, .tb-price__now, .tb-price__was { font-variant-numeric: proportional-nums; }

.tb-sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Visible keyboard focus everywhere the old CSS removed outlines. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--tb-brand);
  outline-offset: 2px;
}

/* ---------- Chips ---------- */
.tb-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: var(--tb-fs-xs); font-weight: 600; line-height: 1; letter-spacing: 0.01em;
  color: var(--tb-ink-2); background: var(--tb-surface-2); border: 1px solid var(--tb-line);
  white-space: nowrap;
}
.tb-chip i { font-size: 0.85em; }
.tb-chip--new { color: var(--tb-new); background: var(--tb-new-soft); border-color: transparent; }
.tb-chip--top { color: var(--tb-ok); background: var(--tb-ok-soft); border-color: transparent; }
.tb-chip--good { color: var(--tb-info); background: var(--tb-info-soft); border-color: transparent; }
.tb-chip--fair { color: var(--tb-warn); background: var(--tb-warn-soft); border-color: transparent; }
.tb-chip--ok { color: var(--tb-ok); background: var(--tb-ok-soft); border-color: transparent; }
.tb-chip--warn { color: var(--tb-warn); background: var(--tb-warn-soft); border-color: transparent; }
.tb-chip--bad { color: var(--tb-bad); background: var(--tb-bad-soft); border-color: transparent; }
.tb-chip--deal { color: #fff; background: #e11d48; border-color: transparent; }

/* ---------- Battery ---------- */
/* Compact: "🔋 92% · Originală" on cards. */
.tb-battery {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--tb-fs-xs); font-weight: 600; color: var(--tb-ink-2); line-height: 1.2;
}
.tb-battery__icon {
  position: relative; width: 18px; height: 9px; border: 1.5px solid currentColor; border-radius: 2.5px; flex: none; color: var(--tb-ink-3);
}
.tb-battery__icon::after {
  content: ''; position: absolute; right: -4px; top: 2px; width: 2px; height: 3px; border-radius: 0 1px 1px 0; background: currentColor;
}
.tb-battery__fill { position: absolute; left: 1px; top: 1px; bottom: 1px; border-radius: 1px; background: var(--tb-ink-3); }
.tb-battery--ok .tb-battery__fill { background: var(--tb-ok); }
.tb-battery--warn .tb-battery__fill { background: var(--tb-warn); }
.tb-battery--bad .tb-battery__fill { background: var(--tb-bad); }
.tb-battery--ok .tb-battery__pct { color: var(--tb-ok); }
.tb-battery--warn .tb-battery__pct { color: var(--tb-warn); }
.tb-battery--bad .tb-battery__pct { color: var(--tb-bad); }
.tb-battery__sep { color: var(--tb-ink-3); font-weight: 400; }
.tb-battery__type--aftermarket { color: var(--tb-warn); }

/* Full row on the product page: two facts side by side with a short explanation. */
.tb-battery-panel {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden;
  border: 1px solid var(--tb-line); border-radius: var(--tb-r-md); background: var(--tb-line);
}
.tb-battery-panel__cell { background: var(--tb-surface); padding: 12px 14px; display: grid; gap: 4px; }
.tb-battery-panel__label { font-size: var(--tb-fs-xs); color: var(--tb-ink-3); font-weight: 500; }
.tb-battery-panel__value { font-size: var(--tb-fs-md); font-weight: 700; color: var(--tb-ink); display: flex; align-items: center; gap: 8px; }
.tb-battery-panel__value--ok { color: var(--tb-ok); }
.tb-battery-panel__value--warn { color: var(--tb-warn); }
.tb-battery-panel__value--bad { color: var(--tb-bad); }
.tb-battery-panel__meter { height: 4px; border-radius: 4px; background: var(--tb-line); overflow: hidden; }
.tb-battery-panel__meter > span { display: block; height: 100%; border-radius: inherit; background: currentColor; }
.tb-battery-panel__note { grid-column: 1 / -1; background: var(--tb-surface-2); padding: 10px 14px; font-size: var(--tb-fs-xs); color: var(--tb-ink-2); line-height: 1.5; }

/* ---------- Product image stage (transparent cutouts) ---------- */
/* A soft stage tinted with the finish colour; the cutout sits centred with breathing room. */
.tb-stage {
  --tb-tint: var(--tb-stage);
  position: relative; display: grid; place-items: center; overflow: hidden;
  aspect-ratio: 1 / 1; border-radius: var(--tb-r-lg);
  background:
    radial-gradient(120% 90% at 50% 100%, color-mix(in srgb, var(--tb-tint) 26%, transparent) 0%, transparent 70%),
    var(--tb-stage);
}
.tb-stage > img {
  width: 100%; height: 100%; object-fit: contain; padding: 9%;
  filter: drop-shadow(0 18px 22px rgba(15, 23, 42, 0.16));
}
.tb-stage--photo > img { padding: 0; object-fit: cover; filter: none; }

/* Small caption on real photos: tells the buyer this is the exact unit. */
.tb-photo-tag {
  position: absolute; left: 10px; bottom: 10px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: #fff; background: rgba(15, 23, 42, 0.62); backdrop-filter: blur(6px);
}

/* ---------- Price ---------- */
.tb-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-variant-numeric: proportional-nums; }
.tb-price__now { font-family: var(--tb-font-display); font-size: var(--tb-fs-xl); font-weight: 700; color: var(--tb-ink); letter-spacing: -0.01em; text-shadow: none; } /* legacy .price-current added a green glow */
.tb-price__was { font-size: var(--tb-fs-sm); color: var(--tb-ink-3); text-decoration: line-through; }
.tb-price__save { font-size: var(--tb-fs-xs); font-weight: 600; color: var(--tb-save); }
.tb-price--lg .tb-price__now { font-size: var(--tb-fs-3xl); }
/* Legal reference of a reduction (lowest price of the 30 days before it, utils/blackFriday.js dealInfo) */
.tb-price__ref { display: block; margin: 6px 0 0; font-size: 0.8125rem; line-height: 1.5; color: var(--tb-ink-2); }
.tb-price__ref-main { display: block; }
.tb-price__ref-meta { display: block; color: var(--tb-ink-3); font-size: var(--tb-fs-xs); }
.tb-price__ref a { color: inherit; font-weight: 600; text-decoration: underline; text-decoration-color: currentColor; text-underline-offset: 2px; white-space: nowrap; }
.tb-price__ref a:hover { color: var(--tb-ink); }
.tb-price--lg .tb-price__was { font-size: var(--tb-fs-md); }

/* ---------- Buttons ---------- */
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--tb-r-md);
  font: 600 var(--tb-fs-md)/1 var(--tb-font); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color .15s var(--tb-ease), border-color .15s var(--tb-ease), transform .1s var(--tb-ease);
}
.tb-btn:active { transform: translateY(1px); }
.tb-btn--primary { background: var(--tb-brand); color: var(--tb-brand-ink); }
.tb-btn--primary:hover { background: color-mix(in srgb, var(--tb-brand) 88%, #000); }
.tb-btn--secondary { background: var(--tb-surface); color: var(--tb-ink); border-color: var(--tb-line-strong); }
.tb-btn--secondary:hover { border-color: var(--tb-ink-3); }
.tb-btn--ghost { background: transparent; color: var(--tb-ink-2); }
.tb-btn--block { width: 100%; }
.tb-btn[disabled], .tb-btn[aria-disabled='true'] { opacity: .5; cursor: not-allowed; }

/* ---------- Option pills (variant selector) ---------- */
.tb-options { display: grid; gap: 8px; }
.tb-options__label { font-size: var(--tb-fs-sm); color: var(--tb-ink-3); font-weight: 500; }
.tb-options__label strong { color: var(--tb-ink); font-weight: 600; }
.tb-options__list { display: flex; flex-wrap: wrap; gap: 8px; }
.tb-option {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px;
  border: 1px solid var(--tb-line-strong); border-radius: var(--tb-r-md); background: var(--tb-surface);
  color: var(--tb-ink); font-size: var(--tb-fs-sm); font-weight: 600; text-decoration: none; line-height: 1.15;
}
.tb-option small { display: block; font-size: 11px; font-weight: 500; color: var(--tb-ink-3); }
.tb-option:hover { border-color: var(--tb-ink-3); }
.tb-option[aria-current='true'], .tb-option.is-active { border-color: var(--tb-brand); box-shadow: inset 0 0 0 1px var(--tb-brand); }
.tb-option__swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); flex: none; }

/* ---------- Spec table ---------- */
.tb-specs { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; margin: 0; border-top: 1px solid var(--tb-line); }
.tb-specs dt, .tb-specs dd { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--tb-line); font-size: var(--tb-fs-sm); }
.tb-specs dt { color: var(--tb-ink-3); padding-right: 16px; }
.tb-specs dd { color: var(--tb-ink); font-weight: 500; }

/* ---------- Trust list ---------- */
.tb-trust { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; list-style: none; margin: 0; padding: 0; }
.tb-trust li { display: flex; gap: 10px; align-items: flex-start; font-size: var(--tb-fs-sm); color: var(--tb-ink-2); line-height: 1.35; }
.tb-trust i { color: var(--tb-brand); margin-top: 2px; width: 16px; text-align: center; }
.tb-trust strong { display: block; color: var(--tb-ink); font-weight: 600; }

/* ---------- Surfaces ---------- */
.tb-card { background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: var(--tb-r-lg); }
.tb-divider { height: 1px; background: var(--tb-line); border: 0; margin: var(--tb-s4) 0; }

/* ---------- Line thumbnail (cart, drawer, checkout, order) ---------- */
/* Square tile; real photos fill it, transparent cutouts sit on the tinted stage. */
.tb-thumb {
  --tb-tint: var(--tb-stage);
  position: relative; display: grid; place-items: center; flex: none; overflow: hidden;
  width: 100%; aspect-ratio: 1 / 1; border-radius: var(--tb-r-md);
  background: var(--tb-stage); border: 1px solid var(--tb-line); color: var(--tb-ink-3);
}
.tb-thumb > img { width: 100%; height: 100%; object-fit: cover; display: block; font-size: 0; color: transparent; } /* font-size 0 hides alt text of a broken image */
.tb-thumb--cutout { background: radial-gradient(120% 90% at 50% 100%, color-mix(in srgb, var(--tb-tint) 24%, transparent) 0%, transparent 70%), var(--tb-stage); }
.tb-thumb--cutout > img { object-fit: contain; padding: 10%; filter: drop-shadow(0 6px 8px rgba(15, 23, 42, 0.14)); }
.tb-thumb > i { font-size: 1.35rem; }

/* ---------- Pagination (views/partials/pagination.ejs) ---------- */
.tb-pager-block { display: grid; justify-items: center; gap: var(--tb-s3); margin: var(--tb-s6) 0 0; }
.tb-pager { display: flex; align-items: center; justify-content: center; gap: var(--tb-s2); max-width: 100%; }
.tb-pager__list { display: flex; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tb-pager__list > li { margin: 0; }
.tb-pager__num, .tb-pager__nav {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 44px; height: 44px; padding: 0 12px; box-sizing: border-box;
  border-radius: var(--tb-r-md); border: 1px solid var(--tb-line); background: var(--tb-surface);
  font: 600 var(--tb-fs-sm)/1 var(--tb-font); font-variant-numeric: tabular-nums;
  color: var(--tb-ink); text-decoration: none;
  transition: border-color .15s var(--tb-ease), background-color .15s var(--tb-ease);
}
.tb-pager__nav { padding: 0 16px; }
.tb-pager__nav i { font-size: 0.8em; }
a.tb-pager__num:hover, a.tb-pager__nav:hover { border-color: var(--tb-ink-3); color: var(--tb-ink); text-decoration: none; }
.tb-pager__num.is-current { background: var(--tb-ink); border-color: var(--tb-ink); color: var(--tb-surface); }
.tb-pager__nav.is-disabled { color: var(--tb-ink-3); background: transparent; opacity: .55; cursor: default; }
.tb-pager__gap { min-width: 24px; text-align: center; color: var(--tb-ink-3); font-weight: 600; user-select: none; }
.tb-pager__status { display: none; min-width: 72px; text-align: center; font: 600 var(--tb-fs-md)/1 var(--tb-font); font-variant-numeric: tabular-nums; color: var(--tb-ink); }
.tb-pager__summary { margin: 0; font-size: var(--tb-fs-sm); color: var(--tb-ink-3); font-variant-numeric: tabular-nums; text-align: center; }
.tb-pager__summary a { color: var(--tb-ink); font-weight: 600; }
@media (max-width: 1023px) {
  .tb-pager__label { display: none; }
  .tb-pager__nav { padding: 0 12px; }
}
/* Two lists are rendered (wide window ±2, narrow window ±1); CSS shows one. */
.tb-pager__list--narrow { display: none; }
@media (max-width: 599px) {
  .tb-pager { gap: 4px; }
  .tb-pager__list--wide { display: none; }
  .tb-pager__list--narrow { display: flex; gap: 4px; }
  .tb-pager__num { min-width: 38px; height: 40px; padding: 0 6px; }
  .tb-pager__nav { min-width: 40px; height: 40px; padding: 0; }
  .tb-pager__gap { min-width: 14px; }
}
/* Very narrow phones: ‹ 6 / 20 › */
@media (max-width: 359px) {
  .tb-pager { gap: var(--tb-s4); }
  .tb-pager__list--narrow { display: none; }
  .tb-pager__status { display: inline-block; }
  .tb-pager__nav { min-width: 48px; height: 48px; }
}

/* ---------- Email popup (Admin → Marketing → Campanii; built by /js/marketing-popup.js) ----------
   Same layout as the admin preview: picture on top, centred text, full-width field and button.
   Templates: modern (solid card), glass (see-through, blurred), minimal (flat, square corners). */
.mk-popup-overlay {
  position: fixed; inset: 0; z-index: 100000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, .55);
  opacity: 0; pointer-events: none;
  transition: opacity .22s var(--tb-ease);
}
.mk-popup-overlay.open { opacity: 1; pointer-events: auto; }
.mk-popup-card {
  position: relative;
  width: min(100%, 380px);
  background: var(--tb-surface);
  color: var(--tb-ink);
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-r-lg);
  box-shadow: 0 24px 64px -16px rgba(2, 6, 23, .45);
  font-family: var(--tb-font);
  text-align: center;
  transform: translateY(14px) scale(.98);
  transition: transform .28s var(--tb-ease);
}
.mk-popup-overlay.open .mk-popup-card { transform: none; }
/* No clipping / scrolling box around the content: Chrome then drops the glass blur and the picture.
   The picture rounds its own top corners; only very short screens scroll (see max-height query below). */
.mk-popup-media { position: relative; width: 100%; height: 190px; overflow: hidden; border-radius: calc(var(--tb-r-lg) - 1px) calc(var(--tb-r-lg) - 1px) 0 0; background: var(--tb-stage); }
.mk-popup-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mk-popup-body { padding: 22px 22px 20px; }
.mk-popup-card:not(.has-media) .mk-popup-body { padding-top: 44px; }
.mk-popup-title {
  margin: 0 0 6px;
  font-family: var(--tb-font-display);
  font-size: var(--tb-fs-xl);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--tb-ink);
  text-wrap: balance;
}
.mk-popup-subtitle { margin: 0 0 18px; font-size: var(--tb-fs-sm); line-height: 1.5; color: var(--tb-ink-3); text-wrap: pretty; }
.mk-popup-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.mk-popup-input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--tb-line-strong);
  border-radius: var(--tb-r-md);
  background: var(--tb-surface-2);
  color: var(--tb-ink);
  font: inherit;
  font-size: 16px; /* no zoom on iOS */
  text-align: center;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.mk-popup-input::placeholder { color: var(--tb-ink-3); }
.mk-popup-input:focus { outline: none; border-color: var(--tb-brand); box-shadow: 0 0 0 3px var(--tb-brand-soft); }
.mk-popup-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--tb-r-md);
  background: var(--tb-brand);
  color: var(--tb-brand-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.mk-popup-btn:hover { background: color-mix(in srgb, var(--tb-brand) 88%, #000); }
.mk-popup-btn:active { transform: translateY(1px); }
.mk-popup-btn:focus-visible { outline: 2px solid var(--tb-brand); outline-offset: 2px; }
.mk-popup-btn[disabled] { opacity: .6; cursor: wait; }
.mk-popup-trap { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
.mk-popup-code {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  margin-top: 14px; padding: 10px 12px;
  border: 1px dashed color-mix(in srgb, var(--tb-brand) 45%, transparent);
  border-radius: var(--tb-r-md);
  background: var(--tb-brand-soft);
  font-size: var(--tb-fs-sm);
  color: var(--tb-ink-2);
}
.mk-popup-code strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--tb-fs-md); letter-spacing: .06em; color: var(--tb-brand-text); }
.mk-popup-msg { min-height: 0; margin-top: 10px; font-size: var(--tb-fs-sm); color: var(--tb-ink-3); }
.mk-popup-msg:empty { display: none; }
.mk-popup-msg.is-ok { color: var(--tb-ok); font-weight: 500; }
.mk-popup-msg.is-error { color: var(--tb-bad); }
.mk-popup-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--tb-surface) 82%, transparent);
  color: var(--tb-ink);
  box-shadow: var(--tb-shadow-1);
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background .15s ease, transform .15s ease;
}
.mk-popup-close::before { content: ''; position: absolute; inset: -4px; } /* 44px tap area */
.mk-popup-close:hover { background: var(--tb-surface); transform: scale(1.05); }
.mk-popup-close:focus-visible { outline: 2px solid var(--tb-brand); outline-offset: 2px; }
.mk-popup-close svg { width: 16px; height: 16px; }

.mk-popup-overlay.template-glass { background: rgba(2, 6, 23, .4); }
.mk-popup-overlay.template-glass .mk-popup-card {
  background: color-mix(in srgb, var(--tb-surface) 84%, transparent);
  border-color: color-mix(in srgb, var(--tb-ink) 14%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
}
.mk-popup-overlay.template-glass .mk-popup-input { background: color-mix(in srgb, var(--tb-surface) 70%, transparent); }

.mk-popup-overlay.template-minimal .mk-popup-card { border-radius: var(--tb-r-sm); box-shadow: 0 12px 32px -14px rgba(2, 6, 23, .35); }
.mk-popup-overlay.template-minimal .mk-popup-media { border-radius: calc(var(--tb-r-sm) - 1px) calc(var(--tb-r-sm) - 1px) 0 0; }
.mk-popup-overlay.template-minimal .mk-popup-input,
.mk-popup-overlay.template-minimal .mk-popup-btn,
.mk-popup-overlay.template-minimal .mk-popup-code { border-radius: 6px; }
.mk-popup-overlay.template-minimal .mk-popup-input { background: var(--tb-surface); }

@media (max-width: 480px) {
  /* Phone: a sheet from the bottom, thumbs reach the field and the button */
  .mk-popup-overlay { align-items: flex-end; padding: 0; }
  .mk-popup-card { width: 100%; border-radius: var(--tb-r-lg) var(--tb-r-lg) 0 0; border-bottom: 0; transform: translateY(100%); padding-bottom: env(safe-area-inset-bottom); }
  .mk-popup-overlay.template-minimal .mk-popup-card { border-radius: var(--tb-r-sm) var(--tb-r-sm) 0 0; }
  .mk-popup-media { height: 150px; }
  .mk-popup-body { padding: 18px 18px 20px; }
}
@media (max-height: 620px) {
  /* Short screen (phone in landscape): the card scrolls, glass turns solid so it stays readable */
  .mk-popup-card { max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain; }
  .mk-popup-media { height: 110px; }
  .mk-popup-overlay.template-glass .mk-popup-card { background: var(--tb-surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
