@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("../vendor/fonts/IBMPlexSansArabic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("../vendor/fonts/IBMPlexSansArabic-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("../vendor/fonts/IBMPlexSansArabic-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("../vendor/fonts/IBMPlexSansArabic-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #050505;
  --bg-soft: #101113;
  --panel: rgba(17, 18, 21, .94);
  --panel-2: #17191d;
  --text: #f8fafc;
  --muted: #a8b0bd;
  --line: rgba(255, 255, 255, .11);
  --brand: #f6b614;
  --brand-2: #2d6cdf;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

html.light {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-soft: #ffffff;
  --panel: rgba(255, 255, 255, .96);
  --panel-2: #eef1f6;
  --text: #111827;
  --muted: #667085;
  --line: rgba(15, 23, 42, .12);
  --shadow: 0 22px 60px rgba(15, 23, 42, .12);
}

* {
  box-sizing: border-box;
}

.mx-auto { margin-left: auto; margin-right: auto; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.block { display: block; }
.inline-flex { display: inline-flex; }
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.p-1 { padding: .25rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.px-3 { padding-left: .75rem; padding-right: .75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-1 { padding-top: .25rem; padding-bottom: .25rem; }
.py-2 { padding-top: .5rem; padding-bottom: .5rem; }
.py-3 { padding-top: .75rem; padding-bottom: .75rem; }
.space-y-3 > * + * { margin-top: .75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-5 > * + * { margin-top: 1.25rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.w-full { width: 100%; }
.max-w-2xl { max-width: 42rem; }
.max-w-\[1220px\] { max-width: 1220px; }
.h-\[44px\] { height: 44px; }
.min-h-\[44px\] { min-height: 44px; }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.text-start { text-align: start; }
.text-center { text-align: center; }
.text-xs { font-size: .75rem; line-height: 1rem; }
.text-sm { font-size: .875rem; line-height: 1.25rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.leading-tight { line-height: 1.2; }
.rounded-full { border-radius: 999px; }
.border { border-width: 1px; border-style: solid; }
.text-black { color: #050505; }
.text-\[color\:var\(--muted\)\] { color: var(--muted); }
.text-\[color\:var\(--brand\)\] { color: var(--brand); }
.bg-\[color\:var\(--brand\)\] { background: var(--brand); }
.border-\[color\:var\(--line\)\] { border-color: var(--line); }
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 640px) {
  .sm\:flex { display: flex; }
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, rgba(246, 182, 20, .11), transparent 24rem),
    radial-gradient(circle at 92% 12%, rgba(45, 108, 223, .15), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-root {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(18px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--brand), #ffd768);
  color: #050505;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), 0 12px 30px rgba(246,182,20,.2);
}

.icon-btn,
.tool-btn,
.seg-btn,
.primary-btn,
.ghost-btn,
.danger-btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel);
  border-radius: 12px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}

.icon-btn {
  width: 42px;
  padding: 0;
}

.install-btn {
  min-height: 42px;
  padding: 0 .85rem;
  border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 14%, var(--panel));
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.install-btn.is-ready,
.install-btn:hover {
  background: var(--brand);
  color: #050505;
  border-color: var(--brand);
}

.tool-btn,
.seg-btn,
.ghost-btn,
.danger-btn {
  padding: .62rem .9rem;
}

.primary-btn {
  padding: .72rem 1rem;
  background: var(--brand);
  color: #050505;
  border-color: color-mix(in srgb, var(--brand) 74%, #000);
  font-weight: 800;
}

.danger-btn {
  color: #fff;
  background: color-mix(in srgb, var(--danger) 78%, #111);
}

.ghost-btn:hover,
.tool-btn:hover,
.icon-btn:hover,
.install-btn:hover,
.seg-btn:hover,
.primary-btn:hover {
  transform: translateY(-1px);
}

.main-area {
  width: min(1220px, 100%);
  margin-inline: auto;
  padding: 20px clamp(14px, 2.8vw, 34px) 96px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.home-panel {
  min-height: calc(100vh - 190px);
  display: grid;
  place-items: center;
  text-align: center;
}

.brand-title {
  font-size: clamp(2.5rem, 9vw, 6.5rem);
  line-height: .95;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-subtitle {
  color: var(--muted);
  font-size: clamp(1rem, 2.3vw, 1.25rem);
}

.plus-button {
  width: clamp(112px, 28vw, 168px);
  height: clamp(112px, 28vw, 168px);
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 36px auto 0;
  background: radial-gradient(circle at 30% 28%, #ffe393, var(--brand) 55%, #bd8200);
  color: #050505;
  box-shadow: 0 24px 70px rgba(246,182,20,.28);
  cursor: pointer;
}

.plus-button i {
  font-size: clamp(3.4rem, 12vw, 6rem);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  z-index: 35;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.nav-btn {
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  font-weight: 700;
  cursor: pointer;
}

.nav-btn.is-active {
  background: var(--brand);
  color: #050505;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.size-card,
.record-card {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 14px;
  padding: 18px;
  text-align: start;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease;
}

.size-card:hover,
.record-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 65%, var(--line));
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 390px);
  gap: 18px;
  align-items: start;
}

.stage-column {
  min-width: 0;
}

.stage-frame {
  display: grid;
  place-items: center;
  padding: clamp(14px, 2.2vw, 26px);
  overflow: auto;
}

.badge-card {
  --card-w: min(78vw, 430px);
  position: relative;
  width: var(--card-w);
  max-width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #020202;
  color: #fff;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
  container-type: inline-size;
  isolation: isolate;
}

.badge-card.cr80,
.badge-card.cr79 {
  aspect-ratio: 54 / 86;
}

.badge-card.cr100 {
  aspect-ratio: 67 / 99;
}

.badge-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    repeating-linear-gradient(166deg, rgba(255,255,255,.09) 0 1px, transparent 1px 33px),
    repeating-linear-gradient(8deg, transparent 0 42px, rgba(255,255,255,.055) 43px 45px, transparent 47px 84px),
    radial-gradient(circle at 72% 15%, rgba(23,93,199,.16), transparent 18%),
    #030303;
  opacity: .78;
}

.badge-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, transparent 0 62%, rgba(0,0,0,.5) 100%);
}

.badge-card.has-bg::before,
.badge-card.has-bg::after {
  opacity: 0;
}

.badge-bg-img {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.badge-element {
  position: absolute;
  z-index: 2;
  min-width: 8%;
  min-height: 2%;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: 0;
  white-space: pre-wrap;
  line-height: 1.25;
  text-shadow: 0 2px 7px rgba(0,0,0,.52);
  user-select: none;
}

.badge-element[data-editable="true"] {
  user-select: text;
}

.badge-element.is-selected {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

.badge-text {
  padding: .15em .35em;
}

.badge-photo,
.badge-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge-photo {
  border-radius: 50%;
  border: .9cqw solid #9a9a9a;
  background: #f3f4f6;
}

.badge-logo {
  object-fit: contain;
  filter: drop-shadow(0 9px 12px rgba(0,0,0,.35));
}

.emblem-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 25%, #76a4ff, #2457b9 58%, #102c74);
  border: .45cqw solid #a88916;
  color: #ffe36b;
  font-size: 6cqw;
  font-weight: 800;
}

.photo-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: .9cqw solid #9a9a9a;
  background: linear-gradient(180deg, #f8fafc, #d5d9df);
  color: #636b75;
  display: grid;
  place-items: center;
  font-size: 9cqw;
}

.id-band {
  background: var(--brand);
  color: #050505;
  font-weight: 800;
  text-shadow: none;
  letter-spacing: .08em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 5.3cqw;
}

.signature-line {
  width: 90%;
  height: 24%;
  border-bottom: .45cqw solid currentColor;
  transform: skewX(-24deg) rotate(-5deg);
  opacity: .9;
}

.control-panel {
  position: sticky;
  top: 82px;
  max-height: calc(100vh - 112px);
  overflow: auto;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-2) 82%, transparent);
  color: var(--text);
  border-radius: 12px;
  padding: .72rem .85rem;
  outline: none;
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand);
}

.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hidden-file {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 18px;
  align-items: start;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  width: 100%;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 18%, transparent);
}

.status-dot.is-online {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34,197,94,.16);
}

.status-dot.is-offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(239,68,68,.16);
}

.toast {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(92vw, 520px);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.print-sheet {
  display: none;
}

[dir="ltr"] .id-band {
  writing-mode: vertical-lr;
  transform: none;
}

@media (max-width: 920px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 560px) {
  .install-btn span {
    display: none;
  }

  .install-btn {
    width: 42px;
    padding: 0;
  }

  .toolbar-grid,
  .style-grid {
    grid-template-columns: 1fr 1fr;
  }

  .badge-card {
    --card-w: min(92vw, 390px);
  }
}

@media print {
  html,
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
  }

  body.printing {
    min-height: 0 !important;
  }

  body.printing .app-shell,
  body.printing .app-root,
  body.printing .toast {
    display: none !important;
  }

  body.printing .print-sheet {
    display: block !important;
    width: var(--print-w);
    margin: 0;
    padding: 0;
  }

  body.printing .print-page {
    width: var(--print-w);
    height: var(--print-h);
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    overflow: hidden;
    break-after: page;
    page-break-after: always;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body.printing .print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  body.printing .badge-card {
    width: var(--print-w);
    height: var(--print-h);
    max-width: none;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  @page {
    margin: 0;
  }
}
