  .app,
  .app *,
  .app *::before,
  .app *::after {
    box-sizing: border-box;
  }

  .app {
    --bg: var(--bg);
    --surface: var(--bg-card-2);
    --border: var(--line);
    --text: var(--text);
    --muted: var(--text-soft);
    --accent: var(--purple-2);
    --accent-dim: var(--purple);
    --danger: #ff9ab5;
    --ok: var(--success);
    --warn: #fbbf24;
    --radius: var(--radius-md);
    font-family: "Figtree", ui-sans-serif, system-ui, sans-serif;
    max-width: 560px;
    margin: 0 auto;
    padding: 1.25rem clamp(1rem, 4vw, 1.75rem) 3rem;
  }
  
  .step-label {
    margin: 0 0 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
  }
  
  .muted.block {
    margin: 0;
    font-size: 0.92rem;
    color: var(--muted);
  }
  
  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }
  
  .panel {
    margin-top: 1.5rem;
    padding: 1.25rem 1.35rem;
    background:
      linear-gradient(145deg, var(--bg-card-2), rgba(129, 74, 200, 0.1)),
      radial-gradient(
        ellipse 120% 80% at 100% 0%,
        rgba(223, 122, 254, 0.12),
        transparent 58%
      );
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.24);
  }
  
  .instructions ul {
    margin: 0 0 1rem;
    padding-left: 1.2rem;
    color: var(--muted);
    font-size: 0.92rem;
  }

  /* Override global typography for the "Before you start" heading. */
  .panel.instructions h2,
  .instructions h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
  }

  /* Scoped typography for the "Before you start" panel body text. */
  .panel.instructions ul {
    font-size: 0.84rem;
    line-height: 1.45;
  }

  .panel.instructions li + li {
    margin-top: 0.2rem;
  }

  .consent-box {
    margin-bottom: 0.85rem;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
  }

  .consent-check {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
  }

  .consent-check input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
  }

  .consent-note {
    margin-top: 0.45rem;
  }
  
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition:
      transform 160ms ease,
      border-color 160ms ease,
      box-shadow 160ms ease,
      background-color 160ms ease;
  }
  
  .btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(223, 122, 254, 0.35);
    background: rgba(255, 255, 255, 0.08);
  }
  
  .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }
  
  .btn.primary {
    background: linear-gradient(
      135deg,
      rgba(129, 74, 200, 0.95),
      rgba(223, 122, 254, 0.95)
    );
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
    box-shadow: 0 10px 28px rgba(129, 74, 200, 0.35);
  }
  
  .btn.primary:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.22);
    filter: none;
  }
  
  .hint {
    margin: 0.85rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
  }
  
  .instructions #models-status.hint {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: var(--muted);
  }
  
  .instructions #models-status.ready {
    color: var(--ok);
  }
  
  .instructions #models-status.failed {
    color: #f5a8a8;
  }
  
  .hidden {
    display: none !important;
  }
  
  .video-wrap {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.14);
    aspect-ratio: 4 / 5;
    max-height: min(70dvh, 520px);
    margin: 0 auto;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  }
  
  .scan-intro {
    margin-bottom: 1rem;
  }
  
  .scan-intro-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
  }
  
  .scan-intro-list {
    margin: 0;
    padding-left: 1.15rem;
    color: var(--muted);
    font-size: 0.88rem;
  }
  
  .scan-intro-list li + li {
    margin-top: 0.25rem;
  }
  
  .card-inset {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
  }
  
  .scan-overlay {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1.25rem;
    background:
      radial-gradient(
        ellipse 120% 85% at 100% 0%,
        rgba(223, 122, 254, 0.14),
        transparent 58%
      ),
      rgba(8, 10, 14, 0.82);
    text-align: center;
    pointer-events: auto;
    backdrop-filter: blur(4px);
  }
  
  .scan-overlay.overlay-error {
    background: rgba(24, 12, 12, 0.88);
  }
  
  .scan-overlay.hidden {
    display: none !important;
  }
  
  .scan-overlay-title {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 600;
  }
  
  .scan-overlay-body {
    margin: 0;
    font-size: 0.88rem;
    color: rgba(232, 236, 241, 0.88);
    max-width: 22rem;
    line-height: 1.45;
  }

  .scan-overlay-progress {
    display: inline-flex;
    gap: 0.35rem;
    margin-top: 0.75rem;
  }

  .scan-overlay-progress span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(223, 122, 254, 0.9);
    animation: scan-overlay-dot 1.15s ease-in-out infinite;
  }

  .scan-overlay-progress span:nth-child(2) {
    animation-delay: 0.15s;
  }

  .scan-overlay-progress span:nth-child(3) {
    animation-delay: 0.3s;
  }

  .scan-overlay-tip {
    margin: 0.55rem 0 0;
    font-size: 0.78rem;
    color: rgba(219, 223, 238, 0.78);
    max-width: 26rem;
  }

  .scan-overlay-stages {
    margin-top: 0.55rem;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .scan-stage {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(11, 15, 28, 0.62);
    color: rgba(226, 232, 248, 0.78);
    padding: 0.22rem 0.58rem;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    transition: all 180ms ease;
  }

  .scan-stage.is-active {
    border-color: rgba(223, 122, 254, 0.55);
    color: #f0e6ff;
    box-shadow: 0 0 0 2px rgba(223, 122, 254, 0.16);
  }

  .scan-stage.is-done {
    border-color: rgba(116, 247, 181, 0.42);
    color: rgba(159, 252, 206, 0.9);
  }
  
  .scan-overlay-spinner {
    margin-top: 1rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--accent);
    animation: spin 0.85s linear infinite;
  }

  @keyframes scan-overlay-dot {
    0%,
    100% {
      opacity: 0.35;
      transform: translateY(0);
    }
    50% {
      opacity: 1;
      transform: translateY(-2px);
    }
  }
  
  .scan-overlay-actions {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: center;
  }
  
  .chrome-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    z-index: 4;
  }

  .scan-hud { display: none !important; }
  
  .placement-status {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    margin: 0;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    background: rgba(10, 10, 16, 0.74);
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.88rem;
    font-weight: 500;
    text-align: center;
    box-sizing: border-box;
    max-width: calc(100% - 28px);
    width: fit-content;
    min-width: 0;
    z-index: 18;
    opacity: 1;
    pointer-events: none;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.28;
    box-shadow:
      0 10px 22px rgba(4, 6, 14, 0.45),
      0 0 12px rgba(115, 170, 255, 0.14);
    transition: color 160ms ease, border-color 160ms ease, opacity 160ms ease;
  }

  /* Wide pill + slightly smaller type so status stays ~2 lines inside the frame. */
  @media (max-width: 540px) {
    .placement-status {
      width: calc(100% - 24px);
      max-width: calc(100% - 24px);
      font-size: 0.8rem;
      font-weight: 500;
      padding: 0.42rem 0.75rem;
      line-height: 1.22;
    }
  }
  
  .placement-status.state-wait {
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.22);
  }
  
  .placement-status.state-good {
    color: var(--ok);
    border-color: rgba(90, 205, 140, 0.55);
  }
  
  .placement-status.state-bad {
    color: var(--warn);
    border-color: rgba(255, 184, 76, 0.64);
    background: rgba(26, 14, 4, 0.82);
  }
  
  .overlay.fullscreen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    font-size: clamp(3rem, 12vw, 4rem);
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.05em;
  }
  
  .recording-pill {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(10, 10, 16, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
  }
  
  .recording-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    animation: pulse 1.2s ease-in-out infinite;
  }
  
  @keyframes pulse {
    0%,
    100% {
      opacity: 1;
    }
    50% {
      opacity: 0.4;
    }
  }
  
  .scan .actions {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
  }
  
  .success {
    margin: 0 0 1rem;
    font-weight: 500;
  }
  
  .result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
  }

  .upload-preview-card {
    margin-top: 0.95rem;
    padding: 0.85rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    display: grid;
    gap: 0.7rem;
  }

  .upload-preview-title {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
  }

  .recorded-preview {
    width: 100%;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: #000;
    max-height: 220px;
  }

  .upload-status-card {
    display: grid;
    gap: 0.45rem;
  }

  .upload-status-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 1.2rem;
  }

  .upload-status-label {
    font-size: 0.84rem;
    color: var(--muted);
  }

  .upload-progress-track {
    --upload-fill: 0%;
    position: relative;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
  }

  .upload-progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--upload-fill);
    background: linear-gradient(
      90deg,
      rgba(129, 74, 200, 0.95),
      rgba(223, 122, 254, 0.95)
    );
    border-radius: inherit;
    transition: width 240ms ease;
  }

  .upload-progress-dot {
    position: absolute;
    top: 50%;
    left: var(--upload-fill);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 2px solid rgba(129, 74, 200, 0.95);
    box-shadow: 0 0 0 3px rgba(223, 122, 254, 0.24);
    transition: left 240ms ease;
  }

  .upload-status-card.is-uploading .upload-progress-track::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      100deg,
      transparent 0%,
      rgba(255, 255, 255, 0.35) 50%,
      transparent 100%
    );
    animation: upload-sweep 1.3s linear infinite;
  }

  .upload-status-card.is-uploading .upload-status-label {
    color: #ded2ff;
  }

  .upload-status-card.is-success .upload-status-label {
    color: var(--ok);
  }

  .upload-status-card.is-error .upload-status-label {
    color: var(--danger);
  }

  @keyframes upload-sweep {
    from {
      transform: translateX(-120%);
    }
    to {
      transform: translateX(120%);
    }
  }
  
  .error {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: rgba(255, 126, 234, 0.11);
    border: 1px solid rgba(255, 154, 181, 0.42);
    color: #ffc2de;
    font-size: 0.9rem;
  }
  