:root {
  --bg: #090b10;
  --panel: #0e1118;
  --panel-soft: #121722;
  --line: #2a303c;
  --line-soft: #1c222d;
  --text: #e6e9ee;
  --muted: #7d8592;
  --accent: #b6f05b;
  --accent-2: #7eb633;
  --danger: #ee7683;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--sans); }
button, input, select { font: inherit; }
button { color: inherit; }

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 68px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
  background: #0b0e14;
}
.brand { display: flex; align-items: center; gap: 11px; width: 232px; color: white; text-decoration: none; }
.brand-mark { display: block; width: 39px; height: 39px; flex: none; object-fit: cover; border: 1px solid #303b43; border-radius: 10px; background: #0d1316; filter: drop-shadow(0 5px 14px #0008); }
.brand span { display: flex; flex-direction: column; gap: 3px; }
.brand b { font-size: 14px; line-height: 1; letter-spacing: .08em; }
.brand b em { color: var(--accent); font-style: normal; font-weight: 720; }
.brand small { color: #89919e; font: 9px var(--mono); letter-spacing: .095em; }
.design-title { display: flex; min-width: 0; flex: 1; align-items: center; gap: 9px; height: 37px; padding-left: 24px; border-left: 1px solid var(--line); }
.design-title input { width: min(340px, 100%); min-width: 0; border: 0; outline: 0; background: transparent; color: #dfe2e8; font-size: 13px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px #b6f05b88; }
.top-actions { display: flex; gap: 8px; }

.btn {
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151922;
  color: #d8dce3;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: border-color .18s, transform .18s, background .18s;
}
.btn:hover { transform: translateY(-1px); border-color: #4b5360; }
.btn.accent { border-color: var(--accent); background: var(--accent); color: #11150a; }
.btn.accent:hover { background: #c6fa74; }
.btn.ghost { background: #11151d; }
.btn span { margin-left: 6px; }

.workspace { display: grid; grid-template-columns: 300px minmax(390px, 1fr) 360px; height: calc(100% - 68px); }
.panel { min-height: 0; overflow: auto; background: var(--panel); scrollbar-width: thin; scrollbar-color: #303745 transparent; }
.cuts-panel { padding: 23px 18px; border-right: 1px solid var(--line-soft); }
.inspector { padding: 23px 20px; border-left: 1px solid var(--line-soft); }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.panel-heading h1 { margin: 4px 0 0; font-size: 17px; letter-spacing: -.02em; }
.eyebrow { color: var(--accent); font: 9px var(--mono); letter-spacing: .16em; }
.count, .section-title > span { color: #89919e; font: 9px var(--mono); letter-spacing: .08em; text-transform: uppercase; }

.cut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.custom-launch { display: flex; align-items: center; gap: 10px; width: 100%; margin: -5px 0 13px; padding: 11px; border: 1px solid #577e29; border-radius: 11px; background: linear-gradient(135deg, #1c2a17, #11181a); color: #eaf8d8; text-align: left; cursor: pointer; box-shadow: inset 0 0 0 1px #b6f05b12; }
.custom-launch:hover { border-color: var(--accent); background: linear-gradient(135deg, #24371b, #121a1d); }
.custom-launch-icon { display: grid; place-items: center; width: 35px; height: 35px; flex: none; border-radius: 9px; background: #b6f05b12; }
.custom-launch-icon svg { width: 24px; fill: none; stroke: var(--accent); stroke-width: 1.5; }
.custom-launch > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 3px; }
.custom-launch strong { font-size: 10px; }
.custom-launch small { color: #9ba991; font: 9px var(--mono); letter-spacing: .03em; }
.custom-launch > b { color: var(--accent); font: 20px/1 var(--mono); }
.custom-resume { display: flex; align-items: center; gap: 9px; width: 100%; margin: -6px 0 13px; padding: 9px 10px; border: 1px solid #35434b; border-radius: 9px; background: #11171b; color: #d9e1e8; text-align: left; cursor: pointer; }
.custom-resume[hidden] { display: none; }
.custom-resume:hover { border-color: #718491; background: #151e23; }
.custom-resume svg { width: 19px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }
.custom-resume span { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.custom-resume strong { font-size: 10px; }
.custom-resume small { color: #91a0aa; font: 9px var(--mono); }
.cut-card {
  position: relative;
  min-height: 130px;
  overflow: hidden;
  padding: 6px 7px 27px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #11151d;
  color: #a8aeb8;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}
.cut-card:hover { transform: translateY(-1px); border-color: #414a58; background: #151a24; }
.cut-card.active { border-color: var(--accent-2); background: linear-gradient(150deg, #1d2918, #12181b 66%); color: #fff; box-shadow: inset 0 0 0 1px #b6f05b22; }
.cut-thumb { display: block; width: 100%; height: auto; aspect-ratio: 120 / 88; border-radius: 7px; background: linear-gradient(145deg, #1c2633, #070b11); }
.cut-card span { position: absolute; left: 10px; bottom: 9px; font-size: 10px; font-weight: 650; }
.cut-card em { position: absolute; top: 7px; right: 8px; color: var(--accent); font: 9px var(--mono); font-style: normal; opacity: 0; }
.cut-card.active em { opacity: 1; }

.tip-card { display: flex; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.tip-icon { display: grid; flex: none; place-items: center; width: 20px; height: 20px; border: 1px solid #3b4350; border-radius: 50%; color: var(--accent); font: 10px var(--mono); }
.tip-card strong { display: block; color: #c8ccd3; font-size: 10px; }
.tip-card p { margin: 4px 0; color: #8a929f; font-size: 9px; line-height: 1.6; }

.viewport-wrap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 38% 72% at 12% 39%, #f7f8fb8f 0 13%, #aeb3bc42 34%, transparent 72%),
    radial-gradient(ellipse 31% 64% at 88% 36%, #f4f6fa78 0 12%, #9ba2ad38 38%, transparent 72%),
    radial-gradient(ellipse 72% 28% at 52% -8%, #ffffff70, transparent 72%),
    linear-gradient(148deg, #7c838d, #444b55 46%, #242a32 76%, #11161c);
  isolation: isolate;
}
.viewport-wrap[data-lighting="white"] { background: #fff; }
.viewport-wrap[data-lighting="black"] { background: #14161b; }
.viewport-wrap::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(ellipse 12% 58% at 23% 43%, #fff9, transparent 72%),
    radial-gradient(ellipse 10% 54% at 77% 40%, #f8fbff80, transparent 72%),
    radial-gradient(ellipse 52% 10% at 51% 12%, #fff7, transparent 74%);
  filter: blur(18px);
  opacity: .7;
  transform: scale(1.06);
  content: "";
  pointer-events: none;
}
.viewport-wrap[data-lighting="white"]::before,
.viewport-wrap[data-lighting="black"]::before { display: none; }
.viewport-wrap canvas { position: relative; display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.viewport-wrap canvas:active { cursor: grabbing; }
.view-toolbar { position: absolute; z-index: 2; top: 18px; right: 20px; left: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; pointer-events: none; }
.view-toolbar > * { pointer-events: auto; }
.view-toolbar-primary, .view-toolbar-secondary { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.view-toolbar-secondary { align-items: flex-end; }
.segmented { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: #11151ddd; backdrop-filter: blur(12px); }
.segmented button { padding: 6px 11px; border: 0; border-radius: 6px; background: transparent; color: #737b88; cursor: pointer; font-size: 10px; }
.segmented button.active { background: #272d39; color: #eef0f4; }
.render-mode-switch { padding: 3px; }
.render-mode-switch button { min-width: 54px; padding: 5px 9px; font: 9px var(--mono); letter-spacing: .03em; }
.display-actions { display: flex; align-items: center; gap: 8px; }
.switch-label { position: relative; display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #11151ddd; color: #9299a5; font-size: 9px; cursor: pointer; }
.switch-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-label span { position: relative; width: 22px; height: 12px; border-radius: 10px; background: #303642; }
.switch-label span::after { position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: #7c8390; content: ""; transition: left .18s, background .18s; }
.switch-label input:checked + span { background: #51751e; }
.switch-label input:checked + span::after { left: 12px; background: var(--accent); }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #11151ddd; color: #a3aab5; cursor: pointer; }
.icon-btn:hover { border-color: #4b5360; color: white; }
.inspector-heading { align-items: center; }
.inspector-heading .icon-btn { color: var(--accent); font-size: 16px; }
.viewport-hint { position: absolute; top: 75px; left: 50%; transform: translateX(-50%); color: #8b939f; font: 9px var(--mono); letter-spacing: .04em; pointer-events: none; }
.viewport-hint span { color: #a0a7b2; }
.viewport-hint i { display: inline-block; width: 3px; height: 3px; margin: 0 7px 2px; border-radius: 50%; background: #464d59; }
.gem-caption { position: absolute; bottom: 44px; left: 50%; text-align: center; transform: translateX(-50%); pointer-events: none; }
.gem-caption div { display: flex; align-items: center; justify-content: center; gap: 8px; }
.gem-caption span { color: var(--accent); font: 9px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.gem-caption strong { font-size: 12px; }
.gem-caption p { margin: 5px 0; color: #89919e; font: 9px var(--mono); }
.viewport-weight { position: absolute; bottom: 22px; left: 22px; display: grid; min-width: 132px; gap: 2px; padding: 9px 11px; border: 1px solid #44582d; border-radius: 9px; background: #0b1110c7; box-shadow: 0 8px 28px #0007; pointer-events: none; backdrop-filter: blur(10px); }
.viewport-weight span { color: #93a287; font: 9px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.viewport-weight strong { color: var(--accent); font: 700 17px/1.15 var(--mono); letter-spacing: -.04em; }
.viewport-weight small { color: #788274; font: 9px var(--mono); }
.scale-ruler { position: absolute; right: 24px; bottom: 26px; display: flex; align-items: center; color: #89919e; font: 9px var(--mono); }
.scale-ruler span { width: 18px; height: 6px; border-top: 1px solid #444b57; }
.scale-ruler span:first-child { border-left: 1px solid #444b57; }
.scale-ruler span:last-child { border-right: 1px solid #444b57; }
.scale-ruler b { margin: 0 5px; font-weight: 400; }

.viewport-wrap[data-lighting="white"] .segmented,
.viewport-wrap[data-lighting="white"] .display-actions > * { border-color: #b9c0c9; background: #eef1f5dd; color: #3d4652; }
.viewport-wrap[data-lighting="white"] .segmented button { color: #66707d; }
.viewport-wrap[data-lighting="white"] .segmented button.active { background: #d7dde5; color: #18202a; }
.viewport-wrap[data-lighting="white"] .gem-caption span { color: #426d12; }
.viewport-wrap[data-lighting="white"] .gem-caption strong { color: #19212c; }
.viewport-wrap[data-lighting="white"] .gem-caption p,
.viewport-wrap[data-lighting="white"] .viewport-hint,
.viewport-wrap[data-lighting="white"] .scale-ruler { color: #4e5865; }
.viewport-wrap[data-lighting="white"] .viewport-hint span { color: #3f4956; }
.viewport-wrap[data-lighting="white"] .viewport-weight { border-color: #a7b58f; background: #f4f7f0dc; box-shadow: 0 8px 28px #59645f2b; }
.viewport-wrap[data-lighting="white"] .viewport-weight span,
.viewport-wrap[data-lighting="white"] .viewport-weight small { color: #5c6852; }
.viewport-wrap[data-lighting="white"] .viewport-weight strong { color: #365f0d; }

.cut-diagrams-card { margin: -4px 0 18px; padding: 13px; border: 1px solid #303b47; border-radius: 12px; background: radial-gradient(circle at 10% 0, #b6f05b0d, transparent 44%), linear-gradient(145deg, #121820, #0c1016); box-shadow: inset 0 1px #ffffff05; }
.cut-diagrams-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.cut-diagrams-heading > div { display: grid; gap: 3px; }
.cut-diagrams-heading span { color: var(--accent); font: 9px var(--mono); letter-spacing: .14em; }
.cut-diagrams-heading h2 { margin: 0; color: #e2e8ee; font-size: 11px; letter-spacing: .01em; }
.cut-diagrams-heading > small { color: #87919c; font: 9px var(--mono); text-align: right; }
.cut-diagrams-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.cut-diagram { min-width: 0; margin: 0; overflow: hidden; border: 1px solid #27313c; border-radius: 8px; background: #090d13; }
.cut-diagram canvas { display: block; width: 100%; height: auto; aspect-ratio: 14 / 11; background: radial-gradient(circle at 50% 43%, #182129, #080c11 76%); }
.cut-diagram figcaption { display: flex; align-items: center; justify-content: space-between; gap: 5px; min-height: 29px; padding: 6px 7px; border-top: 1px solid #242d36; background: #10151c; }
.cut-diagram figcaption span { color: #dfe5eb; font-size: 9px; font-weight: 650; }
.cut-diagram figcaption small { overflow: hidden; color: #7f8b96; font: 9px var(--mono); text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.cut-diagrams-card > p { margin: 9px 1px 0; color: #76818c; font-size: 9px; line-height: 1.45; }
.pavilion-diagram { border-color: #2b3542; }

.cad-handle-layer { position: absolute; z-index: 3; inset: 0; pointer-events: none; }
.cad-handle { position: absolute; display: grid; grid-template-columns: 27px minmax(42px,auto) 27px; grid-template-rows: auto 28px; align-items: center; width: 116px; gap: 4px; padding: 7px; border: 1px solid #3b4654; border-radius: 9px; background: #0c1118d9; box-shadow: 0 9px 25px #0007; color: #c8d0da; pointer-events: auto; backdrop-filter: blur(10px); }
.cad-handle > span { grid-column: 1 / -1; color: #84909c; font: 9px var(--mono); letter-spacing: .11em; text-align: center; text-transform: uppercase; }
.cad-handle button { display: grid; width: 27px; height: 27px; place-items: center; padding: 0; border: 1px solid #46515f; border-radius: 6px; background: #161d27; color: var(--accent); cursor: pointer; font: 15px/1 var(--mono); }
.cad-handle button:hover { border-color: var(--accent); background: #1c2819; }
.cad-handle button:active { transform: translateY(1px); }
.cad-handle button:disabled { border-color: #2c333d; color: #5e6670; cursor: not-allowed; }
.cad-handle output { overflow: hidden; color: #edf2f7; font: 9px var(--mono); text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.cad-handle-size { top: 88px; left: 18px; }
.cad-handle-width { top: 151px; left: 18px; }
.cad-handle-table { top: 214px; left: 18px; border-color: #526b34; }
.cad-handle-crown { top: calc(50% - 101px); right: 18px; }
.cad-handle-girdle { top: calc(50% - 34px); right: 18px; }
.cad-handle-pavilion { top: calc(50% + 33px); right: 18px; }
.viewport-wrap[data-lighting="white"] .cad-handle { border-color: #aab4bf; background: #edf1f5e8; box-shadow: 0 9px 25px #59645f2e; color: #26313d; }
.viewport-wrap[data-lighting="white"] .cad-handle > span { color: #596674; }
.viewport-wrap[data-lighting="white"] .cad-handle button { border-color: #9eabb7; background: #dfe5eb; color: #365f0d; }
.viewport-wrap[data-lighting="white"] .cad-handle output { color: #1e2935; }

.control-section { padding: 18px 0; border-top: 1px solid var(--line-soft); }
.control-section.first { padding-top: 0; border-top: 0; }
.carat-hero { position: relative; overflow: hidden; margin: -4px 0 18px; padding: 15px 16px; border: 1px solid #577e29; border-radius: 12px; background: radial-gradient(circle at 90% 0, #b6f05b22, transparent 45%), linear-gradient(135deg, #172117, #10161b); }
.carat-hero::after { position: absolute; top: -18px; right: -9px; width: 72px; height: 72px; border: 1px solid #b6f05b24; transform: rotate(45deg); content: ""; }
.carat-hero div { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.carat-hero span { color: #9eaa96; font: 9px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.carat-hero strong { position: relative; z-index: 1; color: var(--accent); font: 700 22px/1 var(--mono); letter-spacing: -.05em; }
.carat-hero small { display: block; margin-top: 8px; color: #858f82; font-size: 9px; }
.context-help { position: sticky; z-index: 3; top: -15px; display: grid; grid-template-rows: 11px 15px minmax(0, 1fr); gap: 3px; box-sizing: border-box; height: 92px; min-height: 92px; overflow: hidden; margin: 0 0 17px; padding: 10px 11px; border: 1px solid #2e3c46; border-radius: 9px; background: #101720f2; box-shadow: 0 9px 24px #05070a99; backdrop-filter: blur(12px); }
.context-help > span { color: #7f9ca9; font: 9px var(--mono); letter-spacing: .12em; }
.context-help strong { overflow: hidden; color: #d9e4ea; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.context-help p { display: -webkit-box; min-height: 0; overflow: hidden; margin: 0; color: #88939c; font-size: 10px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.section-title h2 { margin: 0; font-size: 11px; letter-spacing: .02em; }
.section-title > span { max-width: 62%; text-align: right; line-height: 1.35; }
.field-label, .field-grid label > span { display: block; margin: 0 0 6px; color: #8a929f; font: 9px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.facet-pattern-control { margin: 0 0 15px; padding: 11px 11px 10px; border: 1px solid #35404d; border-radius: 8px; background: linear-gradient(145deg, #151a22, #10141a); }
.facet-pattern-control .range-label { margin-top: 13px; }
.facet-pattern-control > small { display: block; margin-top: 8px; color: #7f8996; font-size: 9px; line-height: 1.45; }
.facet-pattern-control select:disabled, .facet-pattern-control input:disabled { opacity: .55; cursor: not-allowed; }
.table-size-control { margin: 0 0 15px; padding: 11px 11px 10px; border: 1px solid #30413b; border-radius: 8px; background: linear-gradient(145deg, #141c1b, #10151a); }
.table-size-control .range-label { margin-top: 0; }
.table-size-control > small { display: block; margin-top: 7px; color: #75827d; font-size: 9px; line-height: 1.4; }
select, .number-field { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: #11151d; color: #e1e4e9; font-size: 11px; }
select { padding: 0 10px; }
.material-select-fallback { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.material-grid { display: grid; gap: 6px; max-height: 254px; overflow: auto; padding: 2px; scrollbar-width: thin; scrollbar-color: #374050 transparent; }
.material-family-group { overflow: hidden; border: 1px solid var(--line-soft); border-radius: 9px; background: #10151d; }
.material-family-group > summary { display: grid; grid-template-columns: 29px minmax(0,1fr) auto; align-items: center; gap: 9px; min-height: 45px; padding: 7px 9px; list-style: none; color: #c2c8d0; cursor: pointer; }
.material-family-group > summary::-webkit-details-marker { display: none; }
.material-family-group > summary:hover { background: #151b24; }
.material-family-group > summary::after { color: var(--accent); font: 13px var(--mono); content: "+"; }
.material-family-group[open] > summary::after { content: "−"; }
.material-family-swatch { position: relative; width: 28px; height: 24px; clip-path: polygon(50% 0, 84% 13%, 100% 43%, 72% 100%, 28% 100%, 0 43%, 16% 13%); background-color: var(--family-c2); background-image: linear-gradient(147deg, #fff8 0 16%, transparent 17%), conic-gradient(from 25deg at 50% 43%, var(--family-c1), var(--family-c2), var(--family-c3), var(--family-c4), var(--family-c1)); }
.material-family-swatch::after { position: absolute; inset: 5px 7px 7px; clip-path: polygon(50% 0, 100% 48%, 74% 100%, 26% 100%, 0 48%); background: linear-gradient(145deg, #fff7, #fff0 42%), color-mix(in srgb, var(--family-c2) 72%, #081018); content: ""; }
.material-family-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.material-family-copy b { font-size: 9px; }
.material-family-copy small { overflow: hidden; color: #7e8895; font: 9px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.material-variants { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 7px 7px; border-top: 1px solid #1b222c; }
.material-chip { display: grid; grid-template-columns: 29px minmax(0,1fr); align-items: center; gap: 8px; min-height: 45px; padding: 7px 8px; border: 1px solid var(--line-soft); border-radius: 8px; background: #11151d; color: #aeb5bf; text-align: left; cursor: pointer; }
.material-chip:hover { border-color: #485363; background: #151b25; }
.material-chip.active { border-color: var(--material-color); background: linear-gradient(135deg, color-mix(in srgb, var(--material-color) 14%, #11151d), #11151d 76%); color: #fff; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--material-color) 22%, transparent); }
.material-chip i { position: relative; width: 29px; height: 25px; overflow: hidden; clip-path: polygon(50% 0, 84% 13%, 100% 43%, 72% 100%, 28% 100%, 0 43%, 16% 13%); background: var(--material-color); background-image: linear-gradient(145deg, #fff9 0 14%, transparent 15% 57%, #02040a77 58%), linear-gradient(35deg, color-mix(in srgb, var(--material-color) 42%, #02040a), var(--material-color) 48%, color-mix(in srgb, var(--material-color) 78%, white)); }
.material-chip i::before { position: absolute; inset: 3px 6px 10px; clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%); background: linear-gradient(155deg, #ffffff9c, #ffffff0a 46%), color-mix(in srgb, var(--material-color) 82%, white); content: ""; }
.material-chip i::after { position: absolute; inset: 9px 4px 3px; clip-path: polygon(0 0, 34% 12%, 50% 100%, 66% 12%, 100% 0, 72% 100%, 28% 100%); background: linear-gradient(90deg, #02040a8a, #fff6 49%, #02040a7a); content: ""; }
.material-chip span { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.material-chip b { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.material-chip small { overflow: hidden; color: #858e9b; font: 9px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.number-field { display: flex; align-items: center; padding: 0 8px 0 10px; }
.number-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: #f0f2f5; font: 11px var(--mono); }
.number-field input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.number-field input[type="number"]::-webkit-inner-spin-button,
.number-field input[type="number"]::-webkit-outer-spin-button { margin: 0; appearance: none; -webkit-appearance: none; }
.number-field b { color: #5f6672; font: 9px var(--mono); font-weight: 400; white-space: nowrap; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 8px; }
.dimensions-grid { margin-top: 12px; }
.field-grid .wide-field { grid-column: 1 / -1; }
.material-row { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; margin-top: 8px; }
.color-field, .material-note { display: flex; align-items: center; height: 45px; border: 1px solid var(--line-soft); border-radius: 7px; background: #11151d; }
.color-field { gap: 8px; padding: 0 8px; cursor: pointer; }
.color-field span { width: 23px; height: 23px; border-radius: 50%; box-shadow: 0 0 12px currentColor; }
.color-field input { position: absolute; width: 1px; opacity: 0; }
.color-field b { color: #b8bec7; font: 9px var(--mono); }
.material-note { align-items: flex-start; justify-content: center; flex-direction: column; padding: 0 9px; }
.material-note span { color: #8a929f; font: 9px var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.material-note b { margin-top: 4px; color: #d9e8c3; font-size: 9px; }
.range-label { display: flex; justify-content: space-between; margin: 13px 0 6px; color: #858c98; font-size: 9px; }
.range-label output { color: #cbd1d9; font: 9px var(--mono); }
input[type="range"] { width: 100%; height: 3px; border-radius: 3px; outline: 0; appearance: none; background: #2b313d; }
input[type="range"]::-webkit-slider-thumb { width: 17px; height: 17px; border: 3px solid var(--accent); border-radius: 50%; appearance: none; background: #0f131a; cursor: pointer; }
.control-note { margin: 10px 0 0; color: #8a929f; font-size: 9px; line-height: 1.55; }
.preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.preset-row button { height: 37px; border: 1px solid var(--line); border-radius: 7px; background: #11151d; color: #8e96a2; cursor: pointer; font-size: 9px; }
.preset-row button i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border: 1px solid #777; border-radius: 50%; }
.preset-row [data-lighting="white"] i { background: #f4f5f7; }
.preset-row [data-lighting="black"] i { background: #020307; }
.preset-row [data-lighting="studio"] i { background: linear-gradient(135deg, #e9f3ff, #243147); }
.preset-row button.active { border-color: var(--accent-2); background: #172015; color: #eef8df; }
.finish-label { margin-top: 12px; }
.inline-switch { width: max-content; max-width: 100%; background: #11151d; }
.shape-control-host:empty { display: none; }
.shape-control-host { margin-top: 14px; padding-top: 2px; border-top: 1px dashed #29313d; }
.shape-control-host .section-title { margin: 13px 0 2px; }
.modifier-note { margin: 5px 0 0; color: #6f7884; font-size: 9px; line-height: 1.45; }
.control-section[hidden] { display: none; }
.construction-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.construction-mode button { display: grid; grid-template-columns: 34px minmax(0,1fr); align-items: center; gap: 8px; min-height: 54px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #11151d; color: #8d96a2; text-align: left; cursor: pointer; }
.construction-mode button:hover { border-color: #485261; }
.construction-mode button.active { border-color: var(--accent-2); background: #172015; color: #eff8e4; }
.construction-mode svg { width: 32px; fill: none; stroke: currentColor; stroke-linejoin: round; stroke-width: 1.3; }
.construction-mode button > span { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.construction-mode b { font-size: 9px; }
.construction-mode small { overflow: hidden; color: #77818d; font: 9px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.construction-mode .active small { color: #94a989; }
.cabochon-dimensions { margin-top: 12px; }
.cabochon-profile-label { margin-top: 12px; }
.cabochon-smooth { margin-top: 14px; }
.cabochon-advanced { margin-top: 15px; border-top: 1px dashed #29313d; }
.cabochon-advanced > summary { min-height: 46px; }
.cabochon-advanced .details-body { margin-top: 4px; padding: 0 1px 3px; }
.cabochon-advanced input:disabled, .cabochon-advanced select:disabled { opacity: .42; }

.research-note { display: grid; gap: 4px; margin: 0 0 13px; padding: 10px; border: 1px solid #263121; border-radius: 8px; background: #111810; line-height: 1.45; }
.research-note b { color: #d7e8bd; font-size: 9px; }
.research-note span { color: #838d7a; font-size: 9px; }
.research-note small { color: #849079; font: 9px var(--mono); }
.profile-badge { color: var(--accent) !important; }
.compact-details { display: block; }
.compact-details > summary { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 12px; list-style: none; cursor: pointer; }
.compact-details > summary::-webkit-details-marker { display: none; }
.compact-details > summary span { color: #c6cbd2; font-size: 10px; font-weight: 650; }
.compact-details > summary small { color: #858e9a; font: 9px var(--mono); text-align: right; }
.compact-details > summary::after { color: var(--accent); font: 13px var(--mono); content: "+"; }
.compact-details[open] > summary::after { content: "−"; }
.compact-details .research-note, .compact-details .details-body { margin-top: 13px; }

.report dl { margin: 0; }
.report dl div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; color: #7f8793; font-size: 9px; }
.report dd { margin: 0; color: #cbd0d7; font: 9px var(--mono); text-align: right; }
.report .weight { margin-top: 6px; padding-top: 11px; border-top: 1px solid var(--line-soft); }
.report .weight dt { color: #bbc0c8; font-weight: 650; }
.report .weight dd { color: var(--accent); font-size: 11px; }
.quality { color: #7fb43c !important; }
.quality.bad { color: var(--danger) !important; }
.quality i { display: inline-block; width: 5px; height: 5px; margin-right: 2px; border-radius: 50%; background: currentColor; box-shadow: 0 0 5px currentColor; }

.export-stack { display: grid; gap: 7px; padding-bottom: 20px; }
.btn.wide { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 51px; padding: 0 14px; text-align: left; }
.btn.wide span { display: flex; flex-direction: column; margin: 0; }
.btn.wide b { font-size: 11px; }
.btn.wide small { margin-top: 2px; font: 9px var(--mono); opacity: .6; }
.btn.wide strong { font-size: 17px; }
.btn.secondary { display: block; height: 36px; color: #858c98; font-size: 9px; text-align: center; }
.export-format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.export-format-grid .btn { display: flex; height: 48px; min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center; padding: 0 10px; text-align: left; }
.export-format-grid .btn b { font: 700 10px var(--mono); }
.export-format-grid .btn small { margin-top: 3px; overflow: hidden; color: #7e8793; font: 9px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.export-note { margin: 2px 1px 0; color: #69727e; font-size: 9px; line-height: 1.45; }
.toast { position: fixed; z-index: 20; bottom: 24px; left: 50%; display: flex; align-items: center; gap: 10px; padding: 10px 15px; border-radius: 9px; background: #efffd7; box-shadow: 0 15px 50px #0008; color: #17200d; transform: translate(-50%, 120px); transition: transform .3s; }
.toast.show { transform: translate(-50%, 0); }
.toast > span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #62931d; color: white; font-size: 11px; }
.toast p { display: flex; flex-direction: column; margin: 0; }
.toast b { font-size: 10px; }
.toast small { margin-top: 2px; color: #65714f; font-size: 9px; }

.custom-modal[hidden] { display: none; }
.custom-modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 24px; background: #030507d9; backdrop-filter: blur(12px); }
.custom-dialog { display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; width: min(1240px, 100%); height: min(850px, 100%); overflow: hidden; border: 1px solid #343d4a; border-radius: 16px; background: #0d1118; box-shadow: 0 30px 100px #000b; }
.custom-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 20px 22px; border-bottom: 1px solid var(--line-soft); background: linear-gradient(120deg, #131b16, #0e1219 45%); }
.custom-dialog-header h2 { margin: 5px 0 0; font-size: 18px; }
.custom-dialog-header p { max-width: 740px; margin: 6px 0 0; color: #8d959f; font-size: 9px; line-height: 1.55; }
.custom-workflow { display: grid; grid-template-columns: minmax(180px,1fr) 50px minmax(180px,1fr); align-items: center; gap: 10px; padding: 10px 22px; border-bottom: 1px solid var(--line-soft); background: #0b0f15; }
.custom-workflow > i { height: 1px; background: linear-gradient(90deg,#46505b,var(--accent)); opacity: .55; }
.custom-workflow button { display: grid; grid-template-columns: 29px minmax(0,1fr); align-items: center; gap: 9px; min-height: 43px; padding: 6px 10px; border: 1px solid #2a323d; border-radius: 9px; background: #111720; color: #7d8793; text-align: left; cursor: pointer; }
.custom-workflow button b { display: grid; width: 27px; height: 27px; place-items: center; border: 1px solid #47515d; border-radius: 50%; font: 10px var(--mono); }
.custom-workflow button span { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.custom-workflow button strong { color: #c2cad3; font-size: 9px; }
.custom-workflow button small { color: #707a86; font: 9px var(--mono); }
.custom-workflow button.active { border-color: #587837; background: linear-gradient(135deg,#1b2817,#111820); color: var(--accent); }
.custom-workflow button.active b { border-color: var(--accent); box-shadow: 0 0 13px #b6f05b33; }
.custom-workflow button:disabled { opacity: .42; cursor: not-allowed; }
.custom-modal:not([data-step="build"]) [data-custom-step="build"],
.custom-modal[data-step="build"] [data-custom-step="sketch"] { display: none !important; }
.custom-editor-layout { display: grid; grid-template-columns: minmax(0,1fr) 310px; min-height: 0; }
.trace-column { display: grid; grid-template-rows: auto minmax(0,1fr) auto; min-width: 0; min-height: 0; padding: 14px; border-right: 1px solid var(--line-soft); }
.trace-toolbar { display: flex; gap: 7px; margin-bottom: 10px; overflow-x: auto; }
.trace-toolbar .btn { height: 33px; flex: none; padding: 0 11px; font-size: 9px; }
.trace-stage { position: relative; width: auto; max-width: 100%; height: 100%; min-height: 0; aspect-ratio: 24 / 17; align-self: center; justify-self: center; overflow: hidden; border: 1px solid #303947; border-radius: 11px; background-color: #080b10; background-image: linear-gradient(#ffffff08 1px,transparent 1px),linear-gradient(90deg,#ffffff08 1px,transparent 1px); background-size: 28px 28px; }
.trace-stage canvas { display: block; width: 100%; height: 100%; outline: 0; cursor: crosshair; touch-action: none; }
.trace-stage canvas[data-calibration] { cursor: crosshair; }
.trace-empty { position: absolute; top: 50%; left: 50%; display: flex; width: min(330px,80%); flex-direction: column; gap: 8px; color: #aab2bd; text-align: center; transform: translate(-50%,-50%); pointer-events: none; }
.trace-empty strong { font-size: 13px; }
.trace-empty span { color: #777f8b; font-size: 9px; line-height: 1.6; }
.trace-help { margin: 10px 2px 0; color: #7f8793; font-size: 9px; }
.trace-help b { color: #b8c0ca; }
.construction-preview-note { margin: 10px 2px 0; padding: 10px 12px; border: 1px solid #3e542c; border-radius: 9px; background: linear-gradient(120deg,#172116,#10161d); }
.construction-preview-note span { color: var(--accent); font: 9px var(--mono); letter-spacing: .12em; }
.construction-preview-note strong { display: block; margin-top: 4px; color: #e1e8d8; font-size: 10px; }
.construction-preview-note p { margin: 4px 0 0; color: #82907e; font-size: 9px; line-height: 1.45; }
.custom-settings { min-height: 0; overflow: auto; padding: 17px; background: #0f131a; }
.custom-settings section { padding: 0 0 18px; margin: 0 0 18px; border-bottom: 1px solid var(--line-soft); }
.custom-settings section[hidden] { display: none; }
.custom-settings h3 { margin: 0; font-size: 10px; }
.custom-construction-label { margin-top: 13px; }
.image-transform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.image-transform-grid .range-label { margin-top: 13px; }
.calibration-row { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 8px; margin-top: 15px; }
.calibration-row .btn { width: 100%; }
.calibration-row > label > span, .custom-symmetry-label > span { display: block; margin: 0 0 6px; color: #8a929f; font: 9px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.calibration-row .btn.active { border-color: var(--accent); background: #1b2817; color: #e7f8d1; }
.scale-box-toggle, .point-corner-toggle { margin-top: 10px; }
.calibration-status { margin: 10px 0 0; padding: 8px 9px; border-left: 2px solid #44505e; background: #11161d; color: #89929d; font-size: 9px; line-height: 1.45; }
.calibration-status.valid { border-color: var(--accent); color: #badc91; }
.calibration-status.error { border-color: var(--danger); color: #e3a0aa; }
.edge-mode-picker { margin: 11px 0 12px; }
.edge-mode-label { display: block; margin: 0 0 7px; color: #aeb7c2; font: 9px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.edge-mode-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.edge-mode-option { position: relative; display: grid; min-width: 0; min-height: 79px; grid-template-rows: 23px auto auto; align-content: center; justify-items: center; gap: 3px; padding: 8px 5px; border: 1px solid #313b47; border-radius: 9px; background: linear-gradient(160deg,#151b24,#0d1219); color: #87919d; text-align: center; cursor: pointer; }
.edge-mode-option:hover { border-color: #596775; color: #c5cdd7; }
.edge-mode-option.active { border-color: #71983f; background: linear-gradient(150deg,#21301a,#111a1b); color: #dff6c4; box-shadow: inset 0 0 0 1px #b6f05b18,0 0 15px #b6f05b0c; }
.edge-mode-option strong { max-width: 100%; color: inherit; font-size: 9px; line-height: 1.15; }
.edge-mode-option small { max-width: 100%; overflow: hidden; color: #697481; font: 9px var(--mono); line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.edge-mode-option.active small { color: #9caf8b; }
.edge-mode-mark { position: relative; display: block; width: 33px; height: 19px; }
.edge-mode-mark::before, .edge-mode-mark::after { position: absolute; content: ''; }
.edge-mode-mark.line::before { top: 9px; left: 3px; width: 27px; height: 1px; background: currentColor; transform: rotate(-18deg); transform-origin: center; }
.edge-mode-mark.line::after { top: 4px; left: 2px; width: 4px; height: 4px; border: 1px solid currentColor; border-radius: 1px; box-shadow: 25px 8px 0 -1px #111820,25px 8px 0 0 currentColor; }
.edge-mode-mark.curve::before { top: 5px; left: 3px; width: 25px; height: 11px; border-top: 1px solid currentColor; border-radius: 50%; transform: rotate(-5deg); }
.edge-mode-mark.curve::after { top: 11px; left: 2px; width: 3px; height: 3px; border: 1px solid currentColor; border-radius: 50%; box-shadow: 26px -3px 0 -1px #111820,26px -3px 0 0 currentColor; }
.edge-mode-mark.mixed::before { top: 10px; left: 2px; width: 14px; height: 1px; background: currentColor; transform: rotate(-14deg); }
.edge-mode-mark.mixed::after { top: 4px; left: 15px; width: 16px; height: 11px; border-top: 1px solid currentColor; border-radius: 50%; transform: rotate(-8deg); }
.edge-mode-picker .control-note { margin: 7px 1px 0; font-size: 9px; line-height: 1.45; }
.custom-symmetry-label { display: block; margin-bottom: 12px; }
.custom-symmetry-label select { width: 100%; }
.point-corner-toggle b { color: inherit; font-size: 9px; font-weight: 500; line-height: 1.35; }
.point-coordinate-grid { margin-bottom: 10px; }
.custom-table-grid { align-items: end; margin-top: 4px; }
.custom-table-grid > label > span { display: block; margin: 0 0 6px; color: #8a929f; font: 9px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.range-compact { display: grid; grid-template-rows: 18px 17px; padding: 8px 9px; border: 1px solid var(--line-soft); border-radius: 7px; background: #11151d; }
.range-compact output { color: #cbd1d9; font: 9px var(--mono); }
.custom-validity { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid #58323a; border-radius: 8px; background: #211217; color: #e1a4ae; font-size: 9px; }
.custom-validity i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 7px currentColor; }
.custom-validity.valid { border-color: #3d6127; background: #142013; color: var(--accent); }
.custom-context-help { position: sticky; top: 0; z-index: 4; margin: 0 0 14px !important; padding: 10px 11px !important; border-bottom: 1px solid #2e3c46 !important; }
.custom-dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 20px; border-top: 1px solid var(--line-soft); background: #0b0e14; }
.custom-dialog-footer > span { max-width: 700px; color: #7f8793; font-size: 9px; line-height: 1.5; }
.custom-dialog-footer > div { display: flex; gap: 8px; }
.custom-dialog-footer .btn { min-width: 118px; }
.custom-dialog-footer .btn:disabled { border-color: #2b3039; background: #252a31; color: #656c76; cursor: not-allowed; }

button:focus-visible, select:focus-visible, .brand:focus-visible, .compact-details > summary:focus-visible, .trace-stage canvas:focus-visible, .design-title input:focus-visible, .color-field:focus-within, .number-field:focus-within, input[type="range"]:focus-visible, .switch-label input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
input:disabled, select:disabled { opacity: .48; cursor: not-allowed; }
body.modal-open { overflow: hidden; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 260px minmax(360px, 1fr) 330px; }
  .brand { width: 190px; }
  .cut-card { min-height: 122px; }
  .cad-handle { width: 105px; }
}

@media (max-width: 960px) {
  body { overflow: auto; }
  .topbar { position: sticky; top: 0; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .cuts-panel { max-height: 280px; border-right: 0; }
  .cut-grid { grid-template-columns: repeat(4, 1fr); }
  .viewport-wrap { height: 58svh; min-height: 460px; }
  .inspector { border-top: 1px solid var(--line-soft); border-left: 0; }
  .top-actions { overflow-x: auto; }
  .custom-modal { padding: 10px; }
  .custom-editor-layout { grid-template-columns: 1fr; overflow: auto; }
  .trace-column { min-height: 470px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .trace-stage { width: 100%; height: auto; }
  .custom-settings { overflow: visible; }
  .cad-handle { width: 101px; }
  .cad-handle-size, .cad-handle-width, .cad-handle-table { left: 10px; }
  .cad-handle-crown, .cad-handle-girdle, .cad-handle-pavilion { right: 10px; }
}

@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: 68px; padding: 10px 12px; }
  .brand { width: 145px; }
  .design-title { padding-left: 12px; }
  .top-actions { order: 3; width: 100%; }
  .top-actions .btn { flex: 1; padding: 0 7px; font-size: 10px; }
  .cuts-panel { max-height: 250px; }
  .cut-grid { grid-template-columns: repeat(3, 1fr); }
  .viewport-wrap { min-height: 500px; }
  .view-toolbar { top: 10px; right: 10px; left: 10px; }
  .view-toolbar-primary { min-width: 0; max-width: calc(100% - 116px); }
  .camera-switch { overflow-x: auto; }
  .camera-switch button { padding-right: 8px; padding-left: 8px; }
  .render-mode-switch button { min-width: 49px; padding-right: 6px; padding-left: 6px; }
  .viewport-hint { display: none; }
  .viewport-weight { bottom: 92px; left: 14px; }
  .cad-handle { width: 92px; grid-template-columns: 24px minmax(34px,auto) 24px; }
  .cad-handle button { width: 24px; height: 24px; }
  .cad-handle-size { top: 72px; }
  .cad-handle-width { top: 131px; }
  .cad-handle-table { top: 190px; }
  .inspector { padding: 20px 16px; }
  .cut-diagrams-card { padding: 11px; }
  .material-variants { grid-template-columns: 1fr; }
  .custom-dialog-header p, .custom-dialog-footer > span { display: none; }
  .custom-dialog-footer { justify-content: flex-end; }
  .custom-workflow { grid-template-columns: 1fr 24px 1fr; padding: 8px 10px; }
  .custom-workflow button small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
}
