:root {
  --brand: #ed1c24;
  --brand-hover: #c9141b;
  --brand-soft: #fdecec;
  --ink: #16181d;
  --ink-2: #4b5160;
  --muted: #7a8090;
  --line: #e7e8ec;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --ok: #138a4b;
  --ok-soft: #e7f5ed;
  --warn: #b26b00;
  --warn-soft: #fdf3e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 5%), 0 1px 3px rgb(16 24 40 / 6%);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 28px; padding-bottom: 64px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; justify-content: center; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.nav-link:hover { background: var(--bg); }
.nav-link.active { color: var(--brand); }
.badge { background: var(--brand); color: #fff; font-size: 0.72rem; min-width: 18px; height: 18px; border-radius: 9px; display: inline-grid; place-items: center; padding: 0 5px; }
.demo-controls { display: flex; align-items: center; gap: 8px; }
.demo-controls select { font: inherit; font-size: 0.8rem; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 4px 8px; color: var(--ink-2); }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 20px; border-radius: 999px; font-weight: 600; border: 1px solid transparent; transition: background 0.15s, border-color 0.15s; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-2); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-block { width: 100%; margin-top: 20px; }
.btn:disabled { opacity: 0.5; }
.btn-link { background: none; border: 0; color: var(--brand); font-weight: 500; padding: 4px; font-size: 0.9rem; }
.btn-link:disabled { opacity: 0.5; }
.input { font: inherit; height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); min-width: 0; }
.input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.input.invalid { border-color: var(--brand); }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); white-space: nowrap; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.field-label { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; margin: 20px 0 8px; }

/* listing */
.page-head { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters .search { flex: 1 1 260px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow 0.15s, transform 0.15s; }
.card-link:hover { box-shadow: 0 8px 24px rgb(16 24 40 / 8%); transform: translateY(-2px); }
.card-body { padding: 14px 16px 16px; flex: 1; }
.card-body h3 { margin-bottom: 4px; }
.card-actions { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.card.sold-out .tile { filter: grayscale(1); opacity: 0.6; }
.price { font-weight: 600; }
.price.big { font-size: 1.5rem; margin-bottom: 12px; }
.tile { aspect-ratio: 4 / 3; display: grid; place-items: center; font-size: 2rem; font-weight: 700; letter-spacing: 0.02em; background: hsl(var(--tile-hue) 30% 94%); color: hsl(var(--tile-hue) 25% 42%); }

/* item */
.item { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: start; }
.item-media .tile { border-radius: var(--radius); font-size: 4rem; }
.back { color: var(--muted); font-size: 0.9rem; display: inline-block; margin-bottom: 12px; }
.options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.option { min-width: 56px; height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-weight: 500; }
.option.selected { border-color: var(--brand); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.option:disabled { color: var(--muted); text-decoration: line-through; opacity: 0.6; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.stepper button { width: 40px; height: 40px; border: 0; background: none; font-size: 1.1rem; color: var(--ink); }
.stepper button:disabled { color: var(--line); }
.stepper span { min-width: 28px; text-align: center; font-weight: 600; }
.stepper.small button { width: 32px; height: 32px; }

/* checkout */
.steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 24px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; font-size: 0.9rem; padding-right: 12px; }
.step + .step::before { content: ''; width: 24px; height: 1px; background: var(--line); margin-right: 4px; }
.step-num { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 0.8rem; background: var(--surface); }
.step.current { color: var(--ink); }
.step.current .step-num { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.done .step-num { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand); }
.checkout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.sidebar { position: sticky; top: 84px; }
.lines { list-style: none; padding: 0; margin: 0 0 12px; }
.line { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.line:last-child { border-bottom: 0; }
.line-name { font-weight: 600; }
.line-controls { display: flex; align-items: center; gap: 16px; }
.line-total { min-width: 90px; text-align: right; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 500; color: var(--ink-2); }
.field.wide { grid-column: 1 / -1; }
.field .input { width: 100%; }
.error-text { color: var(--brand); font-size: 0.8rem; }
.recap { display: flex; justify-content: space-between; align-items: start; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.recap .field-label { margin-top: 0; }
.promo { display: flex; gap: 8px; margin-top: 16px; }
.promo .input { flex: 1; text-transform: uppercase; }
.promo .input::placeholder { text-transform: none; }
.promo.applied { justify-content: space-between; align-items: center; background: var(--ok-soft); color: var(--ok); padding: 10px 14px; border-radius: 10px; }
.note { margin-top: 16px; background: var(--bg); color: var(--ink-2); padding: 12px 14px; border-radius: 10px; font-size: 0.9rem; }
.mock-note { margin: 16px 0; font-size: 0.8rem; color: var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 8px; }
.summary { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sum-row { display: flex; justify-content: space-between; font-size: 0.92rem; color: var(--ink-2); }
.sum-row.accent { color: var(--brand); }
.sum-row.muted { color: var(--muted); }
.sum-row.total { color: var(--ink); font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.hold { background: var(--brand-soft); color: var(--brand-hover); padding: 10px 14px; border-radius: 10px; margin-bottom: 20px; font-size: 0.9rem; }
.points { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.points input { accent-color: var(--brand); }
.points-value { font-weight: 600; }

/* status + orders */
.status { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.hero { text-align: center; padding: 16px 0 4px; display: flex; flex-direction: column; align-items: center; }
.hero-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; margin-bottom: 16px; }
.hero.ok .hero-icon { background: var(--ok-soft); color: var(--ok); }
.hero.bad .hero-icon { background: var(--brand-soft); color: var(--brand); }
.hero .spin.big { margin-bottom: 16px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chip { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.chip-paid, .chip-fulfilled { background: var(--ok-soft); color: var(--ok); }
.chip-pending_payment { background: var(--warn-soft); color: var(--warn); }
.chip-cancelled { background: var(--brand-soft); color: var(--brand); }
.order-list { padding: 0 24px; }
.order-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.order-row:last-child { border-bottom: 0; }
.order-row:hover .line-name { color: var(--brand); }
.order-row-end { display: flex; align-items: center; gap: 16px; }

/* states */
.state { text-align: center; padding: 64px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.state h3 { color: var(--ink); margin: 0; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
.spin.big { width: 44px; height: 44px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 0.9rem; }
.toast-error { background: var(--brand); }
.toast-success { background: var(--ok); }

/* mock payment gateway — deliberately not the merchant's look */
.pg-page { background: #eef1f5; }
.pg { max-width: 440px; margin: 24px auto; background: var(--surface); border-radius: 16px; box-shadow: 0 12px 40px rgb(16 24 40 / 12%); overflow: hidden; }
.pg-head { background: #1f2a44; color: #fff; padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; }
.pg-logo { font-weight: 700; }
.pg-tag { font-size: 0.7rem; letter-spacing: 0.06em; background: rgb(255 255 255 / 15%); padding: 3px 8px; border-radius: 6px; }
.pg-body { padding: 24px; }
.pg-merchant { display: flex; justify-content: space-between; gap: 16px; }
.pg-amount { font-size: 2.2rem; font-weight: 700; text-align: center; margin: 24px 0 8px; }
.pg-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 20px 0; }
.pg-card .input { background: var(--bg); color: var(--ink-2); }
.pg-actions { display: flex; flex-direction: column; gap: 10px; }

@media (max-width: 800px) {
  .header-inner { gap: 12px; height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
  .nav { order: 3; flex-basis: 100%; }
  .demo-controls { margin-left: auto; }
  .item, .checkout { grid-template-columns: 1fr; gap: 24px; }
  .sidebar { position: static; }
  .form-grid { grid-template-columns: 1fr; }
  .line { flex-wrap: wrap; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}

/* layout preview gallery */
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
.preview-links { list-style: none; padding: 0; margin: 0; }
.preview-links a { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.preview-links li:last-child a { border-bottom: 0; }
.preview-links a:hover { color: var(--brand); }

/* styleguide (styleguide.html only — documents the system, not part of it) */
.sg-toc { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.9rem; }
.sg-toc a { color: var(--brand); font-weight: 500; }
.sg-section { padding: 32px 0; border-top: 1px solid var(--line); scroll-margin-top: 72px; }
.sg-specimen { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; padding: 16px 0; }
.sg-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; color: var(--ink-2); word-break: break-word; }
.sg-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.sg-stack { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.sg-stack > * { margin: 0; }
.sg-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.sg-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.sg-swatch { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; }
.sg-chip { height: 56px; border-radius: 10px; border: 1px solid var(--line); }
@media (max-width: 800px) { .sg-specimen { grid-template-columns: 1fr; gap: 8px; } }
