:root {
  --bg: #08080c;
  --panel: #12121b;
  --text: #f4f4f8;
  --muted: #9b9caf;
  --line: rgba(255, 255, 255, .1);
  --primary: #8a8cff;
  --cyan: #5ec8e8;
  --danger: #ff9ba8;
  --success: #79e5b2;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 82px 24px 40px;
  background: radial-gradient(800px 480px at 50% -10%, rgba(138, 140, 255, .17), transparent), var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

html[dir="rtl"] body { font-family: Tajawal, Inter, sans-serif; }

button,
input { font: inherit; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(94, 200, 232, .55);
  outline-offset: 3px;
}

.controls {
  position: fixed;
  top: 16px;
  inset-inline-end: 18px;
  z-index: 10;
  display: flex;
  gap: 9px;
}

.controls button {
  min-width: 40px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  color: inherit;
  cursor: pointer;
}

.shell {
  width: min(920px, 100%);
  margin: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  margin-bottom: 24px;
  color: inherit;
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  gap: 20px;
  align-items: start;
}

.card {
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(21, 21, 31, .94), rgba(13, 13, 20, .96));
  box-shadow: 0 28px 70px rgba(0, 0, 0, .28);
}

h1 {
  margin: 0 0 8px;
  font: 800 clamp(28px, 4vw, 42px) Sora, Tajawal, sans-serif;
}

.sub {
  margin: 0 0 22px;
  color: var(--muted);
}

.items { border-top: 1px solid var(--line); }

.item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.item img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 11px;
  background: #191923;
}

.item h2 {
  margin: 0 0 6px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.item-price { font-weight: 800; }

.remove {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 21px;
}

.remove:hover {
  border-color: rgba(255, 155, 168, .28);
  background: rgba(255, 155, 168, .08);
}

.empty {
  padding: 44px 10px;
  color: var(--muted);
  text-align: center;
}

.items-loading {
  display: grid;
  gap: 11px;
  padding: 22px 0;
}

.items-loading span {
  display: block;
  height: 74px;
  border-radius: 11px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .08), rgba(255, 255, 255, .035));
  background-size: 220% 100%;
  animation: checkout-shimmer 1.15s linear infinite;
}

@keyframes checkout-shimmer { to { background-position: -220% 0; } }

@media (prefers-reduced-motion: reduce) {
  .items-loading span { animation: none; }
}

.continue {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  margin-top: 18px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #bfc1ff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.summary h2 {
  margin: 0 0 18px;
  font: 800 21px Sora, Tajawal, sans-serif;
}

.sum-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.sum-row strong { color: var(--text); }

.sum-row.total {
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 20px;
}

.promo-form { margin: 14px 0 0; }

.promo-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.promo-controls {
  display: flex;
  gap: 8px;
}

.promo-controls input {
  min-width: 0;
  flex: 1;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b0b12;
  color: var(--text);
}

.promo-controls button,
.retry {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(138, 140, 255, .4);
  border-radius: 10px;
  background: rgba(138, 140, 255, .13);
  color: inherit;
  cursor: pointer;
  font-weight: 700;
}

.promo-controls button:disabled {
  cursor: wait;
  opacity: .58;
}

.promo-msg {
  min-height: 25px;
  padding-top: 6px;
  font-size: 12px;
}

.loading {
  padding: 13px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

#paypal-buttons { min-height: 45px; }

.err {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 90, 90, .4);
  border-radius: 10px;
  background: rgba(255, 90, 90, .1);
  color: #ffb4b4;
  font-size: 13px;
  line-height: 1.5;
}

.retry {
  width: 100%;
  margin-top: 9px;
}

.trust {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 17px;
}

.trust-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.trust-item > [aria-hidden="true"] {
  flex: 0 0 auto;
  color: #c6c7ff;
  font-size: 15px;
}

.note,
.legal-copy {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.note { margin: 14px 0 0; }

.legal-copy { margin: 11px 0 0; }

.legal-copy a {
  color: #bfc1ff;
  text-underline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html[data-theme="light"] {
  --bg: #f5f6fa;
  --panel: #fff;
  --text: #171925;
  --muted: #626678;
  --line: rgba(16, 18, 40, .11);
}

html[data-theme="light"] .card { background: #fff; }

html[data-theme="light"] .promo-controls input { background: #f1f2f7; }

html[data-theme="light"] .items-loading span {
  background: linear-gradient(90deg, rgba(16, 18, 40, .035), rgba(16, 18, 40, .075), rgba(16, 18, 40, .035));
  background-size: 220% 100%;
}

@media (max-width: 760px) {
  body { padding: 72px 14px 28px; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 21px; }
  .summary { order: 2; }
}

@media (max-width: 430px) {
  .item { grid-template-columns: 58px minmax(0, 1fr) auto; }
  .item img { width: 58px; height: 58px; }
  .trust { grid-template-columns: 1fr; }
}
