:root {
  --bg: #0a0b0f;
  --surface: #14161c;
  --surface-2: #1b1e26;
  --border: #262a35;
  --text: #eceef3;
  --muted: #9096a5;
  --accent: #7c6bff;
  --accent-2: #a78bff;
  --ok: #34d399;
  --err: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  width: 372px;
  max-height: 580px;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(90% 55% at 50% -10%, rgba(124, 107, 255, .16), transparent 60%),
    var(--bg);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Sur mobile (Orion iOS), le popup s'ouvre en plein écran : on remplit l'écran. */
@media (hover: none) and (pointer: coarse) {
  body {
    width: 100%;
    max-height: none;
    min-height: 100vh;
    min-height: 100dvh;
    font-size: 14px;
  }
}

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #101218, #0a0b0f);
  z-index: 3;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.wordmark {
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
}
.wordmark .w-my { color: var(--accent-2); }

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .3px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); background: rgba(124, 107, 255, .1); }
.btn:active { transform: translateY(1px); }

main { padding: 14px 16px 18px; }

/* ---------- States ---------- */
.status { color: var(--muted); padding: 22px 4px; text-align: center; }
.status.error { color: var(--err); }

/* ---------- Cards / sections ---------- */
.result { display: block; }

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .02), 0 2px 8px rgba(0, 0, 0, .35);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--accent-2);
  font-weight: 700;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

.field { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.field + .field { border-top: 1px solid var(--border); }
.field .k { color: var(--muted); white-space: nowrap; }
.field .v { text-align: right; font-weight: 600; word-break: break-word; color: var(--text); }

.address {
  margin-top: 8px;
  padding: 9px 11px;
  background: #0e1015;
  border-left: 2px solid var(--accent);
  border-radius: 6px;
  line-height: 1.55;
  color: #c8ccd7;
}

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: rgba(124, 107, 255, .14);
  border: 1px solid rgba(124, 107, 255, .4);
  color: var(--accent-2);
  font-weight: 600;
  font-size: 12px;
}

/* ---------- Clé API ---------- */
.key-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: #0e1015;
  border: 1px solid var(--border);
  border-radius: 9px;
}
.key-value {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  letter-spacing: .3px;
  line-height: 1.5;
  color: #cdb9ff;
  word-break: break-all;
}
.btn-copy { flex: 0 0 auto; }

/* ---------- Products ---------- */
.product { display: flex; gap: 12px; align-items: center; padding: 10px 0; }
.product + .product { border-top: 1px solid var(--border); }
.product img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #0e1015;
  flex: 0 0 auto;
}
.product .p-body { flex: 1; min-width: 0; }
.product .p-name { font-size: 14px; font-weight: 700; color: var(--text); }
.product .p-ref {
  display: inline-block;
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: .6px;
  color: var(--muted);
  text-transform: uppercase;
}
.product .p-price {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.total .t-label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.total .t-value {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Barre Valider ---------- */
.validate-bar {
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: linear-gradient(180deg, rgba(10, 11, 15, 0), var(--bg) 42%);
}
.validate-msg {
  margin-bottom: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 12px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  color: var(--muted);
}
.validate-msg.error { color: var(--err); border-color: rgba(248, 113, 113, .35); }
.btn-validate {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .2px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px -12px rgba(124, 107, 255, .85);
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn-validate:hover:not(:disabled) { filter: brightness(1.07); }
.btn-validate:active:not(:disabled) { transform: translateY(1px); }
.btn-validate:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* Bloc "clé non activée" */
.activate-box {
  margin-bottom: 10px;
  padding: 12px 13px;
  border-radius: 11px;
  background: rgba(124, 107, 255, .08);
  border: 1px solid rgba(124, 107, 255, .35);
}
.activate-title { font-weight: 700; color: var(--text); font-size: 13px; margin-bottom: 3px; }
.activate-text { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.btn-activate {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: transparent;
  color: var(--accent-2);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .2px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-activate:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

/* Scrollbar */
body::-webkit-scrollbar { width: 8px; }
body::-webkit-scrollbar-thumb { background: #2c313d; border-radius: 8px; }
body::-webkit-scrollbar-track { background: transparent; }
