:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1b1a17;
  --muted: #6b675f;
  --border: #e2dfd8;
  --accent: #2b59c3;
  --accent-text: #ffffff;
  --accent-soft: #e6edfb;
  --ok: #1f7a46;
  --ok-soft: #e3f3e9;
  --err: #b42318;
  --err-soft: #fdecea;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1c1c1c;
    --surface-2: #262626;
    --text: #f0eee9;
    --muted: #a19d94;
    --border: #333230;
    --accent: #6f95ef;
    --accent-text: #0d1424;
    --accent-soft: #1d2a47;
    --ok: #57c486;
    --ok-soft: #173325;
    --err: #f2867b;
    --err-soft: #3d1c19;
    --warn: #e8b350;
    --warn-soft: #3a2c10;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 50%; object-fit: contain; flex: none; }
.nav { display: flex; gap: 6px; align-items: center; }
.nav a { color: var(--text); padding: 8px 12px; border-radius: 10px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.cart-link { display: inline-flex; align-items: center; gap: 8px; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; font-size: .75rem; font-weight: 700;
  min-width: 22px; height: 22px; padding: 0 7px; display: inline-grid; place-items: center; }

main { padding: 32px 0 64px; min-height: calc(100vh - 160px); }
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: .875rem; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 10px 18px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, opacity .15s; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); opacity: .9; }
.btn-danger { color: var(--err); }
.btn-sm { padding: 6px 12px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=url],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; }
.alert-error { background: var(--err-soft); color: var(--err); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--accent-soft); color: var(--text); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* product grid */
.hero { margin-bottom: 28px; }
.hero p { color: var(--muted); margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.product-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  color: var(--text); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.product-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.product-card .thumb { aspect-ratio: 1; background: var(--surface-2); object-fit: cover; width: 100%; }
.product-card .body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card .name { font-weight: 600; }
.product-card .desc { color: var(--muted); font-size: .9rem; flex: 1; }
.price { font-weight: 700; }
.price .approx { font-weight: 400; color: var(--muted); font-size: .85em; margin-left: 6px; }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); }
.addons { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 16px 0 0; }
.addons legend { font-weight: 600; padding: 0 6px; }
.addon { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.addon + .addon { border-top: 1px solid var(--border); }
.addon input { margin-top: 4px; }
.addon-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.addon-price { font-weight: 600; }
.fx-preview { margin: -8px 0 16px; }
.fx-amounts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); }
.fx-note { margin: 4px 0 0; font-size: .8rem; color: var(--muted); line-height: 1.4; }
.summary .fx-preview { margin: 8px 0 0; font-size: .9rem; }
.summary .fx-amounts { justify-content: flex-end; }
.stock-note { margin: 6px 0 0; font-size: .9rem; color: var(--muted); }
.stock-note.out, .tag.tag-out { color: var(--err); }
.image-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.image-grid figure { margin: 0; width: 120px; }
.image-grid img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.image-grid figcaption { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.upload-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.addon-table td { padding: 4px; vertical-align: middle; }
.addon-table input { width: 100%; min-width: 80px; }
.danger-zone { border-color: var(--err); }
.code-form { max-width: 460px; display: flex; flex-direction: column; gap: 8px; }
.code-form label { font-weight: 600; }
.empty { text-align: center; padding: 60px 16px; color: var(--muted); }

/* product page */
.product-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: start; }
@media (max-width: 820px) { .product-layout { grid-template-columns: 1fr; gap: 24px; } }
.carousel { position: relative; }
.carousel-viewport { overflow: hidden; border-radius: var(--radius); background: var(--surface-2); aspect-ratio: 1; touch-action: pan-y; }
.carousel-track { display: flex; height: 100%; transition: transform .35s ease; }
.carousel-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.carousel-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 1.2rem;
  display: grid; place-items: center; box-shadow: var(--shadow); }
.carousel-btn.prev { left: 12px; } .carousel-btn.next { right: 12px; }
.carousel-thumbs { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; padding-bottom: 4px; }
.carousel-thumbs button { flex: 0 0 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 2px solid transparent;
  padding: 0; cursor: pointer; background: var(--surface-2); }
.carousel-thumbs button.active { border-color: var(--accent); }
.carousel-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.product-info .price { font-size: 1.5rem; margin: 8px 0 16px; }
.product-info .description { white-space: pre-line; color: var(--text); margin: 20px 0; }
.buy-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.qty { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.qty button { width: 38px; border: 0; background: none; color: var(--text); font-size: 1.1rem; cursor: pointer; }
.qty button:hover { background: var(--surface-2); }
.qty input { width: 48px; border: 0; text-align: center; border-radius: 0; padding: 8px 0; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.ship-table { font-size: .9rem; color: var(--muted); }
.section { margin-top: 56px; }

/* cart / checkout */
.two-col { display: grid; grid-template-columns: 1fr 380px; gap: 28px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.cart-line { display: grid; grid-template-columns: 72px 1fr auto; gap: 14px; align-items: center; padding: 14px 0;
  border-bottom: 1px solid var(--border); }
.cart-line:last-child { border-bottom: 0; }
.cart-line img, .cart-line .ph { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.cart-line .meta { min-width: 0; }
.cart-line .meta a { color: var(--text); font-weight: 600; }
.cart-line .controls { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.cart-line .line-total { font-weight: 700; text-align: right; }
@media (max-width: 520px) {
  .cart-line { grid-template-columns: 56px 1fr; }
  .cart-line img, .cart-line .ph { width: 56px; height: 56px; }
  .cart-line .line-total { grid-column: 2; text-align: left; }
}
.summary { position: sticky; top: 84px; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.summary-row.total { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 14px; font-size: 1.15rem; font-weight: 700; }
.summary-row.discount { color: var(--ok); }
.summary-items { font-size: .9rem; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 8px; }
.coupon-row { display: flex; gap: 8px; }
.coupon-row input { text-transform: uppercase; }
.pay-panel { text-align: center; }
.pay-panel hbank-pay-button { display: block; margin: 16px auto; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .65; }

/* tracking */
.status-pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: .85rem;
  background: var(--accent-soft); color: var(--accent); }
.status-pill.s-paid, .status-pill.s-processing { background: var(--accent-soft); color: var(--accent); }
.status-pill.s-shipped { background: var(--warn-soft); color: var(--warn); }
.status-pill.s-delivered, .status-pill.s-completed { background: var(--ok-soft); color: var(--ok); }
.status-pill.s-cancelled, .status-pill.s-refunded { background: var(--err-soft); color: var(--err); }
.status-pill.s-pending_payment { background: var(--surface-2); color: var(--muted); }
.steps { display: flex; gap: 0; margin: 24px 0 8px; }
.steps .step { flex: 1; text-align: center; position: relative; font-size: .85rem; color: var(--muted); }
.steps .step::before { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; margin: 0 auto 8px;
  background: var(--surface); border: 2px solid var(--border); position: relative; z-index: 1; }
.steps .step::after { content: ""; position: absolute; top: 9px; left: -50%; width: 100%; height: 2px; background: var(--border); }
.steps .step:first-child::after { display: none; }
.steps .step.done { color: var(--text); font-weight: 600; }
.steps .step.done::before { background: var(--accent); border-color: var(--accent); }
.steps .step.done::after { background: var(--accent); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* tables (admin) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85em; }

.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-nav a.active { background: var(--surface-2); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); font-size: .875rem; background: var(--surface); }
.tabs a.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar form { display: flex; gap: 8px; }
.inline { display: inline; }
.stack > * + * { margin-top: 20px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.address { white-space: pre-line; font-style: normal; }

/* downloads */
.download-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0;
  border-top: 1px solid var(--border); }
.download-row:first-of-type { border-top: 0; }
.download-row .meta { display: flex; flex-direction: column; min-width: 0; }
.download-row .fname { font-weight: 500; overflow-wrap: anywhere; }

/* icons (Font Awesome) */
.fa-solid, .fa-regular { line-height: 1; }
h1 > .fa-solid, h1 > .fa-regular, h2 > .fa-solid, h2 > .fa-regular { color: var(--accent); margin-right: 4px; font-size: .85em; }
.nav a, .admin-nav a { display: inline-flex; align-items: center; gap: 8px; }
.nav a > i, .admin-nav a > i { font-size: 1rem; width: 1.1em; text-align: center; }
.admin-nav .btn { gap: 6px; }
@media (max-width: 640px) {
  .nav-label { display: none; }            /* icon-only navigation on phones */
  .nav a, .admin-nav a { padding: 8px 10px; }
}
.cart-link > i { font-size: 1.1rem; }
.empty-icon { font-size: 2.5rem; color: var(--muted); margin-bottom: 12px; opacity: .7; }
.thumb-ph { display: grid; place-items: center; font-size: 2.5rem; color: var(--muted); }
.cart-line .ph { display: grid; place-items: center; color: var(--muted); font-size: 1.4rem; }
.qty button i { font-size: .8rem; }
.carousel-btn i { font-size: 1rem; }
.label-icon, label > .fa-solid { color: var(--muted); margin-right: 2px; }
.status-pill i { margin-right: 4px; }
.alert i { margin-right: 4px; }

/* step indicator with icons */
.steps .step::before { display: none; }
.steps .step::after { top: 17px; }
.step-dot { display: grid; place-items: center; width: 36px; height: 36px; margin: 0 auto 8px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border); color: var(--muted); position: relative; z-index: 1; font-size: .9rem; }
.steps .step.done .step-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* download file rows */
.file-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 1.1rem; }
.download-row .meta { flex: 1; }

/* Modal dialog (admin refunds) */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 24px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.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; }
