:root {
  --ink: #1f2328;
  --muted: #6a737d;
  --line: #e3e5e8;
  --bg: #f5f6f7;
  --accent: #c8102e;
  --ok: #1a7f37;
  --warn: #b26b00;
  --err: #c8102e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  font-size: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); height: 100vh; display: flex; flex-direction: column; }

.top { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: #16191d; color: #fff; }
.brand { display: flex; align-items: baseline; gap: 12px; }
.logo { font-weight: 800; letter-spacing: 0.18em; font-size: 18px; }
.sub { color: #c9ced4; }
.demo { font-size: 12px; padding: 3px 8px; border: 1px solid #3a4048; border-radius: 99px; color: #c9ced4; }
.lang { margin-left: auto; display: flex; gap: 2px; }
.lang a { color: #c9ced4; text-decoration: none; font-size: 12px; font-weight: 600; padding: 3px 7px; border-radius: 4px; }
.lang a.cur { background: #fff; color: #16191d; }
.admin-link { color: #fff; text-decoration: none; opacity: 0.85; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px 1fr 320px; }
.panel { overflow-y: auto; background: #fff; border-right: 1px solid var(--line); padding: 4px 18px 24px; }
.panel.right { border-right: 0; border-left: 1px solid var(--line); }
section { padding: 14px 0; border-bottom: 1px solid var(--line); }
section:last-child { border-bottom: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h2 span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; }
h2 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }
h3 { font-size: 12px; margin: 16px 0 8px; color: var(--muted); font-weight: 600; }

.cards { display: grid; gap: 8px; margin-bottom: 10px; }
.card { text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; }
.card span { color: var(--muted); font-size: 12px; }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 3px #c8102e14; }

.field { display: grid; gap: 4px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.field.inline { grid-template-columns: 1fr auto; align-items: center; }
select, input[type=number], input:not([type]), input[type=email], textarea {
  font: inherit; color: var(--ink); border: 1px solid #cfd3d8; border-radius: 6px; padding: 6px 8px; background: #fff; width: 100%;
}
textarea { resize: vertical; }
input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid #cfd3d8; border-radius: 4px; background: none; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.check.tight { margin: 0; gap: 3px; }
.hint, .muted { color: var(--muted); font-size: 12px; }
.hint { margin: -4px 0 8px; }

.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dims label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.chip:hover { border-color: #aab1b8; }

.range { display: grid; grid-template-columns: 70px 1fr; align-items: center; font-size: 12px; color: var(--muted); margin: 4px 0; }
.range.wide { grid-template-columns: auto 220px; gap: 10px; }
.file-row { display: flex; align-items: center; gap: 10px; }
.text-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.text-row select { width: auto; flex: 1; }
.text-row input[type=number] { width: 58px; }

.btn { font: inherit; border: 1px solid #cfd3d8; background: #fff; border-radius: 6px; padding: 8px 14px; cursor: pointer; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px 0; font: inherit; font-size: 12px; }

.stage { display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; }
.tabs button { border: 0; background: none; padding: 8px 14px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.view { flex: 1; min-height: 0; margin: 0 16px; border-radius: 10px; background: radial-gradient(ellipse at 50% 40%, #ffffff 0%, #e6e8eb 75%); position: relative; overflow: hidden; }
#view3d canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.die-view { background: #fff; display: flex; flex-direction: column; border: 1px solid var(--line); }
#dieSvg { flex: 1; min-height: 0; padding: 12px; }
#dieSvg svg { width: 100%; height: 100%; }
.legend { display: flex; gap: 18px; padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.legend i { display: inline-block; width: 22px; height: 0; vertical-align: middle; margin-right: 4px; }
.legend .cut { border-top: 2px solid #e4002b; }
.legend .crease { border-top: 2px dashed #0a74c4; }
.legend .glue { height: 10px; background: repeating-linear-gradient(45deg, #9aa0a6 0 1px, transparent 1px 4px); }
.stage-bar { display: flex; align-items: center; gap: 16px; padding: 12px 16px; flex-wrap: wrap; }

.prices { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.prices th { text-align: right; font-size: 11px; color: var(--muted); font-weight: 500; padding: 4px 6px; }
.prices th:first-child, .prices td:first-child { text-align: left; }
.prices td { text-align: right; padding: 7px 6px; border-top: 1px solid var(--line); cursor: pointer; }
.prices tr.sel td { background: #c8102e0d; font-weight: 600; }
.prices tr.sel td:first-child { box-shadow: inset 3px 0 var(--accent); }
.prices td.err { color: var(--err); cursor: default; text-align: left; }
details { margin-top: 10px; font-size: 12px; }
summary { cursor: pointer; color: var(--muted); }
.breakdown table { width: 100%; font-variant-numeric: tabular-nums; }
.breakdown td:last-child { text-align: right; }
.breakdown p { color: var(--muted); }
.fine { font-size: 11px; color: var(--muted); margin: 10px 0 0; }

.preflight { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 12.5px; }
.preflight li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; line-height: 1.35; }
.ic { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 700; color: #fff; }
.ok .ic { background: var(--ok); }
.info .ic { background: #6a737d; font-style: italic; font-family: Georgia, serif; }
.warn .ic { background: var(--warn); }
.error .ic { background: var(--err); }
.error { color: var(--err); }

.actions { display: grid; gap: 8px; }
.status { font-size: 12.5px; margin: 4px 0 0; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

dialog { border: 0; border-radius: 12px; padding: 22px 24px; width: min(440px, 92vw); box-shadow: 0 20px 60px #0004; }
dialog::backdrop { background: #16191d88; }
dialog h2 { text-transform: none; letter-spacing: 0; font-size: 18px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

@media (max-width: 1100px) {
  body { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .view { height: 60vh; flex: none; }
}
