:root {
  color-scheme: dark;
  --bg: #06080c;
  --panel: #10151d;
  --line: #2a3544;
  --line-soft: #202936;
  --text: #f5f8fc;
  --muted: #91a0b4;
  --blue: #198cff;
  --blue-soft: #67b8ff;
  --orange: #ff681b;
  --danger: #ffbd68;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 83% -8%, rgba(25,140,255,.16), transparent 31rem),
    radial-gradient(circle at 9% 35%, rgba(255,104,27,.055), transparent 28rem),
    linear-gradient(180deg, #090c12, var(--bg) 45%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

button, input, select { font: inherit; }
.topbar {
  max-width: 1420px;
  margin: auto;
  padding: 20px 25px 15px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand > span:last-child { display: grid; }
.brand small { color: var(--blue-soft); font-size: .7rem; font-weight: 900; letter-spacing: .22em; }
.brand strong { font-size: clamp(1.45rem, 4vw, 2rem); letter-spacing: -.045em; }
.brand-mark { width: 44px; height: 40px; display: flex; align-items: center; gap: 3px; }
.brand-mark i { width: 6px; border-radius: 4px; background: linear-gradient(var(--blue-soft), var(--blue)); box-shadow: 0 0 12px rgba(25,140,255,.45); }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(5) { height: 14px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 28px; }
.brand-mark i:nth-child(3) { height: 39px; background: linear-gradient(#ff9a5f, var(--orange)); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.phone-link { padding: 7px 11px; display: grid; color: var(--text); background: #0a1420; border: 1px solid #28527a; border-radius: 9px; text-decoration: none; }
.phone-link span { color: var(--blue-soft); font-size: .6rem; font-weight: 900; letter-spacing: .12em; }
.phone-link strong { font-size: .78rem; }
.ghost-btn, .mini-btn { color: var(--text); background: rgba(7,10,15,.8); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.ghost-btn { padding: 10px 15px; }
.mini-btn { margin-left: auto; padding: 7px 10px; color: var(--muted); font-size: .73rem; white-space: nowrap; }
.ghost-btn:hover, .mini-btn:hover { border-color: var(--blue); color: white; }

main { max-width: 1420px; margin: auto; padding: 0 25px 38px; }
.result-strip {
  display: grid;
  grid-template-columns: 1.35fr repeat(5, 1fr);
  overflow: hidden;
  background: linear-gradient(112deg, #121b29, #0d1219);
  border: 1px solid #2b3a4e;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.3);
}
.hero-result { padding: 19px 23px; border-left: 4px solid var(--orange); display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.hero-result span { flex-basis: 100%; color: var(--muted); font-size: .72rem; font-weight: 900; letter-spacing: .14em; }
.hero-result strong { font-size: clamp(2.25rem, 5.5vw, 3.65rem); line-height: .95; letter-spacing: -.065em; }
.hero-result small { color: var(--blue-soft); font-weight: 900; }
.mini-result { padding: 18px; border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; gap: 7px; }
.mini-result span { color: var(--muted); font-size: .76rem; }
.mini-result strong { font-size: clamp(.96rem, 1.5vw, 1.18rem); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(410px, .95fr); gap: 18px; margin-top: 18px; align-items: start; }
.input-column, .output-column { display: grid; gap: 18px; }
.panel { position: relative; background: rgba(16,21,29,.95); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: inset 0 1px rgba(255,255,255,.025); }
.accent-panel { border-color: #285984; box-shadow: inset 0 1px rgba(103,184,255,.08), 0 0 40px rgba(25,140,255,.035); }
.port-panel { border-color: #33465d; }
.panel-heading { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 17px; }
.panel-heading > div { min-width: 0; }
.panel-heading h2 { margin: 1px 0 3px; font-size: 1.04rem; letter-spacing: -.01em; }
.panel-heading p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.step { flex: 0 0 auto; width: 33px; height: 33px; display: grid; place-items: center; border-radius: 8px; background: #152a40; color: var(--blue-soft); font-size: .71rem; font-weight: 950; }
.field-grid { display: grid; gap: 14px; }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.field-grid.two { grid-template-columns: repeat(2, 1fr); margin-top: 14px; }
.field-grid.no-top { margin-top: 0; }
label { display: grid; grid-template-columns: 1fr auto; gap: 7px; color: #dce6f1; font-size: .875rem; font-weight: 760; }
label > span { color: var(--muted); font-size: .73rem; align-self: center; }
input[type="number"], select {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 47px;
  padding: 10px 12px;
  color: var(--text);
  background: #080c12;
  border: 1px solid #303c4c;
  border-radius: 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(25,140,255,.14); }
input[readonly] { color: #8fcfff; border-color: #28527a; background: #091421; font-weight: 850; }
input:disabled, select:disabled { opacity: .58; cursor: not-allowed; }
.formula-note { margin: 13px 0 0; padding: 10px 12px; color: #a8bad0; background: #0c121b; border-left: 2px solid var(--orange); border-radius: 3px 8px 8px 3px; font-size: .77rem; line-height: 1.45; }
.port-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.port-stats div { display: grid; gap: 5px; padding: 11px; background: #0b1017; border: 1px solid var(--line-soft); border-radius: 9px; }
.port-stats span { color: var(--muted); font-size: .68rem; }
.port-stats strong { font-size: .85rem; }
.fit-note { min-height: 19px; margin-top: 11px; color: #9eb0c5; font-size: .78rem; line-height: 1.42; }
.fit-note.needs-fold { color: var(--danger); }

.preview-panel { overflow: hidden; padding-bottom: 16px; }
.preview-heading { align-items: flex-start; }
.canvas-wrap { position: relative; height: clamp(280px, 34vw, 430px); overflow: hidden; background: radial-gradient(circle at 50% 43%, #162335, #080b10 70%); border: 1px solid #273448; border-radius: 13px; cursor: grab; touch-action: none; }
.canvas-wrap:active { cursor: grabbing; }
#boxCanvas { display: block; width: 100%; height: 100%; }
.drag-hint { position: absolute; right: 10px; bottom: 9px; color: rgba(174,196,222,.46); font-size: .6rem; font-weight: 900; letter-spacing: .12em; pointer-events: none; }
.dimension-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(82px, 1fr)); gap: 8px; margin-top: 10px; }
.dimension-chips span { display: grid; gap: 3px; padding: 8px 9px; color: var(--muted); background: #0a0f16; border: 1px solid var(--line-soft); border-radius: 8px; font-size: .62rem; font-weight: 900; letter-spacing: .08em; }
.dimension-chips strong { color: white; font-size: .78rem; letter-spacing: 0; }

dl { margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid #222c38; }
dt { color: var(--muted); font-size: .86rem; }
dd { margin: 0; font-weight: 820; font-size: .88rem; }
dl .total { margin-top: 4px; padding: 14px 0 3px; border: 0; font-size: 1.05rem; }
dl .total dt, dl .total dd { color: var(--text); font-size: 1rem; }
.warning { margin-top: 15px; padding: 11px 12px; border-radius: 9px; background: rgba(255,104,27,.12); border: 1px solid rgba(255,104,27,.4); color: #ffd2b6; font-size: .81rem; line-height: 1.4; }
.cut-list h3 { margin: 15px 0 5px; color: var(--blue-soft); font-size: .71rem; letter-spacing: .12em; text-transform: uppercase; }
.cut-list h3:first-of-type { margin-top: 0; }
.cut-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid #222c38; }
.cut-row span { color: var(--muted); font-size: .82rem; }
.cut-row strong { text-align: right; font-size: .83rem; }
.cut-note { margin: 11px 0 0; color: #9caec2; font-size: .74rem; line-height: 1.45; }
.primary-btn { width: 100%; margin-top: 17px; min-height: 48px; border: 0; border-radius: 10px; color: white; background: linear-gradient(100deg, #0879e8, #198cff); font-weight: 870; cursor: pointer; box-shadow: 0 8px 28px rgba(25,140,255,.23); }
.primary-btn:active { transform: translateY(1px); }
.copy-status { min-height: 18px; margin: 8px 0 -7px; color: var(--blue-soft); text-align: center; font-size: .77rem; }
.accuracy-note { margin: -3px 8px 0; color: #68778b; font-size: .7rem; line-height: 1.45; }
footer { padding: 1px 24px 30px; text-align: center; color: #627186; font-size: .73rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
footer a { color: #8fcfff; text-decoration: none; }

@media (max-width: 1040px) {
  .result-strip { grid-template-columns: repeat(3, 1fr); }
  .hero-result { grid-row: span 2; }
  .mini-result { border-bottom: 1px solid var(--line); }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(370px, .9fr); }
}
@media (max-width: 840px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { order: -1; }
  .canvas-wrap { height: clamp(285px, 60vw, 430px); }
}
@media (max-width: 580px) {
  .topbar { padding: 16px 13px 12px; }
  .topbar { flex-wrap: wrap; }
  .top-actions { width: 100%; display: grid; grid-template-columns: 1fr auto; }
  .phone-link { min-height: 43px; align-content: center; }
  .brand-mark { width: 37px; }
  .ghost-btn { padding: 9px 10px; font-size: .74rem; }
  main { padding: 0 11px 28px; }
  .result-strip { grid-template-columns: repeat(2, 1fr); border-radius: 14px; }
  .hero-result { grid-column: 1 / -1; grid-row: auto; padding: 16px 17px; }
  .mini-result { padding: 12px 11px; border-left: 0; border-top: 1px solid var(--line); border-bottom: 0; }
  .panel { padding: 15px; border-radius: 13px; }
  .field-grid.three, .field-grid.two { grid-template-columns: 1fr 1fr; }
  .field-grid.three label:last-child { grid-column: 1 / -1; }
  .port-stats { grid-template-columns: 1fr 1fr; }
  .port-stats div:last-child { grid-column: 1 / -1; }
  .preview-heading { flex-wrap: wrap; }
  .preview-heading .mini-btn { margin-left: 44px; }
  .canvas-wrap { height: 285px; }
  .dimension-chips { grid-template-columns: repeat(2, 1fr); }
}
