:root {
  --ink: #14243d;
  --muted: #5b6a80;
  --line: #e1e6ee;
  --panel: #ffffff;
  --stage: #eceef0;
  --accent: #2f6fc8;
  --accent-soft: #e8f0fb;
  --radius: 18px;
  font-family: "Axiforma", "Avenir Next", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--stage); }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: 100%; }

.viewer { position: relative; min-width: 0; min-height: 0; }
#canvasHost { position: absolute; inset: 0; }
#canvasHost canvas { display: block; outline: none; touch-action: none; }

.view-buttons { position: absolute; left: 20px; top: 20px; display: flex; gap: 10px; }
.view-buttons button {
  border: 0; border-radius: 14px; padding: 12px 20px; font: inherit; font-weight: 800; font-size: 15px;
  color: var(--ink); background: #fff; box-shadow: 0 6px 20px rgba(20, 36, 61, 0.12); cursor: pointer;
}
.view-buttons button:hover { background: var(--accent); color: #fff; }
.view-buttons button:focus-visible, .chip:focus-visible, .type-card:focus-visible, .swatch:focus-visible, .shop-link:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

.dims-toggle { position: absolute; right: 20px; top: 20px; display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-radius: 14px; background: #fff; box-shadow: 0 6px 20px rgba(20, 36, 61, 0.12); font-size: 15px; font-weight: 800; cursor: pointer; }
.dims-toggle input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.refine { position: absolute; left: 20px; right: 20px; bottom: 44px; height: 3px; border-radius: 3px; background: rgba(20, 36, 61, 0.08); overflow: hidden; transition: opacity 0.5s; }
.refine span { display: block; height: 100%; width: calc(var(--progress, 0) * 100%); background: var(--accent); }
.refine.is-done { opacity: 0; }
.hint { position: absolute; left: 20px; bottom: 14px; margin: 0; font-size: 12.5px; color: var(--muted); }

.panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 22px 22px 32px; display: flex; flex-direction: column; gap: 22px; }
.panel-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 900; letter-spacing: -0.01em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 14px; }
.block h2 { margin: 0 0 12px; font-size: 15px; font-weight: 900; }
.block > div { display: grid; gap: 12px; }

.type-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px !important; }
.type-card {
  display: grid; gap: 6px; justify-items: center; align-content: start; padding: 8px 6px 10px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff; font: inherit; color: var(--ink);
}
.type-card img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 12px; background: #f6f8fb; }
.type-card span { font-size: 12px; font-weight: 800; text-align: center; line-height: 1.2; overflow-wrap: anywhere; hyphens: auto; max-width: 100%; }
.type-card:hover { border-color: #b9c8de; }
.type-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

.field-label { margin: 0 0 -4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }

.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.swatch { display: grid; gap: 6px; padding: 0; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: center; }
.swatch-color { display: block; aspect-ratio: 1; border-radius: 14px; border: 1.5px solid var(--line); background-color: #ddd; background-blend-mode: multiply; box-shadow: inset 0 0 0 3px #fff; }
.swatch span:last-child { font-size: 12px; font-weight: 700; line-height: 1.2; }
.swatch[aria-pressed="true"] .swatch-color { border-color: var(--accent); box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px var(--accent); }
.swatches-small { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.swatches-small .swatch span:last-child { font-size: 10.5px; font-weight: 600; }

.slider { display: grid; gap: 6px; }
.slider-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--muted); }
.slider-head output { color: var(--ink); font-variant-numeric: tabular-nums; }
.slider input { width: 100%; accent-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.note { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.summary { border-top: 1px solid var(--line); padding-top: 20px; }
.summary h2 { font-size: 18px; margin-bottom: 6px; }
.summary p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.summary dl { margin: 0 0 16px; display: grid; gap: 6px; }
.row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.row dt { color: var(--muted); }
.row dd { margin: 0; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.shop-link { display: block; text-align: center; text-decoration: none; background: var(--accent); color: #fff; font-weight: 800; padding: 13px 16px; border-radius: 14px; }
.shop-link:hover { background: #245aa6; }

@media (max-width: 900px) {
  html, body { height: auto; }
  .app { grid-template-columns: 1fr; height: auto; }
  .viewer { height: 58vh; min-height: 320px; position: sticky; top: 0; z-index: 1; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 18px 16px 28px; }
  .view-buttons { left: 12px; top: 12px; }
  .view-buttons button { padding: 10px 14px; font-size: 14px; }
  .dims-toggle { right: 12px; top: 12px; padding: 9px 12px; font-size: 14px; }
  .hint { display: none; }
  .refine { bottom: 10px; left: 12px; right: 12px; }
}
