/* Krank'd Truss Studio — standalone styling. Self-contained: no dependency on the
   live site's CSS so this can run locally and later drop into an Astro page. */

:root {
  --bg: #0a0a0f;
  --bg-grad: radial-gradient(1200px 600px at 70% -10%, #1a0f33 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 20%, #160a2b 0%, transparent 55%);
  --card: #13131a;
  --card-2: #1c1c26;
  --el: #242432;
  --el-2: #2c2c3c;
  --line: #2a2a38;
  --line-2: #353548;
  --purple: #7d28db;
  --purple-l: #9b4dff;
  --purple-xl: #c4a3ff;
  --tx: #eeeeee;
  --tx-dim: #9aa0b4;
  --tx-faint: #6b7088;
  --ok: #86efac;
  --ok-bg: #0f2c1c;
  --warn: #fdba74;
  --warn-bg: #2c1f0f;
  --bad: #fca5a5;
  --bad-bg: #2c0f12;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.7);
  --glow: 0 0 0 1px rgba(155, 77, 255, 0.25), 0 8px 30px -8px rgba(125, 40, 219, 0.45);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--tx);
  font-family: 'Heebo', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: 'Poppins', 'Heebo', sans-serif; letter-spacing: -0.01em; }

a { color: var(--purple-xl); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout shell ---------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 22px clamp(14px, 3vw, 32px) 80px; }

.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .k {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border-radius: 11px; font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 24px;
  color: #fff; background: linear-gradient(145deg, var(--purple-l), var(--purple));
  box-shadow: var(--glow); transform: skewX(-6deg);
}
.brand .k span { transform: skewX(6deg); }
.brand .title { line-height: 1.1; }
.brand .title b { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 18px; display: block; }
.brand .title small { color: var(--tx-dim); font-size: 12.5px; }

.topbar .spacer { flex: 1; }

/* ---------- segmented controls ---------- */
.seg {
  display: inline-flex; background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; padding: 3px; gap: 2px;
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--tx-dim);
  font: inherit; font-weight: 600; font-size: 13.5px; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.seg button:hover:not(:disabled) { color: var(--tx); }
.seg button[aria-pressed='true'] {
  background: linear-gradient(145deg, var(--purple), var(--purple-d, #5b1aa3));
  color: #fff; box-shadow: 0 2px 12px -4px rgba(125, 40, 219, .8);
}
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.seg.sm button { padding: 5px 10px; font-size: 12.5px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; }
.tabs button {
  appearance: none; border: 0; background: transparent; color: var(--tx-dim);
  font: inherit; font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 15px;
  padding: 9px 4px; margin-right: 14px; cursor: pointer; position: relative;
}
.tabs button[aria-selected='true'] { color: var(--tx); }
.tabs button[aria-selected='true']::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 3px;
  border-radius: 3px; background: linear-gradient(90deg, var(--purple-l), var(--purple));
}

.view { display: none; }
.view.active { display: block; }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 18px; }
.calc-grid { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); }
.plan-grid { grid-template-columns: 230px minmax(0, 1fr) 300px; }
@media (max-width: 1080px) { .calc-grid, .plan-grid { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--tx-dim); font-weight: 600; }
.card + .card { margin-top: 18px; }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 12.5px; color: var(--tx-dim); margin-bottom: 7px; font-weight: 600; }

/* inputs */
input[type='number'], input[type='text'], select {
  width: 100%; background: var(--bg); border: 1px solid var(--line-2); color: var(--tx);
  font: inherit; padding: 9px 11px; border-radius: 9px; outline: none;
}
input:focus, select:focus { border-color: var(--purple-l); box-shadow: 0 0 0 3px rgba(155, 77, 255, .18); }
input[type='range'] { width: 100%; accent-color: var(--purple-l); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.inline-num { width: 96px; flex: none; text-align: right; }
.muted { color: var(--tx-dim); }
.faint { color: var(--tx-faint); }
.small { font-size: 12.5px; }

/* ---------- result hero ---------- */
.result-hero { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.result-hero .num {
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 56px; line-height: 1;
  background: linear-gradient(160deg, #fff, var(--purple-xl));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result-hero .unit { font-size: 20px; color: var(--tx-dim); font-weight: 600; }
.result-sub { margin-top: 6px; color: var(--tx-dim); }
.udl-total { margin-top: 8px; font-size: 15px; display: flex; align-items: baseline; gap: 7px; }
.udl-total .eq { color: var(--purple-l); font-weight: 700; font-size: 18px; }
.udl-total b { font-family: 'Poppins', sans-serif; color: var(--tx); font-size: 18px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin-top: 16px; font-size: 14px; }
.kv dt { color: var(--tx-dim); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; border: 1px solid transparent;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: #1c5237; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: #5a4118; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: #5a1f25; }
.pill.est { background: #1a1430; color: var(--purple-xl); border-color: #3a2a66; }

.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 10px;
  font-size: 13px; line-height: 1.45;
}
.banner.warn { background: var(--warn-bg); color: #f2cfa0; border: 1px solid #5a4118; }
.banner.est { background: #1a1430; color: var(--purple-xl); border: 1px solid #3a2a66; }
.banner .ico { font-size: 15px; line-height: 1.3; }

/* ---------- charts / svg ---------- */
.chart-wrap { margin-top: 8px; }
svg { display: block; max-width: 100%; }
.beam-diagram { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }

/* ---------- planner ---------- */
.palette { display: flex; flex-direction: column; gap: 8px; }
.palette .group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--tx-faint); margin: 10px 0 2px; }
.preset-btn, .piece-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--el); border: 1px solid var(--line); color: var(--tx);
  border-radius: 10px; padding: 9px 11px; cursor: pointer; font: inherit; font-size: 13.5px;
  transition: border-color .15s, background .15s;
}
.preset-btn:hover, .piece-btn:hover { border-color: var(--purple-l); background: var(--el-2); }
.preset-btn[aria-pressed='true'] { border-color: var(--purple-l); background: linear-gradient(180deg, #241640, var(--el)); box-shadow: inset 0 0 0 1px rgba(155,77,255,.3); }
.preset-btn .ico { font-size: 17px; }
.preset-btn b { font-weight: 600; }
.preset-btn small { display: block; color: var(--tx-dim); font-size: 11.5px; }

.canvas-card { padding: 0; overflow: hidden; }
.canvas-toolbar { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.canvas-stage { position: relative; background:
  linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 40px,
  linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 40px 100%,
  var(--bg);
  background-blend-mode: normal; min-height: 460px;
}

.bom-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bom-table th { text-align: left; color: var(--tx-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.bom-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.bom-table td.qty { text-align: right; font-variant-numeric: tabular-nums; color: var(--purple-xl); font-weight: 600; }
.bom-table tr:last-child td { border-bottom: 0; }
.bom-total { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); font-weight: 600; }

.stat-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }

.btn {
  appearance: none; font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px;
  padding: 9px 15px; border: 1px solid var(--line-2); background: var(--el); color: var(--tx);
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--purple-l); background: var(--el-2); }
.btn.primary { background: linear-gradient(145deg, var(--purple-l), var(--purple)); border-color: transparent; color: #fff; box-shadow: 0 4px 16px -6px rgba(125,40,219,.8); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.sm { padding: 6px 11px; font-size: 13px; }

/* ---------- global disclaimer ---------- */
.disclaimer-bar {
  margin-top: 24px; padding: 14px 16px; border-radius: 12px; font-size: 12.5px; line-height: 1.55;
  background: #14101f; border: 1px solid #2e2547; color: var(--tx-dim);
}
.disclaimer-bar b { color: var(--warn); }

.footer-note { margin-top: 22px; color: var(--tx-faint); font-size: 12px; text-align: center; }

.hidden { display: none !important; }

/* ===================== Rig Designer ===================== */
.rig-grid { grid-template-columns: 300px minmax(0, 1fr) 320px; }
@media (max-width: 1180px) { .rig-grid { grid-template-columns: 1fr; } }

.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* fixture picker */
.pick-list { margin-top: 10px; max-height: 230px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.pick-list::-webkit-scrollbar { width: 8px; }
.pick-list::-webkit-scrollbar-thumb { background: var(--el-2); border-radius: 4px; }
.pick-row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--el); border: 1px solid var(--line); color: var(--tx);
  border-radius: 9px; padding: 7px 10px; cursor: pointer; font: inherit; transition: border-color .12s, background .12s;
}
.pick-row:hover { border-color: var(--purple-l); background: var(--el-2); }
.pick-name { flex: 1; font-size: 13px; line-height: 1.25; min-width: 0; }
.pick-wt { font-size: 12px; color: var(--tx-dim); font-variant-numeric: tabular-nums; }
.pick-add { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border-radius: 6px; background: var(--purple); color: #fff; font-weight: 700; font-size: 15px; }

/* payload list */
.payload-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.payload-row:last-of-type { border-bottom: 0; }
.pl-name { flex: 1; font-size: 13px; min-width: 0; }
.pl-wt { font-size: 12.5px; color: var(--purple-xl); font-variant-numeric: tabular-nums; font-weight: 600; }
.stepper { display: inline-flex; align-items: center; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.stepper button { appearance: none; border: 0; background: transparent; color: var(--tx); width: 24px; height: 26px; cursor: pointer; font-size: 15px; line-height: 1; }
.stepper button:hover { background: var(--el-2); color: var(--purple-xl); }
.stepper .qty { min-width: 22px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.payload-total { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px; }
.payload-total span:last-child { color: var(--purple-xl); }

/* verdict */
.verdict-big { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 40px; line-height: 1.05; margin: 2px 0; }
.verdict-big.ok { color: #b9f5cf; }
.verdict-big.warn { color: var(--warn); }
.verdict-big.bad { color: var(--bad); }

/* utilisation bars */
.ubar { margin-top: 13px; }
.ubar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; font-size: 13px; gap: 8px; }
.ubar-head .over { color: var(--bad); }
.ubar-track { height: 7px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.ubar-fill { height: 100%; border-radius: 99px; transition: width .18s ease; }
.ubar-fill.ok { background: linear-gradient(90deg, #4ade80, #86efac); }
.ubar-fill.warn { background: linear-gradient(90deg, #f59e42, #fdba74); }
.ubar-fill.bad { background: linear-gradient(90deg, #ef4444, #fca5a5); }

/* mini stats (calculator) */
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.mini-stat { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
.ms-label { font-size: 11.5px; color: var(--tx-dim); margin-bottom: 4px; }
.ms-value { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 20px; }
.ms-value.ok { color: #86efac; } .ms-value.warn { color: var(--warn); } .ms-value.bad { color: var(--bad); }
.ms-note { margin-top: 2px; }

.rig-stage { min-height: 360px; display: block; }
.stage-empty { display: grid; place-items: center; min-height: 360px; }

/* colour swatch on payload rows (the fixture legend) */
.swatch { width: 12px; height: 12px; flex: none; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }

/* manual truss piece builder */
.piece-palette { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { appearance: none; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 5px 10px; border: 1px solid var(--line-2); background: var(--el); color: var(--tx); }
.chip-btn:hover { border-color: var(--purple-l); background: var(--el-2); }
.piece-chips-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; width: 100%; }
.piece-chips { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.piece-chip { display: inline-flex; align-items: center; gap: 4px; background: #1a1430; border: 1px solid #3a2a66; color: var(--purple-xl); border-radius: 7px; padding: 3px 4px 3px 9px; font-size: 12.5px; font-weight: 600; }
.piece-chip button { appearance: none; border: 0; background: transparent; color: var(--tx-dim); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 3px; }
.piece-chip button:hover { color: var(--bad); }
.fixture-marker:hover rect { stroke: #fff; }
