:root {
  --bg: #ffffff;
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f4c81;
  --brand-ink: #ffffff;
  --accent: #0aa06e;
  --radius: 12px;
  --max: 1100px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* Header / footer */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.brand { display: flex; flex-direction: column; }
.brand:hover { text-decoration: none; }
.brand-name { font-weight: 700; font-size: 1.25rem; color: var(--ink); }
.brand-tag { font-size: .8rem; color: var(--muted); }
.cart-link { font-weight: 600; }
.cart-count {
  display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 4px;
  text-align: center; background: var(--brand); color: var(--brand-ink);
  border-radius: 999px; font-size: .8rem;
}
.wrap { max-width: var(--max); margin: 0 auto; padding: 28px 24px 60px; }
.site-footer { border-top: 1px solid var(--line); padding: 24px; text-align: center; color: var(--muted); font-size: .9rem; }
.footer-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.footer-links a { color: var(--muted); font-weight: 500; }

/* Content pages (Markdown) */
.page-content { max-width: 720px; margin: 0 auto; line-height: 1.7; }
.page-content h2 { margin: 28px 0 10px; font-size: 1.3rem; }
.page-content h3 { margin: 22px 0 8px; font-size: 1.1rem; }
.page-content p, .page-content ul, .page-content ol { margin: 0 0 14px; }
.page-content ul, .page-content ol { padding-left: 22px; }
.page-content li { margin-bottom: 6px; }

.page-title { font-size: 1.6rem; margin: 0 0 20px; }

/* Homepage hero */
.hero {
  background: linear-gradient(135deg, var(--brand), #0a6b8f 55%, var(--accent));
  color: #fff; border-radius: 16px; padding: 54px 40px; margin-bottom: 24px;
}
.hero-text { max-width: 640px; }
.hero h1 { font-size: 2.6rem; margin: 0 0 6px; line-height: 1.1; }
.hero-tag { font-size: 1.2rem; font-weight: 600; opacity: .95; margin: 0 0 14px; }
.hero-sub { font-size: 1.02rem; opacity: .9; margin: 0 0 24px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-cta .btn { background: #fff; color: var(--brand); }
.hero-cta .btn.btn-designer { background: var(--accent); color: #fff; }
.hero-cta .btn:hover { filter: brightness(1.05); text-decoration: none; }

.cat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.cat-tile {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 4px; color: var(--ink);
  transition: box-shadow .15s, transform .15s;
}
.cat-tile:hover { box-shadow: 0 8px 22px rgba(0,0,0,.08); transform: translateY(-2px); text-decoration: none; }
.cat-tile-name { font-weight: 700; font-size: 1.1rem; }
.cat-tile-count { color: var(--muted); font-size: .9rem; }

@media (max-width: 640px) { .hero { padding: 36px 22px; } .hero h1 { font-size: 2rem; } }
.back { display: inline-block; margin-bottom: 16px; color: var(--muted); }

/* Catalog grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  color: var(--ink); background: #fff; transition: box-shadow .15s, transform .15s;
}
.card:hover { text-decoration: none; box-shadow: 0 8px 24px rgba(0,0,0,.09); transform: translateY(-2px); }
.card-img { aspect-ratio: 1/1; background: #f3f4f6; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.noimg { display: grid; place-items: center; height: 100%; color: var(--muted); }
.card-body { padding: 12px 14px 16px; }
.card-title {
  font-size: .95rem; font-weight: 600; margin: 0 0 8px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; align-items: center; justify-content: space-between; }
.price { font-weight: 700; }
.opts { font-size: .78rem; color: var(--muted); }

/* Product page */
.product { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.main-media { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: #f3f4f6; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.thumb.active { border-color: var(--brand); }
.details h1 { font-size: 1.5rem; margin: 0 0 8px; }
.details .price { font-size: 1.5rem; margin-bottom: 20px; }
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
select, input[type=number] {
  width: 100%; max-width: 320px; padding: 10px 12px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.qty-field input { max-width: 120px; }
.description { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); color: #333; }
.materials { color: var(--muted); font-size: .9rem; }

/* Buttons */
.btn {
  display: inline-block; padding: 13px 22px; border: none; border-radius: 10px;
  background: var(--brand); color: var(--brand-ink); font-size: 1rem; font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-add { margin-top: 6px; }
.btn-designer { display: block; background: var(--accent); text-align: center; margin: 4px 0 20px; }
.btn-designer:hover { text-decoration: none; filter: brightness(1.08); }
.btn-pay { width: 100%; background: #111827; }
.added-msg { margin-top: 12px; color: var(--accent); font-weight: 600; }

/* Cart */
.cart-line {
  display: grid; grid-template-columns: 72px 1fr 90px 90px; gap: 14px;
  align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line);
}
.cart-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: #f3f4f6; }
.cart-title { font-weight: 600; }
.cart-opts { font-size: .85rem; color: var(--muted); }
.cart-qty { width: 70px; padding: 8px; }
.cart-line-total { text-align: right; font-weight: 600; }
.link-btn { background: none; border: none; color: var(--muted); padding: 4px 0; cursor: pointer; font-size: .85rem; text-decoration: underline; }
.cart-summary { max-width: 340px; margin: 24px 0 0 auto; }
.cart-summary .row { display: flex; justify-content: space-between; padding: 6px 0; }
.cart-summary .row.muted { color: var(--muted); font-size: .92rem; }
.cart-summary .row.total { font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; }
.checkout-buttons { max-width: 340px; margin: 20px 0 0 auto; display: flex; flex-direction: column; gap: 12px; }
.error-msg { color: #b91c1c; text-align: right; }

.centered { text-align: center; padding: 60px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Header search */
.search { display: flex; flex: 1; max-width: 420px; margin: 0 20px; }
.search input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px 0 0 8px; border-right: none; font-size: .95rem;
}
.search button {
  padding: 0 16px; border: none; background: var(--brand); color: #fff;
  border-radius: 0 8px 8px 0; cursor: pointer; font-weight: 600;
}

/* Category nav */
.cat-nav {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 12px 24px; border-bottom: 1px solid var(--line);
  max-width: var(--max); margin: 0 auto;
}
.cat-nav a {
  padding: 6px 14px; border-radius: 999px; color: var(--ink);
  font-size: .9rem; font-weight: 500;
}
.cat-nav a:hover { background: #f3f4f6; text-decoration: none; }
.cat-nav a.on { background: var(--brand); color: #fff; }
.cat-nav .pill { opacity: .6; font-size: .8rem; }
.cat-nav .nav-cta { background: var(--accent); color: #fff; margin-left: auto; }
.cat-nav .nav-cta:hover { background: var(--accent); filter: brightness(1.08); }

/* Flash messages */
.flashes { padding-top: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: .95rem; }
.flash.ok { background: #e7f6ee; color: #0a6b45; }
.flash.error { background: #fdecec; color: #b91c1c; }

/* Product tags */
.tags { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .78rem; background: #f3f4f6; color: #4b5563; padding: 3px 10px; border-radius: 999px; }

/* Admin */
.admin-nav { display: flex; align-items: center; gap: 18px; padding: 10px 0 14px; margin-bottom: 18px; border-bottom: 2px solid var(--line); }
.admin-nav-brand { font-weight: 700; }
.admin-nav a { color: var(--muted); font-weight: 600; }
.admin-nav a.on { color: var(--brand); border-bottom: 2px solid var(--brand); padding-bottom: 12px; margin-bottom: -14px; }
.admin-nav-logout { margin-left: auto; }
.admin-filter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 18px; }
.admin-filter input[type=search] { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; min-width: 220px; }
.admin-filter select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; }
.admin-pager { display: flex; align-items: center; gap: 16px; justify-content: center; margin: 22px 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin: 6px 0 20px; }
.stat-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-val { font-size: 1.6rem; font-weight: 700; }
.stat-lbl { color: var(--muted); font-size: .85rem; }
.bulk-bar { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.bulk-bar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.order-tabs { display: flex; gap: 8px; margin: 6px 0 18px; flex-wrap: wrap; }
.order-tabs a { padding: 6px 14px; border-radius: 999px; color: var(--ink); font-size: .9rem; font-weight: 500; }
.order-tabs a:hover { background: #f3f4f6; text-decoration: none; }
.order-tabs a.on { background: var(--brand); color: #fff; }
.order-badge { font-size: .78rem; font-weight: 700; text-transform: uppercase; padding: 2px 9px; border-radius: 999px; }
.order-badge.paid { background: #fdecc8; color: #8a5a00; }
.order-badge.fulfilled { background: #e7f6ee; color: #0a6b45; }
.order-badge.pending { background: #eee; color: #666; }
.order-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 16px 0 26px; }
.order-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.order-card h3 { margin: 0 0 10px; font-size: 1rem; }
.order-total-row { display: flex; justify-content: space-between; padding: 4px 0; }
.order-total-row.grand { font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
@media (max-width: 640px) { .order-grid { grid-template-columns: 1fr; } }

.admin-login { max-width: 340px; margin: 40px auto; }
.admin-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.admin-actions { display: flex; align-items: center; gap: 16px; }
.cat-add { margin: 12px 0 20px; }
.cat-add summary { cursor: pointer; color: var(--muted); }
.cat-add form { display: flex; gap: 8px; margin-top: 10px; }
.rehost-box { background: #fff7e6; border: 1px solid #f0d9a8; border-radius: 8px; padding: 12px 14px; margin: 6px 0 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.admin-table tr.inactive { opacity: .5; }
.admin-thumb-cell { width: 52px; }
.admin-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.admin-row-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.admin-row-actions form { display: inline; }
.link-btn.danger { color: #b91c1c; }
.btn.small { padding: 8px 14px; font-size: .9rem; }

.admin-form { max-width: 640px; }
.admin-form textarea, .admin-form input, .admin-form select { font-family: inherit; }
.admin-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }
.field.checkbox { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox input { width: auto; }
.hint { display: block; color: var(--muted); margin-top: 6px; font-size: .82rem; }
.hint code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; }
.admin-images { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }
.admin-image { width: 120px; text-align: center; }
.admin-image img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.admin-video { max-width: 320px; border-radius: 8px; margin-bottom: 12px; }
.upload-form { display: flex; gap: 10px; align-items: center; margin: 10px 0 24px; flex-wrap: wrap; }
hr { border: none; border-top: 1px solid var(--line); margin: 32px 0; }

/* Registration designer */
.reg-designer { margin-top: 18px; }
.reg-stage {
  background: linear-gradient(160deg, #e7edf2, #c7d0d8);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
  min-height: 200px; display: flex; align-items: center; justify-content: center;
  overflow-x: auto;
}
.reg-preview { display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 20px; min-width: min-content; }
.reg-placeholder { color: #8a949c; font-size: 1.1rem; }
.reg-group { display: flex; align-items: center; gap: 1px; }
.reg-char { display: block; }
.reg-zoombar { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin: 14px 2px; color: var(--muted); font-size: .9rem; }
.reg-zoombar label { display: flex; align-items: center; gap: 8px; }
.reg-zoombar input[type=range] { width: 180px; vertical-align: middle; }
.reg-estimate { font-weight: 600; color: var(--ink); }
.reg-disclaimer { margin-top: 18px; font-size: .82rem; color: var(--muted); font-style: italic; }
.border-tuner { margin-top: 20px; border: 1px dashed var(--line); border-radius: 10px; padding: 12px 16px; }
.border-tuner summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.border-tuner .svgtest-diamond { margin-top: 14px; }

/* Enlarge modal */
.reg-modal { position: fixed; inset: 0; z-index: 100; background: rgba(15,20,26,.86);
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.reg-modal[hidden] { display: none; }
.reg-modal-inner { background: linear-gradient(160deg, #eef2f6, #cdd6de);
  border-radius: 14px; padding: 32px; max-width: 96vw; max-height: 90vh; overflow: auto; }
.reg-modal-inner .reg-preview { justify-content: flex-start; gap: 28px; }
.reg-modal-note { text-align: center; color: #556; font-size: .82rem; margin-top: 18px; font-style: italic; }
.reg-modal-close { position: fixed; top: 18px; right: 24px; background: none; border: none;
  color: #fff; font-size: 2.4rem; line-height: 1; cursor: pointer; }
.reg-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 28px; margin-top: 10px; }
.reg-col { display: flex; flex-direction: column; gap: 16px; }
.reg-buy { justify-content: flex-start; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: var(--sw); border: 2px solid rgba(0,0,0,.15); padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.swatch:hover { transform: scale(1.1); }
.swatch.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.swatch.pattern { background-size: cover; background-position: center; border-radius: 6px; }
.swatch-label { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.reg-price { font-size: 1.6rem; font-weight: 700; margin: 18px 0 10px; }

.fonts { display: flex; flex-wrap: wrap; gap: 8px; }
.font-btn {
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: .95rem; font-weight: 600; color: var(--ink);
}
.font-btn:hover { border-color: var(--brand); }
.font-btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.font-btn .badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 999px; margin-left: 4px;
}
.toggle-field { flex-direction: row; align-items: center; gap: 8px; font-size: .9rem; }
.toggle-field input { width: auto; }

/* Diamond tuner */
.tuner { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; margin-top: 18px; }
.tuner-stage {
  background: linear-gradient(160deg, #e7edf2, #c7d0d8);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  display: flex; gap: 20px; align-items: flex-start; justify-content: center;
}
#tuner-letter { border-radius: 8px; }
.tuner-swatch-wrap { text-align: center; }
#tuner-tile { border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; }
.tuner-controls { display: flex; flex-direction: column; gap: 16px; }
.trange { display: flex; flex-direction: column; font-size: .9rem; font-weight: 600; gap: 4px; }
.trange output { font-weight: 400; color: var(--brand); }
.trange input[type=range] { width: 100%; }
.trow { display: flex; gap: 18px; }
.tsmall { display: flex; flex-direction: column; font-size: .85rem; font-weight: 600; gap: 4px; }
.tsmall input[type=text] { width: 60px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; text-align: center; text-transform: uppercase; }
.tsmall input[type=color] { width: 60px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: none; }
.tuner-readout { background: #f3f4f6; border-radius: 8px; padding: 12px 14px; font-size: .9rem; }

@media (max-width: 720px) { .tuner { grid-template-columns: 1fr; } }

/* SVG vector test */
.svgtest-stage { background: linear-gradient(160deg, #e7edf2, #c7d0d8); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 30px; display: flex; justify-content: center; overflow: auto; }
.svgtest-stage svg { height: auto; }
.svgtest-controls { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 16px; align-items: center; }
.svgtest-controls label { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; }
.svgtest-controls input[type=color] { width: 48px; height: 34px; border: 1px solid var(--line); border-radius: 6px; }
.svgtest-diamond { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px 24px; margin-top: 18px; }

@media (max-width: 720px) {
  .product { grid-template-columns: 1fr; gap: 24px; }
  .cart-line { grid-template-columns: 56px 1fr 70px; }
  .cart-line-total { grid-column: 2 / 4; text-align: left; }
  .site-header { flex-wrap: wrap; }
  .search { order: 3; max-width: 100%; margin: 10px 0 0; width: 100%; }
  .field-row { flex-direction: column; gap: 0; }
  .reg-designer { grid-template-columns: 1fr; }
}
