:root {
  --paper: #FAF7F6;
  --card: #FFFFFF;
  --ink: #2B1A24;
  --muted: #6E5A64;
  --line: #E7DEDD;
  --lacquer: #B3122E;
  --lacquer-dark: #8E0D24;
  --peg: #E4DCD9;
  --wa: #128C4A;
  --wa-dark: #0D6E3A;

  --display: "Gloock", Georgia, serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: 2.5rem;
  --step-4: clamp(2.4rem, 4.6vw, 3.75rem);

  --wrap: 1240px;
  color-scheme: light;
}
:root:lang(zh) {
  --display: "Gloock", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --body: "Figtree", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}
:root:lang(ja) {
  --display: "Gloock", "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --body: "Figtree", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}
:root:lang(ar) {
  --display: "Noto Naskh Arabic", "Gloock", serif;
  --body: "Noto Sans Arabic", "Figtree", "Segoe UI", sans-serif;
}
:root:lang(zh-Hant) {
  --display: "Gloock", "Noto Serif TC", "Songti TC", "PMingLiU", "Microsoft JhengHei", serif;
  --body: "Figtree", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}
:root:lang(ko) {
  --display: "Gloock", "Noto Serif KR", "Apple SD Gothic Neo", "Malgun Gothic", serif;
  --body: "Figtree", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
:root:lang(ru) {
  --display: "Gloock", "Noto Serif", "Times New Roman", serif;
  --body: "Figtree", "Noto Sans", "Segoe UI", sans-serif;
}
:root:lang(th) {
  --display: "Gloock", "Noto Serif Thai", "Noto Sans Thai", serif;
  --body: "Figtree", "Noto Sans Thai", "Thonburi", "Tahoma", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html.i18n-pending body { visibility: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
:lang(zh) body, :lang(ja) body, :lang(ko) body, :lang(th) body { line-height: 1.7; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.15; margin: 0; }
h2 { font-size: var(--step-3); }
:lang(zh) h1, :lang(zh) h2, :lang(ja) h1, :lang(ja) h2, :lang(ko) h1, :lang(ko) h2 { font-weight: 600; letter-spacing: .02em; }

:focus-visible { outline: 3px solid var(--lacquer); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { inset-inline-start: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  font-weight: 600; text-decoration: none; cursor: pointer; border: 2px solid transparent;
}
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: #000; }
.btn-line { border-color: var(--ink); background: transparent; }
.btn-line:hover { background: var(--ink); color: #fff; }
.btn-wa { background: var(--wa); color: #fff; width: 100%; }
.btn-wa:hover { background: var(--wa-dark); }
.btn-wa[aria-disabled="true"] { background: #B9C9BF; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); font-size: 1.4rem; line-height: 1; cursor: pointer;
}

/* Header */
.top { position: sticky; top: 0; z-index: 20; background: rgba(250, 247, 246, 0.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: var(--wrap); margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; font-family: "Gloock", Georgia, serif; font-size: var(--step-1); text-decoration: none; white-space: nowrap; }
.brand img, .brand svg { height: 24px; width: auto; }
.search { flex: 1; max-width: 420px; margin-inline-start: auto; }
.search input {
  width: 100%; height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
}
.lang select {
  height: 44px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer;
}
.order-pill {
  display: flex; flex-direction: column; gap: 4px; align-items: stretch;
  min-width: 140px; padding: 8px 16px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--card); font-weight: 600; font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}
.order-pill-bar { height: 4px; border-radius: 2px; background: var(--peg); overflow: hidden; }
.order-pill-bar span { display: block; height: 100%; width: 0; background: var(--lacquer); transition: width .3s ease; }
.order-pill.is-ready { background: var(--wa); border-color: var(--wa); color: #fff; }
.order-pill.is-ready .order-pill-bar { background: rgba(255,255,255,.35); }
.order-pill.is-ready .order-pill-bar span { background: #fff; }
.order-pill.bump { animation: bump .35s ease; }
@keyframes bump { 50% { transform: scale(1.06); } }

/* Hero */
.hero {
  max-width: var(--wrap); margin: 0 auto; padding: 56px 24px 48px;
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; align-items: center;
}
.hero:has(#wall[hidden]) { grid-template-columns: 1fr; }
.hero h1 { font-size: var(--step-4); max-width: 13ch; }
:lang(zh) .hero h1, :lang(ja) .hero h1, :lang(ko) .hero h1 { max-width: 9em; }
:lang(th) .hero h1 { max-width: 16em; line-height: 1.45; }
:lang(ar) .hero h1 { max-width: 16ch; line-height: 1.35; }
.lede { font-size: var(--step-1); color: var(--muted); max-width: 34em; margin: 20px 0 28px; line-height: 1.5; }
:lang(zh) .lede, :lang(ja) .lede, :lang(ko) .lede, :lang(th) .lede { line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.terms { margin: 36px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; border-top: 1px solid var(--line); padding-top: 20px; }
.terms dt { font-size: var(--step--1); color: var(--muted); }
.terms dd { margin: 2px 0 0; font-weight: 600; line-height: 1.35; }

/* Pegboard wall */
.wall {
  position: relative; border-radius: 6px; padding: 28px 22px 22px;
  background-color: var(--peg);
  background-image: radial-gradient(circle, #CFC4C0 2.5px, transparent 3px);
  background-size: 28px 28px; background-position: 14px 14px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px 16px;
  box-shadow: inset 0 0 0 1px #D6CCC8;
}
.wall .hang { position: relative; transform-origin: 50% 0; }
.wall .hang:nth-child(odd) { transform: rotate(-1.2deg); }
.wall .hang:nth-child(3n) { transform: rotate(1.6deg); }
.wall .hang::before {
  content: ""; position: absolute; top: -10px; left: 50%; width: 4px; height: 16px;
  margin-left: -2px; border-radius: 2px; background: #9C908C; z-index: 2;
}
.wall svg, .wall img { width: 100%; height: auto; filter: drop-shadow(0 3px 2px rgba(60, 30, 40, .14)); }
.wall img { aspect-ratio: 4 / 5; object-fit: cover; border-radius: 46% 46% 6px 6px / 18% 18% 6px 6px; }
@media (prefers-reduced-motion: no-preference) {
  .wall .hang { animation: hang .6s cubic-bezier(.2,.9,.3,1.3) both; animation-delay: calc(var(--i) * 45ms); }
  @keyframes hang { from { opacity: 0; translate: 0 -28px; } to { opacity: 1; translate: 0 0; } }
}

/* Sections */
.steps, .catalog, .faq { max-width: var(--wrap); margin: 0 auto; padding: 56px 24px; }
.steps { border-top: 1px solid var(--line); }
.steps ol {
  list-style: none; counter-reset: step; padding: 0; margin: 28px 0 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px;
}
.steps li { counter-increment: step; color: var(--muted); }
.steps li::before {
  content: counter(step); display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%; margin-bottom: 14px;
  border: 2px solid var(--lacquer); color: var(--lacquer); font-family: "Gloock", Georgia, serif; font-size: var(--step-1);
}
.steps strong { display: block; color: var(--ink); font-size: var(--step-1); font-weight: 600; line-height: 1.3; margin-bottom: 6px; }
.section-note { color: var(--muted); margin: 8px 0 24px; max-width: 60ch; }

/* Product display cards */
.pcard { display: flex; flex-direction: column; }
.pcard-img {
  position: relative; display: block; width: 100%; padding: 0; border: 0; cursor: pointer;
  background: var(--card); border-radius: 46% 46% 10px 10px / 18% 18% 10px 10px;
  overflow: hidden; aspect-ratio: 4 / 5;
  box-shadow: 0 0 0 1px var(--line);
}
.pcard-img svg, .pcard-img img { width: 100%; height: 100%; object-fit: cover; }
.pcard-img:hover { box-shadow: 0 0 0 2px var(--ink); }
.pcard.is-out .pcard-img > svg, .pcard.is-out .pcard-img > img { opacity: .45; }
.tag {
  position: absolute; top: 14%; inset-inline-start: 10px;
  font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
}
.tag-new { background: var(--lacquer); color: #fff; }
.tag-stock { top: auto; bottom: 10px; background: var(--ink); color: #fff; }
.tag-low { top: auto; bottom: 10px; background: #fff; color: var(--lacquer-dark); box-shadow: 0 0 0 1px var(--lacquer); }
.pcard-body { padding: 12px 2px 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: baseline; }
.pcard-code { font-weight: 700; font-size: var(--step-1); letter-spacing: .01em; direction: ltr; unicode-bidi: isolate; }
.pcard-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.pcard-price small { color: var(--muted); font-weight: 400; }
.pcard-name { grid-column: 1 / -1; color: var(--muted); font-size: var(--step--1); }
.pcard-qty { margin-top: 10px; }
.pick {
  width: 100%; min-height: 42px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--card); color: var(--ink);
  font-weight: 600; font-size: var(--step--1); font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.pick:hover { background: var(--ink); color: #fff; }
.pick.is-picked { background: var(--ink); color: #fff; justify-content: space-between; }
.pick.is-picked:hover { background: #000; }
.pick-edit { font-weight: 400; opacity: .75; text-decoration: underline; text-underline-offset: 3px; }
.pick:disabled { border-color: var(--line); background: transparent; color: var(--muted); cursor: not-allowed; }

/* Size and quantity rows in the product window */
.size-rows { border-top: 1px solid var(--line); margin-bottom: 4px; }
.size-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.size-name { font-weight: 600; }
.size-meta { font-weight: 400; color: var(--lacquer-dark, #8A1024); font-size: var(--step--1); }
.size-row.is-out { opacity: .55; }
.size-row.is-out .stepper { pointer-events: none; }
.stepper {
  display: grid; grid-template-columns: 38px 64px 38px; height: 38px;
  border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card);
}
.stepper button { border: 0; background: transparent; font-size: 1.15rem; cursor: pointer; color: var(--ink); }
.stepper button:hover:not(:disabled) { background: var(--paper); }
.stepper button:disabled { color: #CFC4C0; cursor: default; }
.stepper input {
  min-width: 0; border: 0; text-align: center; font-weight: 700; background: transparent;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper.has-qty { border-color: var(--ink); }
.modal-total { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Catalog */
.catalog { border-top: 1px solid var(--line); }
.catalog-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.result-count { color: var(--muted); margin: 0; }
.catalog-body { display: grid; grid-template-columns: 210px 1fr; gap: 36px; align-items: start; }
.catalog-body > * { min-width: 0; }
.filters { position: sticky; top: 88px; display: grid; gap: 22px; }
.filters fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.filters legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: var(--step--1);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.clear-filters { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: var(--muted); justify-self: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 32px 20px; }
.empty { grid-column: 1 / -1; padding: 40px 0; color: var(--muted); }

/* FAQ */
.faq { border-top: 1px solid var(--line); max-width: 820px; }
.faq h2 { margin-bottom: 20px; }
.faq details { border-bottom: 1px solid var(--line); padding: 16px 0; }
.faq summary { cursor: pointer; font-weight: 600; font-size: var(--step-1); }
.faq p { color: var(--muted); margin: 10px 0 0; max-width: 65ch; }

.foot { border-top: 1px solid var(--line); padding: 32px 24px 48px; text-align: center; color: var(--muted); }
.foot p { margin: 4px 0; }
.foot p:empty { display: none; }

/* Order panel */
.scrim { position: fixed; inset: 0; background: rgba(43, 26, 36, .4); z-index: 40; }
.order {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; z-index: 50; width: min(440px, 100%);
  background: var(--paper); display: flex; flex-direction: column;
  box-shadow: 0 0 40px rgba(43, 26, 36, .18);
}
@media (prefers-reduced-motion: no-preference) {
  .order:not([hidden]) { animation: slidein .25s ease-out; }
  [dir="rtl"] .order:not([hidden]) { animation-name: slidein-rtl; }
  @keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
  @keyframes slidein-rtl { from { transform: translateX(-40px); opacity: 0; } }
}
.order-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px 12px; }
.order-head h2 { font-size: var(--step-2); }
.meter { padding: 0 22px 14px; border-bottom: 1px solid var(--line); }
.meter-bar { height: 10px; border-radius: 5px; background: var(--peg); overflow: hidden; }
.meter-bar span { display: block; height: 100%; width: 0; background: var(--lacquer); transition: width .3s ease; }
.meter.is-ready .meter-bar span { background: var(--wa); }
.meter p { margin: 8px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.order { overflow-y: auto; }
.lines { list-style: none; margin: 0; padding: 4px 22px; flex: 1 0 auto; }
.form-row { display: grid; grid-template-columns: 3fr 2fr; gap: 10px; }
.lines li { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line-thumb { width: 52px; height: 64px; border-radius: 40% 40% 6px 6px / 16% 16% 6px 6px; overflow: hidden; background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.line-thumb svg, .line-thumb img { width: 100%; height: 100%; object-fit: cover; }
.line-info b { display: block; direction: ltr; unicode-bidi: isolate; text-align: start; }
.line-info span { color: var(--muted); font-size: var(--step--1); }
.line-qty { display: flex; align-items: center; gap: 4px; }
.line-qty input { width: 58px; height: 36px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-variant-numeric: tabular-nums; }
.line-qty button { width: 32px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; }
.line-remove { grid-column: 2 / -1; justify-self: start; background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: var(--step--1); }
.lines .empty-line { display: block; color: var(--muted); border: 0; padding: 28px 0; }
.order-foot { padding: 14px 22px 22px; border-top: 1px solid var(--line); background: var(--card); }
.estimate { margin: 0 0 12px; font-variant-numeric: tabular-nums; }
.estimate:empty { display: none; }
.estimate small { display: block; color: var(--muted); }
#orderForm { display: grid; gap: 10px; }
#orderForm label { display: grid; gap: 4px; font-size: var(--step--1); font-weight: 600; }
#orderForm input, #orderForm select { height: 42px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); font-weight: 400; }
.form-error { color: var(--lacquer-dark); margin: 0; font-size: var(--step--1); }
.form-error:empty { display: none; }
.fine { color: var(--muted); font-size: 0.8rem; margin: 0; text-align: center; }

/* Product modal */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(43, 26, 36, .45); display: grid; place-items: center; padding: 20px; }
.modal-card {
  position: relative; background: var(--paper); border-radius: 14px; width: min(880px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding: 28px;
}
.modal-card .icon-btn { position: absolute; top: 14px; inset-inline-end: 14px; z-index: 2; }
.modal-img { border-radius: 46% 46% 10px 10px / 18% 18% 10px 10px; overflow: hidden; background: var(--card); box-shadow: 0 0 0 1px var(--line); aspect-ratio: 4 / 5; }
.modal-img svg, .modal-img img { width: 100%; height: 100%; object-fit: cover; }
.modal-info h3 { font-size: var(--step-3); font-family: "Gloock", Georgia, serif; direction: ltr; unicode-bidi: isolate; text-align: start; }
.modal-info .sub { color: var(--muted); margin: 4px 0 16px; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0 0 18px; font-size: var(--step--1); }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; font-weight: 600; }
.tiers { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-variant-numeric: tabular-nums; }
.tiers th, .tiers td { text-align: start; padding: 7px 0; border-bottom: 1px solid var(--line); }
.tiers th { font-size: var(--step--1); color: var(--muted); font-weight: 600; }
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 14px; }
.size-grid label { display: grid; gap: 4px; font-size: var(--step--1); font-weight: 600; }
.size-grid input { height: 40px; border: 1px solid var(--line); border-radius: 8px; text-align: center; background: var(--card); }
.modal-note { color: var(--muted); font-size: var(--step--1); margin: 0 0 14px; }
.modal-out { color: var(--lacquer-dark); font-weight: 600; margin: 0 0 14px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 70; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.load-error { max-width: var(--wrap); margin: 40px auto; padding: 0 24px; color: var(--lacquer-dark); font-weight: 600; }

/* Responsive */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding-top: 32px; }
  .steps ol { grid-template-columns: repeat(2, 1fr); }
  .catalog-body { grid-template-columns: 1fr; }
  .filters { position: static; }
  .filters .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .chip { white-space: nowrap; }
  .modal-card { grid-template-columns: 1fr; }
  .modal-img { max-width: 320px; }
}
@media (max-width: 640px) {
  .top-inner { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .top-inner { gap: 8px; }
  .brand img { height: 15px; }
  .lang { margin-inline-start: auto; }
  .lang select { height: 40px; padding: 0 6px; }
  .order-pill { min-width: 0; padding: 6px 10px; }
  .terms { grid-template-columns: 1fr; }
  .wall { grid-template-columns: repeat(3, 1fr); }
  .wall .hang:nth-child(n+10) { display: none; }
  .steps ol { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 24px 12px; }
  .steps, .catalog, .faq { padding: 40px 16px; }
  .hero { padding-left: 16px; padding-right: 16px; }
}
