/* ============================================================
   QRFlow — Design System
   Premium · Technical · Human-Centered
   ============================================================ */

:root {
  /* Brand foundation */
  --navy-950: #07122A;
  --navy-900: #0A1633;
  --navy-800: #0D1D3D;
  --navy-700: #101F42;
  --navy-600: #1A2F5C;

  /* Accents */
  --blue-500: #0087FA;
  --blue-600: #006EFF;
  --cyan-400: #00C3F8;
  --cyan-300: #00D9F6;
  --brand-gradient: linear-gradient(135deg, #0087FA 0%, #00C3F8 100%);
  --brand-gradient-strong: linear-gradient(135deg, #006EFF 0%, #00D9F6 100%);

  /* Light surfaces */
  --white: #FFFFFF;
  --surface-0: #F8FBFF;
  --surface-1: #F4F8FC;
  --surface-2: #EEF5FB;
  --surface-3: #E4EEF8;

  /* Text */
  --text-primary: #07122A;
  --text-secondary: #3A4A68;
  --text-muted: #6B7A94;
  --text-faint: #97A4BB;
  --text-on-dark: #FFFFFF;
  --text-on-accent: #FFFFFF;

  /* Borders */
  --border: #D8E3F0;
  --border-strong: #C3D2E6;
  --border-dark: rgba(255, 255, 255, 0.08);
  --border-dark-strong: rgba(255, 255, 255, 0.14);

  /* Semantic */
  --success: #1F8A5B;
  --success-soft: rgba(31, 138, 91, 0.12);
  --warning: #C4851A;
  --warning-soft: rgba(196, 133, 26, 0.12);
  --error: #C93B3B;
  --error-soft: rgba(201, 59, 59, 0.10);
  --info: #0087FA;
  --info-soft: rgba(0, 135, 250, 0.10);

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(7, 18, 42, 0.04);
  --shadow-sm: 0 2px 8px rgba(7, 18, 42, 0.05), 0 1px 2px rgba(7, 18, 42, 0.03);
  --shadow-md: 0 12px 32px -12px rgba(7, 18, 42, 0.14), 0 4px 10px -4px rgba(7, 18, 42, 0.06);
  --shadow-lg: 0 28px 64px -24px rgba(7, 18, 42, 0.28);
  --shadow-glow: 0 0 0 1px rgba(0, 135, 250, 0.12), 0 12px 40px -16px rgba(0, 135, 250, 0.35);

  /* Radius scale */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 999px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 220ms;
  --duration-slow: 420ms;

  /* Type — Vazirmatn everywhere for Persian UI */
  --font: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
  --mono: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
  --code: ui-monospace, "Cascadia Mono", Consolas, monospace;

  --fs-display: clamp(2.2rem, 4vw, 3.25rem);
  --fs-h1: clamp(1.85rem, 3vw, 2.6rem);
  --fs-h2: 1.35rem;
  --fs-h3: 1.15rem;
  --fs-body: 1rem;
  --fs-small: 0.9375rem;
  --fs-caption: 0.875rem;
  --fs-label: 0.8125rem;

  --lh-tight: 1.2;
  --lh-snug: 1.45;
  --lh-normal: 1.7;
  --lh-relaxed: 1.85;

  /* Layout — keep header compact; logo may overflow */
  --header-h: 72px;
  --studio-max: 440px;
}

/* ============================================================ Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input { font: inherit; }
a { color: inherit; }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 3px;
}

/* ============================================================ App shell — split layout */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface-0);
}

/* ============================================================ Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: 0 clamp(18px, 3.5vw, 40px);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border-bottom: 1px solid rgba(216, 227, 240, 0.85);
  box-shadow: 0 1px 0 rgba(0, 135, 250, 0.04);
  overflow: visible;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  min-width: 0;
  transition: opacity var(--duration) var(--ease);
  height: var(--header-h);
}
.brand:hover { opacity: 0.88; }

.brand-logo {
  width: 165px;
  height: auto;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 15px;
  margin-top: 0;
  filter: drop-shadow(0 10px 22px rgba(7, 18, 42, 0.18));
}

.nav-switch {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xs);
  gap: 2px;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-full);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}
.nav-link:hover { color: var(--text-primary); }
.nav-link.is-active {
  color: var(--text-on-dark);
  background: var(--navy-950);
  box-shadow: 0 6px 16px -8px rgba(7, 18, 42, 0.55);
}
.nav-link svg {
  width: 15px;
  height: 15px;
  opacity: 0.85;
}

/* ============================================================ Workspace — full-bleed split */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  gap: 0;
  min-height: calc(100vh - var(--header-h));
  width: 100%;
  align-items: start;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
    align-items: stretch;
  }
  .studio-pane {
    order: -1;
    min-height: 56vh;
    position: relative;
    top: auto;
    height: auto;
  }
}

/* ============================================================ Control pane */
.control-pane {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(28px, 5vw, 72px) clamp(22px, 5vw, 72px);
  position: relative;
  background:
    radial-gradient(720px 420px at 100% 0%, rgba(0, 135, 250, 0.06), transparent 55%),
    linear-gradient(180deg, var(--white) 0%, var(--surface-0) 100%);
}

.control-inner {
  width: 100%;
  max-width: 540px;
  margin-inline: auto;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 var(--space-5);
  padding: 7px 14px 7px 12px;
  background: var(--info-soft);
  border: 1px solid rgba(0, 135, 250, 0.16);
  border-radius: var(--radius-full);
  color: var(--blue-500);
  font-family: var(--font);
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: 0;
}

.kicker-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-gradient);
  box-shadow: 0 0 0 3px rgba(0, 135, 250, 0.15);
}

.page-title {
  margin: 0 0 var(--space-4);
  font-size: var(--fs-display);
  font-weight: 300;
  line-height: var(--lh-tight);
  letter-spacing: -0.03em;
  color: var(--text-primary);
}
.page-title strong {
  font-weight: 700;
  color: var(--blue-500);
}

.page-lede {
  margin: 0 0 var(--space-6);
  max-width: 42ch;
  font-size: 0.98rem;
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
  font-weight: 400;
}

/* ============================================================ QR type picker */
.type-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 var(--space-6);
}

.type-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-secondary);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}
.type-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.type-btn.is-active {
  color: var(--text-on-dark);
  border-color: transparent;
  background: var(--navy-950);
  box-shadow: 0 8px 18px -10px rgba(7, 18, 42, 0.55);
}
.type-btn:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

.type-fields {
  display: grid;
  gap: 14px;
  margin-bottom: var(--space-2);
}

.composer-card {
  margin: 8px 0 28px;
  padding: 20px 18px 18px;
  background:
    linear-gradient(180deg, #FFFFFF 0%, #F8FBFF 100%);
  border: 1px solid rgba(0, 135, 250, 0.18);
  border-radius: var(--radius-lg);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.8) inset,
    0 16px 40px -28px rgba(0, 135, 250, 0.35),
    var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.composer-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand-gradient);
}
.composer-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.composer-step {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--navy-950);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.composer-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}
.composer-sub {
  margin: 4px 0 0;
  font-size: var(--fs-caption);
  color: var(--text-muted);
}

.helper {
  min-height: 22px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-1);
  border: 1px solid transparent;
  transition: all var(--duration) var(--ease);
}
.helper.error {
  color: var(--error);
  background: var(--error-soft);
  border-color: rgba(201, 59, 59, 0.2);
}
.helper.is-pending {
  color: var(--blue-500);
  background: var(--info-soft);
  border-color: rgba(0, 135, 250, 0.18);
}
.helper.is-warn {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: rgba(196, 133, 26, 0.22);
}
.helper.is-ready {
  color: #0F6B45;
  background: linear-gradient(135deg, rgba(31, 138, 91, 0.14), rgba(0, 195, 248, 0.08));
  border-color: rgba(31, 138, 91, 0.28);
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 16px;
  box-shadow: 0 10px 24px -18px rgba(31, 138, 91, 0.55);
}

.type-fields .field-shell input,
.type-fields .field-shell textarea,
.type-fields .field-shell select {
  flex: 1;
  min-width: 0;
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 14px 16px;
  resize: vertical;
}
.type-fields .field-shell textarea {
  min-height: 88px;
  line-height: 1.7;
}
.type-fields .field-shell select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7A94' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  padding-left: 36px;
}
.type-fields .field-shell input[dir="ltr"],
.type-fields .field-shell textarea[dir="ltr"],
.type-fields .ltr-code {
  direction: ltr;
  text-align: left;
  font-family: var(--code);
  font-size: 0.9rem;
}

.fields-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) {
  .fields-row { grid-template-columns: 1fr; }
}

/* ============================================================ Fields */
.field-group { margin-bottom: var(--space-5); }

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--mono);
}
.field-label label { cursor: pointer; }
.label-meta {
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-faint);
  font-size: var(--fs-caption);
}

.field-shell {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    background var(--duration) var(--ease);
}
.field-shell:hover {
  border-color: var(--border-strong);
}
.field-shell:focus-within {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(0, 135, 250, 0.12), var(--shadow-sm);
}
.field-shell.has-error {
  border-color: var(--error);
  box-shadow: 0 0 0 4px var(--error-soft);
}

#urlInput {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 16px 18px;
  direction: ltr;
  text-align: right;
}
#urlInput::placeholder {
  color: var(--text-faint);
  font-family: var(--font);
  font-size: 0.875rem;
}

.field-status {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}
.status-dot.err {
  background: var(--error);
  box-shadow: 0 0 0 4px var(--error-soft);
}
.status-dot.pending {
  background: var(--blue-500);
  animation: pulse-dot 1.1s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1); }
}

/* ============================================================ Buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--space-6);
}

.btn,
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--white);
  color: var(--text-secondary);
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
  transition:
    transform var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    opacity var(--duration) var(--ease);
  touch-action: manipulation;
}
.btn svg,
.action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.btn:hover:not(:disabled),
.action-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--navy-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn:active:not(:disabled),
.action-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}
.btn:disabled,
.action-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary,
.action-btn.primary {
  border: 0;
  color: var(--text-on-accent);
  background: var(--brand-gradient);
  box-shadow: 0 10px 24px -12px rgba(0, 135, 250, 0.65);
}
.btn-primary:hover:not(:disabled),
.action-btn.primary:hover:not(:disabled) {
  color: var(--text-on-accent);
  border: 0;
  background: var(--brand-gradient-strong);
  box-shadow: 0 14px 28px -12px rgba(0, 110, 255, 0.7);
}
.btn-primary:disabled,
.action-btn.primary:disabled {
  background: var(--text-faint);
  box-shadow: none;
  color: rgba(255, 255, 255, 0.9);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: transparent;
}

.cam-active {
  border-color: var(--blue-500) !important;
  color: var(--blue-500) !important;
  background: var(--info-soft) !important;
  box-shadow: inset 0 0 0 1px rgba(0, 135, 250, 0.12) !important;
}

/* ============================================================ Studio pane */
.studio-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 3.5vw, 40px);
  background: var(--surface-1);
  position: relative;
  overflow: hidden;
}

@media (min-width: 981px) {
  .studio-pane {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    max-height: calc(100vh - var(--header-h));
    align-self: start;
  }

  .studio-pane .device {
    margin: 0 auto;
    max-height: calc(100vh - var(--header-h) - 48px);
    min-height: min(480px, calc(100vh - var(--header-h) - 64px));
  }

  .studio-pane .seal-face,
  .studio-pane .plate-inner {
    min-height: 220px;
  }
}

.device {
  position: relative;
  z-index: 1;
  width: min(100%, var(--studio-max));
  margin: auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(420px 280px at 78% 12%, rgba(0, 135, 250, 0.22), transparent 62%),
    radial-gradient(360px 260px at 18% 92%, rgba(0, 195, 248, 0.12), transparent 58%),
    linear-gradient(165deg, var(--navy-900) 0%, var(--navy-950) 55%, #050d1f 100%);
  border: 1px solid var(--border-dark-strong);
  border-radius: var(--radius-xl);
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 18px;
  overflow: hidden;
  min-height: min(520px, 72vh);
}

.device::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, black 18%, transparent 78%);
  pointer-events: none;
  opacity: 0.65;
  z-index: 0;
}

.device::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -70px;
  top: -50px;
  background: radial-gradient(circle, rgba(0, 195, 248, 0.24), transparent 70%);
  pointer-events: none;
  filter: blur(10px);
  z-index: 0;
}

.device > * {
  position: relative;
  z-index: 1;
}

.device-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 16px;
  border-bottom: 1px solid var(--border-dark);
}

.device-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan-400);
  box-shadow: 0 0 0 4px rgba(0, 195, 248, 0.18);
  animation: live-blink 2.4s ease-in-out infinite;
}
@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.device-title {
  font-family: var(--mono);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.device-meta {
  margin-right: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.38);
}

.device-screen {
  position: relative;
  flex: 1;
  margin: 16px 0;
  min-height: 280px;
  border-radius: var(--radius-lg);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(7, 18, 42, 0.06),
    0 8px 28px -12px rgba(0, 0, 0, 0.35);
}

#plateInner.seal-face,
#plateInner.plate-inner,
.seal-face,
.plate-inner {
  position: relative;
  flex: 1;
  margin: 16px 0;
  min-height: 280px;
  border-radius: var(--radius-lg);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(7, 18, 42, 0.06),
    0 8px 28px -12px rgba(0, 0, 0, 0.35);
}

#qrCanvas {
  position: relative;
  z-index: 2;
  display: block;
  width: 72% !important;
  height: 72% !important;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity var(--duration-slow) var(--ease-out), transform var(--duration-slow) var(--ease-out);
}
#qrCanvas.visible {
  opacity: 1;
  transform: scale(1);
}

.empty-state,
.error-state {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 28px;
  transition: opacity var(--duration-slow) var(--ease);
}
.empty-state {
  color: var(--text-faint);
}
.empty-state svg {
  width: 36px;
  height: 36px;
  opacity: 0.7;
  color: var(--blue-500);
}
.empty-state span {
  font-size: var(--fs-small);
  font-weight: 500;
  max-width: 200px;
  line-height: var(--lh-relaxed);
  color: var(--text-muted);
}
.empty-state.hidden {
  opacity: 0;
  pointer-events: none;
}

.error-state {
  color: var(--error);
  opacity: 0;
  pointer-events: none;
  background: var(--white);
}
.error-state.visible {
  opacity: 1;
  pointer-events: auto;
}
.error-state svg { width: 28px; height: 28px; }
.error-state span {
  font-size: var(--fs-small);
  font-weight: 600;
  max-width: 220px;
  line-height: var(--lh-relaxed);
}

/* Engrave sweep */
.seal-face::after,
#plateInner.seal-face::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -30%;
  height: 30%;
  background: linear-gradient(180deg, transparent, rgba(0, 135, 250, 0.28), transparent);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.seal-face.engraving::after,
#plateInner.engraving::after {
  animation: sweep 0.7s var(--ease);
}
@keyframes sweep {
  0% { top: -30%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 110%; opacity: 0; }
}

.device-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-dark);
}
.chip {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-dark-strong);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.04);
}
.caption-note {
  font-size: var(--fs-caption);
  color: rgba(255, 255, 255, 0.42);
}

/* Reader media */
#preview,
#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 2;
}
#preview {
  object-fit: contain;
  background: var(--white);
}
#video {
  object-fit: cover;
  background: var(--navy-950);
}
#preview.show,
#video.show { display: block; }

.scan-frame {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 4;
}
.scan-frame.active { display: block; }

.corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 0 solid var(--cyan-400);
}
.corner.tl { top: 18px; left: 18px; border-top-width: 2.5px; border-left-width: 2.5px; border-radius: 4px 0 0 0; }
.corner.tr { top: 18px; right: 18px; border-top-width: 2.5px; border-right-width: 2.5px; border-radius: 0 4px 0 0; }
.corner.bl { bottom: 18px; left: 18px; border-bottom-width: 2.5px; border-left-width: 2.5px; border-radius: 0 0 0 4px; }
.corner.br { bottom: 18px; right: 18px; border-bottom-width: 2.5px; border-right-width: 2.5px; border-radius: 0 0 4px 0; }

.scan-line {
  position: absolute;
  left: 14%;
  right: 14%;
  top: 12%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan-400), transparent);
  box-shadow: 0 0 12px rgba(0, 195, 248, 0.45);
  animation: scan-y 2.2s var(--ease) infinite;
}
@keyframes scan-y {
  0% { top: 12%; }
  50% { top: calc(88% - 2px); }
  100% { top: 12%; }
}

/* ============================================================ Result panel */
.result-panel {
  max-height: 0;
  overflow: hidden;
  margin-top: 0;
  opacity: 0;
  transition:
    max-height var(--duration-slow) var(--ease),
    margin-top var(--duration) var(--ease),
    opacity var(--duration) var(--ease);
}
.result-panel.show {
  max-height: 360px;
  margin-top: var(--space-7);
  opacity: 1;
}

.result-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.result-value {
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: var(--lh-snug);
  color: var(--text-primary);
  word-break: break-all;
  direction: ltr;
  text-align: left;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  max-height: 140px;
  overflow: auto;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

/* ============================================================ Footer strip */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: var(--space-9);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}
.site-footer .f-brand {
  font-family: var(--mono);
  font-size: var(--fs-label);
  letter-spacing: 0.14em;
  color: var(--text-muted);
  font-weight: 600;
}
.site-footer .f-meta {
  font-size: var(--fs-caption);
  color: var(--text-faint);
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.site-footer a:hover {
  color: var(--blue-500);
  border-color: var(--blue-500);
}

/* ============================================================ Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 16px);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--navy-950);
  color: var(--text-on-dark);
  font-size: var(--fs-small);
  font-weight: 500;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
  z-index: 80;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-dark-strong);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast svg {
  width: 16px;
  height: 16px;
  color: var(--cyan-400);
  flex-shrink: 0;
}

/* ============================================================ Responsive */
@media (max-width: 980px) {
  .studio-pane {
    min-height: 420px;
  }
  .device {
    min-height: 340px;
    width: min(100%, 400px);
  }
  .page-title {
    font-size: clamp(2rem, 7vw, 2.75rem);
  }
}

@media (min-width: 981px) {
  .control-inner {
    margin-inline: auto 8%;
  }
}

@media (max-width: 640px) {
  .site-header {
    height: var(--header-h);
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    overflow: visible;
  }
  .brand { height: var(--header-h); }
  .brand-logo {
    width: 110px;
    height: auto;
    margin-top: 0;
    border-radius: 15px;
  }
  .nav-switch { width: auto; flex-shrink: 0; }
  .nav-link {
    flex: 0 1 auto;
    padding: 0 10px;
    font-size: 0.8125rem;
    min-height: 36px;
  }
  .nav-link svg { display: none; }
  .control-pane {
    padding: 36px 18px 40px;
  }
  .actions .btn,
  .actions .action-btn {
    flex: 1 1 calc(50% - 10px);
  }
  .btn-primary,
  .action-btn.primary {
    flex: 1 1 100%;
  }
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 400px) {
  .actions .btn,
  .actions .action-btn {
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}

/* Legacy class bridges (keep JS class hooks working) */
.seal { display: contents; }
.seal-col { display: contents; }
.tick { display: none; }
.grain, .vignette, .noise { display: none; }

/* ============================================================ LTR code values */
.ltr-code,
[dir="ltr"].code-value {
  font-family: var(--code) !important;
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

/* ============================================================ Studio extras */
.panel {
  margin-top: var(--space-6);
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--text-primary);
}
.panel-grid {
  display: grid;
  gap: 12px;
}
.panel-grid.two {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 560px) {
  .panel-grid.two { grid-template-columns: 1fr; }
}

.template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 var(--space-5);
}
.template-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px dashed var(--border-strong);
  background: var(--surface-0);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.template-btn:hover {
  border-style: solid;
  border-color: var(--blue-500);
  color: var(--blue-500);
  background: var(--info-soft);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-row input[type="color"] {
  width: 42px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.color-row span {
  font-size: var(--fs-caption);
  color: var(--text-muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--fs-small);
  color: var(--text-secondary);
}
.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  flex-shrink: 0;
}
.toggle.on {
  background: var(--blue-500);
  border-color: var(--blue-500);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration) var(--ease);
}
.toggle.on::after { transform: translateX(-18px); }

.size-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.size-pill {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--white);
  font-family: var(--font);
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.size-pill.is-active {
  background: var(--navy-950);
  border-color: var(--navy-950);
  color: #fff;
}

.stats-list {
  display: grid;
  gap: 10px;
  max-height: 220px;
  overflow: auto;
}
.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-0);
  border: 1px solid var(--border);
  font-size: var(--fs-caption);
}
.stat-item strong { font-weight: 700; color: var(--text-primary); }
.stat-item .meta { color: var(--text-muted); }
.stat-item button {
  border: 0;
  background: transparent;
  color: var(--error);
  font-family: var(--font);
  font-size: var(--fs-caption);
  cursor: pointer;
}

.batch-box textarea {
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font);
  font-size: var(--fs-small);
  resize: vertical;
  background: var(--surface-0);
}
.batch-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.batch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: var(--fs-caption);
}
.batch-item button {
  font-family: var(--font);
  font-size: var(--fs-caption);
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-0);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-secondary);
}

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-0);
  font-family: var(--font);
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ============================================================ Rich result cards */
.result-panel.show {
  max-height: none;
  margin-top: var(--space-7);
  opacity: 1;
  overflow: visible;
}

.smart-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--white);
  box-shadow: var(--shadow-md);
  animation: card-in 0.45s var(--ease-out);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.smart-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--navy-950), var(--navy-800));
  color: #fff;
}
.smart-card-head.email { background: linear-gradient(135deg, #0B1B3A, #1A3A6E); }
.smart-card-head.wifi { background: linear-gradient(135deg, #07122A, #0E3A5C); }
.smart-card-head.phone,
.smart-card-head.sms { background: linear-gradient(135deg, #07122A, #12324F); }
.smart-card-head.whatsapp { background: linear-gradient(135deg, #0B2A1C, #128C7E); }
.smart-card-head.telegram { background: linear-gradient(135deg, #0A2744, #229ED9); }
.smart-card-head.instagram { background: linear-gradient(135deg, #2A1030, #C13584); }
.smart-card-head.bank { background: linear-gradient(135deg, #07122A, #1B3B2A); }
.smart-card-head.vcard { background: linear-gradient(135deg, #07122A, #1E2F55); }
.smart-card-head.event { background: linear-gradient(135deg, #1A1420, #4A2C6A); }
.smart-card-head.location { background: linear-gradient(135deg, #07122A, #1F4B3A); }

.smart-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
  font-size: 1.1rem;
  font-weight: 700;
}
.smart-card-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.smart-card-head p {
  margin: 2px 0 0;
  font-size: var(--fs-caption);
  opacity: 0.78;
}

.email-shell { background: #F3F6FB; padding: 14px; }
.email-window {
  background: #fff;
  border: 1px solid #D7E0EC;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 28px -18px rgba(7,18,42,0.35);
}
.email-bar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: #EEF3FA;
  border-bottom: 1px solid #D7E0EC;
}
.email-bar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #C9D5E6;
  display: block;
}
.email-bar i:nth-child(1) { background: #FF6B6B; }
.email-bar i:nth-child(2) { background: #FFD166; }
.email-bar i:nth-child(3) { background: #06D6A0; }
.email-meta {
  padding: 14px 16px 8px;
  display: grid;
  gap: 8px;
  border-bottom: 1px solid #EEF2F7;
}
.email-meta .row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  font-size: var(--fs-small);
}
.email-meta .row .k { color: var(--text-muted); font-weight: 600; }
.email-meta .row .v {
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
}
.email-body {
  padding: 16px;
  min-height: 84px;
  font-size: var(--fs-small);
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.kv-list { display: grid; gap: 0; padding: 4px 0; }
.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-small);
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.kv-row .v {
  color: var(--text-primary);
  font-weight: 500;
  text-align: left;
  direction: ltr;
  word-break: break-word;
}

.wifi-card-body { padding: 18px 16px; text-align: center; }
.wifi-ssid { font-size: 1.25rem; font-weight: 700; margin: 0 0 6px; }
.wifi-pass {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  font-family: var(--code);
  direction: ltr;
  font-size: var(--fs-small);
}

.vcard-hero { padding: 20px 16px 12px; text-align: center; }
.vcard-avatar {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
}
.vcard-hero h4 { margin: 0; font-size: 1.15rem; }
.vcard-hero p { margin: 4px 0 0; color: var(--text-muted); font-size: var(--fs-small); }

.bank-strip {
  margin: 14px;
  padding: 18px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(0,135,250,0.16), rgba(0,195,248,0.08)),
    linear-gradient(160deg, #0A1633, #07122A);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.bank-strip .label { font-size: var(--fs-caption); opacity: 0.7; margin-bottom: 6px; }
.bank-strip .num {
  font-family: var(--code);
  direction: ltr;
  text-align: left;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.bank-strip .name { margin-top: 14px; font-size: var(--fs-small); opacity: 0.9; }

.link-preview { padding: 16px; }
.link-url {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  font-family: var(--code);
  direction: ltr;
  text-align: left;
  word-break: break-all;
  font-size: var(--fs-small);
  color: var(--blue-500);
}

.text-block {
  padding: 16px;
  font-size: var(--fs-small);
  line-height: 1.85;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px 14px;
  background: var(--surface-0);
  border-top: 1px solid var(--border);
}

/* Landing page */
.landing-page {
  min-height: 100vh;
  background:
    radial-gradient(700px 420px at 90% 0%, rgba(0,135,250,0.10), transparent 55%),
    linear-gradient(180deg, #fff, var(--surface-0));
  padding: 28px 18px 48px;
  font-family: var(--font);
}
.landing-shell { max-width: 480px; margin: 0 auto; }
.landing-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.landing-brand img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: contain;
}
.landing-brand strong { font-size: 1.05rem; }
.landing-brand span {
  display: block;
  font-size: var(--fs-caption);
  color: var(--text-muted);
}
.landing-cta {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.landing-cta a,
.landing-cta button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-family: var(--font);
  font-weight: 700;
  font-size: var(--fs-small);
  border: 0;
  cursor: pointer;
}
.landing-cta .primary {
  color: #fff;
  background: var(--brand-gradient);
  box-shadow: 0 12px 24px -14px rgba(0,135,250,0.7);
}
.landing-cta .ghost {
  color: var(--text-secondary);
  background: var(--white);
  border: 1px solid var(--border);
}
.scan-count {
  margin-top: 18px;
  text-align: center;
  font-size: var(--fs-caption);
  color: var(--text-muted);
}

.field-label {
  font-family: var(--font) !important;
  letter-spacing: 0.02em !important;
  text-transform: none !important;
  font-size: var(--fs-caption) !important;
}
.kicker,
.device-title,
.device-meta,
.chip,
.f-brand,
.type-btn,
.nav-link,
.btn,
.action-btn,
.helper,
.caption-note {
  font-family: var(--font) !important;
}
.device-meta,
.chip {
  letter-spacing: 0.04em;
}
