:root {
  color-scheme: dark;
  --bg0: #1a1410;
  --bg1: #2a2118;
  --ink: #f3e6d4;
  --muted: #b9a690;
  --accent: #e85d04;
  --accent2: #ffba08;
  --card: #241c15;
  --card-soft: rgba(36, 28, 21, 0.85);
  --line: rgba(243, 230, 212, 0.12);
  --line-strong: rgba(243, 230, 212, 0.16);
  --wine: #4a1e1a;
  --ok: #7cb518;
  --danger: #c1341a;
  --radius: 0.5rem;
  --font-display: "Syne", ui-sans-serif, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --max-main: 960px;
  --max-shell: 1180px;
}

* { box-sizing: border-box; }
html {
  margin: 0;
  min-height: 100%;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--bg0);
  background-image:
    radial-gradient(120% 80% at 12% -10%, rgba(74, 30, 26, 0.55) 0%, transparent 55%),
    radial-gradient(90% 70% at 100% 0%, rgba(232, 93, 4, 0.14) 0%, transparent 50%),
    radial-gradient(120% 120% at 50% 120%, rgba(42, 33, 24, 0.9) 0%, transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

.noise,
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  /* No z-index here: it would trap .site-header below body-level .nav-scrim. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* Fixed header: sticky breaks under overflow-x on ancestors (mobile Safari). */
  padding-top: calc(4rem + env(safe-area-inset-top, 0px));
}
@media (max-width: 480px) {
  .shell {
    padding-top: calc(3.5rem + env(safe-area-inset-top, 0px));
  }
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  border-bottom: 1px solid var(--line);
  background: rgba(26, 20, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-top: env(safe-area-inset-top, 0px);
}
.site-header-inner {
  max-width: var(--max-main);
  margin: 0 auto;
  padding: 0 1rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
  position: relative;
}
@media (max-width: 480px) {
  .site-header-inner {
    height: 3.5rem;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }
  .brand-mark { font-size: 1.55rem; }
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}
.brand-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(232, 93, 4, 0.35);
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.85rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
  transition: transform 0.15s ease;
}
.brand:hover .brand-mark { transform: rotate(-3deg); }
.brand:hover .brand-icon { transform: rotate(-4deg) scale(1.03); transition: transform 0.15s ease; }
.brand-sub {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--muted);
}
@media (max-width: 560px) {
  .brand-sub { display: none; }
}

#nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}
#nav a,
#nav .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  border: none;
  background: transparent;
  color: rgba(243, 230, 212, 0.8);
  font: inherit;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
#nav a:hover,
#nav .nav-link:hover {
  background: var(--bg1);
  color: var(--ink);
}
#nav a.nav-admin { color: var(--accent2); }
#nav a.nav-admin:hover {
  background: var(--bg1);
  color: var(--accent2);
}
#nav a.nav-login {
  background: var(--accent);
  color: var(--bg0);
  font-weight: 700;
  padding: 0.5rem 1rem;
}
#nav a.nav-login:hover {
  background: var(--accent2);
  color: var(--bg0);
}
#nav .nav-user {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 0.5rem 0 0.35rem;
  border-radius: var(--radius);
  background: var(--bg1);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
}
#nav .nav-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: calc(var(--radius) * 0.8);
  background: var(--accent);
  color: var(--bg0);
  font-size: 0.7rem;
  font-weight: 800;
}
#nav .nav-user-name {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  z-index: 2;
}
.nav-burger-lines,
.nav-burger-lines::before,
.nav-burger-lines::after {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  position: relative;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.nav-burger-lines::before,
.nav-burger-lines::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-burger-lines::before { top: -6px; }
.nav-burger-lines::after { top: 6px; }
.nav-burger[aria-expanded="true"] .nav-burger-lines { background: transparent; }
.nav-burger[aria-expanded="true"] .nav-burger-lines::before {
  top: 0;
  transform: rotate(45deg);
}
.nav-burger[aria-expanded="true"] .nav-burger-lines::after {
  top: 0;
  transform: rotate(-45deg);
}
.nav-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.nav-scrim.is-open { display: block; }

@media (max-width: 720px) {
  .nav-burger { display: inline-flex; }
  #nav {
    position: fixed;
    top: calc(3.5rem + env(safe-area-inset-top, 0px));
    right: 0.75rem;
    left: auto;
    width: min(16.5rem, calc(100vw - 1.5rem));
    max-height: calc(100dvh - 4.5rem - env(safe-area-inset-top, 0px));
    overflow: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: rgba(26, 20, 16, 0.97);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-0.35rem);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 110;
  }
  #nav.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
  }
  #nav a,
  #nav .nav-link,
  #nav .nav-user {
    width: 100%;
    justify-content: flex-start;
    padding: 0.7rem 0.85rem;
  }
  #nav a.nav-login {
    justify-content: center;
    margin-top: 0.25rem;
  }
  #nav .nav-user-name { display: inline; max-width: none; }
  #nav .nav-logout-label { display: inline; }
}
@media (min-width: 481px) and (max-width: 720px) {
  #nav {
    top: calc(4rem + env(safe-area-inset-top, 0px));
  }
}
@media (min-width: 721px) {
  #nav .nav-user-name { display: inline; }
}

.ad-strip {
  max-width: var(--max-main);
  margin: 0 auto;
  padding: 0.75rem 1rem 0;
  width: 100%;
}
@media (max-width: 640px) {
  .ad-strip {
    padding: 0.5rem 0.75rem 0;
  }
  .ad-strip .ad-slot {
    min-height: 2.75rem;
    padding: 0.45rem;
  }
  .ad-strip .ad-placeholder { display: none; }
}
.shell-body {
  display: flex;
  flex: 1;
  gap: 1.5rem;
  width: 100%;
  max-width: var(--max-shell);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  min-width: 0;
}
@media (max-width: 640px) {
  .shell-body {
    gap: 0;
    padding: 1rem 0.75rem 1.5rem;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }
}
/* Must beat .ad-slot { display:flex } — was crushing mobile layout */
.ad-slot.side-ad,
.side-ad {
  display: none !important;
  position: sticky;
  top: 6rem;
  flex: 0 0 10rem;
  width: 10rem;
  height: 520px;
  align-self: start;
}
@media (min-width: 1280px) {
  .ad-slot.side-ad,
  .side-ad {
    display: flex !important;
  }
}
main#app {
  flex: 1;
  width: 100%;
  max-width: var(--max-main);
  margin: 0 auto;
  min-width: 0;
  overflow-x: clip;
}
main#app > * { min-width: 0; max-width: 100%; }

.ad-slot {
  border: 1px dashed var(--line);
  background: rgba(36, 28, 21, 0.4);
  border-radius: var(--radius);
  min-height: 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem;
  text-align: center;
}
.ad-slot.ad-side {
  height: 100%;
  min-height: 520px;
}
.ad-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--muted);
}
.ad-placeholder {
  font-size: 0.75rem;
  color: rgba(185, 166, 144, 0.7);
}

.foot {
  margin-top: 4rem;
  border-top: 1px solid var(--line);
}
.foot-inner {
  max-width: var(--max-main);
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
@media (min-width: 640px) {
  .foot-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.foot-brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 0.35rem;
}
.foot-copy {
  margin: 0;
  max-width: 24rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
}
.foot-bot {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.foot-bot:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.foot-bot a {
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin-top: 0.85rem;
}
.foot-links a {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.foot-links a:hover { color: var(--accent); }

.legal-doc {
  max-width: 44rem;
}
.legal-doc h2 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.15rem;
}
.legal-doc p,
.legal-doc li {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}
.legal-doc ul {
  padding-left: 1.2rem;
  margin: 0.4rem 0 0.8rem;
}
.legal-doc .legal-updated {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.85;
}
.studio-legal {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}
.studio-legal a { color: var(--accent2, #3ecf8e); }

.tariff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}
.tariff-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.tariff-card-accent {
  border-color: rgba(255, 186, 8, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 186, 8, 0.12);
}
.tariff-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.85rem;
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #111;
  background: var(--accent);
  padding: 0.2rem 0.45rem;
  border-radius: 0.25rem;
}
.tariff-name {
  margin: 0;
  font-size: 1.15rem;
}
.tariff-price {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.1;
}
.tariff-price span { font-size: 0.7em; }
.tariff-meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.tariff-perks {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
.tariff-cta { margin-top: auto; text-align: center; }
.tariff-status {
  margin: 0.5rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 0.9rem;
  line-height: 1.45;
}
.tariff-status.ok { border-color: rgba(62, 207, 142, 0.35); }
.tariff-status.warn { border-color: rgba(255, 186, 8, 0.35); }
.tariff-note {
  margin-top: 0.5rem;
  padding: 1rem 1.1rem;
}
.tariff-note h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.tariff-note ol {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  padding: 0.75rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  background: rgba(12, 10, 8, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.cookie-banner[hidden] { display: none !important; }
.cookie-banner-inner {
  max-width: var(--max-main);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
}
.cookie-banner-text {
  margin: 0;
  flex: 1 1 16rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink);
}
.cookie-banner-text a { color: var(--accent); }
.cookie-accept {
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #111;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
}
.cookie-accept:hover { filter: brightness(1.05); }
.tg-webapp .cookie-banner { display: none !important; }
.muted { color: var(--muted); opacity: 1; }

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 9vw, 3.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 0.95;
  margin: 0.35rem 0 0.75rem;
  text-wrap: balance;
}
.hero-title .accent { color: var(--accent); }
.hero-sub {
  color: var(--muted);
  margin: 0 0 1.25rem;
  max-width: 36rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  text-wrap: pretty;
}
@media (min-width: 640px) {
  .hero-sub {
    margin-bottom: 1.75rem;
    font-size: 1rem;
  }
}
.page-block {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
  width: 100%;
}
.page-block > * { min-width: 0; max-width: 100%; }
@media (min-width: 640px) {
  .page-block { gap: 1.75rem; }
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}
.back-link:hover { color: var(--accent); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.search-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.search-toolbar input {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.75rem;
  padding: 0 0.85rem;
  font-size: 1rem; /* avoid iOS zoom */
}
.search-toolbar button {
  flex: 0 0 auto;
  white-space: nowrap;
  height: 2.75rem;
  padding: 0 1rem;
}
@media (max-width: 380px) {
  .search-toolbar button {
    padding: 0 0.75rem;
  }
}

input, select, textarea, button {
  font: inherit;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 0.65rem 0.8rem;
}
input, select, textarea {
  min-width: 0;
  flex: 1;
  outline: none;
  transition: border-color 0.12s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: rgba(185, 166, 144, 0.7); }
button {
  cursor: pointer;
  background: var(--accent);
  border-color: transparent;
  color: var(--bg0);
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease, color 0.12s ease;
}
button:hover { background: var(--accent2); }
button.secondary {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}
button.secondary:hover {
  border-color: var(--muted);
  background: var(--bg1);
}
button.ok {
  background: var(--accent2);
  color: var(--bg0);
}
button.ok:hover { filter: brightness(1.05); }
button.danger {
  background: transparent;
  border-color: var(--line);
  color: var(--danger);
}
button.danger:hover { border-color: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

a.buttonish {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
  background: var(--accent);
  color: var(--bg0);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
a.buttonish:hover { background: var(--accent2); }
a.buttonish.ok {
  background: var(--accent2);
  color: var(--bg0);
}
a.buttonish.secondary {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}
a.buttonish.secondary:hover { border-color: var(--muted); }

.tag-rail,
.no-scrollbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 0 1.5rem;
  padding: 0.15rem 0 0.35rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  user-select: none;
  touch-action: pan-x;
}
.tag-rail::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.tag-rail:active,
.no-scrollbar:active { cursor: grabbing; }

.tag-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: rgba(243, 230, 212, 0.8);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.tag-chip:hover {
  color: var(--ink);
  border-color: var(--muted);
}
.tag-chip.active {
  color: var(--bg0);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.tag-chip.mini {
  pointer-events: none;
  padding: 0.15rem 0.4rem;
  font-size: 0.6875rem;
  cursor: default;
  background: var(--bg1);
  color: var(--muted);
  border: none;
  border-radius: 0.25rem;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem !important;
  padding-top: 0.15rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
@media (min-width: 480px) {
  .grid { gap: 1rem; }
}
@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  overflow: hidden;
  min-width: 0;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(232, 93, 4, 0.6);
  box-shadow: 0 8px 0 0 rgba(232, 93, 4, 0.25);
}
@media (max-width: 640px) {
  .card:hover {
    transform: none;
    box-shadow: none;
  }
}
.card-media {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg1);
}
.card img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #000;
  transition: transform 0.3s ease;
}
.card:hover img { transform: scale(1.04); }
.card .meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.7rem 0.75rem;
  flex: 1;
  min-width: 0;
}
@media (min-width: 480px) {
  .card .meta { padding: 0.75rem; }
}
.card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
}
@media (min-width: 480px) {
  .card h3 { font-size: 1rem; }
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (min-width: 480px) {
  .card p { font-size: 0.875rem; }
}
.card-badge {
  position: absolute;
  top: 0.5rem;
  z-index: 1;
  padding: 0.15rem 0.45rem;
  border-radius: 0.25rem;
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card-badge.hot {
  left: 0.5rem;
  background: var(--accent);
  color: var(--bg0);
}
.card-badge.face {
  right: 0.5rem;
  background: var(--accent2);
  color: var(--bg0);
}
.catalog-meta {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 4rem 1rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 0.75rem;
}
.empty-state h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
}
.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.studio {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
}
.studio-title {
  font-size: clamp(1.75rem, 7vw, 2.75rem);
  margin-top: 0;
}
.studio-main { display: grid; gap: 0.85rem; min-width: 0; }
.studio-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-top: 0.25rem;
}
@media (min-width: 640px) {
  .studio-actions.studio-actions--trio {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .studio-actions.studio-actions--duo {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.studio-actions > button,
.studio-actions > a.buttonish {
  width: 100%;
  justify-content: center;
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
}
.studio-actions > #btn-download,
.studio-actions > #btn-share {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
}
.studio-actions > #btn-download:hover,
.studio-actions > #btn-share:hover {
  border-color: var(--muted);
  background: var(--bg1);
}
.studio-actions > #btn-clean-dl,
.studio-actions > a.buttonish.ok { font-weight: 800; }
.studio-pay {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}
.studio-pay--solo {
  grid-template-columns: 1fr;
}
.studio-pay > a.buttonish,
.studio-pay > button {
  width: 100%;
  justify-content: center;
  text-align: center;
  padding: 0.8rem 0.75rem;
  font-size: 0.875rem;
}
.studio-pay > #btn-clean-job {
  font-weight: 800;
}
.studio-hint-pay {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.field { margin-bottom: 0.85rem; }
.field label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.field .hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.preview-wrap { text-align: center; }
.preview-wrap img {
  max-width: 100%;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.zone-stage {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 0.625rem;
  border: 1px solid var(--line);
  background: var(--card);
  user-select: none;
}
.zone-stage > img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}
.zone-layer { position: absolute; inset: 0; pointer-events: none; }
.zone {
  position: absolute;
  pointer-events: auto;
  border: 2px dashed rgba(232, 93, 4, 0.7);
  background: rgba(232, 93, 4, 0.1);
  color: #fff;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  border-radius: 0.25rem;
  transition: background 0.12s ease;
  transform-origin: center center;
}
.zone .zone-label {
  background: rgba(0, 0, 0, 0.55);
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: clamp(0.55rem, 2.6vw, 0.7rem);
  pointer-events: none;
}
.zone-text .zone-live {
  display: none;
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: 8%;
  overflow: hidden;
  color: #1a1410;
  text-transform: none;
  letter-spacing: 0;
  pointer-events: none;
  place-items: center;
}
.zone-text .zone-live-inner {
  display: block;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  text-align: center;
  white-space: normal;
  font-weight: 700;
  line-height: 1.2;
}
.zone-text.has-live.await-preview {
  background: rgba(245, 239, 230, 0.94);
  border-style: solid;
  overflow: visible;
}
.zone-text.has-live.await-preview .zone-live { display: grid; }
.zone-text.has-live.await-preview .zone-label { display: none; }
.zone-face {
  border-color: rgba(255, 186, 8, 0.95);
  background: rgba(255, 186, 8, 0.12);
  border-radius: 999px;
}
.zone-face.has-face {
  border-style: solid;
  background: rgba(255, 186, 8, 0.28);
}
.face-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 0.75rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.78);
}
.face-crop-modal[hidden] { display: none !important; }
.face-crop-sheet {
  width: min(96vw, 560px);
  max-height: min(90dvh, 90vh, 760px);
  overflow: hidden;
  background: #2a2118;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
}
.face-crop-head {
  flex-shrink: 0;
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 0.9rem 0.55rem;
}
.face-crop-stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 0.35rem 0.75rem;
  background: #15110e;
}
.face-crop-stage {
  position: relative;
  margin: 0 auto;
  touch-action: none;
  line-height: 0;
  user-select: none;
}
.face-crop-stage img {
  display: block;
  max-width: 100%;
  max-height: min(42dvh, 48vh, 420px);
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}
.face-crop-sel {
  position: absolute;
  border: 2.5px solid #ffba08;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  box-sizing: border-box;
  transform-origin: center center;
}
.face-crop-sel.mask-oval,
.face-crop-sel.mask-circle {
  border-radius: 50%;
}
.face-crop-sel.mask-square {
  border-radius: 0.2rem;
}
.face-crop-sel.mask-triangle {
  border-radius: 0;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  /* clip kills outer shadow — fake dim with inset ring */
  box-shadow: inset 0 0 0 2px #ffba08;
}
.face-crop-sel i {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffba08;
  border: 1px solid #1a1410;
  border-radius: 2px;
  z-index: 2;
}
.face-crop-sel.mask-oval i,
.face-crop-sel.mask-circle i {
  border-radius: 50%;
}
.face-crop-sel i[data-h="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
.face-crop-sel i[data-h="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
.face-crop-sel i[data-h="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
.face-crop-sel i[data-h="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }
.face-crop-actions {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 0.6rem;
  align-items: stretch;
  padding: 0.85rem 0.9rem;
  padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
  background: #241c15;
  border-top: 1px solid rgba(255, 186, 8, 0.35);
  box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.35);
}
.face-crop-actions .secondary,
#face-crop-cancel {
  width: 100%;
  background: #4a3f34 !important;
  border: 2px solid rgba(243, 230, 212, 0.55) !important;
  color: #f3e6d4 !important;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.85rem 1rem;
}
#face-crop-cancel:hover {
  background: #5a4d40 !important;
  border-color: #f3e6d4 !important;
}
#face-crop-ok,
button#face-crop-ok {
  width: 100%;
  background: #ffcc00 !important;
  color: #111 !important;
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  border: 2px solid #fff3a8 !important;
  box-shadow: 0 0 0 2px rgba(255, 204, 0, 0.35), 0 8px 22px rgba(255, 204, 0, 0.55);
  padding: 0.85rem 1rem;
}
#face-crop-ok:hover,
button#face-crop-ok:hover {
  background: #ffe14a !important;
  color: #111 !important;
  filter: none;
}
.zone:hover, .zone:focus {
  outline: none;
  background: rgba(232, 93, 4, 0.22);
  z-index: 2;
}
.zone-text.has-live.await-preview:hover,
.zone-text.has-live.await-preview:focus {
  background: rgba(245, 239, 230, 0.97);
}
.zone-face:hover, .zone-face:focus {
  background: rgba(255, 186, 8, 0.22);
}

/* Fixed to viewport bottom so tall memes don't hide the editor sheet */
.zone-popover {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(92vw, 360px);
  max-height: min(50vh, 22rem);
  overflow: auto;
  background: #2a2118;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
  display: grid;
  gap: 0.5rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.zone-popover[hidden] { display: none !important; }
.zone-pop-title {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted);
}
.zone-popover textarea { width: 100%; resize: vertical; }
.zone-popover textarea[hidden],
.zone-popover input[hidden],
.zone-popover button[hidden] { display: none !important; }
.zone-pop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}
.zone-pop-actions .secondary { width: 100%; }

.login-panel {
  max-width: 24rem;
  margin: 2.5rem auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-mark {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.login-panel .hero-title {
  font-size: clamp(1.75rem, 4vw, 2rem);
  margin-top: 1.5rem;
}
.login-panel .hero-sub {
  margin-left: auto;
  margin-right: auto;
  font-size: 0.875rem;
}
.login-box {
  width: 100%;
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.login-shield {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 0.75rem;
  color: var(--muted);
}
.login-shield::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--accent2);
  flex: 0 0 auto;
}

.admin-tabs {
  display: flex;
  width: 100%;
  gap: 0.25rem;
  margin: 0.75rem 0 1.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  flex: 1 0 auto;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  padding: 0.55rem 0.65rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-size: 0.8125rem;
}
@media (min-width: 640px) {
  .admin-tab {
    flex: 1;
    font-size: 0.875rem;
    padding: 0.55rem 0.75rem;
    gap: 0.4rem;
  }
}
.admin-tab:hover {
  color: var(--ink);
  background: transparent;
}
.admin-tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.admin-tab .tab-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  min-width: 1.25rem;
  text-align: center;
}
.admin-tab.active .tab-count {
  color: var(--ink);
  background: rgba(255, 186, 8, 0.12);
  border-color: rgba(255, 186, 8, 0.35);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.stats-grid-dense { margin-top: 0.5rem; }
.stats-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.stats-k {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stats-v {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0.25rem 0;
}
.stats-section-title {
  margin: 1.5rem 0 0.35rem;
  font-size: 1.05rem;
}
.stats-table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.stats-table th,
.stats-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.stats-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table td:nth-child(n+3) { font-variant-numeric: tabular-nums; }
.stats-legend { margin-top: 0.75rem; max-width: 48rem; }
.stats-th-sub {
  display: inline-block;
  margin-top: 0.15rem;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  opacity: 0.9;
}
.stats-split {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.stats-sep { color: var(--muted); font-weight: 400; }
.stats-web { color: var(--accent2, #3ecf8e); }
.stats-bot { color: var(--accent, #ffba08); }
.stats-channel-line { margin: 0.15rem 0 0; font-size: 0.8rem; }
.stats-table-wide th { vertical-align: bottom; line-height: 1.25; }

.support-layout {
  display: grid;
  grid-template-columns: minmax(12rem, 18rem) 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
  min-height: 24rem;
}
@media (max-width: 720px) {
  .support-layout { grid-template-columns: 1fr; }
}
.support-list {
  display: grid;
  gap: 0.4rem;
  align-content: start;
  max-height: 70vh;
  overflow: auto;
}
.support-item {
  text-align: left;
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
}
.support-item.active {
  border-color: rgba(255, 186, 8, 0.55);
  background: #2f261c;
}
.support-preview {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.support-chat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  display: flex;
  flex-direction: column;
  min-height: 24rem;
  max-height: 70vh;
}
.support-chat-head {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.15rem;
}
.support-msgs {
  flex: 1;
  overflow: auto;
  padding: 0.75rem;
  display: grid;
  gap: 0.5rem;
  align-content: start;
}
.support-bubble {
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: 0.5rem;
  background: #1a1410;
  border: 1px solid var(--line);
  white-space: pre-wrap;
}
.support-bubble.admin {
  justify-self: end;
  background: rgba(255, 186, 8, 0.12);
  border-color: rgba(255, 186, 8, 0.35);
}
.support-bubble-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.support-reply {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
}
.support-reply textarea { width: 100%; }
.admin-list { display: grid; gap: 0.75rem; }
.admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--card);
}
.admin-row-main {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
  flex: 1;
}
.admin-thumb {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  flex: 0 0 auto;
  background: var(--bg1);
}
.admin-row .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0;
}
.admin-row .actions > button,
.admin-row .actions > a.buttonish {
  font-size: 0.75rem;
  padding: 0.4rem 0.65rem;
}
.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  border: none;
}
.badge.ready { color: var(--accent); background: rgba(232, 93, 4, 0.2); }
.badge.draft { color: var(--accent2); background: rgba(255, 186, 8, 0.15); }
.badge.deleted { color: var(--danger); background: rgba(193, 52, 26, 0.2); }
.error { color: #ff8a80; margin: 0.5rem 0; }
pre.json {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  background: #0f0c0a;
  padding: 0.75rem;
  border-radius: 0.5rem;
  max-height: 420px;
  overflow: auto;
}

.editor-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.9fr);
  margin-top: 0.75rem;
  align-items: start;
}
.editor-canvas-wrap {
  position: sticky;
  top: 0.75rem;
  align-self: start;
  z-index: 2;
}
.editor-right { display: grid; gap: 0.75rem; align-content: start; }
.ed-fold {
  padding: 0;
  overflow: hidden;
}
.ed-fold > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ed-fold > summary::-webkit-details-marker { display: none; }
.ed-fold > summary::before {
  content: "▸";
  display: inline-block;
  font-size: 0.85em;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.ed-fold[open] > summary::before { transform: rotate(90deg); }
.ed-fold-body {
  padding: 0 1rem 1rem;
}
.ed-fold.panel > summary + .ed-fold-body > h2,
.ed-fold.panel > summary { margin: 0; }
.color-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.color-row input[type="color"] {
  width: 2.4rem;
  height: 2.2rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--bg1);
  cursor: pointer;
  flex: 0 0 auto;
}
.color-row input[type="text"] {
  flex: 1;
  min-width: 0;
}
.group-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem;
  margin-bottom: 0.45rem;
  background: rgba(0, 0, 0, 0.15);
}
.group-block.open { border-color: var(--accent2); }
.group-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
.group-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  margin: 0.2rem 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 500;
}
.group-item.nested { margin-left: 0.75rem; width: calc(100% - 0.75rem); }
.group-item.active {
  border-color: var(--ok);
  background: rgba(124, 181, 24, 0.15);
}
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.35);
}
.editor-meta .two-col,
.editor-side .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.editor-stage-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  max-width: 28rem;
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg1);
}
.editor-stage-tabs .stage-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
}
.editor-stage-tabs .stage-tab:hover {
  color: var(--ink);
  background: transparent;
}
.editor-stage-tabs .stage-tab.active {
  background: var(--card);
  border: none;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.editor-stage-tabs .stage-tab[hidden],
.editor-stage-tabs #ed-refresh-preview[hidden] {
  display: none !important;
}
.editor-stage-tabs #ed-refresh-preview {
  flex: 0 0 auto;
  margin-left: auto;
}
.canvas-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  touch-action: none;
  user-select: none;
  overflow: hidden;
  border-radius: 0.625rem;
  border: 1px solid var(--line);
  background: var(--card);
}
.canvas-stage > #ed-img {
  display: block;
  max-width: 100%;
  height: auto;
}
.canvas-stage canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.canvas-stage > #ed-live-preview {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0f0c0a;
  z-index: 3;
  pointer-events: none;
}
.canvas-stage > #ed-live-preview[hidden] { display: none !important; }
.canvas-stage[data-mode="preview"] > #ed-img { visibility: hidden; }
.canvas-stage[data-mode="preview"] > canvas {
  visibility: hidden;
  pointer-events: none;
}
.editor-canvas-wrap #ed-preview-status[hidden],
.editor-right [hidden],
.preview-face-row img[hidden],
#ed-err[hidden] {
  display: none !important;
}
.shape-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.shape-row button.ok { background: var(--ok); color: #fff; }
.preview-face-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}
.preview-face-row img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
}
.crop-section {
  margin: 0.85rem 0 0.5rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--line);
}
.crop-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
}
.crop-section .muted {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  line-height: 1.35;
}
.crop-section input[type="number"] {
  width: 100%;
}
.editor-right #ed-wm-panel .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-canvas-wrap { position: static; }
}

/* Telegram Mini App: tighter chrome, less ad chrome */
.tg-webapp .ad-strip { display: none; }
.tg-webapp .shell-body {
  padding-top: 0.75rem;
}
.tg-webapp .foot {
  margin-top: 2rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}
@media (max-width: 640px) {
  .foot { margin-top: 2.5rem; }
  .foot-inner { padding: 1.5rem 0.75rem; }
}

